Skip to content
Browse files

Release 1.0.0

* Update the generators to be Rails 3 compliant.
* Use the ActiveRecord#[] method to access the version attribute instead of the attribute accessor.
  • Loading branch information...
1 parent 770ee99 commit 0b5b1e59baff1cb0deb3d3f710290310958bbfa5 @midas committed Jul 8, 2010
View
24 .rake_tasks~
@@ -0,0 +1,24 @@
+build
+check_dependencies
+check_dependencies:development
+check_dependencies:runtime
+clobber_rcov
+clobber_rdoc
+gemcutter:release
+gemspec
+gemspec:debug
+gemspec:generate
+gemspec:validate
+git:release
+github:release
+install
+rcov
+rdoc
+release
+rerdoc
+spec
+version
+version:bump:major
+version:bump:minor
+version:bump:patch
+version:write
View
6 History.txt
@@ -1,3 +1,9 @@
+== 1.0.0 2010-07-08
+
+* Using the ActiveRecord#[] method to access the version attribute of the current version.
+* Made the generators Rails 3 compliant.
+
+
== 0.0.3 2010-01-04
* Fixed a file include issue to make Genesis work with bundler gem.
View
18 README.rdoc
@@ -26,6 +26,12 @@ seeding tools currently available.
db:genesis RAILS_ENV=production)
+== COMPATABILITY
+
+* Ruby 1.8
+* Rails 3
+* Rails 2
+
== TODO
* Add option to override Rails db:seed task
@@ -44,21 +50,25 @@ seeding tools currently available.
Run the prepare seeding generator to create a lib/tasks/genesis.rake file:
- script/generate prepare_seeding
+ rails generate prepare_genesis # Rails 3
+ script/generate prepare_seeding # Rails 2
Or to specify which environments to create:
- script/generate prepare_seeding env:[development,staging,production]
+ rails generate prepare_genesis [development,staging,production] # Rails 3
+ script/generate prepare_seeding env:[development,staging,production] # Rails 2
Generate a seed file:
- script/generate genesis create_users
+ rails generate genesis create_users # Rails 3
+ script/generate genesis create_users # Rails 2
This will generate a seed file for you in the db/seeds directory.
Generate a seed file in a specific environment folder:
- script/generate genesis create_users production
+ rails generate genesis create_users production # Rails 3
+ script/generate genesis create_users production # Rails 2
This will generate a seed file for you in the db/seeds/production directory.
View
2 VERSION
@@ -1 +1 @@
-0.0.3
+1.0.0
View
15 genesis.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{genesis}
- s.version = "0.0.3"
+ s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["C. Jason Harrelson (midas)"]
- s.date = %q{2010-01-04}
+ s.date = %q{2010-07-08}
s.description = %q{A data seeding solution for Ruby on Rails providing seeding facilities far more advanced than the current built in Ruby on Rails solution.}
s.email = %q{jason@lookforwardenterprises.com}
s.extra_rdoc_files = [
@@ -25,6 +25,11 @@ Gem::Specification.new do |s|
"Rakefile",
"VERSION",
"genesis.gemspec",
+ "lib/generators/genesis/genesis_generator.rb",
+ "lib/generators/genesis/templates/migration.erb",
+ "lib/generators/prepare_genesis/prepare_genesis_generator.rb",
+ "lib/generators/prepare_genesis/templates/genesis.rake",
+ "lib/generators/prepare_genesis/templates/genesis_callbacks.rb",
"lib/genesis.rb",
"lib/genesis/active_record_extensions.rb",
"lib/genesis/create_schema_seeds.rb",
@@ -38,16 +43,18 @@ Gem::Specification.new do |s|
"rails_generators/prepare_seeding/prepare_seeding_generator.rb",
"rails_generators/prepare_seeding/templates/genesis.rake",
"rails_generators/prepare_seeding/templates/genesis_callbacks.rb",
+ "spec/generators/genesis_generator_spec.rb",
"spec/genesis_spec.rb",
"spec/spec_helper.rb"
]
s.homepage = %q{http://github.com/midas/genesis}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
+ s.rubygems_version = %q{1.3.6}
s.summary = %q{A data seeding solution for Ruby on Rails.}
s.test_files = [
- "spec/genesis_spec.rb",
+ "spec/generators/genesis_generator_spec.rb",
+ "spec/genesis_spec.rb",
"spec/spec_helper.rb"
]
View
33 lib/generators/genesis/genesis_generator.rb
@@ -0,0 +1,33 @@
+require 'rails/generators'
+
+class GenesisGenerator < Rails::Generators::Base
+ #source_root File.join( File.dirname(__FILE__), 'templates' )
+ argument :seed_name, :type => :string
+ argument :env, :type => :string, :default => ''
+
+ def self.source_root
+ File.join( File.dirname(__FILE__), 'templates' )
+ end
+
+ def install_seed
+ template "migration.erb", "db/seeds/#{env_str}#{timestamp}_#{file_name}.rb"
+ end
+
+private
+
+ def file_name
+ seed_name.underscore
+ end
+
+ def class_name
+ seed_name.camelcase
+ end
+
+ def timestamp
+ DateTime.now.strftime( "%Y%m%d%H%M%S" )
+ end
+
+ def env_str
+ return env.blank? ? '' : "#{env}/"
+ end
+end
View
9 lib/generators/genesis/templates/migration.erb
@@ -0,0 +1,9 @@
+class <%= class_name %>
+ def self.up
+
+ end
+
+ def self.down
+
+ end
+end
View
15 lib/generators/prepare_genesis/prepare_genesis_generator.rb
@@ -0,0 +1,15 @@
+require 'rails/generators'
+
+class PrepareGenesisGenerator < Rails::Generators::Base
+ argument :envs, :type => :string, :default => %w(development production)
+
+ def self.source_root
+ File.join( File.dirname(__FILE__), 'templates' )
+ end
+
+ def install_seeding
+ envs.each { |env| empty_directory "db/seeds/#{env}" }
+ copy_file 'genesis.rake', 'lib/tasks/genesis.rake'
+ copy_file 'genesis_callbacks.rb', 'db/seeds/genesis_callbacks.rb'
+ end
+end
View
23 lib/generators/prepare_genesis/templates/genesis.rake
@@ -0,0 +1,23 @@
+namespace :db do
+ desc "Loads seed data for the current environment."
+ task :genesis => :environment do
+ Genesis::Seeder.verify_or_create_version_table
+ ignores = %w()
+ seeds = Dir[File.join( RAILS_ROOT, 'db', 'seeds', '*.rb' )] +
+ Dir[File.join( RAILS_ROOT, 'db', 'seeds', RAILS_ENV, '*.rb') ]
+ Genesis::Seeder.run( seeds, ENV['VERSION'] || nil, ignores )
+ end
+
+ desc "Drops and recreates all tables along with seeding the database"
+ task :mulligan => :environment do
+ Rake::Task['db:migrate:reset'].invoke
+ Rake::Task['db:genesis'].invoke
+ end
+
+ namespace :genesis do
+ desc "Returns the current seed version from teh schema_seeds table"
+ task :version => :environment do
+ puts "[Genesis Seed Version] #{Genesis::Seeder.get_current_version}"
+ end
+ end
+end
View
13 lib/generators/prepare_genesis/templates/genesis_callbacks.rb
@@ -0,0 +1,13 @@
+class GenesisCallbacks
+ def self.before_up
+ end
+
+ def self.after_up
+ end
+
+ def self.before_down
+ end
+
+ def self.after_down
+ end
+end
View
1 lib/genesis.rb
@@ -3,6 +3,7 @@
require 'genesis/active_record_extensions'
require 'genesis/seeder'
+require 'genesis/schema_seed'
module Genesis
VERSION = '0.0.3'
View
2 lib/genesis/seeder.rb
@@ -81,7 +81,7 @@ def self.validate_version_existence( to_version )
def self.determine_current_version
current_seed = SchemaSeed.find( :last, :order => :version )
- @current_version = current_seed.nil? ? '' : current_seed.version
+ @current_version = current_seed.nil? ? '' : current_seed[:version]
end
def self.determine_and_prepare_seed_direction( to_version )
View
24 spec/generators/genesis_generator_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+require 'generators/genesis/genesis_generator'
+
+describe GenesisGenerator do
+ before :each do
+ @destination = File.join 'tmp', 'test_app'
+ @source = GenesisGenerator.source_root
+ GenesisGenerator.start '', :destination_root => @destination
+ end
+
+ after :each do
+ FileUtils.rm_rf @destination
+ end
+
+ {}.each do |file, path|
+ it "should copy '#{file}' to '#{path}'" do
+ File.exists?( File.join( @destination, path ) ).should be_true
+ end
+
+ # it "should agree that the contents of '#{file}' are identical to '#{path}'" do
+ # File.read( File.join( @source, file ) ).should eql File.read( File.join( @destination, path ) )
+ # end
+ end
+end
View
4 spec/genesis_spec.rb
@@ -1,7 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Genesis" do
- it "fails" do
- fail "hey buddy, you should probably rename this file and start specing for real"
- end
+
end

0 comments on commit 0b5b1e5

Please sign in to comment.
Something went wrong with that request. Please try again.