evil-seed 0.1.3 → 0.2.0

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: 16e2debd96436300fcb0428895a7483a599303ac6819b01f343077153b6c5802
4
- data.tar.gz: '09b8b97f80484b8904e4fe6283d4cd2652b8cbdbe14e1dfd9d1ff11ec7739a10'
3
+ metadata.gz: 49f3bab8298bfc4a918791ff92abb7d60d63f7a8d14bbb37b353bfa59fe33818
4
+ data.tar.gz: f11da93930102998a035b1ea83e1bc3c382ad829d43490a6ef7263af27d8e7c7
5
5
  SHA512:
6
- metadata.gz: 947a49967d2703291fcfd35a7841b5ed821b6edd348184d5a6a4205d2d98b42d36b45a61f70bdab2245864e161db8f3d716907152a2842740c8124b25d5db9ef
7
- data.tar.gz: e589e7c129d730802c802bf7a630ab09c088d8479e2e39e304fb94b51b36d07e7827d5bc703bc29c74e74f1d20c8c28dc23ffd5f3bcc8a0a9e6eb75901045c58
6
+ metadata.gz: f446f6c8634d9385d75f8ccdf7e2a76cdfea9b17886759ca63993a70044bc15e77f111442e9d323c4c158907c7751ee927c778b3c58e43c06f81bef737e26ff6
7
+ data.tar.gz: 604448e710c92999cffe29a6e137a4cee328f3f8bec5b2c44fa5c3ee3fb9b1393c87b104c2826e8792f4724cec34bfd576bd55e588dfc8bdd50eb63c991e0a56
data/Appraisals CHANGED
@@ -1,10 +1,3 @@
1
- appraise 'activerecord-4-2' do
2
- gem 'activerecord', '~> 4.2.0'
3
- gem 'pg', '~> 0.20'
4
- gem 'mysql2', '~> 0.3.18'
5
- gem 'sqlite3', '~> 1.3.6'
6
- end
7
-
8
1
  appraise 'activerecord-5-0' do
9
2
  gem 'activerecord', '~> 5.0.0'
10
3
  gem "pg", ">= 0.20", "< 2.0"
data/evil-seed.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.required_ruby_version = '>= 2.0'
29
29
 
30
- spec.add_dependency 'activerecord', '>= 4.2'
30
+ spec.add_dependency 'activerecord', '>= 5.0'
31
31
 
32
32
  spec.add_development_dependency 'rake', '~> 12.0'
33
33
  spec.add_development_dependency 'minitest', '~> 5.0'
@@ -33,13 +33,13 @@ module EvilSeed
33
33
  end
34
34
 
35
35
  def respond_to_missing?(attribute_name)
36
- @model_class.attribute_names.include?(attribute_name.to_s) || super
36
+ @model_class.column_names.include?(attribute_name.to_s) || super
37
37
  end
38
38
 
39
39
  private
40
40
 
41
41
  def method_missing(attribute_name, &block)
42
- return super unless @model_class.attribute_names.include?(attribute_name.to_s)
42
+ return super unless @model_class.column_names.include?(attribute_name.to_s)
43
43
  @changers[attribute_name.to_s] = block
44
44
  end
45
45
  end
@@ -53,7 +53,7 @@ module EvilSeed
53
53
  def insert_statement
54
54
  connection = model_class.connection
55
55
  table_name = connection.quote_table_name(model_class.table_name)
56
- columns = model_class.attribute_names.map { |c| connection.quote_column_name(c) }.join(', ')
56
+ columns = model_class.column_names.map { |c| connection.quote_column_name(c) }.join(', ')
57
57
  "INSERT INTO #{table_name} (#{columns}) VALUES\n"
58
58
  end
59
59
 
@@ -73,27 +73,8 @@ module EvilSeed
73
73
 
74
74
  def prepare(attributes)
75
75
  attributes.map do |key, value|
76
- model_class.connection.quote(serialize(attribute_types[key], value))
77
- end
78
- end
79
-
80
- # Handles ActiveRecord API differences between AR 4.2 and 5.0
81
- def attribute_types
82
- return @attribute_types if defined?(@attribute_types)
83
- @attribute_types = if model_class.respond_to?(:attribute_types)
84
- model_class.attribute_types
85
- else
86
- model_class.column_types
87
- end
88
- end
89
-
90
- # Handles ActiveRecord API differences between AR 4.2 and 5.0
91
- # Casts a value from the ruby type to a type that the database knows how to understand.
92
- def serialize(type, value)
93
- if type.respond_to?(:serialize)
94
- type.serialize(value)
95
- else
96
- type.type_cast_for_database(value)
76
+ type = model_class.attribute_types[key]
77
+ model_class.connection.quote(type.serialize(value))
97
78
  end
98
79
  end
99
80
  end
@@ -124,8 +124,8 @@ module EvilSeed
124
124
  # @param relation [ActiveRecord::Relation]
125
125
  # @return [Array<Hash{String => String, Integer, Float, Boolean, nil}>]
126
126
  def fetch_attributes(relation)
127
- relation.pluck(*model_class.attribute_names).map do |row|
128
- Hash[model_class.attribute_names.zip(row)]
127
+ relation.pluck(*model_class.column_names).map do |row|
128
+ Hash[model_class.column_names.zip(row)]
129
129
  end
130
130
  end
131
131
 
@@ -146,7 +146,7 @@ module EvilSeed
146
146
  next false if reflection.options[:polymorphic] # TODO: Add support for polymorphic belongs_to
147
147
  excluded = root.excluded?("#{association_path}.#{reflection.name}") || reflection.name == inverse_reflection
148
148
  if excluded
149
- nullify_columns << reflection.foreign_key if model_class.attribute_names.include?(reflection.foreign_key)
149
+ nullify_columns << reflection.foreign_key if model_class.column_names.include?(reflection.foreign_key)
150
150
  else
151
151
  foreign_keys[reflection.name] = reflection.foreign_key
152
152
  table_names[reflection.name] = reflection.table_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvilSeed
4
- VERSION = '0.1.3'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evil-seed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-09-01 00:00:00.000000000 Z
12
+ date: 2022-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4.2'
20
+ version: '5.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '4.2'
27
+ version: '5.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +172,6 @@ files:
172
172
  - bin/setup
173
173
  - evil-seed.gemspec
174
174
  - gemfiles/.bundle/config
175
- - gemfiles/activerecord_4_2.gemfile
176
175
  - gemfiles/activerecord_5_0.gemfile
177
176
  - gemfiles/activerecord_5_1.gemfile
178
177
  - gemfiles/activerecord_5_2.gemfile
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.2.0"
6
- gem "pg", "~> 0.20"
7
- gem "mysql2", "~> 0.3.18"
8
- gem "sqlite3", "~> 1.3.6"
9
-
10
- gemspec path: "../"