fixture_builder 0.5.2 → 0.5.3.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e4cfc50092c04b49b80830b479a2a1b1092397ceea1c9d4d1a95e10c196c240
4
- data.tar.gz: 29ae27d39da1fdead7bf37dadb1c40deea757f7d5e0f9923b293f50aa6d2cc8f
3
+ metadata.gz: 6960984d23f57205013cfbeb21f7ca1f261b112a5fccdd1b6d08f6fc2dcc2e90
4
+ data.tar.gz: b484db209790fb4926306f42906ad706a7c548d50020d8883cab58536440213f
5
5
  SHA512:
6
- metadata.gz: 2a8100257b856a58751c5cf14d7bac16ed1a2f2b86cbf466b4ae6f5dd1e456b7d70c9ed988e8f17490736752dd1b355ed5251aaf7f887f2a004adf079bd9e1c3
7
- data.tar.gz: 5599b6ee38401778aceb139539d2dc0effd95bf3f5bfb4f2ba8714d48e568269b2015e898a313c13b268d7acbaaf7eed2c826bdff51d9d7a95f4f2657fe68042
6
+ metadata.gz: 0b73f1cad2d377dff0238ab09d049288e7c9133716d79ff82bf054a5ac559b2e7a8baadd0b343231b31815baa46d7eb2950d9c3b1222e1a300fe083e8e06caa3
7
+ data.tar.gz: 6e5af6db6d0597e7b2a7437bd0bf964d19ef34795d506367d0f9c583375b1948af3c364ec2ebd7d04a6e30d32e086877b5ec523fffa67a9cbf957c150cfc805e
data/README.markdown CHANGED
@@ -310,4 +310,4 @@ class CreateFixtures
310
310
 
311
311
  Copyright (c) 2009 Ryan Dy & David Stevenson, released under the MIT license
312
312
 
313
- Currently maintained by [Chad Woolley](thewoolleyman@gmail.com)
313
+ Currently maintained by [Chad Woolley](mailto:thewoolleyman@gmail.com)
@@ -99,7 +99,7 @@ module FixtureBuilder
99
99
  table_klass = table_name.classify.constantize rescue nil
100
100
  if table_klass && table_klass < ActiveRecord::Base
101
101
  rows = table_klass.unscoped do
102
- table_klass.all.collect do |obj|
102
+ table_klass.order(:id).all.collect do |obj|
103
103
  attrs = obj.attributes.select { |attr_name| table_klass.column_names.include?(attr_name) }
104
104
  attrs.inject({}) do |hash, (attr_name, value)|
105
105
  hash[attr_name] = serialized_value_if_needed(table_klass, attr_name, value)
@@ -1,6 +1,6 @@
1
1
  require 'active_support/core_ext'
2
2
  require 'active_support/core_ext/string'
3
- require 'digest/md5'
3
+ require 'digest'
4
4
  require 'fileutils'
5
5
  require 'hashdiff'
6
6
 
@@ -24,6 +24,7 @@ module FixtureBuilder
24
24
 
25
25
  def initialize(opts={})
26
26
  @namer = Namer.new(self)
27
+ @use_sha1_digests = opts[:use_sha1_digests] || false
27
28
  @file_hashes = file_hashes
28
29
  @write_empty_files = true
29
30
  end
@@ -115,8 +116,9 @@ module FixtureBuilder
115
116
  private
116
117
 
117
118
  def file_hashes
119
+ algorithm = @use_sha1_digests ? Digest::SHA1 : Digest::MD5
118
120
  files_to_check.inject({}) do |hash, filename|
119
- hash[filename] = Digest::MD5.hexdigest(File.read(filename))
121
+ hash[filename] = algorithm.hexdigest(File.read(filename))
120
122
  hash
121
123
  end
122
124
  end
@@ -1,3 +1,3 @@
1
1
  module FixtureBuilder
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3.rc2'
3
3
  end
@@ -97,4 +97,22 @@ class FixtureBuilderTest < Test::Unit::TestCase
97
97
  generated_fixture = YAML.load(File.open(test_path("fixtures/magical_creatures.yml")))
98
98
  assert_equal "---\n- shading\n- rooting\n- seeding\n", generated_fixture['enty']['powers']
99
99
  end
100
+
101
+ def test_sha1_digests
102
+ create_and_blow_away_old_db
103
+ force_fixture_generation_due_to_differing_file_hashes
104
+
105
+ FixtureBuilder.configure(use_sha1_digests: true) do |fbuilder|
106
+ fbuilder.files_to_check += Dir[test_path("*.rb")]
107
+ fbuilder.factory do
108
+ @enty = MagicalCreature.create(:name => 'Enty', :species => 'ent',
109
+ :powers => %w{shading rooting seeding})
110
+ end
111
+ first_modified_time = File.mtime(test_path("fixtures/magical_creatures.yml"))
112
+ fbuilder.factory do
113
+ end
114
+ second_modified_time = File.mtime(test_path("fixtures/magical_creatures.yml"))
115
+ assert_equal first_modified_time, second_modified_time
116
+ end
117
+ end
100
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixture_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Dy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-11 00:00:00.000000000 Z
13
+ date: 2019-10-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord