interactor-initializer 0.1.0 → 0.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
- SHA1:
3
- metadata.gz: e1f044791f85be189cabd9da79621ce3d3693909
4
- data.tar.gz: 978fd420eac6c5289c81bb81ae73af930f43ba3f
2
+ SHA256:
3
+ metadata.gz: 5af4b74086ee54c325a0978227a41cba1449b7369ae4d77d8144cb93e4392a36
4
+ data.tar.gz: cc5551943cffcf530daf69fe18c29bee0fcb46a4c07cb411bb13074a5f74772d
5
5
  SHA512:
6
- metadata.gz: 676883689febe2cc7f639c65a7558028be891c65c1745d2c89a2be83e659cfdcb02e418aea052f15d878e902a586c953ccce340e38e1744477f1cd1cf4544ee5
7
- data.tar.gz: 0c4ad289a43efedebd3847ce07823227ab03ae2a11edc75736f60d1de40d02a55472882308b41c50d591676a690aa716f73f7677def33b1046fc87d0fe14e9c7
6
+ metadata.gz: f7cf6987a066b3649813d0c38da664c6c6f49aac8541e34055c636e5f182c03c30a3d55987cce42b36c299bc8b49003e92a3a52780e9ea8dec45a7fb9fc2bc9b
7
+ data.tar.gz: 5ee5a3989601d9c70eec1245c1fab592ff78b45aa4a2efe614f5036382bbcf4986e692581dda139470f29ee1d205e8c5f9c29b8be46ea363fdaabed156b9c6f9
@@ -0,0 +1,53 @@
1
+ name: Build and release ruby gem
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ master ]
6
+ push:
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build-release-pipeline:
11
+ runs-on: ubuntu-latest
12
+ container: ruby:2.7.2
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Setup
16
+ run: |
17
+ gem install bundler
18
+ bundle install
19
+
20
+ - name: Test
21
+ run: bundle exec rspec
22
+
23
+ - name: Build
24
+ id: build
25
+ if: success() && github.ref == 'refs/heads/master'
26
+ run: |
27
+ bundle exec rake build
28
+ echo "::set-output name=gem_version::v$(bundle exec rake version)"
29
+
30
+ - name: Release
31
+ if: success() && github.ref == 'refs/heads/master'
32
+ run: |
33
+ mkdir -p $HOME/.gem
34
+ touch $HOME/.gem/credentials
35
+ chmod 600 $HOME/.gem/credentials
36
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
37
+ gem push pkg/*
38
+ env:
39
+ GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}"
40
+
41
+ - name: Tag repo with new gem version
42
+ if: success() && github.ref == 'refs/heads/master'
43
+ uses: actions/github-script@v3
44
+ with:
45
+ github-token: ${{ github.token }}
46
+ script: |
47
+ github.git.createRef({
48
+ owner: context.repo.owner,
49
+ repo: context.repo.repo,
50
+ ref: "refs/tags/${{ steps.build.outputs.gem_version }}",
51
+ sha: context.sha
52
+ })
53
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --color
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Vinted
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Interactor::Initializer
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/vinted/interactor-initializer.png)](http://travis-ci.org/vinted/interactor-initializer)
4
+ [![Gem Version](https://badge.fury.io/rb/interactor-initializer.png)](http://badge.fury.io/rb/interactor-initializer)
5
+
3
6
  Dry interactor initializer
4
7
 
5
8
  ## Installation
data/Rakefile CHANGED
@@ -1,3 +1,7 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
3
  task default: :spec
4
+
5
+ task :version do |t|
6
+ puts Interactor::Initializer::VERSION
7
+ end
@@ -8,14 +8,16 @@ Gem::Specification.new do |spec|
8
8
  spec.platform = Gem::Platform::RUBY
9
9
  spec.version = Interactor::Initializer::VERSION
10
10
  spec.authors = ['Šarūnas Kūjalis']
11
- spec.email = ['sarjalis@gmail.com']
11
+ spec.email = ['admin@vinted.com']
12
12
  spec.summary = 'Dry interactor initializer'
13
13
  spec.homepage = 'https://github.com/vinted/interactor-initializer'
14
+ spec.license = 'MIT'
14
15
 
15
16
  spec.files = `git ls-files`.split($/)
16
17
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
17
18
  spec.require_paths = ['lib']
18
19
 
19
- spec.add_development_dependency 'bundler', '~> 1.11'
20
+ spec.add_development_dependency 'bundler'
20
21
  spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rspec', '~> 3.0'
21
23
  end
@@ -1,13 +1,26 @@
1
1
  require 'interactor/initializer/version'
2
+ require 'interactor/initializer/attr_readers'
3
+ require 'interactor/initializer/initialize'
2
4
 
3
5
  module Interactor
4
6
  module Initializer
5
7
  def self.included(target_class)
6
8
  target_class.extend ClassMethods
7
- Interactor::Initializer::CallMethods.for(target_class)
8
9
  end
9
10
 
10
11
  module ClassMethods
12
+ def for(*args)
13
+ new(*args).run
14
+ end
15
+
16
+ def with(*args)
17
+ new(*args).run
18
+ end
19
+
20
+ def run(*args)
21
+ new(*args).run
22
+ end
23
+
11
24
  module_function
12
25
 
13
26
  def initialize_with(*attributes)
@@ -1,5 +1,10 @@
1
1
  class Interactor::Initializer::AttrReaders
2
2
  def self.for(target_class, attributes)
3
- target_class.class_eval { attr_reader(*attributes) }
3
+ target_class.class_eval do
4
+ attributes.each do |attribute|
5
+ attr_reader(attribute)
6
+ protected(attribute)
7
+ end
8
+ end
4
9
  end
5
10
  end
@@ -1,6 +1,6 @@
1
1
  class Interactor::Initializer::Initialize
2
- def self.for(*args)
3
- new(*args).run
2
+ def self.for(*args, **kwargs)
3
+ new(*args, **kwargs).run
4
4
  end
5
5
 
6
6
  attr_reader :target_class, :attributes, :keyword_params
@@ -1,5 +1,5 @@
1
1
  module Interactor
2
2
  module Initializer
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,13 @@
1
+ describe Interactor::Initializer::AttrReaders do
2
+ describe '.for' do
3
+ subject { described_class.for(dummy_class, attributes) }
4
+ let(:dummy_class) { Class.new }
5
+ let(:attributes) { [:test1, :test2] }
6
+
7
+ it 'adds protected attr_reader' do
8
+ subject
9
+ expect(dummy_class.protected_method_defined?(:test1)).to be_truthy
10
+ expect(dummy_class.protected_method_defined?(:test2)).to be_truthy
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ describe Interactor::Initializer::Initialize do
2
+ describe '.for' do
3
+ subject { described_class.for(dummy_class, attributes, keyword_params: keyword_params) }
4
+ let(:dummy_class) { Class.new }
5
+ let(:attributes) { [:test1, :test2] }
6
+ let(:keyword_params) { false }
7
+
8
+ shared_examples 'object initializer' do
9
+ it 'adds object initializer' do
10
+ subject
11
+ expect(dummy_instance.instance_variable_get(:@test1)).to eq 1
12
+ expect(dummy_instance.instance_variable_get(:@test2)).to eq 2
13
+ end
14
+ end
15
+
16
+ it_behaves_like 'object initializer' do
17
+ let(:dummy_instance) { dummy_class.new(1, 2) }
18
+ end
19
+
20
+ context 'when keyword params' do
21
+ let(:keyword_params) { true }
22
+
23
+ it_behaves_like 'object initializer' do
24
+ let(:dummy_instance) { dummy_class.new(test1: 1, test2: 2) }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ describe Interactor::Initializer do
2
+ let(:interactor) do
3
+ Class.new do
4
+ include Interactor::Initializer
5
+
6
+ def run
7
+ :result
8
+ end
9
+ end
10
+ end
11
+
12
+ describe '.for' do
13
+ subject { interactor.for }
14
+
15
+ it { is_expected.to eq(:result) }
16
+ end
17
+
18
+ describe '.with' do
19
+ subject { interactor.with }
20
+
21
+ it { is_expected.to eq(:result) }
22
+ end
23
+
24
+ describe '.run' do
25
+ subject { interactor.run }
26
+
27
+ it { is_expected.to eq(:result) }
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+ require 'interactor/initializer'
3
+
4
+ RSpec.configure do |config|
5
+ config.order = :random
6
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interactor-initializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - "Šarūnas Kūjalis"
7
+ - Šarūnas Kūjalis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-07 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: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,26 +38,47 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
41
55
  description:
42
56
  email:
43
- - sarjalis@gmail.com
57
+ - admin@vinted.com
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
62
+ - ".github/workflows/build_release_pipeline.yaml"
48
63
  - ".gitignore"
64
+ - ".rspec"
49
65
  - ".rubocop.yml"
50
66
  - Gemfile
67
+ - LICENSE
51
68
  - README.md
52
69
  - Rakefile
53
70
  - interactor-initializer.gemspec
54
71
  - lib/interactor/initializer.rb
55
72
  - lib/interactor/initializer/attr_readers.rb
56
- - lib/interactor/initializer/call_methods.rb
57
73
  - lib/interactor/initializer/initialize.rb
58
74
  - lib/interactor/initializer/version.rb
75
+ - spec/interactor/initializer/attr_readers_spec.rb
76
+ - spec/interactor/initializer/initialize_spec.rb
77
+ - spec/interactor/initializer_spec.rb
78
+ - spec/spec_helper.rb
59
79
  homepage: https://github.com/vinted/interactor-initializer
60
- licenses: []
80
+ licenses:
81
+ - MIT
61
82
  metadata: {}
62
83
  post_install_message:
63
84
  rdoc_options: []
@@ -74,8 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
95
  - !ruby/object:Gem::Version
75
96
  version: '0'
76
97
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.4.5
98
+ rubygems_version: 3.1.4
79
99
  signing_key:
80
100
  specification_version: 4
81
101
  summary: Dry interactor initializer
@@ -1,9 +0,0 @@
1
- class Interactor::Initializer::CallMethods
2
- METHOD_NAMES = %i(for with run).freeze
3
-
4
- def self.for(target_class)
5
- METHOD_NAMES.each do |method_name|
6
- target_class.define_singleton_method(method_name) { |*args| new(*args).run }
7
- end
8
- end
9
- end