Permalink
Browse files

Added rake svn:ignore and default database.yml files

  • Loading branch information...
1 parent bf56075 commit 893a5b3673bec754b14cc733acafad30daf7d385 Iain Hecker committed Jan 23, 2009
View
@@ -8,7 +8,8 @@ Some handy rake tasks for subversion.
* *svn:add* adds all new files to svn
* *svn:rm* removes all missing files from svn
* *svn:both* adds all new files and removes missing files to svn
-* *svn:ignores* sets common ignores for rails
+* *svn:init_rails* sets common ignores for rails
+* *svn:ignore* add an ignore, use DIR='x' and IGNORE='foo;bar' (semicolon separated)
Copyright (c) 2008 Iain Hecker, released under the MIT license
@@ -0,0 +1,45 @@
+# MySQL. Versions 4.1 and 5.0 are recommended.
+#
+# Install the MySQL driver:
+# gem install mysql
+# On Mac OS X:
+# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
+# On Mac OS X Leopard:
+# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
+# This sets the ARCHFLAGS environment variable to your native architecture
+# On Windows:
+# gem install mysql
+# Choose the win32 build.
+# Install MySQL and put its /bin directory on your path.
+#
+# And be sure to use new-style password hashing:
+# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
+development:
+ adapter: mysql
+ encoding: utf8
+ database: app_development
+ pool: 5
+ username: root
+ password:
+ socket: /opt/local/var/run/mysql5/mysqld.sock
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: mysql
+ encoding: utf8
+ database: app_test
+ pool: 5
+ username: root
+ password:
+ socket: /opt/local/var/run/mysql5/mysqld.sock
+
+production:
+ adapter: mysql
+ encoding: utf8
+ database: app_production
+ pool: 5
+ username: root
+ password:
+ socket: /opt/local/var/run/mysql5/mysqld.sock
@@ -0,0 +1,39 @@
+# Oracle/OCI 8i, 9, 10g
+#
+# Requires Ruby/OCI8:
+# http://rubyforge.org/projects/ruby-oci8/
+#
+# Specify your database using any valid connection syntax, such as a
+# tnsnames.ora service name, or a SQL connect url string of the form:
+#
+# //host:[port][/service name]
+#
+# By default prefetch_rows (OCI_ATTR_PREFETCH_ROWS) is set to 100. And
+# until true bind variables are supported, cursor_sharing is set by default
+# to 'similar'. Both can be changed in the configation below; the defaults
+# are equivalent to specifying:
+#
+# prefetch_rows: 100
+# cursor_sharing: similar
+#
+
+development:
+ adapter: oracle
+ database: app_development
+ username: app
+ password:
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: oracle
+ database: app_test
+ username: app
+ password:
+
+production:
+ adapter: oracle
+ database: app_production
+ username: app
+ password:
@@ -0,0 +1,51 @@
+# PostgreSQL. Versions 7.4 and 8.x are supported.
+#
+# Install the ruby-postgres driver:
+# gem install ruby-postgres
+# On Mac OS X:
+# gem install ruby-postgres -- --include=/usr/local/pgsql
+# On Windows:
+# gem install ruby-postgres
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+development:
+ adapter: postgresql
+ encoding: unicode
+ database: app_development
+ pool: 5
+ username: app
+ password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # The server defaults to notice.
+ #min_messages: warning
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: postgresql
+ encoding: unicode
+ database: app_test
+ pool: 5
+ username: app
+ password:
+
+production:
+ adapter: postgresql
+ encoding: unicode
+ database: app_production
+ pool: 5
+ username: app
+ password:
@@ -0,0 +1,19 @@
+# SQLite version 2.x
+# gem install sqlite-ruby
+development:
+ adapter: sqlite
+ database: db/development.sqlite2
+ pool: 5
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite
+ database: db/test.sqlite2
+ pool: 5
+
+production:
+ adapter: sqlite
+ database: db/production.sqlite2
+ pool: 5
@@ -0,0 +1,22 @@
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
@@ -2,7 +2,7 @@ namespace :svn do
desc "Gets the current svn repository url."
task :repository do
- SVN_BASE = `svn info | grep ^URL | awk '{print $2}'`
+ SVN_BASE = `svn info | grep ^URL | awk '{print $2}'`.sub(/trunk$/,'').strip
puts "Using repository #{SVN_BASE}"
end
@@ -32,7 +32,7 @@ namespace :svn do
task :both => [:add, :rm]
desc "Configure Subversion for Rails"
- task :ignores do
+ task :init_rails do
svn_ignore 'log', '*'
svn_ignore 'db', '*.sqlite*', 'schema.rb'
@@ -43,30 +43,53 @@ namespace :svn do
svn_ignore 'public/stylesheets', '*.css'
- svn "update config/"
- svn "move config/database.yml config/database.example"
- svn "commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'"
- svn "update config/"
+ svn "update config/", :verbose => false
+ database_files = Dir.glob("#{File.dirname(__FILE__)}/../database-files/*.yml")
+ FileUtils.cp database_files, "config/", :verbose => true
+ database_files.each do |file|
+ svn "add config/#{File.basename(file)}"
+ end
+ svn "commit -m 'Added example database configurations'"
svn_ignore 'config', 'database.yml'
end
+ desc "Adds an ignore. Use DIR='log' and IGNORE='foo;log' (semicolon separated)"
+ task :ignore do
+ raise "You must specify an existing directory, e.g. DIR='log'" unless File.directory?(ENV['DIR'])
+ raise "You must specify which file(-pattern) to ignore, e.g. IGNORE='*.log'" unless ENV['IGNORE'].blank?
+ svn_ignore ENV['DIR'], *ENV['IGNORE'].split(";")
+ end
+
end
-def svn(command)
- puts "", "svn #{command.gsub("\r","\n")}"
+def svn(command, options = {})
+ puts "", "svn #{command.gsub("\r","\n")}" unless !options[:verbose]
system "svn #{command}"
end
def svn_ignore(dir, *files)
- svn "update #{dir}"
- files.each do |f|
- svn "remove #{File.join(dir, f)}"
+
+ # updating that dir to make sure no conflicts appear
+ svn "update #{dir}", :verbose => false
+
+ # append any files to already ignored files
+ files += `svn pg svn:ignore #{ENV['dir']}`.split("\n")
+ files = files.compact.uniq.collect(&:strip)
+
+ # delete existing files first
+ unless (existing_files = files.reject { |it| File.exist?(it) }).empty?
+ existing_files.each do |f|
+ svn "remove #{File.join(dir, f)}"
+ end
+ svn "commit -m 'Removing #{existing_files.join(', ')} in #{dir} before ignoring it'"
+ svn "update #{dir}", :verbose => false
end
- svn "commit -m 'Removing #{files.join(', ')} in #{dir} before ignoring it'"
- svn "update #{dir}"
+
+ # finally we can ignore the files
svn "propset svn:ignore '#{files.join("\r")}' #{dir}"
- svn "update #{dir}"
+ svn "update #{dir}", :verbose => false
svn "commit -m 'Ignoring #{files.join(', ')} in #{dir}'"
- svn "update #{dir}"
+ svn "update #{dir}", :verbose => false
+
end

0 comments on commit 893a5b3

Please sign in to comment.