evil-client 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e0323c33d7f3cf56d4aca84057aef698e57efbb
4
- data.tar.gz: fde6a5543b7c8775350d18cf805b8efe277d65cb
3
+ metadata.gz: 2ccf12ec7a65e3b93d702235488587267b4b63bf
4
+ data.tar.gz: 24d639ea31d94a956cf919c873098f3ec2beea75
5
5
  SHA512:
6
- metadata.gz: 4bcaf9be801454e01f7a99d0385f71eafabbe6e98955ea24b3541d0a5a68bfb88e891ca714736354a8bbd3e45c57c4936ee84e2a2f65abd4606b4b45dc53b149
7
- data.tar.gz: 21161df236b8079fb8511bac24f5a3c87e4054803d18f7811a0d46a68941595ed4a5de59517e856c1e4a9ce8f1ef9022eeebf7e67a7dc4b9154303e684ebb09d
6
+ metadata.gz: c0db70d946408b64ec9875605b37c7f26af598c0f062c31bf4524ddb820b41ff43d598626e9f865ffd859ab7a911c7c20c4add08f3e080ab0ba6e83c128ba050
7
+ data.tar.gz: 25f5a6ffb7c7c05ed40ceb47a3899ce651db16453f7561b631c6bb680a4713b963ba10eb291044a4ce168d9fd653abe214537555828bf0882471018020f6cf39
data/CHANGELOG.md CHANGED
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog], and this project adheres
5
5
  to [Semantic Versioning].
6
6
 
7
- ## [2.1.0] [WIP]
7
+ ## [2.1.1] [2018-01-05]
8
+
9
+ ### Changed
10
+
11
+ - Dependency from [tram-policy] was updated to v2.3+ (nepalez)
12
+
13
+ ## [2.1.0] [2018-01-04]
8
14
 
9
15
  ### Added
10
16
 
@@ -23,7 +29,7 @@ to [Semantic Versioning].
23
29
  end
24
30
  ```
25
31
 
26
- - Method to pass response handling to parent scopes by @Envek ([#21](https://github.com/evilmartians/evil-client/pull/21]))
32
+ - Method to pass response handling to parent scopes (Envek)
27
33
 
28
34
  Allow to handle specific cases in operations and common cases in parent scopes.
29
35
 
@@ -44,11 +50,11 @@ to [Semantic Versioning].
44
50
 
45
51
  ### Fixed
46
52
 
47
- - Generation of English error messages in case of using non-English locales
53
+ - Generation of English error messages in case of using non-English locales (Envek)
48
54
 
49
55
  ### Changed
50
56
 
51
- - Version requirement for tram-policy is limited due to regression in 0.2.4
57
+ - Version requirement for tram-policy is limited due to regression in 0.2.4 (Envek)
52
58
 
53
59
  See https://github.com/tram-rb/tram-policy/commit/874c8f61399dbe174c158fec729d16c2b1ffb2fd#r26432444
54
60
 
@@ -432,7 +438,8 @@ formats will be added.
432
438
 
433
439
  [Keep a Changelog]: http://keepachangelog.com/
434
440
  [Semantic Versioning]: http://semver.org/
435
- [dry-initializer]: http://github.com/dry-rb/dry-initalizer
441
+ [dry-initializer]: https://github.com/dry-rb/dry-initalizer
442
+ [tram-policy]: https://github.com/tram-rb/tram-policy
436
443
  [0.3.1]: https://github.com/evilmartians/evil-client/compare/v0.3.0...v0.3.1
437
444
  [0.3.2]: https://github.com/evilmartians/evil-client/compare/v0.3.1...v0.3.2
438
445
  [0.3.3]: https://github.com/evilmartians/evil-client/compare/v0.3.2...v0.3.3
data/evil-client.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "evil-client"
3
- gem.version = "2.1.0"
3
+ gem.version = "2.1.1"
4
4
  gem.author = ["Andrew Kozin (nepalez)", "Ravil Bairamgalin (brainopia)"]
5
5
  gem.email = ["andrew.kozin@gmail.com", "nepalez@evilmartians.com"]
6
6
  gem.homepage = "https://github.com/evilmartians/evil-client"
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.add_runtime_dependency "dry-initializer", "~> 2.1"
17
17
  gem.add_runtime_dependency "mime-types", "~> 3.1"
18
18
  gem.add_runtime_dependency "rack", "~> 2"
19
- gem.add_runtime_dependency "tram-policy", "~> 0.2.2", "<= 0.2.3"
19
+ gem.add_runtime_dependency "tram-policy", "~> 0.2.3"
20
20
 
21
21
  gem.add_development_dependency "rake", ">= 10"
22
22
  gem.add_development_dependency "rspec", "~> 3.0"
@@ -79,22 +79,11 @@ class Evil::Client
79
79
  # @param [Evil::Client::Model] other
80
80
  # @return [self]
81
81
  #
82
- # rubocop: disable Metrics/AbcSize
83
82
  def extend(other)
84
83
  return super if other.instance_of? Module
85
-
86
- unless other.ancestors.include? Evil::Client::Model
87
- raise TypeError, "#{other} is not a subclass of Evil::Client::Model"
88
- end
89
-
90
- other.dry_initializer.options.each do |definition|
91
- option definition.source, definition.options
92
- end
93
-
94
- other.lets.each { |key, block| let(key, &block) }
95
- other.policy.all.each { |validator| policy.local << validator }
84
+ validate_model other
85
+ extend_model other
96
86
  end
97
- # rubocop: enable Metrics/AbcSize
98
87
 
99
88
  # Model instance constructor
100
89
  #
@@ -113,13 +102,28 @@ class Evil::Client
113
102
  private
114
103
 
115
104
  def in_english(&block)
116
- unless I18n.available_locales.include?(:en)
117
- available_locales = I18n.available_locales
118
- I18n.available_locales += %i[en]
119
- end
105
+ available_locales = Array I18n.available_locales
106
+ I18n.available_locales = available_locales | %i[en]
120
107
  I18n.with_locale(:en, &block)
121
108
  ensure
122
- I18n.available_locales = available_locales if available_locales
109
+ I18n.available_locales = available_locales
110
+ end
111
+
112
+ def validate_model(other)
113
+ return if other.ancestors.include? Evil::Client::Model
114
+ raise TypeError, "#{other} is not a subclass of Evil::Client::Model"
115
+ end
116
+
117
+ def extend_model(other)
118
+ other.dry_initializer.options.each do |definition|
119
+ option definition.source, definition.options
120
+ end
121
+
122
+ other.lets.each { |key, block| let(key, &block) }
123
+
124
+ other.policy.validators.each do |validator|
125
+ policy.local_validators << validator
126
+ end
123
127
  end
124
128
  end
125
129
  end
@@ -32,11 +32,13 @@ class Evil::Client
32
32
  alias_method :to_sym, :name
33
33
  alias_method :inspect, :name
34
34
 
35
- private
36
-
35
+ # Redefines translation scope for the policy
36
+ #
37
+ # @return[Array<Symbol>]
38
+ #
37
39
  def scope
38
40
  @scope ||= %i[evil client errors] << \
39
- Tram::Policy::Inflector.underscore(model.to_s)
41
+ Tram::Policy::Inflector.underscore(model.to_s).to_sym
40
42
  end
41
43
  end
42
44
 
@@ -9,9 +9,12 @@ en:
9
9
  token_present: "To update user id:%{id} you must provide a token"
10
10
  name_present: "The user has no name"
11
11
  test/client:
12
- valid_credentials: You should set either token or password to authenticate the client
12
+ valid_credentials: &vc You should set either token or password to authenticate the client
13
13
  crm:
14
14
  users:
15
+ valid_credentials: *vc
16
+ fetch:
17
+ valid_credentials: *vc
15
18
  filter:
16
19
  filter_given: You should define some filter with either name, email, or id
17
20
  test/model:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evil-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin (nepalez)
@@ -58,9 +58,6 @@ dependencies:
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: 0.2.2
63
- - - "<="
64
61
  - !ruby/object:Gem::Version
65
62
  version: 0.2.3
66
63
  type: :runtime
@@ -68,9 +65,6 @@ dependencies:
68
65
  version_requirements: !ruby/object:Gem::Requirement
69
66
  requirements:
70
67
  - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: 0.2.2
73
- - - "<="
74
68
  - !ruby/object:Gem::Version
75
69
  version: 0.2.3
76
70
  - !ruby/object:Gem::Dependency