genesis 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +8 -0
- data/VERSION +1 -1
- data/genesis.gemspec +1 -1
- data/lib/generators/prepare_genesis/templates/genesis.rake +15 -0
- data/lib/genesis.rb +1 -1
- data/lib/genesis/seeder.rb +14 -3
- data/rails_generators/prepare_seeding/templates/genesis.rake +15 -0
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
== 1.2.1 2010-09-19
|
2
|
+
|
3
|
+
* Fix issue with outputting seed delimiter message when the class names are too long.
|
4
|
+
* Add seeding start and end messages with contexts referenced.
|
5
|
+
* Add total seeding time message.
|
6
|
+
|
7
|
+
|
1
8
|
== 1.2.0 2010-09-19
|
2
9
|
|
3
10
|
* Make create_or_update_by_* methods able to convert AR objects to IDs if the attribute name includes '_id'.
|
11
|
+
* Add contexts.
|
4
12
|
|
5
13
|
|
6
14
|
== 1.1.0 2010-07-27
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/genesis.gemspec
CHANGED
@@ -8,13 +8,18 @@ namespace :db do
|
|
8
8
|
|
9
9
|
contexts = ENV['CONTEXTS']
|
10
10
|
unless contexts.nil? || contexts.empty?
|
11
|
+
using_contexts = true
|
11
12
|
contexts = expand_contexts if contexts == 'all'
|
12
13
|
contexts.split( ',' ).each do |context|
|
13
14
|
seeds += Dir[File.join( Rails.root, 'db', 'seeds', 'contexts', context, '*.rb' )]
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
18
|
+
|
19
|
+
|
20
|
+
puts "", message( contexts, :using_contexts => using_contexts, :start => true ), ""
|
17
21
|
Genesis::Seeder.run( seeds, ENV['VERSION'] || nil, ignores )
|
22
|
+
puts message( contexts, :using_contexts => using_contexts ), "", ""
|
18
23
|
end
|
19
24
|
|
20
25
|
desc "Drops and recreates all tables along with seeding the database"
|
@@ -71,3 +76,13 @@ end
|
|
71
76
|
def expand_contexts
|
72
77
|
Dir[File.join( contexts_root, '*' )].map { |d| d.split( '/' ).last }.join ','
|
73
78
|
end
|
79
|
+
|
80
|
+
def message( contexts, options={} )
|
81
|
+
msg = options[:using_contexts] ?
|
82
|
+
"*** #{start_or_end_word( options )} seeding (contexts: #{contexts.split(',').join(', ')})" :
|
83
|
+
"*** #{start_or_end_word( options )} seeding"
|
84
|
+
end
|
85
|
+
|
86
|
+
def start_or_end_word( options )
|
87
|
+
return options[:start] ? 'Start' : 'End'
|
88
|
+
end
|
data/lib/genesis.rb
CHANGED
data/lib/genesis/seeder.rb
CHANGED
@@ -43,7 +43,7 @@ module Genesis
|
|
43
43
|
#
|
44
44
|
def self.run( seeds=[], to_version=nil, ignores=[] )
|
45
45
|
ignores << 'genesis_callbacks.rb'
|
46
|
-
@separator_size =
|
46
|
+
@separator_size = 95
|
47
47
|
determine_current_version
|
48
48
|
map_versions( seeds, ignores )
|
49
49
|
raise 'There are no seeds to execute.' if @versions_map.empty?
|
@@ -115,12 +115,16 @@ module Genesis
|
|
115
115
|
GenesisCallbacks.send( callback_method ) if GenesisCallbacks.respond_to?( callback_method )
|
116
116
|
end
|
117
117
|
|
118
|
+
@time_start_seeding = Time.now
|
118
119
|
@to_run.each { |version, metadata| self.run_seed( version, metadata ) }
|
120
|
+
@time_end_seeding = Time.now
|
119
121
|
|
120
122
|
if should_run_callbacks
|
121
123
|
callback_method = :"after_#{@method}"
|
122
124
|
GenesisCallbacks.send( callback_method ) if GenesisCallbacks.respond_to?( callback_method )
|
123
125
|
end
|
126
|
+
|
127
|
+
log_seeding_finish
|
124
128
|
end
|
125
129
|
|
126
130
|
def self.run_seed( version, metadata )
|
@@ -143,14 +147,21 @@ module Genesis
|
|
143
147
|
|
144
148
|
def self.log_entry_start( class_name )
|
145
149
|
entry = "== #{class_name}: seeding (#{@method.to_s}) "
|
146
|
-
entry << "="*(@separator_size-entry.length
|
150
|
+
entry << "="*(@separator_size-entry.length) << "\n"
|
147
151
|
puts entry
|
148
152
|
RAILS_DEFAULT_LOGGER.info entry
|
149
153
|
end
|
150
154
|
|
151
155
|
def self.log_entry_finish( class_name, total_time )
|
152
156
|
entry = "== #{class_name}: seeded (#{@method.to_s}) (#{total_time}s) "
|
153
|
-
|
157
|
+
num_to_finish = @separator_size-entry.length
|
158
|
+
entry << "="*(num_to_finish) << "\n\n" if num_to_finish > 0
|
159
|
+
puts entry
|
160
|
+
RAILS_DEFAULT_LOGGER.info entry
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.log_seeding_finish
|
164
|
+
entry = "*** Seeding total time: #{@time_end_seeding - @time_start_seeding}s"
|
154
165
|
puts entry
|
155
166
|
RAILS_DEFAULT_LOGGER.info entry
|
156
167
|
end
|
@@ -8,13 +8,18 @@ namespace :db do
|
|
8
8
|
|
9
9
|
contexts = ENV['CONTEXTS']
|
10
10
|
unless contexts.nil? || contexts.empty?
|
11
|
+
using_contexts = true
|
11
12
|
contexts = expand_contexts if contexts == 'all'
|
12
13
|
contexts.split( ',' ).each do |context|
|
13
14
|
seeds += Dir[File.join( Rails.root, 'db', 'seeds', 'contexts', context, '*.rb' )]
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
18
|
+
|
19
|
+
|
20
|
+
puts "", message( contexts, :using_contexts => using_contexts, :start => true ), ""
|
17
21
|
Genesis::Seeder.run( seeds, ENV['VERSION'] || nil, ignores )
|
22
|
+
puts message( contexts, :using_contexts => using_contexts ), "", ""
|
18
23
|
end
|
19
24
|
|
20
25
|
desc "Drops and recreates all tables along with seeding the database"
|
@@ -71,3 +76,13 @@ end
|
|
71
76
|
def expand_contexts
|
72
77
|
Dir[File.join( contexts_root, '*' )].map { |d| d.split( '/' ).last }.join ','
|
73
78
|
end
|
79
|
+
|
80
|
+
def message( contexts, options={} )
|
81
|
+
msg = options[:using_contexts] ?
|
82
|
+
"*** #{start_or_end_word( options )} seeding (contexts: #{contexts.split(',').join(', ')})" :
|
83
|
+
"*** #{start_or_end_word( options )} seeding"
|
84
|
+
end
|
85
|
+
|
86
|
+
def start_or_end_word( options )
|
87
|
+
return options[:start] ? 'Start' : 'End'
|
88
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- C. Jason Harrelson (midas)
|