commande 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +116 -115
- data/lib/commande/version.rb +5 -5
- data/lib/commande.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d25e8ec7120ae92efec0d9213a85eb7406ba2cae
|
4
|
+
data.tar.gz: 511b45c1ca6eb7d0b9f45a2322cc1c8e41f74e73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5866e974388a65b94f57d4b053db322734f68090e71c438b6f47ffd20440625ceb9e205cd2a8628f94c6424f5b61b58469d35697d842b75a869be9e49f98aa07
|
7
|
+
data.tar.gz: 602a9ffdd2b80d1c18cc3cef9702ce6bea0e230928c421151389bfaadd7aca264214cf6d75db2dc4dca4be658d0d33ddfd49f6e2d9680b4fdd8e7903386ce3a8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,115 +1,116 @@
|
|
1
|
-
# Command
|
2
|
-
[](https://travis-ci.com/SleeplessByte/command)
|
3
|
-
[](https://badge.fury.io/rb/commande)
|
4
|
-
[](http://opensource.org/licenses/MIT)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
was
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
[`
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
result
|
73
|
-
result.
|
74
|
-
|
75
|
-
|
76
|
-
result.
|
77
|
-
result.
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
| `
|
91
|
-
| `
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
1
|
+
# Command
|
2
|
+
[](https://travis-ci.com/SleeplessByte/command)
|
3
|
+
[](https://badge.fury.io/rb/commande)
|
4
|
+
[](http://opensource.org/licenses/MIT)
|
5
|
+
[](https://codeclimate.com/github/SleeplessByte/command/maintainability)
|
6
|
+
|
7
|
+
Command adds the [Command Design Pattern](https://sourcemaking.com/design_patterns/command) to any `Class`.
|
8
|
+
|
9
|
+
This was based on `Hanami::Interactor`, and started off as adding a direct `call` on the singleton class, before that
|
10
|
+
was added to Hanami's. After working with different interactors and command-style gems, including ways to organize
|
11
|
+
units for execution and without depending on other utility classes, `command` was born.
|
12
|
+
|
13
|
+
Because [`command`](https://rubygems.org/gems/command) has been taken on rubygems (but not updated since 2013), and
|
14
|
+
[`commando`](https://rubygems.org/gems/commando) has been taken (but not updated since 2009) and the Dutch `opdracht` is
|
15
|
+
probably not pronounceable by most people using this, I've decided to register this on the French
|
16
|
+
[`commande`](https://rubygems.org/gems/commande).
|
17
|
+
|
18
|
+
However, if you are using this directly from GitHub, you can continue using it as is, without renaming, as long as you
|
19
|
+
change the Gemfile line to `require: 'command'`.
|
20
|
+
|
21
|
+
```Ruby
|
22
|
+
# Gemfile
|
23
|
+
gem 'commande', require: 'command'
|
24
|
+
```
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
Add this line to your application's Gemfile:
|
29
|
+
|
30
|
+
```Ruby
|
31
|
+
gem 'commande'
|
32
|
+
```
|
33
|
+
|
34
|
+
or alternatively if you would like to refer to commande as `Command`:
|
35
|
+
|
36
|
+
```Ruby
|
37
|
+
gem 'commande', require: 'command'
|
38
|
+
```
|
39
|
+
|
40
|
+
And then execute:
|
41
|
+
|
42
|
+
$ bundle
|
43
|
+
|
44
|
+
Or install it yourself as:
|
45
|
+
|
46
|
+
$ gem install commande
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
There are examples in the code and the tests. Here is a crude and basic example:
|
51
|
+
|
52
|
+
```Ruby
|
53
|
+
class FetchSecondInput
|
54
|
+
include Commande
|
55
|
+
|
56
|
+
output :fetched
|
57
|
+
|
58
|
+
def call(*args)
|
59
|
+
# always define call
|
60
|
+
self.fetched = args.second
|
61
|
+
end
|
62
|
+
|
63
|
+
def valid?(*args)
|
64
|
+
args.length == 2
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
attr_accessor :fetched
|
70
|
+
end
|
71
|
+
|
72
|
+
result = FetchSecondInput.call(42, 'gem')
|
73
|
+
result.successful? # => true
|
74
|
+
result.fetched # => 'gem'
|
75
|
+
|
76
|
+
result = FetchSecondInput.call(42, 'gem', 'three is a crowd')
|
77
|
+
result.successful? # => false
|
78
|
+
result.fetched # => nil
|
79
|
+
```
|
80
|
+
|
81
|
+
## Testing
|
82
|
+
|
83
|
+
There are some `Minitest` assertions included in this library.
|
84
|
+
|
85
|
+
```Ruby
|
86
|
+
require 'commande/minitest'
|
87
|
+
```
|
88
|
+
| Assert | Refute | |
|
89
|
+
|:---:|:---:|:---:|
|
90
|
+
| `assert_successful(command_result)` | `refute_successful` | passes if the command is successful?
|
91
|
+
| `assert_valid(command, *args_for_valid)` | `refute_valid` | passes if the command is valid
|
92
|
+
| `assert_with_error(expected, actual)` | `refute_with_error` | passes if the command has a certain error message
|
93
|
+
|
94
|
+
## Development
|
95
|
+
|
96
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
|
97
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
98
|
+
|
99
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
100
|
+
version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
|
101
|
+
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
Bug reports and pull requests are welcome on GitHub at [SleeplessByte/commmand](https://github.com/SleeplessByte/command).
|
106
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
|
107
|
+
the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
108
|
+
|
109
|
+
## License
|
110
|
+
|
111
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
112
|
+
|
113
|
+
## Code of Conduct
|
114
|
+
|
115
|
+
Everyone interacting in the Shrine::ConfigurableStorage project’s codebases, issue trackers, chat rooms and mailing
|
116
|
+
lists is expected to follow the [code of conduct](https://github.com/SleeplessByte/command/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/commande/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Commande
|
4
|
-
VERSION = '0.3.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Commande
|
4
|
+
VERSION = '0.3.1'
|
5
|
+
end
|
data/lib/commande.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commande
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derk-Jan Karrenbeld
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|