ii_interactor 2.1.0 → 2.2.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: f27fe194dd295f5882f0533132588686a9fead26c638f86db95b8b66979553bf
4
- data.tar.gz: '08c3c2fbd0687fb42077215abb8edd0e85a76eda538c418fa5f869f50957ed90'
3
+ metadata.gz: 8d41caaf17018a5faf867b26ee15e97c68afbf3126e69ce4a81fc5c0b2394345
4
+ data.tar.gz: dbe6665d293c2f8c42030592ebdbe7671f57c7737ddd28f50c326539e2635536
5
5
  SHA512:
6
- metadata.gz: ab6289235d21d6085ce7b20d123efd152d1e387f6d17a708a107e735f259036bb87be8533e9e7e5b07613cc9ca14fd0b699521bbb1c6f42c855054884f0e690e
7
- data.tar.gz: 76c6d853fc4ef5b6103d9dda4cdac6ecb9179b0b21c6b35e72519dd2059bb1efb95a431ae23dca207f51a78e8a8e598c56028851842b98b6a4181221da725f76
6
+ metadata.gz: 90c35516d55b89a9e37d56b5b280df3840c96b378ae37cba70d46ad5d5aff694b1c66b2029871028ff72db71293490b232a6796e4e9575eaacbe5d1b353c27f0
7
+ data.tar.gz: f25a6c2e3923c06d7aac135059979108c207953f0034bea8039ed159b88a4ab8adcfbe3f4019ca6c3b5bcf77e7415bde97c11adabb310c64b3bed4621b8e8e04
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0']
11
+ ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1]
12
12
  gemfile: ['rails50', 'rails51', 'rails52', 'rails60', 'rails61', 'rails70']
13
13
  exclude:
14
14
  - ruby: 2.3
@@ -33,6 +33,12 @@ jobs:
33
33
  gemfile: rails51
34
34
  - ruby: 3.0
35
35
  gemfile: rails52
36
+ - ruby: 3.1
37
+ gemfile: rails50
38
+ - ruby: 3.1
39
+ gemfile: rails51
40
+ - ruby: 3.1
41
+ gemfile: rails52
36
42
 
37
43
  name: ruby ${{ matrix.ruby }}, ${{ matrix.gemfile }}
38
44
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.2.0
4
+
5
+ * Use coactive 0.3.
6
+
3
7
  ## 2.1.0
4
8
 
5
9
  * Add traversal config.
data/bin/console CHANGED
@@ -10,5 +10,5 @@ require "ii_interactor"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- # require "irb"
14
- # IRB.start
13
+ require "irb"
14
+ IRB.start
@@ -1,5 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem "rails", "~> 6.0.0"
4
+ gem "psych", "~> 3.3.0"
4
5
 
5
6
  gemspec path: "../"
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "rails", "~> 7.0.0"
3
+ gem "rails", "~> 7.0.1"
4
4
 
5
5
  gemspec path: "../"
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "activesupport", ">= 5.0"
21
- spec.add_dependency "coactive", ">= 0.2"
21
+ spec.add_dependency "coactive", ">= 0.3"
22
22
 
23
23
  spec.add_development_dependency "rails", ">= 5.0"
24
24
  spec.add_development_dependency "sqlite3"
@@ -2,21 +2,33 @@
2
2
 
3
3
  module IIInteractor
4
4
  class Context < Coactive::Context
5
+ class Status < Struct.new(:failed, :stopped, :called)
6
+ def initialize(*)
7
+ self.failed = false
8
+ self.stopped = false
9
+ self.called = []
10
+ end
11
+ end
12
+
13
+ attr_reader :_status, :_block
14
+
5
15
  def initialize(data = {}, &block)
16
+ if data.is_a?(IIInteractor::Context)
17
+ @_block = data._block
18
+ @_status = data._status
19
+ else
20
+ @_block = block
21
+ @_status = Status.new
22
+ end
6
23
  super
7
- @_data[:_block] ||= block
8
- @_data[:_failed] ||= false
9
- @_data[:_stopped] ||= false
10
- @_data[:_called] ||= []
11
24
  end
12
25
 
13
26
  def to_s
14
- attrs = @_data.reject { |k, _| k.to_s =~ /^_/ }.map { |k, v| "#{k}=#{v.to_s.truncate(300)}" }.join(', ')
15
- "#<#{self.class} #{attrs}>"
27
+ "#<#{self.class} #{self.class.inspect(@_data)} (#{self.class.inspect(@_status.to_h)})>"
16
28
  end
17
29
 
18
30
  def call_block!(*args)
19
- @_data[:_block].call(*args) if @_data[:_block]
31
+ @_block.call(*args) if @_block
20
32
  end
21
33
 
22
34
  def success?
@@ -24,27 +36,27 @@ module IIInteractor
24
36
  end
25
37
 
26
38
  def failure?
27
- @_data[:_failed] == true
39
+ @_status.failed == true
28
40
  end
29
41
 
30
42
  def stopped?
31
- @_data[:_stopped] == true
43
+ @_status.stopped == true
32
44
  end
33
45
 
34
46
  def fail!(data = {})
35
- @_data[:_failed] = true
47
+ @_status.failed = true
36
48
  data.each { |k, v| @_data[k] = v }
37
49
  define_accessors!(data.keys)
38
50
  end
39
51
 
40
52
  def stop!(data = {})
41
- @_data[:_stopped] = true
53
+ @_status.stopped = true
42
54
  data.each { |k, v| @_data[k] = v }
43
55
  define_accessors!(data.keys)
44
56
  end
45
57
 
46
58
  def called!(interactor)
47
- @_data[:_called] << interactor
59
+ @_status.called << interactor
48
60
  end
49
61
  end
50
62
  end
@@ -65,7 +65,7 @@ module IIInteractor
65
65
  interactor.call_all
66
66
  interactor.context
67
67
  rescue UnprogressableError
68
- interactor.context[:_called].reverse.each do |called|
68
+ interactor.context._status.called.reverse.each do |called|
69
69
  called.rollback
70
70
  end
71
71
  interactor.context
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IIInteractor
4
- VERSION = '2.1.0'
4
+ VERSION = '2.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ii_interactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshikazu Kaneta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.2'
33
+ version: '0.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.2'
40
+ version: '0.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.1.6
165
+ rubygems_version: 3.3.3
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: A base interactor to support management of bussiness logic