active_data 1.1.0 → 1.1.1

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: df62766321d027161f359a1101e7e8a94842386b72188a02d7a3686f679f466e
4
- data.tar.gz: 0331643a7e25c573a79269df28096971189efc52730c41b58e3922a1ab0c50af
3
+ metadata.gz: a7a72a84858d1c5737ed98029682614052de1281e89d617d934a5ab7e16cd93c
4
+ data.tar.gz: ca64b3895dd8bbdd4503e8a8425aef4c210e0fb33f15f456bfe69d25fe741776
5
5
  SHA512:
6
- metadata.gz: de160dbcd218f15a9203e29bf6e1fdde66b028fb97cee58b8f2816e6191202909c173da2d8db6ea8fd2db02e91314510b501c358852d3e2fe9b13876d093794c
7
- data.tar.gz: 20b7783fc647ce010928847da8e5d8c4bd9cfeb0fcb0618114b72186cbcd76e6efa723f79f0f2856f41cd7cb766a5cfa3e6eddd3c34d02b5ce949754a5e83b0b
6
+ metadata.gz: 18452047bf27f1a2ea4b2428ebc0e887bce1fb03bbed3dc44a0e2867ad761dca984a828796cd4691b9c6a5240f432cfe4f6c79ff20197be044cd30971db84a41
7
+ data.tar.gz: 9f11d63a14102cee31677b9a97bdda8ff90f734ca3d18d3473ee0fee9da2ae8a61c08e240e4697d4eb86d55f5b56b79412438eeb92fd7f8197098510f2969882
data/.gitignore CHANGED
@@ -15,3 +15,7 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rvmrc
19
+ .version-conf
20
+ .ruby-version
21
+ .ruby-gemset
data/.rubocop.yml CHANGED
@@ -1,5 +1,9 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ AllCops:
4
+ DisplayCopNames: true
5
+ TargetRubyVersion: 2.2.10
6
+
3
7
  Lint/AmbiguousBlockAssociation:
4
8
  Enabled: false
5
9
 
@@ -54,3 +58,6 @@ Style/AndOr:
54
58
 
55
59
  Style/DoubleNegation:
56
60
  Enabled: false
61
+
62
+ Style/FrozenStringLiteralComment:
63
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -10,11 +10,6 @@
10
10
  Metrics/AbcSize:
11
11
  Max: 54
12
12
 
13
- # Offense count: 1
14
- # Configuration parameters: CountComments.
15
- Metrics/BlockLength:
16
- Max: 26
17
-
18
13
  # Offense count: 2
19
14
  # Configuration parameters: CountComments.
20
15
  Metrics/ClassLength:
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  sudo: false
2
2
 
3
3
  rvm:
4
- - 2.2.8
5
- - 2.3.5
4
+ - 2.2.10
5
+ - 2.3.7
6
+ - 2.4.4
6
7
  - rbx
7
8
 
8
9
  gemfile:
@@ -11,15 +12,18 @@ gemfile:
11
12
  - gemfiles/rails.4.2.gemfile
12
13
  - gemfiles/rails.5.0.gemfile
13
14
  - gemfiles/rails.5.1.gemfile
15
+ - gemfiles/rails.5.2.gemfile
14
16
 
15
17
  matrix:
16
18
  allow_failures:
17
19
  - rvm: rbx
18
- include:
19
- - rvm: 2.4.2
20
- gemfile: gemfiles/rails.5.0.gemfile
21
- - rvm: 2.4.2
22
- gemfile: gemfiles/rails.5.1.gemfile
20
+ exclude:
21
+ - rvm: 2.4.4
22
+ gemfile: gemfiles/rails.4.0.gemfile
23
+ - rvm: 2.4.4
24
+ gemfile: gemfiles/rails.4.1.gemfile
25
+ - rvm: 2.4.4
26
+ gemfile: gemfiles/rails.4.2.gemfile
23
27
 
24
28
  before_install:
25
29
  - gem update --system --no-doc
data/Appraisals CHANGED
@@ -1,4 +1,4 @@
1
- %w[4.0 4.1 4.2 5.0 5.1].each do |version|
1
+ %w[4.0 4.1 4.2 5.0 5.1 5.2].each do |version|
2
2
  appraise "rails.#{version}" do
3
3
  gem 'activesupport', "~> #{version}.0"
4
4
  gem 'activemodel', "~> #{version}.0"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # master
2
2
 
3
+ # Version 1.1.1
4
+
5
+ ## Changes
6
+
7
+ * `ActiveData.base_class` config option (#63)
8
+
9
+ * ActiveModel 5.2 compatibility (#62)
10
+
3
11
  # Version 1.1.0
4
12
 
5
13
  ## Incompatible changes
data/active_data.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_development_dependency 'rake'
21
21
  gem.add_development_dependency 'rspec'
22
22
  gem.add_development_dependency 'rspec-its'
23
- gem.add_development_dependency 'rubocop'
23
+ gem.add_development_dependency 'rubocop', '0.52.1'
24
24
  gem.add_development_dependency 'rubysl', '~> 2.0' if RUBY_ENGINE == 'rbx'
25
25
  gem.add_development_dependency 'sqlite3'
26
26
  gem.add_development_dependency 'uuidtools'
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 5.2.0"
6
+ gem "activemodel", "~> 5.2.0"
7
+ gem "activerecord", "~> 5.2.0"
8
+
9
+ group :test do
10
+ gem "guard"
11
+ gem "guard-rspec"
12
+ end
13
+
14
+ gemspec path: "../"
@@ -2,7 +2,7 @@ module ActiveData
2
2
  class Config
3
3
  include Singleton
4
4
 
5
- attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute,
5
+ attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute, :base_class,
6
6
  :_normalizers, :_typecasters
7
7
 
8
8
  def self.delegated
@@ -7,7 +7,7 @@ module ActiveData
7
7
  if block
8
8
  options[:class] = proc do |reflection|
9
9
  superclass = reflection.options[:class_name].to_s.presence.try(:constantize)
10
- klass = Class.new(superclass || ActiveData::Base) do
10
+ klass = Class.new(superclass || ActiveData.base_class) do
11
11
  include ActiveData::Model
12
12
  include ActiveData::Model::Associations
13
13
  include ActiveData::Model::Lifecycle
@@ -16,34 +16,39 @@ module ActiveData
16
16
  def self.included(_base); end
17
17
  end
18
18
 
19
+ include DIRTY_CLONE
20
+
19
21
  included do
20
- include DIRTY_CLONE
22
+ attribute_names(false).each do |name|
23
+ define_dirty name, generated_attributes_methods
24
+ end
25
+ _attribute_aliases.each_key do |name|
26
+ define_dirty name, generated_attributes_methods
27
+ end
28
+ end
21
29
 
22
- unless method_defined?(:set_attribute_was)
23
- def set_attribute_was(attr, old_value)
24
- changed_attributes[attr] = old_value
25
- end
26
- private :set_attribute_was
30
+ if !method_defined?(:set_attribute_was) && !private_method_defined?(:set_attribute_was)
31
+ private def set_attribute_was(attr, old_value)
32
+ changed_attributes[attr] = old_value
27
33
  end
34
+ end
28
35
 
29
- unless method_defined?(:clear_changes_information)
30
- if method_defined?(:reset_changes)
31
- def clear_changes_information
32
- reset_changes
33
- end
34
- else
35
- def clear_changes_information
36
- @previously_changed = nil
37
- @changed_attributes = nil
38
- end
36
+ unless method_defined?(:clear_changes_information)
37
+ if method_defined?(:reset_changes)
38
+ def clear_changes_information
39
+ reset_changes
40
+ end
41
+ else
42
+ def clear_changes_information
43
+ @previously_changed = nil
44
+ @changed_attributes = nil
39
45
  end
40
46
  end
47
+ end
41
48
 
42
- attribute_names(false).each do |name|
43
- define_dirty name, generated_attributes_methods
44
- end
45
- _attribute_aliases.each_key do |name|
46
- define_dirty name, generated_attributes_methods
49
+ unless method_defined?(:_read_attribute)
50
+ def _read_attribute(attr)
51
+ __send__(attr)
47
52
  end
48
53
  end
49
54
 
@@ -1,3 +1,3 @@
1
1
  module ActiveData
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
data/lib/active_data.rb CHANGED
@@ -136,6 +136,8 @@ end
136
136
 
137
137
  require 'active_data/base'
138
138
 
139
+ ActiveData.base_class = ActiveData::Base
140
+
139
141
  ActiveSupport.on_load :active_record do
140
142
  require 'active_data/active_record/associations'
141
143
  require 'active_data/active_record/nested_attributes'
@@ -53,7 +53,7 @@ describe ActiveData::Model::Associations::Validations do
53
53
  specify { expect(user.validate).to eq(false) }
54
54
  specify do
55
55
  expect { user.validate }.to change { user.errors.messages }
56
- .to(:'projects.0.author.name' => ["can't be blank"])
56
+ .to('projects.0.author.name': ["can't be blank"])
57
57
  end
58
58
  end
59
59
 
@@ -70,7 +70,7 @@ describe ActiveData::Model::Associations::Validations do
70
70
  specify { expect(user.validate).to eq(false) }
71
71
  specify do
72
72
  expect { user.validate }.to change { user.errors.messages }
73
- .to(:'projects.1.title' => ["can't be blank"])
73
+ .to('projects.1.title': ["can't be blank"])
74
74
  end
75
75
  end
76
76
  end
@@ -98,7 +98,7 @@ describe ActiveData::Model::Associations::Validations do
98
98
  specify { expect(user.invalid_ancestry?).to eq(true) }
99
99
  specify do
100
100
  expect { user.validate_ancestry }.to change { user.errors.messages }
101
- .to(:'projects.0.author.name' => ["can't be blank"])
101
+ .to('projects.0.author.name': ["can't be blank"])
102
102
  end
103
103
  end
104
104
 
@@ -110,7 +110,7 @@ describe ActiveData::Model::Associations::Validations do
110
110
  specify { expect(user.invalid_ancestry?).to eq(true) }
111
111
  specify do
112
112
  expect { user.validate_ancestry }.to change { user.errors.messages }
113
- .to(:'profile.first_name' => ["can't be blank"])
113
+ .to('profile.first_name': ["can't be blank"])
114
114
  end
115
115
  end
116
116
 
@@ -122,14 +122,14 @@ describe ActiveData::Model::Associations::Validations do
122
122
  specify { expect(user.invalid_ancestry?).to eq(true) }
123
123
  specify do
124
124
  expect { user.validate_ancestry }.to change { user.errors.messages }
125
- .to(:'projects.1.title' => ["can't be blank"])
125
+ .to('projects.1.title': ["can't be blank"])
126
126
  end
127
127
 
128
128
  context do
129
129
  before { user.update(login: '') }
130
130
  specify do
131
131
  expect { user.validate_ancestry }.to change { user.errors.messages }
132
- .to(:'projects.1.title' => ["can't be blank"], login: ["can't be blank"])
132
+ .to('projects.1.title': ["can't be blank"], login: ["can't be blank"])
133
133
  end
134
134
  end
135
135
  end
@@ -120,7 +120,7 @@ describe ActiveData::Model::Representation do
120
120
 
121
121
  specify do
122
122
  expect { post.validate }.to change { post.errors.messages }
123
- .to(hash_including(:'author.user.email' => ['is invalid'], name: ["can't be blank"]))
123
+ .to(hash_including('author.user.email': ['is invalid'], name: ["can't be blank"]))
124
124
  end
125
125
  end
126
126
  end
@@ -68,7 +68,7 @@ describe ActiveData::Model::Validations::AssociatedValidator do
68
68
  it { is_expected.not_to be_valid }
69
69
  specify do
70
70
  expect { instance.validate }.to change { instance.errors.messages }
71
- .to(:'validated_many.0.name' => ["can't be blank"], validated_many: ['is invalid'])
71
+ .to('validated_many.0.name': ["can't be blank"], validated_many: ['is invalid'])
72
72
  end
73
73
  end
74
74
 
@@ -96,7 +96,7 @@ describe ActiveData::Model::Validations::AssociatedValidator do
96
96
  it { is_expected.not_to be_valid }
97
97
  specify do
98
98
  expect { instance.validate }.to change { instance.errors.messages }
99
- .to(:'validated_many.0.name' => ["can't be blank"], validated_many: ['is invalid'])
99
+ .to('validated_many.0.name': ["can't be blank"], validated_many: ['is invalid'])
100
100
  end
101
101
  end
102
102
  end
@@ -45,7 +45,7 @@ describe ActiveData::Model::Validations::NestedValidator do
45
45
  it { is_expected.not_to be_valid }
46
46
  specify do
47
47
  expect { instance.validate }.to change { instance.errors.messages }
48
- .to(:'validated_one.name' => ["can't be blank"])
48
+ .to('validated_one.name': ["can't be blank"])
49
49
  end
50
50
  end
51
51
 
@@ -69,7 +69,7 @@ describe ActiveData::Model::Validations::NestedValidator do
69
69
  it { is_expected.not_to be_valid }
70
70
  specify do
71
71
  expect { instance.validate }.to change { instance.errors.messages }
72
- .to(:'validated_many.0.name' => ["can't be blank"])
72
+ .to('validated_many.0.name': ["can't be blank"])
73
73
  end
74
74
  end
75
75
 
@@ -88,7 +88,7 @@ describe ActiveData::Model::Validations::NestedValidator do
88
88
  it { is_expected.not_to be_valid }
89
89
  specify do
90
90
  expect { instance.validate }.to change { instance.errors.messages }
91
- .to(:'validated_one.name' => ["can't be blank"])
91
+ .to('validated_one.name': ["can't be blank"])
92
92
  end
93
93
  end
94
94
 
@@ -152,7 +152,7 @@ describe ActiveData::Model::Validations::NestedValidator do
152
152
  it { is_expected.not_to be_valid }
153
153
  specify do
154
154
  expect { instance.validate }.to change { instance.errors.messages }
155
- .to(:'validated_many.0.name' => ["can't be blank"])
155
+ .to('validated_many.0.name': ["can't be blank"])
156
156
  end
157
157
  end
158
158
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pyromaniac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-23 00:00:00.000000000 Z
11
+ date: 2018-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.52.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.52.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sqlite3
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +190,6 @@ files:
190
190
  - ".rspec"
191
191
  - ".rubocop.yml"
192
192
  - ".rubocop_todo.yml"
193
- - ".rvmrc"
194
193
  - ".travis.yml"
195
194
  - Appraisals
196
195
  - CHANGELOG.md
@@ -205,6 +204,7 @@ files:
205
204
  - gemfiles/rails.4.2.gemfile
206
205
  - gemfiles/rails.5.0.gemfile
207
206
  - gemfiles/rails.5.1.gemfile
207
+ - gemfiles/rails.5.2.gemfile
208
208
  - lib/active_data.rb
209
209
  - lib/active_data/active_record/associations.rb
210
210
  - lib/active_data/active_record/nested_attributes.rb
@@ -333,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  requirements: []
335
335
  rubyforge_project:
336
- rubygems_version: 2.7.4
336
+ rubygems_version: 2.7.6
337
337
  signing_key:
338
338
  specification_version: 4
339
339
  summary: Working with hashes in AR style
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create 2.4@active_data