genesis 0.0.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.0.0 2010-07-08
2
+
3
+ * Using the ActiveRecord#[] method to access the version attribute of the current version.
4
+ * Made the generators Rails 3 compliant.
5
+
6
+
1
7
  == 0.0.3 2010-01-04
2
8
 
3
9
  * Fixed a file include issue to make Genesis work with bundler gem.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 1.0.0
data/genesis.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{genesis}
8
- s.version = "0.0.3"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
12
- s.date = %q{2010-01-04}
12
+ s.date = %q{2010-07-08}
13
13
  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.}
14
14
  s.email = %q{jason@lookforwardenterprises.com}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,11 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "genesis.gemspec",
28
+ "lib/generators/genesis/genesis_generator.rb",
29
+ "lib/generators/genesis/templates/migration.erb",
30
+ "lib/generators/prepare_genesis/prepare_genesis_generator.rb",
31
+ "lib/generators/prepare_genesis/templates/genesis.rake",
32
+ "lib/generators/prepare_genesis/templates/genesis_callbacks.rb",
28
33
  "lib/genesis.rb",
29
34
  "lib/genesis/active_record_extensions.rb",
30
35
  "lib/genesis/create_schema_seeds.rb",
@@ -38,16 +43,18 @@ Gem::Specification.new do |s|
38
43
  "rails_generators/prepare_seeding/prepare_seeding_generator.rb",
39
44
  "rails_generators/prepare_seeding/templates/genesis.rake",
40
45
  "rails_generators/prepare_seeding/templates/genesis_callbacks.rb",
46
+ "spec/generators/genesis_generator_spec.rb",
41
47
  "spec/genesis_spec.rb",
42
48
  "spec/spec_helper.rb"
43
49
  ]
44
50
  s.homepage = %q{http://github.com/midas/genesis}
45
51
  s.rdoc_options = ["--charset=UTF-8"]
46
52
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.5}
53
+ s.rubygems_version = %q{1.3.6}
48
54
  s.summary = %q{A data seeding solution for Ruby on Rails.}
49
55
  s.test_files = [
50
- "spec/genesis_spec.rb",
56
+ "spec/generators/genesis_generator_spec.rb",
57
+ "spec/genesis_spec.rb",
51
58
  "spec/spec_helper.rb"
52
59
  ]
53
60
 
@@ -0,0 +1,33 @@
1
+ require 'rails/generators'
2
+
3
+ class GenesisGenerator < Rails::Generators::Base
4
+ #source_root File.join( File.dirname(__FILE__), 'templates' )
5
+ argument :seed_name, :type => :string
6
+ argument :env, :type => :string, :default => ''
7
+
8
+ def self.source_root
9
+ File.join( File.dirname(__FILE__), 'templates' )
10
+ end
11
+
12
+ def install_seed
13
+ template "migration.erb", "db/seeds/#{env_str}#{timestamp}_#{file_name}.rb"
14
+ end
15
+
16
+ private
17
+
18
+ def file_name
19
+ seed_name.underscore
20
+ end
21
+
22
+ def class_name
23
+ seed_name.camelcase
24
+ end
25
+
26
+ def timestamp
27
+ DateTime.now.strftime( "%Y%m%d%H%M%S" )
28
+ end
29
+
30
+ def env_str
31
+ return env.blank? ? '' : "#{env}/"
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ class <%= class_name %>
2
+ def self.up
3
+
4
+ end
5
+
6
+ def self.down
7
+
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+
3
+ class PrepareGenesisGenerator < Rails::Generators::Base
4
+ argument :envs, :type => :string, :default => %w(development production)
5
+
6
+ def self.source_root
7
+ File.join( File.dirname(__FILE__), 'templates' )
8
+ end
9
+
10
+ def install_seeding
11
+ envs.each { |env| empty_directory "db/seeds/#{env}" }
12
+ copy_file 'genesis.rake', 'lib/tasks/genesis.rake'
13
+ copy_file 'genesis_callbacks.rb', 'db/seeds/genesis_callbacks.rb'
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ namespace :db do
2
+ desc "Loads seed data for the current environment."
3
+ task :genesis => :environment do
4
+ Genesis::Seeder.verify_or_create_version_table
5
+ ignores = %w()
6
+ seeds = Dir[File.join( RAILS_ROOT, 'db', 'seeds', '*.rb' )] +
7
+ Dir[File.join( RAILS_ROOT, 'db', 'seeds', RAILS_ENV, '*.rb') ]
8
+ Genesis::Seeder.run( seeds, ENV['VERSION'] || nil, ignores )
9
+ end
10
+
11
+ desc "Drops and recreates all tables along with seeding the database"
12
+ task :mulligan => :environment do
13
+ Rake::Task['db:migrate:reset'].invoke
14
+ Rake::Task['db:genesis'].invoke
15
+ end
16
+
17
+ namespace :genesis do
18
+ desc "Returns the current seed version from teh schema_seeds table"
19
+ task :version => :environment do
20
+ puts "[Genesis Seed Version] #{Genesis::Seeder.get_current_version}"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ class GenesisCallbacks
2
+ def self.before_up
3
+ end
4
+
5
+ def self.after_up
6
+ end
7
+
8
+ def self.before_down
9
+ end
10
+
11
+ def self.after_down
12
+ end
13
+ end
data/lib/genesis.rb CHANGED
@@ -3,6 +3,7 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
  require 'genesis/active_record_extensions'
5
5
  require 'genesis/seeder'
6
+ require 'genesis/schema_seed'
6
7
 
7
8
  module Genesis
8
9
  VERSION = '0.0.3'
@@ -81,7 +81,7 @@ module Genesis
81
81
 
82
82
  def self.determine_current_version
83
83
  current_seed = SchemaSeed.find( :last, :order => :version )
84
- @current_version = current_seed.nil? ? '' : current_seed.version
84
+ @current_version = current_seed.nil? ? '' : current_seed[:version]
85
85
  end
86
86
 
87
87
  def self.determine_and_prepare_seed_direction( to_version )
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'generators/genesis/genesis_generator'
3
+
4
+ describe GenesisGenerator do
5
+ before :each do
6
+ @destination = File.join 'tmp', 'test_app'
7
+ @source = GenesisGenerator.source_root
8
+ GenesisGenerator.start '', :destination_root => @destination
9
+ end
10
+
11
+ after :each do
12
+ FileUtils.rm_rf @destination
13
+ end
14
+
15
+ {}.each do |file, path|
16
+ it "should copy '#{file}' to '#{path}'" do
17
+ File.exists?( File.join( @destination, path ) ).should be_true
18
+ end
19
+
20
+ # it "should agree that the contents of '#{file}' are identical to '#{path}'" do
21
+ # File.read( File.join( @source, file ) ).should eql File.read( File.join( @destination, path ) )
22
+ # end
23
+ end
24
+ end
data/spec/genesis_spec.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Genesis" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
4
+
7
5
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genesis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - C. Jason Harrelson (midas)
@@ -9,29 +14,34 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-04 00:00:00 -06:00
17
+ date: 2010-07-08 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: activerecord
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 0
23
30
  version: "2.0"
24
- version:
31
+ type: :runtime
32
+ version_requirements: *id001
25
33
  - !ruby/object:Gem::Dependency
26
34
  name: rspec
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
30
37
  requirements:
31
38
  - - ">="
32
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
33
42
  version: "0"
34
- version:
43
+ type: :development
44
+ version_requirements: *id002
35
45
  description: A data seeding solution for Ruby on Rails providing seeding facilities far more advanced than the current built in Ruby on Rails solution.
36
46
  email: jason@lookforwardenterprises.com
37
47
  executables: []
@@ -50,6 +60,11 @@ files:
50
60
  - Rakefile
51
61
  - VERSION
52
62
  - genesis.gemspec
63
+ - lib/generators/genesis/genesis_generator.rb
64
+ - lib/generators/genesis/templates/migration.erb
65
+ - lib/generators/prepare_genesis/prepare_genesis_generator.rb
66
+ - lib/generators/prepare_genesis/templates/genesis.rake
67
+ - lib/generators/prepare_genesis/templates/genesis_callbacks.rb
53
68
  - lib/genesis.rb
54
69
  - lib/genesis/active_record_extensions.rb
55
70
  - lib/genesis/create_schema_seeds.rb
@@ -63,6 +78,7 @@ files:
63
78
  - rails_generators/prepare_seeding/prepare_seeding_generator.rb
64
79
  - rails_generators/prepare_seeding/templates/genesis.rake
65
80
  - rails_generators/prepare_seeding/templates/genesis_callbacks.rb
81
+ - spec/generators/genesis_generator_spec.rb
66
82
  - spec/genesis_spec.rb
67
83
  - spec/spec_helper.rb
68
84
  has_rdoc: true
@@ -78,21 +94,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
94
  requirements:
79
95
  - - ">="
80
96
  - !ruby/object:Gem::Version
97
+ segments:
98
+ - 0
81
99
  version: "0"
82
- version:
83
100
  required_rubygems_version: !ruby/object:Gem::Requirement
84
101
  requirements:
85
102
  - - ">="
86
103
  - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
87
106
  version: "0"
88
- version:
89
107
  requirements: []
90
108
 
91
109
  rubyforge_project:
92
- rubygems_version: 1.3.5
110
+ rubygems_version: 1.3.6
93
111
  signing_key:
94
112
  specification_version: 3
95
113
  summary: A data seeding solution for Ruby on Rails.
96
114
  test_files:
115
+ - spec/generators/genesis_generator_spec.rb
97
116
  - spec/genesis_spec.rb
98
117
  - spec/spec_helper.rb