tram-policy 2.0.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: d2d94489718b8070f78e8a4792e67902336e87d03da02d216fe49069767684fb
4
- data.tar.gz: 4c9e417c8a39f18e0faf75c2b7bae22f7d3aa0e53c2c9486e068910f59837f2f
3
+ metadata.gz: ee9ed362efd81c55cfe3097f6188f8da61af5b3ec78eee0eb6e5182bbfd62245
4
+ data.tar.gz: f2ab09546f5c6c5a70fca9459b1e2658dab85b0b2f9ffd27685ba61b00c62f06
5
5
  SHA512:
6
- metadata.gz: 71862e68041ee87d414f60bcf79c5f84f4996db5bc1ddc143628598dc29f0ca4a9816c7669b63a1c10e9e737e371800ff9ad1b214ed814753ce4c393c3877165
7
- data.tar.gz: 6278ffc6803fdb5ab6f96bc4c4d2a38ad7758e2eb723fca763234aa647e2ba6b1854220059d2ce0cc182215042b2926080ad39f39eb815614610850d12e2d72c
6
+ metadata.gz: 4ff7aaa1632158f2c5664b7bd492cd3a0f7d574f91c7232a97fb2a45b8ebdaf4923578716d805b56c66098ab4ddb7dbe2a2a506832f42d5a03c2e4128675acb4
7
+ data.tar.gz: 8d28126a3d030a3b7ff4a59e11f3444865bb634358997fd690af1117380b9001d2221b40456d2a727cd32ba2fd0ed2a03fd6eef3618caa13e3e068f5427f8da5
@@ -0,0 +1,44 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - "*"
10
+
11
+ jobs:
12
+ build:
13
+ name: Ruby ${{ matrix.ruby }}
14
+
15
+ strategy:
16
+ fail-fast: true
17
+ matrix:
18
+ ruby:
19
+ - "2.5.0"
20
+ - "3.0.0"
21
+ - "head"
22
+
23
+ runs-on: ubuntu-latest
24
+
25
+ steps:
26
+ - name: Checkout
27
+ uses: actions/checkout@v2
28
+
29
+ - name: Install dependent libraries
30
+ run: sudo apt-get install libpq-dev
31
+
32
+ - name: Install Ruby ${{ matrix.ruby }}
33
+ uses: ruby/setup-ruby@v1.61.1
34
+ with:
35
+ ruby-version: ${{ matrix.ruby }}
36
+ bundler-cache: true # 'bundle install' and cache
37
+
38
+ - name: Check code style
39
+ run: bundle exec rubocop
40
+ continue-on-error: false
41
+
42
+ - name: Run tests
43
+ run: bundle exec rake --trace
44
+ continue-on-error: false
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ AllCops:
3
3
  DisplayCopNames: true
4
4
  DisplayStyleGuide: true
5
5
  StyleGuideCopsOnly: true
6
- TargetRubyVersion: 2.4
6
+ TargetRubyVersion: 3.0
7
7
 
8
8
  Lint/AmbiguousBlockAssociation:
9
9
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [2.2.0] - [2022-06-18]
8
+
9
+ ### Added
10
+ - Support for Ruby 3+ (HolyWalley)
11
+
12
+ ## [2.1.0] - [2021-11-30]
13
+
14
+ ### Fixed
15
+ - Difference between last positional and keyword arguments in Ruby 3.0+ (mrexox)
16
+
17
+ ## [2.0.1] - [2019-11-14]
18
+
19
+ ### Fixed
20
+ - Allow translation :scope to be customized in the #merge operation (sclinede)
21
+ Before the fix, the customized value was always replaced by the default value.
22
+
7
23
  ## [2.0.0] - [2019-07-04]
8
24
 
9
25
  ### Changed
@@ -212,3 +228,6 @@ This is a first public release (@nepalez, @charlie-wasp, @JewelSam, @sergey-chec
212
228
  [1.0.0]: https://github.com/tram-rb/tram-policy/compare/v0.4.0...v1.0.0
213
229
  [1.0.1]: https://github.com/tram-rb/tram-policy/compare/v1.0.0...v1.0.1
214
230
  [2.0.0]: https://github.com/tram-rb/tram-policy/compare/v1.0.1...v2.0.0
231
+ [2.0.1]: https://github.com/tram-rb/tram-policy/compare/v2.0.0...v2.0.1
232
+ [2.1.0]: https://github.com/tram-rb/tram-policy/compare/v2.0.1...v2.1.0
233
+ [2.1.0]: https://github.com/tram-rb/tram-policy/compare/v2.1.0...v2.2.0
data/README.md CHANGED
@@ -6,7 +6,6 @@ Policy Object Pattern
6
6
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
7
7
 
8
8
  [![Gem Version][gem-badger]][gem]
9
- [![Build Status][travis-badger]][travis]
10
9
  [![Inline docs][inch-badger]][inch]
11
10
 
12
11
  ## Intro
@@ -340,7 +339,6 @@ The gem is available as open source under the terms of the [MIT License](http://
340
339
  [inch-badger]: http://inch-ci.org/github/tram-rb/tram-policy.svg
341
340
  [inch]: https://inch-ci.org/github/tram-rb/tram-policy
342
341
  [travis-badger]: https://img.shields.io/travis/tram-rb/tram-policy/master.svg?style=flat
343
- [travis]: https://travis-ci.org/tram-rb/tram-policy
344
342
  [active-model-validation]: http://api.rubyonrails.org/classes/ActiveModel/Validations.html
345
343
  [active-record-validation]: http://guides.rubyonrails.org/active_record_validations.html
346
344
  [dry-validation]: http://dry-rb.org/gems/dry-validation/
@@ -9,7 +9,7 @@ class Tram::Policy
9
9
  # @return [self]
10
10
  #
11
11
  def validate(name = nil, **opts, &block)
12
- local_validators << Validator.new(name, block, opts)
12
+ local_validators << Validator.new(name, block, **opts)
13
13
  self
14
14
  end
15
15
 
@@ -18,8 +18,8 @@ class Tram::Policy
18
18
  # @param [Object] *args
19
19
  # @return [Tram::Policy]
20
20
  #
21
- def [](*args)
22
- new(*args)
21
+ def [](*args, **kwargs)
22
+ new(*args, **kwargs)
23
23
  end
24
24
 
25
25
  # Sets the root scope of the policy and its subclasses
@@ -41,7 +41,7 @@ class Tram::Policy
41
41
  # @return [String]
42
42
  #
43
43
  def message
44
- key.is_a?(Symbol) ? I18n.t(*item) : key.to_s
44
+ key.is_a?(Symbol) ? I18n.t(key, **tags) : key.to_s
45
45
  end
46
46
 
47
47
  # Fetches an option
@@ -105,8 +105,8 @@ class Tram::Policy
105
105
  true
106
106
  end
107
107
 
108
- def method_missing(name, *args, &block)
109
- args.any? || block ? super : tags[name]
108
+ def method_missing(name, *args, **kwargs, &block)
109
+ args.any? || kwargs.any? || block ? super : tags[name]
110
110
  end
111
111
  end
112
112
  end
@@ -24,7 +24,7 @@ class Tram::Policy
24
24
  raise ArgumentError.new("Error message should be defined") unless message
25
25
 
26
26
  tap do
27
- tags = tags.merge(scope: scope) if message.is_a?(Symbol)
27
+ tags = { scope: scope }.merge(tags) if message.is_a?(Symbol)
28
28
  @set << Tram::Policy::Error.new(message, **tags)
29
29
  end
30
30
  end
@@ -47,7 +47,7 @@ class Tram::Policy
47
47
  #
48
48
  def filter(key = nil, **tags)
49
49
  list = each_with_object(Set.new) do |error, obj|
50
- obj << error if error.contain?(key, tags)
50
+ obj << error if error.contain?(key, **tags)
51
51
  end
52
52
  self.class.new(scope: scope, errors: list)
53
53
  end
@@ -95,7 +95,7 @@ class Tram::Policy
95
95
  other.each do |err|
96
96
  key, opts = err.item
97
97
  opts = yield(opts) if block_given?
98
- add key, opts.merge(options)
98
+ add key, **opts.merge(options)
99
99
  end
100
100
 
101
101
  self
@@ -6,7 +6,7 @@ RSpec::Matchers.define :be_invalid_at do |**tags|
6
6
  end
7
7
 
8
8
  def check(policy, tags)
9
- @errors ||= policy.errors.filter(tags).map do |error|
9
+ @errors ||= policy.errors.filter(**tags).map do |error|
10
10
  { item: error.item }.tap do |obj|
11
11
  locales.each { |l| obj[l] = I18n.with_locale(l) { error.message } }
12
12
  end
data/lib/tram/policy.rb CHANGED
@@ -101,7 +101,7 @@ module Tram
101
101
 
102
102
  private
103
103
 
104
- def initialize(*)
104
+ def initialize(*, **)
105
105
  super
106
106
 
107
107
  self.class.validators.each do |validator|
@@ -1,5 +1,5 @@
1
1
  RSpec.describe Tram::Policy::Error do
2
- subject(:error) { described_class.new :bad, options }
2
+ subject(:error) { described_class.new :bad, **options }
3
3
 
4
4
  let(:scope) { %w[tram-policy] }
5
5
  let(:options) { { level: "warning", scope: scope } }
data/tram-policy.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "tram-policy"
3
- gem.version = "2.0.0"
3
+ gem.version = "2.2.0"
4
4
  gem.author = ["Viktor Sokolov (gzigzigzeo)", "Andrew Kozin (nepalez)"]
5
5
  gem.email = "andrew.kozin@gmail.com"
6
- gem.homepage = "https://github.com/tram/tram-policy"
6
+ gem.homepage = "https://github.com/tram-rb/tram-policy"
7
7
  gem.summary = "Policy Object Pattern"
8
8
  gem.license = "MIT"
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tram-policy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sokolov (gzigzigzeo)
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-04 00:00:00.000000000 Z
12
+ date: 2022-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-initializer
@@ -125,10 +125,10 @@ extra_rdoc_files:
125
125
  - CHANGELOG.md
126
126
  files:
127
127
  - ".codeclimate.yml"
128
+ - ".github/workflows/ci.yml"
128
129
  - ".gitignore"
129
130
  - ".rspec"
130
131
  - ".rubocop.yml"
131
- - ".travis.yml"
132
132
  - CHANGELOG.md
133
133
  - Gemfile
134
134
  - LICENSE.txt
@@ -160,7 +160,7 @@ files:
160
160
  - spec/tram/policy/validation_error_spec.rb
161
161
  - spec/tram/policy_spec.rb
162
162
  - tram-policy.gemspec
163
- homepage: https://github.com/tram/tram-policy
163
+ homepage: https://github.com/tram-rb/tram-policy
164
164
  licenses:
165
165
  - MIT
166
166
  metadata: {}
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.0.3
182
+ rubygems_version: 3.2.3
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: Policy Object Pattern
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- bundler_args: --without benchmarks tools
6
- script:
7
- - bundle exec rake
8
- - bundle exec rubocop
9
- rvm:
10
- - 2.3.0
11
- - 2.6.2
12
- - ruby-head
13
- - jruby-9.2.7.0
14
- - truffleruby
15
- env:
16
- global:
17
- - JRUBY_OPTS='--dev -J-Xmx1024M'
18
- matrix:
19
- allow_failures:
20
- - rvm: ruby-head
21
- - rvm: jruby-head
22
- - rvm: truffleruby