dry-monads-sorbet 1.1.0.pre.11 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +34 -6
- data/dry-monads-sorbet.gemspec +6 -0
- data/lib/bundled_rbi/dry-monads.rbi +3 -0
- data/lib/dry-monads-sorbet/tasks/dry_monads_sorbet.rake +7 -5
- data/lib/dry/monads/sorbet/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25c5b71c33daec16deda28a30aa06d0ba39738295c86c87c497554f12d7a9ca3
|
4
|
+
data.tar.gz: 1479a94070fa413a7adefdd171b740987a583b62802cdb6f14f919cdd4730f4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08ef83a7c701035db63f190270acd65599d5f37703e5debee6d659a0460e324be13e012ace46238d1bdaa6a65576ac8836dfb07e55868eeffbf0f93b71ef9705'
|
7
|
+
data.tar.gz: 246a737a59c34f0e8a371be92a6ccf0d22c0d66fab043f21ac0c7edcd1b1bb22d99e861ecd614765e4fe52cc6f41f7e0309eb3a9f0abe5cb11f18e3e49b77f76
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
1.1.2
|
2
|
+
|
3
|
+
* Fix an issue when used alongside `sorbet-rails`
|
4
|
+
|
5
|
+
1.1.1
|
6
|
+
|
7
|
+
* Remove the accidentally bundled `/rbi` directory.
|
8
|
+
|
9
|
+
1.1.0
|
10
|
+
|
11
|
+
* Now shipping the rbi bundled with the gem with a rake task to update this as/when we update the gem.
|
12
|
+
|
1
13
|
1.0.0
|
2
14
|
|
3
15
|
* Initial release
|
data/README.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
![dry-monads-sorbet](https://user-images.githubusercontent.com/2643026/69986703-dfc68200-1535-11ea-9035-38ecbdb67138.png)
|
2
2
|
|
3
|
-
# Dry Monads Sorbet ![CI Badge](https://github.com/tricycle/dry-monads-sorbet/workflows/
|
3
|
+
# Dry Monads Sorbet ![CI Badge](https://github.com/tricycle/dry-monads-sorbet/workflows/Continuous%20Integration/badge.svg)
|
4
4
|
|
5
5
|
Sorbet type hints for Dry::Monads.
|
6
6
|
|
7
|
+
This gem is very small, it opens up the `Dry::Monads::Result` and `Dry::Monads::Maybe` classes to add type members
|
8
|
+
that are subsequently referred to in a bundled `.rbi` file for the `dry-monads` gem.
|
9
|
+
|
10
|
+
The bundled rbi annotations are installed/updated via a rake task included in the gem.
|
11
|
+
|
7
12
|
## Installation
|
8
13
|
|
9
14
|
Add the gem to your Gemfile:
|
@@ -24,7 +29,7 @@ The rake task that copies the bundled `.rbi` files into your project should alre
|
|
24
29
|
bundle exec rake dry_monads_sorbet:update_rbi
|
25
30
|
```
|
26
31
|
|
27
|
-
### Outside of
|
32
|
+
### Outside of Rails projects:
|
28
33
|
|
29
34
|
Include the `Rakefile` in your own projects `Rakefile` to get access to the rbi update command:
|
30
35
|
|
@@ -40,13 +45,36 @@ After including the Rakefile you should then have access to the task as describe
|
|
40
45
|
|
41
46
|
## Usage
|
42
47
|
|
48
|
+
Usage is fairly simple, just annotate your methods as follows:
|
49
|
+
|
43
50
|
```ruby
|
44
51
|
require 'dry/monads/sorbet'
|
45
52
|
|
46
|
-
class
|
53
|
+
class MyLoginService
|
47
54
|
extend T::Sig
|
48
55
|
|
49
|
-
sig{returns(Dry::Monads::Result[StandardError, String])}
|
50
|
-
def
|
51
|
-
|
56
|
+
sig{params(username: String).returns(Dry::Monads::Result[StandardError, String])}
|
57
|
+
def check_username(username)
|
58
|
+
case username
|
59
|
+
when 'samuelgiles93'
|
60
|
+
Dry::Monads::Success('Hi Sam!')
|
61
|
+
else
|
62
|
+
Dry::Monads::Failure(
|
63
|
+
StandardError.new('Unauthorised')
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
sig{params(username: String).returns(Dry::Monads::Maybe[Integer])}
|
69
|
+
def find_fullname(username)
|
70
|
+
case username
|
71
|
+
when 'samuelgiles93'
|
72
|
+
Dry::Monads::Some('Samuel Giles')
|
73
|
+
else
|
74
|
+
Dry::Monads::None()
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
52
78
|
```
|
79
|
+
|
80
|
+
With the type annotations in place you'll get type errors when you attempt to say call a method that doesn't exist on the `Some` of a `Maybe` or the `Success` of a `Result`.
|
data/dry-monads-sorbet.gemspec
CHANGED
@@ -21,6 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = 'exe'
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
|
+
spec.post_install_message = <<~TEXT
|
25
|
+
dry-monads-sorbet has been installed/updated.
|
26
|
+
|
27
|
+
This gem ships with a bundled rbi file that must be copied into your project.
|
28
|
+
You can use the included "dry_monads_sorbet:update_rbi" to do this.
|
29
|
+
TEXT
|
24
30
|
|
25
31
|
spec.add_dependency 'sorbet'
|
26
32
|
spec.add_dependency 'sorbet-runtime'
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# typed: strong
|
2
2
|
#
|
3
|
+
# This rbi file is bundled in the dry-monads-sorbet gem and is copied down
|
4
|
+
# into projects using the dry_monads_sorbet:update_rbi rake task.
|
5
|
+
#
|
3
6
|
# Any changes to the type annotations for Dry::Monads should be made
|
4
7
|
# in the dry-monads-sorbet gem itself in its bundled_rbi directory.
|
5
8
|
|
@@ -1,23 +1,25 @@
|
|
1
1
|
require 'dry-monads-sorbet'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
DRY_MONADS_SORBET_RAKE_DIR = File.dirname(__FILE__)
|
4
5
|
|
5
6
|
namespace :dry_monads_sorbet do
|
6
|
-
|
7
|
+
desc "Generate rbis for dry/monads"
|
8
|
+
task :update_rbi do
|
7
9
|
FileUtils.rm_rf(dry_monads_sorbet_rbi_path)
|
8
10
|
|
9
|
-
|
11
|
+
dry_monads_sorbet_copy_bundled_rbi('dry-monads.rbi')
|
10
12
|
end
|
11
13
|
|
12
14
|
def dry_monads_sorbet_rbi_path
|
13
|
-
Rake.original_dir.join('sorbet', 'dry-monads-sorbet')
|
15
|
+
Pathname.new(Rake.original_dir).join('sorbet', 'dry-monads-sorbet')
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
puts "Copy bundled file #{filename}"
|
18
|
+
def dry_monads_sorbet_copy_bundled_rbi(filename)
|
18
19
|
bundled_rbi_file_path = File.join(DRY_MONADS_SORBET_RAKE_DIR, '..', '..', 'bundled_rbi', filename)
|
19
20
|
copy_to_path = dry_monads_sorbet_rbi_path.join(filename)
|
20
21
|
FileUtils.mkdir_p(File.dirname(copy_to_path))
|
21
22
|
FileUtils.cp(bundled_rbi_file_path, copy_to_path)
|
23
|
+
puts "Copied bundled rbi file: #{filename}"
|
22
24
|
end
|
23
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-monads-sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Worth
|
@@ -140,7 +140,11 @@ homepage: https://github.com/tricycle/dry-monads-sorbet
|
|
140
140
|
licenses:
|
141
141
|
- MIT
|
142
142
|
metadata: {}
|
143
|
-
post_install_message:
|
143
|
+
post_install_message: |
|
144
|
+
dry-monads-sorbet has been installed/updated.
|
145
|
+
|
146
|
+
This gem ships with a bundled rbi file that must be copied into your project.
|
147
|
+
You can use the included "dry_monads_sorbet:update_rbi" to do this.
|
144
148
|
rdoc_options: []
|
145
149
|
require_paths:
|
146
150
|
- lib
|
@@ -151,9 +155,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
155
|
version: '0'
|
152
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
157
|
requirements:
|
154
|
-
- - "
|
158
|
+
- - ">="
|
155
159
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
160
|
+
version: '0'
|
157
161
|
requirements: []
|
158
162
|
rubygems_version: 3.1.2
|
159
163
|
signing_key:
|