dry-effects 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -5
  3. data/LICENSE +1 -1
  4. data/README.md +19 -11
  5. data/dry-effects.gemspec +33 -41
  6. data/lib/dry/effects/all.rb +4 -4
  7. data/lib/dry/effects/container.rb +1 -1
  8. data/lib/dry/effects/effect.rb +2 -2
  9. data/lib/dry/effects/effects/async.rb +3 -1
  10. data/lib/dry/effects/effects/cache.rb +13 -9
  11. data/lib/dry/effects/effects/cmp.rb +3 -1
  12. data/lib/dry/effects/effects/current_time.rb +4 -2
  13. data/lib/dry/effects/effects/defer.rb +3 -1
  14. data/lib/dry/effects/effects/env.rb +4 -2
  15. data/lib/dry/effects/effects/fork.rb +3 -1
  16. data/lib/dry/effects/effects/implicit.rb +4 -2
  17. data/lib/dry/effects/effects/interrupt.rb +4 -2
  18. data/lib/dry/effects/effects/lock.rb +8 -6
  19. data/lib/dry/effects/effects/parallel.rb +4 -2
  20. data/lib/dry/effects/effects/random.rb +5 -3
  21. data/lib/dry/effects/effects/reader.rb +1 -1
  22. data/lib/dry/effects/effects/resolve.rb +23 -3
  23. data/lib/dry/effects/effects/retry.rb +4 -2
  24. data/lib/dry/effects/effects/state.rb +4 -2
  25. data/lib/dry/effects/effects/timeout.rb +3 -1
  26. data/lib/dry/effects/effects/timestamp.rb +3 -1
  27. data/lib/dry/effects/errors.rb +4 -4
  28. data/lib/dry/effects/extensions/active_support/tagged_logging.rb +13 -0
  29. data/lib/dry/effects/extensions/auto_inject.rb +5 -5
  30. data/lib/dry/effects/extensions/system.rb +8 -7
  31. data/lib/dry/effects/extensions.rb +12 -4
  32. data/lib/dry/effects/frame.rb +30 -9
  33. data/lib/dry/effects/halt.rb +3 -3
  34. data/lib/dry/effects/handler.rb +1 -1
  35. data/lib/dry/effects/inflector.rb +1 -1
  36. data/lib/dry/effects/initializer.rb +17 -16
  37. data/lib/dry/effects/instruction.rb +1 -1
  38. data/lib/dry/effects/instructions/execute.rb +2 -1
  39. data/lib/dry/effects/instructions/raise.rb +2 -1
  40. data/lib/dry/effects/provider/class_interface.rb +2 -2
  41. data/lib/dry/effects/provider.rb +2 -2
  42. data/lib/dry/effects/providers/async.rb +2 -2
  43. data/lib/dry/effects/providers/cache.rb +2 -2
  44. data/lib/dry/effects/providers/cmp.rb +1 -1
  45. data/lib/dry/effects/providers/current_time/time_generators.rb +1 -1
  46. data/lib/dry/effects/providers/current_time.rb +5 -5
  47. data/lib/dry/effects/providers/defer.rb +6 -6
  48. data/lib/dry/effects/providers/env.rb +2 -2
  49. data/lib/dry/effects/providers/fork.rb +2 -2
  50. data/lib/dry/effects/providers/implicit.rb +1 -1
  51. data/lib/dry/effects/providers/interrupt.rb +3 -3
  52. data/lib/dry/effects/providers/lock.rb +6 -8
  53. data/lib/dry/effects/providers/parallel.rb +3 -3
  54. data/lib/dry/effects/providers/random.rb +74 -2
  55. data/lib/dry/effects/providers/reader.rb +1 -1
  56. data/lib/dry/effects/providers/resolve.rb +8 -7
  57. data/lib/dry/effects/providers/retry.rb +5 -7
  58. data/lib/dry/effects/providers/state.rb +2 -2
  59. data/lib/dry/effects/providers/timeout.rb +2 -2
  60. data/lib/dry/effects/providers/timestamp.rb +2 -2
  61. data/lib/dry/effects/stack.rb +6 -6
  62. data/lib/dry/effects/version.rb +1 -1
  63. data/lib/dry/effects.rb +7 -7
  64. metadata +22 -69
  65. data/.codeclimate.yml +0 -12
  66. data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
  67. data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -30
  68. data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
  69. data/.github/workflows/ci.yml +0 -74
  70. data/.github/workflows/docsite.yml +0 -34
  71. data/.github/workflows/sync_configs.yml +0 -34
  72. data/.gitignore +0 -12
  73. data/.rspec +0 -4
  74. data/.rubocop.yml +0 -95
  75. data/CODE_OF_CONDUCT.md +0 -13
  76. data/CONTRIBUTING.md +0 -29
  77. data/Gemfile +0 -23
  78. data/Rakefile +0 -8
  79. data/docsite/source/effects/cache.html.md +0 -84
  80. data/docsite/source/effects/current_time.html.md +0 -186
  81. data/docsite/source/effects/defer.html.md +0 -130
  82. data/docsite/source/effects/env.html.md +0 -144
  83. data/docsite/source/effects/interrupt.html.md +0 -109
  84. data/docsite/source/effects/parallel.html.md +0 -25
  85. data/docsite/source/effects/reader.html.md +0 -126
  86. data/docsite/source/effects/resolve.html.md +0 -188
  87. data/docsite/source/effects/state.html.md +0 -178
  88. data/docsite/source/effects/timeout.html.md +0 -42
  89. data/docsite/source/effects.html.md +0 -29
  90. data/docsite/source/index.html.md +0 -212
  91. data/examples/cmp.rb +0 -51
  92. data/examples/state.rb +0 -29
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/effects/provider'
4
- require 'dry/effects/halt'
3
+ require "dry/effects/provider"
4
+ require "dry/effects/halt"
5
5
 
6
6
  module Dry
7
7
  module Effects
@@ -18,15 +18,13 @@ module Dry
18
18
  # Yield the block with the handler installed
19
19
  #
20
20
  # @api private
21
- def call(limit)
21
+ def call(limit, &block)
22
22
  @limit = limit
23
23
  @attempts = 0
24
24
 
25
25
  loop do
26
- begin
27
- return attempt { yield }
28
- rescue halt
29
- end
26
+ return attempt(&block)
27
+ rescue halt # rubocop:disable Lint/SuppressedException
30
28
  end
31
29
  end
32
30
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/effects/providers/reader'
4
- require 'dry/effects/instructions/raise'
3
+ require "dry/effects/providers/reader"
4
+ require "dry/effects/instructions/raise"
5
5
 
6
6
  module Dry
7
7
  module Effects
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/effects/provider'
3
+ require "dry/effects/provider"
4
4
 
5
5
  module Dry
6
6
  module Effects
7
7
  module Providers
8
8
  class Timeout < Provider[:timeout]
9
- def self.handle_method(scope, as: Undefined, **)
9
+ def self.handle_method(_scope, as: Undefined, **)
10
10
  Undefined.default(as) { :with_timeout }
11
11
  end
12
12
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/effects/provider'
4
- require 'dry/effects/providers/current_time'
3
+ require "dry/effects/provider"
4
+ require "dry/effects/providers/current_time"
5
5
 
6
6
  module Dry
7
7
  module Effects
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/effects/initializer'
4
- require 'dry/effects/effect'
5
- require 'dry/effects/instructions/raise'
3
+ require "dry/effects/initializer"
4
+ require "dry/effects/effect"
5
+ require "dry/effects/instructions/raise"
6
6
 
7
7
  module Dry
8
8
  module Effects
@@ -23,7 +23,7 @@ module Dry
23
23
  else
24
24
  yield
25
25
  end
26
- rescue ::Exception => e
26
+ rescue ::Exception => e # rubocop:disable Lint/RescueException
27
27
  Instructions::Raise.new(e)
28
28
  end
29
29
 
@@ -56,9 +56,9 @@ module Dry
56
56
 
57
57
  def to_s
58
58
  if empty?
59
- '#<Dry::Effects::Stack>'
59
+ "#<Dry::Effects::Stack>"
60
60
  else
61
- stack = map(&:represent).reverse.join('->')
61
+ stack = map(&:represent).reverse.join("->")
62
62
 
63
63
  "#<Dry::Effects::Stack #{stack}>"
64
64
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Effects
5
- VERSION = '0.1.2'
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/dry/effects.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/core/constants'
4
- require 'dry/effects/version'
5
- require 'dry/effects/container'
6
- require 'dry/effects/errors'
7
- require 'dry/effects/instructions/raise'
3
+ require "dry/core/constants"
4
+ require "dry/effects/version"
5
+ require "dry/effects/container"
6
+ require "dry/effects/errors"
7
+ require "dry/effects/instructions/raise"
8
8
 
9
9
  module Dry
10
10
  module Effects
@@ -69,5 +69,5 @@ module Dry
69
69
  end
70
70
  end
71
71
 
72
- require 'dry/effects/all'
73
- require 'dry/effects/extensions'
72
+ require "dry/effects/all"
73
+ require "dry/effects/extensions"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-effects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Shilnikov
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-15 00:00:00.000000000 Z
11
+ date: 2021-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -50,40 +50,20 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.4'
53
+ version: '0.5'
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 0.4.7
56
+ version: '0.5'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0.4'
63
+ version: '0.5'
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 0.4.7
67
- - !ruby/object:Gem::Dependency
68
- name: dry-equalizer
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: '0.2'
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 0.2.2
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '0.2'
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: 0.2.2
66
+ version: '0.5'
87
67
  - !ruby/object:Gem::Dependency
88
68
  name: dry-inflector
89
69
  requirement: !ruby/object:Gem::Requirement
@@ -136,69 +116,41 @@ dependencies:
136
116
  name: rake
137
117
  requirement: !ruby/object:Gem::Requirement
138
118
  requirements:
139
- - - "~>"
119
+ - - ">="
140
120
  - !ruby/object:Gem::Version
141
- version: '10.0'
121
+ version: '0'
142
122
  type: :development
143
123
  prerelease: false
144
124
  version_requirements: !ruby/object:Gem::Requirement
145
125
  requirements:
146
- - - "~>"
126
+ - - ">="
147
127
  - !ruby/object:Gem::Version
148
- version: '10.0'
128
+ version: '0'
149
129
  - !ruby/object:Gem::Dependency
150
130
  name: rspec
151
131
  requirement: !ruby/object:Gem::Requirement
152
132
  requirements:
153
- - - "~>"
133
+ - - ">="
154
134
  - !ruby/object:Gem::Version
155
- version: '3.0'
135
+ version: '0'
156
136
  type: :development
157
137
  prerelease: false
158
138
  version_requirements: !ruby/object:Gem::Requirement
159
139
  requirements:
160
- - - "~>"
140
+ - - ">="
161
141
  - !ruby/object:Gem::Version
162
- version: '3.0'
163
- description: Algebraic effects.
142
+ version: '0'
143
+ description: Algebraic effects
164
144
  email:
165
145
  - fg@flashgordon.ru
166
146
  executables: []
167
147
  extensions: []
168
148
  extra_rdoc_files: []
169
149
  files:
170
- - ".codeclimate.yml"
171
- - ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
172
- - ".github/ISSUE_TEMPLATE/---bug-report.md"
173
- - ".github/ISSUE_TEMPLATE/---feature-request.md"
174
- - ".github/workflows/ci.yml"
175
- - ".github/workflows/docsite.yml"
176
- - ".github/workflows/sync_configs.yml"
177
- - ".gitignore"
178
- - ".rspec"
179
- - ".rubocop.yml"
180
150
  - CHANGELOG.md
181
- - CODE_OF_CONDUCT.md
182
- - CONTRIBUTING.md
183
- - Gemfile
184
151
  - LICENSE
185
152
  - README.md
186
- - Rakefile
187
- - docsite/source/effects.html.md
188
- - docsite/source/effects/cache.html.md
189
- - docsite/source/effects/current_time.html.md
190
- - docsite/source/effects/defer.html.md
191
- - docsite/source/effects/env.html.md
192
- - docsite/source/effects/interrupt.html.md
193
- - docsite/source/effects/parallel.html.md
194
- - docsite/source/effects/reader.html.md
195
- - docsite/source/effects/resolve.html.md
196
- - docsite/source/effects/state.html.md
197
- - docsite/source/effects/timeout.html.md
198
- - docsite/source/index.html.md
199
153
  - dry-effects.gemspec
200
- - examples/cmp.rb
201
- - examples/state.rb
202
154
  - lib/dry/effects.rb
203
155
  - lib/dry/effects/all.rb
204
156
  - lib/dry/effects/constructors.rb
@@ -224,6 +176,7 @@ files:
224
176
  - lib/dry/effects/effects/timestamp.rb
225
177
  - lib/dry/effects/errors.rb
226
178
  - lib/dry/effects/extensions.rb
179
+ - lib/dry/effects/extensions/active_support/tagged_logging.rb
227
180
  - lib/dry/effects/extensions/auto_inject.rb
228
181
  - lib/dry/effects/extensions/rspec.rb
229
182
  - lib/dry/effects/extensions/system.rb
@@ -258,12 +211,12 @@ files:
258
211
  - lib/dry/effects/providers/timestamp.rb
259
212
  - lib/dry/effects/stack.rb
260
213
  - lib/dry/effects/version.rb
261
- homepage: https://github.com/dry-rb/dry-effects
214
+ homepage: https://dry-rb.org/gems/dry-effects
262
215
  licenses:
263
216
  - MIT
264
217
  metadata:
265
218
  allowed_push_host: https://rubygems.org
266
- homepage_uri: https://github.com/dry-rb/dry-effects
219
+ changelog_uri: https://github.com/dry-rb/dry-effects/blob/master/CHANGELOG.md
267
220
  source_code_uri: https://github.com/dry-rb/dry-effects
268
221
  bug_tracker_uri: https://github.com/dry-rb/dry-effects/issues
269
222
  post_install_message:
@@ -274,15 +227,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
227
  requirements:
275
228
  - - ">="
276
229
  - !ruby/object:Gem::Version
277
- version: '2.4'
230
+ version: 2.6.0
278
231
  required_rubygems_version: !ruby/object:Gem::Requirement
279
232
  requirements:
280
233
  - - ">="
281
234
  - !ruby/object:Gem::Version
282
235
  version: '0'
283
236
  requirements: []
284
- rubygems_version: 3.0.6
237
+ rubygems_version: 3.1.6
285
238
  signing_key:
286
239
  specification_version: 4
287
- summary: Algebraic effects.
240
+ summary: Algebraic effects
288
241
  test_files: []
data/.codeclimate.yml DELETED
@@ -1,12 +0,0 @@
1
- # this file is managed by dry-rb/devtools project
2
-
3
- version: "2"
4
-
5
- exclude_patterns:
6
- - "benchmarks/"
7
- - "examples/"
8
- - "spec/"
9
-
10
- plugins:
11
- rubocop:
12
- enabled: true
@@ -1,10 +0,0 @@
1
- ---
2
- name: "⚠️ Please don't ask for support via issues"
3
- about: See CONTRIBUTING.md for more information
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
-
@@ -1,30 +0,0 @@
1
- ---
2
- name: "\U0001F41B Bug report"
3
- about: See CONTRIBUTING.md for more information
4
- title: ''
5
- labels: bug
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS**
11
-
12
- For more information see `CONTRIBUTING.md`.
13
-
14
- **Describe the bug**
15
-
16
- A clear and concise description of what the bug is.
17
-
18
- **To Reproduce**
19
-
20
- Provide detailed steps to reproduce, an executable script would be best.
21
-
22
- **Expected behavior**
23
-
24
- A clear and concise description of what you expected to happen.
25
-
26
- **Your environment**
27
-
28
- - Affects my production application: **YES/NO**
29
- - Ruby version: ...
30
- - OS: ...
@@ -1,18 +0,0 @@
1
- ---
2
- name: "\U0001F6E0 Feature request"
3
- about: See CONTRIBUTING.md for more information
4
- title: ''
5
- labels: feature
6
- assignees: ''
7
-
8
- ---
9
-
10
- Summary of what the feature is supposed to do.
11
-
12
- ## Examples
13
-
14
- Code examples showing how the feature could be used.
15
-
16
- ## Resources
17
-
18
- Additional information, like a link to the discussion forum thread where the feature was discussed etc.
@@ -1,74 +0,0 @@
1
- # this file is managed by dry-rb/devtools project
2
-
3
- name: ci
4
-
5
- on:
6
- push:
7
- paths:
8
- - .github/workflows/ci.yml
9
- - lib/**
10
- - spec/**
11
- - Gemfile
12
- - "*.gemspec"
13
-
14
- jobs:
15
- tests-mri:
16
- runs-on: ubuntu-latest
17
- strategy:
18
- fail-fast: false
19
- matrix:
20
- ruby: ["2.6.x", "2.5.x", "2.4.x"]
21
- include:
22
- - ruby: "2.6.x"
23
- coverage: "true"
24
- steps:
25
- - uses: actions/checkout@v1
26
- - name: Set up Ruby
27
- uses: actions/setup-ruby@v1
28
- with:
29
- ruby-version: ${{matrix.ruby}}
30
- - name: Download test reporter
31
- if: "matrix.coverage == 'true'"
32
- run: |
33
- mkdir -p tmp/
34
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
35
- chmod +x ./tmp/cc-test-reporter
36
- ./tmp/cc-test-reporter before-build
37
- - name: Run all tests
38
- env:
39
- COVERAGE: ${{matrix.coverage}}
40
- run: |
41
- gem install bundler
42
- bundle install --jobs 4 --retry 3 --without tools docs benchmarks
43
- bundle exec rake
44
- - name: Send coverage results
45
- if: "matrix.coverage == 'true'"
46
- env:
47
- CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
48
- GIT_COMMIT_SHA: ${{github.sha}}
49
- GIT_BRANCH: ${{github.ref}}
50
- GIT_COMMITTED_AT: ${{github.event.head_commit.timestamp}}
51
- run: |
52
- GIT_BRANCH=`ruby -e "puts ENV['GITHUB_REF'].split('/', 3).last"` \
53
- GIT_COMMITTED_AT=`ruby -r time -e "puts Time.iso8601(ENV['GIT_COMMITTED_AT']).to_i"` \
54
- ./tmp/cc-test-reporter after-build
55
-
56
- tests-others:
57
- runs-on: ubuntu-latest
58
- strategy:
59
- fail-fast: false
60
- matrix:
61
- image: ["jruby:9.2.8", "ruby:rc"]
62
- container:
63
- image: ${{matrix.image}}
64
- steps:
65
- - uses: actions/checkout@v1
66
- - name: Install git
67
- run: |
68
- apt-get update
69
- apt-get install -y --no-install-recommends git
70
- - name: Run all tests
71
- run: |
72
- gem install bundler
73
- bundle install --jobs 4 --retry 3 --without tools docs benchmarks
74
- bundle exec rspec