fixture_builder 0.4.1 → 0.5.0.pre.RC1

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
  SHA1:
3
- metadata.gz: 88be66fdfa6b55c410181695639f1f8eccb4cf40
4
- data.tar.gz: 1b67144f414b08d6b4eb1f9e7c6b9231d5e3abbd
3
+ metadata.gz: fd04e7fa891e330d81f57fd11d2e85245f81ba60
4
+ data.tar.gz: 67001cc364472a4acffbf1123d14efaf48127d49
5
5
  SHA512:
6
- metadata.gz: f11e75f29b93eec5e1a3e80e57842859683b9966fb309645892f9ee8958e23b9c80599b0705d686c6efaf19aac0ae090bec867b428a1cc274d707436acd34adc
7
- data.tar.gz: e7088a5a2d5efd38b7b3b2f2f744f1a62bd8b7955e58167526f01318d12a9909d8d1578d5b28d4b45d836189fe0758216a8df4b4dc7e51fa167300c2dedbf4ee
6
+ metadata.gz: 23700888f067cf8065ed961eb2f80e84e18283bfb0cf567e817cd6b126602c8e61a49525887a85d9e4d588a88fc4942ba0e655e68988db3857ca0856b168a873
7
+ data.tar.gz: d6bc268f5279448748b4c9a27d16d2510f59547dea8edbab35a0a8e00b9e80d7cb3e660f5ea925855daf12954e89276f43f0a9e393cad1729e116be9cfa91ce5
data/.travis.yml CHANGED
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.5
4
+ before_install:
5
+ - gem update --system
6
+ - gem update bundler
7
+ - gem cleanup bundler
data/README.markdown CHANGED
@@ -77,8 +77,8 @@ By default these are set as:
77
77
  * fixture_builder_file: RAILS_ROOT/tmp/fixture_builder.yml
78
78
  * record_name_fields: %w{ schema_migrations }
79
79
  * skip_tables: %w{ schema_migrations }
80
- * select_sql: SELECT * FROM %s
81
- * delete_sql: DELETE FROM %s
80
+ * select_sql: SELECT * FROM %{table}
81
+ * delete_sql: DELETE FROM %{table}
82
82
 
83
83
  Sequence Collisions
84
84
  ===================
@@ -62,7 +62,7 @@ module FixtureBuilder
62
62
 
63
63
  def write_data_to_files
64
64
  delete_yml_files
65
- dump_empty_fixtures_for_all_tables
65
+ dump_empty_fixtures_for_all_tables if write_empty_files
66
66
  dump_tables
67
67
  end
68
68
 
@@ -73,7 +73,7 @@ module FixtureBuilder
73
73
 
74
74
  def delete_tables
75
75
  ActiveRecord::Base.connection.disable_referential_integrity do
76
- tables.each { |t| ActiveRecord::Base.connection.delete(delete_sql % ActiveRecord::Base.connection.quote_table_name(t)) }
76
+ tables.each { |t| ActiveRecord::Base.connection.delete(delete_sql % {table: ActiveRecord::Base.connection.quote_table_name(t)}) }
77
77
  end
78
78
  end
79
79
 
@@ -108,7 +108,7 @@ module FixtureBuilder
108
108
  end
109
109
  end
110
110
  else
111
- rows = ActiveRecord::Base.connection.select_all(select_sql % ActiveRecord::Base.connection.quote_table_name(table_name))
111
+ rows = ActiveRecord::Base.connection.select_all(select_sql % {table: ActiveRecord::Base.connection.quote_table_name(table_name)})
112
112
  end
113
113
  next files if rows.empty?
114
114
 
@@ -129,7 +129,11 @@ module FixtureBuilder
129
129
 
130
130
  def serialized_value_if_needed(table_klass, attr_name, value)
131
131
  if table_klass.respond_to?(:type_for_attribute)
132
- table_klass.type_for_attribute(attr_name).type_cast_for_database(value)
132
+ if table_klass.type_for_attribute(attr_name).respond_to?(:serialize)
133
+ table_klass.type_for_attribute(attr_name).serialize(value)
134
+ else
135
+ table_klass.type_for_attribute(attr_name).type_cast_for_database(value)
136
+ end
133
137
  else
134
138
  if table_klass.serialized_attributes.has_key? attr_name
135
139
  table_klass.serialized_attributes[attr_name].dump(value)
@@ -8,7 +8,8 @@ module FixtureBuilder
8
8
  include Delegations::Namer
9
9
 
10
10
  ACCESSIBLE_ATTRIBUTES = [:select_sql, :delete_sql, :skip_tables, :files_to_check, :record_name_fields,
11
- :fixture_builder_file, :fixture_directory, :after_build, :legacy_fixtures, :model_name_procs]
11
+ :fixture_builder_file, :fixture_directory, :after_build, :legacy_fixtures, :model_name_procs,
12
+ :write_empty_files]
12
13
  attr_accessor(*ACCESSIBLE_ATTRIBUTES)
13
14
 
14
15
  SCHEMA_FILES = ['db/schema.rb', 'db/development_structure.sql', 'db/test_structure.sql', 'db/production_structure.sql']
@@ -16,6 +17,7 @@ module FixtureBuilder
16
17
  def initialize(opts={})
17
18
  @namer = Namer.new(self)
18
19
  @file_hashes = file_hashes
20
+ @write_empty_files = true
19
21
  end
20
22
 
21
23
  def include(*args)
@@ -34,11 +36,27 @@ module FixtureBuilder
34
36
  end
35
37
 
36
38
  def select_sql
37
- @select_sql ||= "SELECT * FROM %s"
39
+ @select_sql ||= "SELECT * FROM %{table}"
40
+ end
41
+
42
+ def select_sql=(sql)
43
+ if sql =~ /%s/
44
+ ActiveSupport::Deprecation.warn("Passing '%s' into select_sql is deprecated. Please use '%{table}' instead.", caller)
45
+ sql = sql.sub(/%s/, '%{table}')
46
+ end
47
+ @select_sql = sql
38
48
  end
39
49
 
40
50
  def delete_sql
41
- @delete_sql ||= "DELETE FROM %s"
51
+ @delete_sql ||= "DELETE FROM %{table}"
52
+ end
53
+
54
+ def delete_sql=(sql)
55
+ if sql =~ /%s/
56
+ ActiveSupport::Deprecation.warn("Passing '%s' into delete_sql is deprecated. Please use '%{table}' instead.", caller)
57
+ sql = sql.sub(/%s/, '%{table}')
58
+ end
59
+ @delete_sql = sql
42
60
  end
43
61
 
44
62
  def skip_tables
@@ -1,3 +1,3 @@
1
1
  module FixtureBuilder
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0-RC1'
3
3
  end
@@ -9,7 +9,7 @@ namespace :spec do
9
9
 
10
10
  desc "Build the generated fixtures to spec/fixtures if dirty"
11
11
  task :build => :environment do
12
- ActiveRecord::Base.establish_connection('test')
12
+ ActiveRecord::Base.establish_connection(:test)
13
13
  Dir.glob(File.join(Rails.root, '{spec,test}', '**', 'fixture_builder.rb')).each{|file| require(file)}
14
14
  end
15
15
 
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.4.1
4
+ version: 0.5.0.pre.RC1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Dy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-04 00:00:00.000000000 Z
12
+ date: 2016-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project: fixture_builder
150
- rubygems_version: 2.2.2
150
+ rubygems_version: 2.4.3
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: Build YAML fixtures using object factories