Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated readme, added comments to Rakefile, added license

  • Loading branch information...
commit 84b1bd6a1ddd88681a4c9fa5aa543dcd4fd61e6f 1 parent 13770c9
@colszowka authored
Showing with 38 additions and 1 deletion.
  1. +20 −0 MIT-LICENSE
  2. +9 −0 README.textile
  3. +9 −1 Rakefile
View
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Christoph Olszowka
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
9 README.textile
@@ -0,0 +1,9 @@
+h1. ActiveRecord Skeleton
+A basic skeleton for ActiveRecord-backed Ruby apps, including a ready-to-go structure with YAML database config and rake tasks for migrating the database and generating migrations
+
+h2. Usage
+# TODO...
+
+h2. Copyright
+
+activerecord-skeleton is Copyright © 2009 Christoph Olszowka, It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
View
10 Rakefile
@@ -12,26 +12,34 @@ namespace :generate do
task :migration => :environment do
raise "Please specify desired migration name with NAME=my_migration_name" unless ENV['NAME']
+ # Find migration name from env
migration_name = ENV['NAME'].strip.chomp
+ # Define migrations path (needed later)
migrations_path = File.join(File.dirname(__FILE__), 'db', 'migrate')
- # Find the highest existing migration version
+ # Find the highest existing migration version or set to 1
if (existing_migrations = Dir[File.join(migrations_path, '*.rb')]).length > 0
version = File.basename(existing_migrations.sort.reverse.first)[/^(\d+)_/,1].to_i + 1
else
version = 1
end
+ # Read the contents of the migration template into string
migrations_template = File.read(File.join(migrations_path, 'migration.template') )
+ # Replace the migration name in template with the acutal one
migration_content = migrations_template.gsub('__migration_name__', migration_name.camelize)
+
+ # Generate migration filename
migration_filename = "#{"%03d" % version}_#{migration_name}.rb"
+ # Write the migration
File.open(File.join(migrations_path, migration_filename), "w+") do |migration|
migration.puts migration_content
end
+ # Done!
puts "Successfully created migration #{migration_filename}"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.