iron_fixture_extractor 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## 1.1.0 -> 1.1.0
2
+ * Deprecation warning for fe_manifest.yml's extracted from 1.0.0 or earlier.
3
+
4
+ * Fix for Oracle reset pk seq (didn't work on 1.1.0)
5
+
1
6
  ## 1.0.0 -> 1.1.0
2
7
  * Shouldn't be any breaking changes, mostly a switch to rspec for
3
8
  testing.
data/README.md CHANGED
@@ -172,6 +172,34 @@ In a nutshell:
172
172
  See spec/README_FOR_DEVELOPERS.md for more details.
173
173
 
174
174
 
175
+
176
+ #### TODO: JOE REPLACE THE ABOVE CONTENT WITH THIS METHOD
177
+ Alternatively, another way to lower the barrier to contributing is to submodule the Gem into your project
178
+ and hack in the features you need to support your app specific, then add
179
+ a test case to the Gem itself that illustrates your change...
180
+
181
+ #### TODO: Write a "For Rspec users", include an initializer:
182
+
183
+ # config/initializers/iron_fixture_extractor.rb
184
+ Fe.fixtures_root = 'spec/fe_fixtures' if defined?(Fe)
185
+
186
+ #### TODO: Write something up about bug with has_many :through
187
+ * If you have a query that utilizes a has_many :through. Make sure to
188
+ put the table that facilitates the :through AFTER the one that uses it.
189
+ ie.
190
+
191
+ # NOT WORKING
192
+ query='Etl::Receipt.includes(:audits, :instcd_to_jobid_mappings, :dars_job_queue_lists => {:job_queue_runs => [:job_queue_outs, {:job_queue_reqs => {:job_queue_subreqs => :job_queue_courses}}]})'
193
+ t=Fe.extract(query,:name => 'poo')
194
+
195
+ # WORKING
196
+ query='Etl::Receipt.includes(:audits, {:dars_job_queue_lists => {:job_queue_runs => [:job_queue_outs, {:job_queue_reqs => {:job_queue_subreqs => :job_queue_courses}}]}}, :instcd_to_jobid_mappings)'
197
+ t=Fe.extract(query,:name => 'poo')
198
+
199
+ * Beers, kudos, praise, and glory for a developer who can find the
200
+ reason for this and a fix...I tried, but couldn't figure it out, hence
201
+ the work around.
202
+
175
203
  ## Footnotes
176
204
  I used various ideas from the following blog posts, gists, and existing
177
205
  ruby gems, thanks to the authors of these pages:
@@ -57,10 +57,15 @@ module Fe
57
57
  raise "No models to load, relax your :only or :except filters (or don't bother calling this method)" if the_tables.empty?
58
58
 
59
59
  the_tables.each do |table_name|
60
+ class_name = if self.table_name_to_model_name_hash.kind_of?(Hash)
61
+ self.table_name_to_model_name_hash[table_name]
62
+ else
63
+ ActiveSupport::Deprecation.warn "your fe_manifest.yml does not contain a table_name_to_model_name_hash (as found in 1.0.0 or earlier). Version 2.0.0 will require this. See test cases for how to manually jigger your fe_manifest.ymls to function."
64
+ nil
65
+ end
60
66
  if options[:map].nil?
61
67
  # Vanilla create_fixtures will work fine when no mapping is being used
62
68
  ActiveRecord::Fixtures.create_fixtures(self.target_path, table_name)
63
- next
64
69
  else
65
70
  # Map table_name via a function (great for prefixing)
66
71
  new_table_name = if options[:map].kind_of?(Proc)
@@ -71,7 +76,6 @@ module Fe
71
76
  else
72
77
  table_name # No mapping for this table name
73
78
  end
74
- class_name = self.table_name_to_model_name_hash[table_name]
75
79
  fixtures = ActiveRecord::Fixtures.new( ActiveRecord::Base.connection,
76
80
  new_table_name,
77
81
  class_name,
@@ -87,6 +91,7 @@ module Fe
87
91
  # calls. aka this code should be eliminated/live elsewhere.
88
92
  case ActiveRecord::Base.connection.adapter_name
89
93
  when /oracle/i
94
+ model = class_name.constantize
90
95
  if model.column_names.include? "id"
91
96
  sequence_name = model.sequence_name.to_s
92
97
  max_id = model.maximum(:id)
@@ -212,18 +217,14 @@ module Fe
212
217
  raise "This gem only knows how to extract stuff w ActiveRecord" unless record.kind_of? ActiveRecord::Base
213
218
  key = record.class.base_class.to_s # the base_class is key for correctly handling STI
214
219
  @output_hash[key] ||= Set.new # Set ensures no duplicates
215
- @output_hash[key].add record
216
- record.association_cache.each do |assoc_cache|
217
- assoc_name = assoc_cache.first
218
- assoc_value = assoc_cache.last.target
219
- unless assoc_value.kind_of? Array
220
- assoc_value = Array(assoc_value)
221
- end
222
- assoc_value.each do |a|
220
+ @output_hash[key].add(record)
221
+ record.association_cache.each_pair do |assoc_name,association_def|
222
+ Array(association_def.target).each do |a|
223
223
  self.recurse(a)
224
224
  end
225
225
  end
226
226
  end
227
+
227
228
  def write_model_fixtures
228
229
  FileUtils.mkdir_p(self.target_path)
229
230
  self.output_hash.each_pair do |key,records|
@@ -1,3 +1,3 @@
1
1
  module Fe
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_fixture_extractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: 553662890390521503
146
+ hash: -3292280525626444386
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements:
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  segments:
154
154
  - 0
155
- hash: 553662890390521503
155
+ hash: -3292280525626444386
156
156
  requirements: []
157
157
  rubyforge_project:
158
158
  rubygems_version: 1.8.23