dry-effects 0.1.0 → 0.1.1

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: b4b516150a36745c1fac9a030dc079a629737b0a79b35b5e6901c413e7019479
4
- data.tar.gz: 0f81389b62e44b1196535332407cec3d894ccc7f6413f97e32766d0b5109426f
3
+ metadata.gz: a830eaa18fc97f22045d9f3aaffe905729749e6a69d05b0d4e5e7de435a3f5ab
4
+ data.tar.gz: 414d49b7b5e1be23f327aa33511a575153aefc5ff50dc429def6739b81cb4571
5
5
  SHA512:
6
- metadata.gz: 97c935e9b3b37f026c74b1e5e055f43f17b718dad48095b80f730c610d685990a0e9d1cd473859154d78fa388f44ae211f861ec066ec268b95b58d1543b2d07b
7
- data.tar.gz: dc49f0fd42b63ec247322a177e73334a30f336e70b904c03c9708b2991dd85344b9b6f62833b768501082434b49fc69060980111ca0a137c922b66186d27d7a9
6
+ metadata.gz: d599d1e85269f9a65bfdef7d9b6c60b37c91c1b340c8b18d2b8e40980be4a312a8cd9e5573f905b6b84a0d800aaac480b3eb422c6cc3d63eaa2b5578690b801e
7
+ data.tar.gz: 39809721fe1bb1d1b0e190fd75cf58c772ad36fe4f6ecec734da4e48a2226923da084ddb0425589bdff781c9640a7ba4323c53b8a72f4bb82c9017f2784adadf
@@ -1,9 +1,6 @@
1
- version: "2"
1
+ # this file is managed by dry-rb/devtools project
2
2
 
3
- prepare:
4
- fetch:
5
- - url: "https://raw.githubusercontent.com/dry-rb/devtools/master/.rubocop.yml"
6
- path: ".rubocop.yml"
3
+ version: "2"
7
4
 
8
5
  exclude_patterns:
9
6
  - "benchmarks/"
@@ -0,0 +1,10 @@
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
+
@@ -0,0 +1,34 @@
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 [our contribution guidelines](https://github.com/rom-rb/rom/blob/master/CONTRIBUTING.md)
13
+
14
+ **Before you report**
15
+
16
+ :warning: If you have a problem related to a schema, please **report it under [dry-schema issues](https://github.com/dry-rb/dry-schema/issues/new?assignees=&labels=bug&template=---bug-report.md&title=)** instead.
17
+
18
+ **Describe the bug**
19
+
20
+ A clear and concise description of what the bug is.
21
+
22
+ **To Reproduce**
23
+
24
+ Provide detailed steps to reproduce, an executable script would be best.
25
+
26
+ **Expected behavior**
27
+
28
+ A clear and concise description of what you expected to happen.
29
+
30
+ **Your environment**
31
+
32
+ - Affects my production application: **YES/NO**
33
+ - Ruby version: ...
34
+ - OS: ...
@@ -0,0 +1,18 @@
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.
@@ -0,0 +1,74 @@
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
@@ -0,0 +1,34 @@
1
+ # this file is managed by dry-rb/devtools project
2
+
3
+ name: docsite
4
+
5
+ on:
6
+ push:
7
+ paths:
8
+ - docsite/**
9
+ - .github/workflows/docsite.yml
10
+ branches:
11
+ - master
12
+ - release-**
13
+ tags:
14
+
15
+ jobs:
16
+ update-docs:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v1
20
+ - name: Set up Ruby
21
+ uses: actions/setup-ruby@v1
22
+ with:
23
+ ruby-version: "2.6.x"
24
+ - name: Install dependencies
25
+ run: |
26
+ gem install bundler
27
+ bundle install --jobs 4 --retry 3 --without benchmarks sql
28
+ - name: Symlink ossy
29
+ run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
30
+ - name: Trigger dry-rb.org deploy
31
+ env:
32
+ GITHUB_LOGIN: dry-bot
33
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
34
+ run: bin/ossy github workflow dry-rb/dry-rb.org ci
@@ -0,0 +1,34 @@
1
+ # this file is managed by dry-rb/devtools project
2
+
3
+ name: sync_configs
4
+
5
+ on:
6
+ repository_dispatch:
7
+
8
+ jobs:
9
+ sync-configs:
10
+ runs-on: ubuntu-latest
11
+ if: github.event.action == 'sync_configs'
12
+ steps:
13
+ - uses: actions/checkout@v1
14
+ - name: Update configuration files from devtools
15
+ env:
16
+ GITHUB_LOGIN: dry-bot
17
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
18
+ run: |
19
+ git clone https://github.com/dry-rb/devtools.git tmp/devtools
20
+
21
+ if [ -f ".github/workflows/custom_ci.yml" ]; then
22
+ rsync -av --exclude '.github/workflows/ci.yml' tmp/devtools/shared/ . ;
23
+ else
24
+ rsync -av tmp/devtools/shared/ . ;
25
+ fi
26
+
27
+ git config --local user.email "dry-bot@dry-rb.org"
28
+ git config --local user.name "dry-bot"
29
+ git add -A
30
+ git commit -m "[devtools] config sync" || echo "nothing changed"
31
+ - name: Push changes
32
+ uses: ad-m/github-push-action@master
33
+ with:
34
+ github_token: ${{ secrets.GH_PAT }}
data/.rspec CHANGED
@@ -1,3 +1,4 @@
1
- --format documentation
2
1
  --color
3
2
  --require spec_helper
3
+ --order random
4
+
@@ -1,3 +1,5 @@
1
+ # this file is managed by dry-rb/devtools project
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 2.4
3
5
 
@@ -20,6 +22,9 @@ Style/StabbyLambdaParentheses:
20
22
  Style/FormatString:
21
23
  Enabled: false
22
24
 
25
+ Style/Documentation:
26
+ Enabled: false
27
+
23
28
  Layout/SpaceInLambdaLiteral:
24
29
  Enabled: false
25
30
 
@@ -40,9 +45,7 @@ Metrics/AbcSize:
40
45
  Max: 20
41
46
 
42
47
  Metrics/BlockLength:
43
- Enabled: true
44
- Exclude:
45
- - 'spec/**/*_spec.rb'
48
+ Enabled: false
46
49
 
47
50
  Metrics/CyclomaticComplexity:
48
51
  Enabled: true
@@ -62,12 +65,25 @@ Layout/IndentFirstArrayElement:
62
65
 
63
66
  Style/ClassAndModuleChildren:
64
67
  Exclude:
65
- - 'spec/**/*_spec.rb'
68
+ - "spec/**/*_spec.rb"
66
69
 
67
70
  Lint/HandleExceptions:
68
71
  Exclude:
69
- - 'spec/spec_helper.rb'
72
+ - "spec/spec_helper.rb"
70
73
 
71
74
  Naming/FileName:
72
75
  Exclude:
73
- - 'lib/dry-*.rb'
76
+ - "lib/dry-*.rb"
77
+
78
+ Style/SymbolArray:
79
+ Exclude:
80
+ - "spec/**/*_spec.rb"
81
+
82
+ Style/ConditionalAssignment:
83
+ Enabled: false
84
+
85
+ Naming/MethodName:
86
+ Enabled: false
87
+
88
+ Style/AsciiComments:
89
+ Enabled: false
@@ -1,3 +1,18 @@
1
- # v0.1.0
1
+ # v0.1.1 - 2019-11-30
2
2
 
3
- TBD
3
+ ## Added
4
+
5
+ - Extension for RSpec. Some features of RSpec require access to thread-local storage. This extension patches RSpec so that storage is shared between the root fiber and dry-effects context (flash-gordon)
6
+
7
+ ```ruby
8
+ # in spec_helper.rb do
9
+ require 'dry/effects'
10
+
11
+ Dry::Effects.load_extensions(:rspec)
12
+ ```
13
+
14
+ [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-effects/compare/v0.1.0...v0.1.1)
15
+
16
+ # v0.1.0 - 2019-09-28
17
+
18
+ Initial release.
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct)
@@ -10,7 +10,7 @@ Report a feature request **only after discussing it first on [discourse.dry-rb.o
10
10
 
11
11
  ## Reporting questions, support requests, ideas, concerns etc.
12
12
 
13
- **PLEASE DON'T** - use [discourse.dry-rb.org](https://discourse.dry-rb.org) instead.
13
+ **PLEASE DON'T** - use [discourse.dry-rb.org](http://discourse.dry-rb.org) instead.
14
14
 
15
15
  # Pull Request Guidelines
16
16
 
@@ -26,4 +26,4 @@ Other requirements:
26
26
 
27
27
  # Asking for help
28
28
 
29
- If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.dry-rb.org](https://discourse.dry-rb.org).
29
+ If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.dry-rb.org](https://discourse.dry-rb.org) or join [our chat](https://dry-rb.zulipchat.com).
data/Gemfile CHANGED
@@ -16,6 +16,7 @@ end
16
16
  group :tools do
17
17
  gem 'pry-byebug', platform: :mri
18
18
  gem 'rubocop'
19
+ gem 'ossy', git: 'https://github.com/solnic/ossy.git', branch: 'master'
19
20
  end
20
21
 
21
22
  gem 'dry-struct'
data/LICENSE CHANGED
@@ -1,21 +1,20 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Nikita Shilnikov
3
+ Copyright (c) 2015-2019 dry-rb team
4
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:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
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
21
- THE SOFTWARE.
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
- [travis]: https://travis-ci.com/dry-rb/dry-effects
1
+ [gem]: https://rubygems.org/gems/dry-effects
2
+ [ci]: https://github.com/dry-rb/dry-effects/actions?query=workflow%3Aci
2
3
  [codeclimate]: https://codeclimate.com/github/dry-rb/dry-effects/maintainability
3
4
  [coverage]: https://codeclimate.com/github/dry-rb/dry-effects/test_coverage
4
5
  [chat]: https://dry-rb.zulipchat.com
5
6
 
6
7
  # dry-effects [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
7
8
 
8
- [![Build Status](https://travis-ci.com/dry-rb/dry-effects.svg?branch=master)][travis]
9
+ [![Gem Version](https://badge.fury.io/rb/dry-effects.svg)][gem]
10
+ [![Build Status](https://github.com/dry-rb/dry-monads/workflows/ci/badge.svg)][ci]
9
11
  [![Maintainability](https://api.codeclimate.com/v1/badges/83bdab1ec9e1097c2284/maintainability)][codeclimate]
10
12
  [![Test Coverage](https://api.codeclimate.com/v1/badges/83bdab1ec9e1097c2284/test_coverage)][coverage]
11
13
 
@@ -0,0 +1,29 @@
1
+ ---
2
+ title: Effects
3
+ layout: gem-single
4
+ name: dry-effects
5
+ sections:
6
+ - reader
7
+ - state
8
+ - resolve
9
+ - cache
10
+ - current_time
11
+ - env
12
+ - interrupt
13
+ - defer
14
+ - timeout
15
+ - parallel
16
+ ---
17
+
18
+ `dry-effects` has a bunch of built-in effects and providers:
19
+
20
+ - [Reader](/gems/dry-effects/0.1/effects/reader)
21
+ - [State](/gems/dry-effects/0.1/effects/state)
22
+ - [Resolve (Dependency Injection)](/gems/dry-effects/0.1/effects/resolve)
23
+ - [Cache](/gems/dry-effects/0.1/effects/cache)
24
+ - [Current Time](/gems/dry-effects/0.1/effects/current_time)
25
+ - [Environment](/gems/dry-effects/0.1/effects/env)
26
+ - [Interrupt](/gems/dry-effects/0.1/effects/interrupt)
27
+ - [Deferred Execution](/gems/dry-effects/0.1/effects/defer)
28
+ - [Timeout](/gems/dry-effects/0.1/effects/timeout)
29
+ - [Parallel execution](/gems/dry-effects/0.1/effects/parallel)
@@ -0,0 +1,84 @@
1
+ ---
2
+ title: Cache
3
+ layout: gem-single
4
+ name: dry-effects
5
+ ---
6
+
7
+ Cache provides two interfaces for caching. Set up a handler:
8
+
9
+ ```ruby
10
+ require 'dry/effects'
11
+
12
+ class CacheMiddleware
13
+ # Providing scope is required
14
+ # All cache values will be scoped with this key
15
+ include Dry::Effects::Handler.Cache(:blog)
16
+
17
+ def initialize(app)
18
+ @app = app
19
+ end
20
+
21
+ def call(env)
22
+ with_cache { @app.env }
23
+ end
24
+ end
25
+ ```
26
+
27
+ Using `prepend`:
28
+
29
+ ```ruby
30
+ require 'dry/effects'
31
+
32
+ class ShowUsers
33
+ include Dry::Effects.Resolve(:user_repo)
34
+ # It will cache .find_user calls
35
+ # Users with the same id won't be searched twice
36
+ # Effectively (no pun intended),
37
+ # it's `memoize` scoped with the call in CacheMiddleware
38
+ prepend Dry::Effects.Cache(blog: :find_user)
39
+
40
+ def call(user_ids)
41
+ users = user_ids.map { find_user(id) }
42
+ # ...
43
+ end
44
+
45
+ def find_user(id)
46
+ user_repo.find(id)
47
+ end
48
+ end
49
+ ```
50
+
51
+ Or using `include`:
52
+
53
+ ```ruby
54
+ require 'dry/effects'
55
+
56
+ class ShowUsers
57
+ include Dry::Effects.Resolve(:user_repo)
58
+ # When included, adds #cache method
59
+ include Dry::Effects.Cache(:blog)
60
+
61
+ def call(user_ids)
62
+ users = user_ids.map { cache(:user, id) { user_repo.find(id) } }
63
+ # ...
64
+ end
65
+ end
66
+ ```
67
+
68
+ ### Cache longevity
69
+
70
+ The default cache handler doesn't (yet) support long-lived storage. Cache values are discarded once `with_cache` returns.
71
+
72
+ ### Using in tests
73
+
74
+ It's usually OK to have a global handler for cache effects:
75
+
76
+ ```ruby
77
+ require 'dry/effects'
78
+
79
+ with_cache = Object.new.extend(Dry::Effects::Handler.Cache(:my_app, as: :call))
80
+
81
+ RSpec.configure do |config|
82
+ config.around(:each) { with_cache.(&ex) }
83
+ end
84
+ ```