polist 1.2.0 → 1.4.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: d41a9ea7c84cd858fc92d79160ea448ed78fd36cfcf164195a7afe9cc5dbd59e
4
- data.tar.gz: 2d2e676fd05d9b57f3b3159955a473933e95500de4f4e80f63b708a1cdc04f83
3
+ metadata.gz: a66da4b33f58d9ed4ff5e449d0ee209793fd17477648a2ae37292ee856cb5a58
4
+ data.tar.gz: 6d0886005342b86c7b2dc75510f3ede54b108b1b17eb2fe1c5cc273f544cd20a
5
5
  SHA512:
6
- metadata.gz: f447ab40d832e15136acbf2b312f2941d2d18b0c8a046f40a4a3e26a76aa4e8be4df313e30962c665e3cc0f755ed1989f3ea8c6df050d0a4c28555fffd457558
7
- data.tar.gz: 7e02ad12d1e8a13669a9e657c8ed7a181d19707c85c754c227c2fb006ba84e2b411ed4fe226001e8aeb2a3fa2a0aaee198eba1ef04d0432752f2353a8ce0f9fa
6
+ metadata.gz: fd47fe21f11eefac3483d886fba883c0ae5b5675eb93c5f2d0850826f09c5ba9ebef845ffa104b48e2f3da4aa5aa4aedacc5f7210df94b466084f52b89a278e4
7
+ data.tar.gz: 1f38095d7c52be31ba11f23e1fd0b92c50df90442ec506124d34cf10f5b5fb5a88aa71e10214baf81b86fe1ba2b4cdc41de2738e03e19f09b8ce0771b2d47a65
@@ -0,0 +1,31 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ # We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
10
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'umbrellio/polist'
11
+
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ["2.7", "3.0"]
16
+
17
+ name: ${{ matrix.ruby }}
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+
27
+ - run: bundle exec rake
28
+
29
+ - uses: coverallsapp/github-action@v1.1.2
30
+ with:
31
+ github-token: ${{ secrets.GITHUB_TOKEN }}
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.5
6
+ TargetRubyVersion: 2.7
7
7
 
8
8
  Naming/MemoizedInstanceVariableName:
9
9
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased]
3
+ ## [1.4.0] - 2021-06-21
4
+
5
+ ### Fixed
6
+
7
+ - Fixes for Ruby 3 ([@tycooon]) [#9]
4
8
 
5
9
  ## [1.2.0] - 2019-03-15
6
10
 
@@ -35,7 +39,8 @@
35
39
  [1.1.0]: https://github.com/umbrellio/polist/compare/v1.0.0...v1.1.0
36
40
  [1.1.1]: https://github.com/umbrellio/polist/compare/v1.1.0...v1.1.1
37
41
  [1.2.0]: https://github.com/umbrellio/polist/compare/v1.1.1...v1.2.0
38
- [Unreleased]: https://github.com/umbrellio/polist/compare/v1.2.0...HEAD
42
+ [1.4.0]: https://github.com/umbrellio/polist/compare/v1.2.0...v1.4.0
43
+ [Unreleased]: https://github.com/umbrellio/polist/compare/v1.4.0...HEAD
39
44
 
40
45
  [@nesaulov]: https://github.com/nesaulov
41
46
  [@VanyaZ158]: https://github.com/VanyaZ158
@@ -45,3 +50,4 @@
45
50
  [#3]: https://github.com/umbrellio/polist/pull/3
46
51
  [#4]: https://github.com/umbrellio/polist/pull/4
47
52
  [#5]: https://github.com/umbrellio/polist/pull/5
53
+ [#9]: https://github.com/umbrellio/polist/pull/9
data/Gemfile CHANGED
@@ -1,8 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in polist.gemspec
6
4
  gemspec
7
-
8
- gem "rubocop-config-umbrellio", github: "umbrellio/code-style"
data/Gemfile.lock ADDED
@@ -0,0 +1,117 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ polist (1.4.0)
5
+ activemodel (>= 3.0)
6
+ plissken (>= 0.3)
7
+ tainbox
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activemodel (6.1.3.2)
13
+ activesupport (= 6.1.3.2)
14
+ activesupport (6.1.3.2)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ zeitwerk (~> 2.3)
20
+ ast (2.4.2)
21
+ coderay (1.1.3)
22
+ concurrent-ruby (1.1.9)
23
+ diff-lcs (1.4.4)
24
+ docile (1.4.0)
25
+ i18n (1.8.10)
26
+ concurrent-ruby (~> 1.0)
27
+ method_source (1.0.0)
28
+ minitest (5.14.4)
29
+ parallel (1.20.1)
30
+ parser (3.0.1.1)
31
+ ast (~> 2.4.1)
32
+ plissken (1.4.1)
33
+ pry (0.14.1)
34
+ coderay (~> 1.1)
35
+ method_source (~> 1.0)
36
+ rack (2.2.3)
37
+ rainbow (3.0.0)
38
+ rake (13.0.3)
39
+ regexp_parser (2.1.1)
40
+ rexml (3.2.5)
41
+ rspec (3.10.0)
42
+ rspec-core (~> 3.10.0)
43
+ rspec-expectations (~> 3.10.0)
44
+ rspec-mocks (~> 3.10.0)
45
+ rspec-core (3.10.1)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-expectations (3.10.1)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.2)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.2)
54
+ rubocop (1.11.0)
55
+ parallel (~> 1.10)
56
+ parser (>= 3.0.0.0)
57
+ rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.8, < 3.0)
59
+ rexml
60
+ rubocop-ast (>= 1.2.0, < 2.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (>= 1.4.0, < 3.0)
63
+ rubocop-ast (1.7.0)
64
+ parser (>= 3.0.1.1)
65
+ rubocop-config-umbrellio (1.11.0.51)
66
+ rubocop (= 1.11.0)
67
+ rubocop-performance (= 1.10.0)
68
+ rubocop-rails (= 2.9.1)
69
+ rubocop-rake (= 0.5.1)
70
+ rubocop-rspec (= 2.2.0)
71
+ rubocop-sequel (= 0.2.0)
72
+ rubocop-performance (1.10.0)
73
+ rubocop (>= 0.90.0, < 2.0)
74
+ rubocop-ast (>= 0.4.0)
75
+ rubocop-rails (2.9.1)
76
+ activesupport (>= 4.2.0)
77
+ rack (>= 1.1)
78
+ rubocop (>= 0.90.0, < 2.0)
79
+ rubocop-rake (0.5.1)
80
+ rubocop
81
+ rubocop-rspec (2.2.0)
82
+ rubocop (~> 1.0)
83
+ rubocop-ast (>= 1.1.0)
84
+ rubocop-sequel (0.2.0)
85
+ rubocop (~> 1.0)
86
+ ruby-progressbar (1.11.0)
87
+ simplecov (0.21.2)
88
+ docile (~> 1.1)
89
+ simplecov-html (~> 0.11)
90
+ simplecov_json_formatter (~> 0.1)
91
+ simplecov-html (0.12.3)
92
+ simplecov-lcov (0.8.0)
93
+ simplecov_json_formatter (0.1.3)
94
+ tainbox (2.1.2)
95
+ activesupport
96
+ tzinfo (2.0.4)
97
+ concurrent-ruby (~> 1.0)
98
+ unicode-display_width (2.0.0)
99
+ zeitwerk (2.4.2)
100
+
101
+ PLATFORMS
102
+ x86_64-darwin-19
103
+ x86_64-darwin-20
104
+ x86_64-linux
105
+
106
+ DEPENDENCIES
107
+ bundler
108
+ polist!
109
+ pry
110
+ rake
111
+ rspec
112
+ rubocop-config-umbrellio
113
+ simplecov
114
+ simplecov-lcov
115
+
116
+ BUNDLED WITH
117
+ 2.2.20
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Yuri Smirnov
3
+ Copyright (c) 2017-2019 Yuri Smirnov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Polist   [![Gem Version](https://badge.fury.io/rb/polist.svg)](https://badge.fury.io/rb/polist) [![Build Status](https://travis-ci.org/umbrellio/polist.svg?branch=master)](https://travis-ci.org/umbrellio/polist) [![Coverage Status](https://coveralls.io/repos/github/umbrellio/polist/badge.svg?branch=master)](https://coveralls.io/github/umbrellio/polist?branch=master)
2
2
 
3
+ ## DEPRECATION NOTICE
4
+
5
+ This gem is no longer actively maintained. As a replacement, you can use [Resol](https://github.com/umbrellio/resol) as well as gems from [smart-rb](https://github.com/smart-rb) family.
6
+
7
+ ## Description
8
+
3
9
  Polist is a set of simple tools for creating business logic layer of your applications:
4
10
 
5
11
  - `Polist::Service` is a simple class designed for creating service classes.
data/Rakefile CHANGED
@@ -2,7 +2,19 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
+ require "rubocop"
6
+ require "rubocop-rspec"
7
+ require "rubocop-performance"
8
+ require "rubocop/rake_task"
5
9
 
6
- RSpec::Core::RakeTask.new(:spec)
10
+ RuboCop::RakeTask.new(:rubocop) do |t|
11
+ config_path = File.expand_path(File.join(".rubocop.yml"), __dir__)
7
12
 
8
- task default: :spec
13
+ t.options = ["--config", config_path]
14
+ t.requires << "rubocop-rspec"
15
+ t.requires << "rubocop-performance"
16
+ end
17
+
18
+ RSpec::Core::RakeTask.new(:rspec)
19
+
20
+ task default: %i[rubocop rspec]
data/bin/console ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'polist'
6
+
7
+ require 'pry'
8
+ Pry.start
@@ -1,32 +1,54 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "uber/builder"
4
-
5
3
  module Polist
4
+ # Most of the code here is borrowed from Uber::Builder code
5
+ # See https://github.com/apotonick/uber/blob/master/lib/uber/builder.rb
6
6
  module Builder
7
7
  def self.included(base)
8
- base.include(Uber::Builder)
9
8
  base.extend(ClassMethods)
10
9
  end
11
10
 
11
+ class Builders < Array
12
+ def call(context, *args, **kwargs)
13
+ each do |block|
14
+ klass = block.call(context, *args, **kwargs) and return klass
15
+ end
16
+
17
+ context
18
+ end
19
+
20
+ def <<(proc)
21
+ wrapped_proc = -> (ctx, *args, **kwargs) { ctx.instance_exec(*args, **kwargs, &proc) }
22
+ super(wrapped_proc)
23
+ end
24
+ end
25
+
12
26
  module ClassMethods
27
+ def builders
28
+ @builders ||= Builders.new
29
+ end
30
+
31
+ def builds(proc = nil, &block)
32
+ builders << (proc || block)
33
+ end
34
+
35
+ def build(*args, **kwargs)
36
+ build_klass(*args, **kwargs).new(*args, **kwargs)
37
+ end
38
+
13
39
  # Recursively runs class builders on class until no builders on that class found
14
40
  # or some builder returns the class itself
15
- def build_klass(*args)
41
+ def build_klass(*args, **kwargs)
16
42
  klass = self
17
43
 
18
44
  loop do
19
- new_klass = klass.build!(klass, *args)
45
+ new_klass = klass.builders.call(klass, *args, **kwargs)
20
46
  break if new_klass == klass
21
47
  klass = new_klass
22
48
  end
23
49
 
24
50
  klass
25
51
  end
26
-
27
- def build(*args)
28
- build_klass(*args).new(*args)
29
- end
30
52
  end
31
53
  end
32
54
  end
@@ -39,18 +39,19 @@ module Polist
39
39
  klass.const_set(:Failure, Class.new(klass::Failure))
40
40
  klass.prepend(MiddlewareCaller)
41
41
  klass.instance_variable_set(:@__polist_middlewares__, __polist_middlewares__.dup)
42
+ super
42
43
  end
43
44
 
44
- def self.build(*args)
45
- new(*args)
45
+ def self.build(*args, **options)
46
+ new(*args, **options)
46
47
  end
47
48
 
48
- def self.call(*args, &block)
49
- build(*args).tap { |service| service.call(&block) }
49
+ def self.call(*args, **options, &block)
50
+ build(*args, **options).tap { |service| service.call(&block) }
50
51
  end
51
52
 
52
- def self.run(*args, &block)
53
- build(*args).tap { |service| service.run(&block) }
53
+ def self.run(*args, **options, &block)
54
+ build(*args, **options).tap { |service| service.run(&block) }
54
55
  end
55
56
 
56
57
  def self.param(*names)
@@ -103,7 +104,10 @@ module Polist
103
104
  end
104
105
 
105
106
  def validate!
106
- error!(form.errors.to_h.values.first) unless form.valid?
107
+ return if form.valid?
108
+ first_error = form.errors.to_hash.values.first
109
+ first_error = first_error.first if first_error.is_a?(Array)
110
+ error!(first_error)
107
111
  end
108
112
 
109
113
  private
@@ -13,8 +13,8 @@ class Polist::Service::Middleware
13
13
  attr_reader :service
14
14
 
15
15
  %i[fail! error! success! form form_attributes].each do |service_method|
16
- define_method(service_method) do |*args|
17
- service.send(service_method, *args)
16
+ define_method(service_method) do |*args, **options|
17
+ service.send(service_method, *args, **options)
18
18
  end
19
19
  end
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polist
4
- VERSION = "1.2.0"
4
+ VERSION = "1.4.0"
5
5
  end
data/polist.gemspec CHANGED
@@ -5,28 +5,30 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "polist/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = "polist"
9
- spec.version = Polist::VERSION
10
- spec.authors = ["Yuri Smirnov"]
11
- spec.email = ["tycooon@yandex.ru"]
8
+ spec.required_ruby_version = ">= 2.7.0"
12
9
 
13
- spec.summary = "A gem for creating simple service classes and more."
14
- spec.description = "Polist is a gem for creating simple service classes and more."
15
- spec.homepage = "https://github.com/umbrellio/polist"
16
- spec.license = "MIT"
10
+ spec.name = "polist"
11
+ spec.version = Polist::VERSION
12
+ spec.authors = ["Yuri Smirnov"]
13
+ spec.email = ["tycooon@yandex.ru", "oss@umbrellio.biz"]
17
14
 
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
15
+ spec.summary = "A gem for creating simple service classes and more."
16
+ spec.description = "Polist is a gem for creating simple service classes and more."
17
+ spec.homepage = "https://github.com/umbrellio/polist"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
19
21
  spec.require_paths = ["lib"]
20
22
 
21
23
  spec.add_runtime_dependency "activemodel", ">= 3.0"
22
24
  spec.add_runtime_dependency "plissken", ">= 0.3"
23
25
  spec.add_runtime_dependency "tainbox"
24
- spec.add_runtime_dependency "uber"
25
26
 
26
27
  spec.add_development_dependency "bundler"
27
- spec.add_development_dependency "coveralls"
28
28
  spec.add_development_dependency "pry"
29
29
  spec.add_development_dependency "rake"
30
30
  spec.add_development_dependency "rspec"
31
+ spec.add_development_dependency "rubocop-config-umbrellio"
31
32
  spec.add_development_dependency "simplecov"
33
+ spec.add_development_dependency "simplecov-lcov"
32
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-15 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -53,13 +53,13 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: uber
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :runtime
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bundler
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: coveralls
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry
98
+ name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rake
112
+ name: rubocop-config-umbrellio
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rspec
126
+ name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: simplecov
140
+ name: simplecov-lcov
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -153,19 +153,22 @@ dependencies:
153
153
  description: Polist is a gem for creating simple service classes and more.
154
154
  email:
155
155
  - tycooon@yandex.ru
156
+ - oss@umbrellio.biz
156
157
  executables: []
157
158
  extensions: []
158
159
  extra_rdoc_files: []
159
160
  files:
161
+ - ".github/workflows/ci.yml"
160
162
  - ".gitignore"
161
163
  - ".rspec"
162
164
  - ".rubocop.yml"
163
- - ".travis.yml"
164
165
  - CHANGELOG.md
165
166
  - Gemfile
167
+ - Gemfile.lock
166
168
  - LICENSE.txt
167
169
  - README.md
168
170
  - Rakefile
171
+ - bin/console
169
172
  - lib/polist.rb
170
173
  - lib/polist/builder.rb
171
174
  - lib/polist/service.rb
@@ -177,7 +180,7 @@ homepage: https://github.com/umbrellio/polist
177
180
  licenses:
178
181
  - MIT
179
182
  metadata: {}
180
- post_install_message:
183
+ post_install_message:
181
184
  rdoc_options: []
182
185
  require_paths:
183
186
  - lib
@@ -185,15 +188,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
188
  requirements:
186
189
  - - ">="
187
190
  - !ruby/object:Gem::Version
188
- version: '0'
191
+ version: 2.7.0
189
192
  required_rubygems_version: !ruby/object:Gem::Requirement
190
193
  requirements:
191
194
  - - ">="
192
195
  - !ruby/object:Gem::Version
193
196
  version: '0'
194
197
  requirements: []
195
- rubygems_version: 3.0.3
196
- signing_key:
198
+ rubygems_version: 3.2.20
199
+ signing_key:
197
200
  specification_version: 4
198
201
  summary: A gem for creating simple service classes and more.
199
202
  test_files: []
data/.travis.yml DELETED
@@ -1,24 +0,0 @@
1
- language: ruby
2
-
3
- sudo: false
4
-
5
- rvm:
6
- - 2.3
7
- - 2.4
8
- - 2.5
9
- - ruby-head
10
-
11
- before_install: gem install bundler
12
-
13
- env: SUITE="rspec"
14
-
15
- script: bundle exec $SUITE
16
-
17
- matrix:
18
- fast_finish: true
19
- # Only run RuboCop on the latest Ruby
20
- include:
21
- - rvm: 2.5
22
- env: SUITE="rubocop"
23
- allow_failures:
24
- - rvm: ruby-head