gl_command 1.1.3 → 1.2.0
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/README.md +18 -0
- data/lib/gl_command/callable.rb +3 -3
- data/lib/gl_command/chainable.rb +1 -1
- data/lib/gl_command/context.rb +1 -5
- data/lib/gl_command/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 705c23dec5e3038e7a6b4d0736f58589b775edd30ee53056d2478b8361f9a3d6
|
4
|
+
data.tar.gz: a547c64df86a0f2a533ad43ea5f1ee0a1e2dfcc8fe27e6f1c85b4a018ad75b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b13e47c074cc18aeeb50cd0e874c088cd7c0091b52fc5d705b4b5b79ddbb18fa1b3d12b596bf2febd85264a1fe5f9e933fa0893444b21369a4a8cc4a3a33c64f
|
7
|
+
data.tar.gz: 25ac2f9a597e199fef77ebcd08442937615b63102bd8e071d0aea68ede1a2e83da085e902022f54ed32a41ddcf474510e9be811f3dc37941b78f7a2498a0c383
|
data/README.md
CHANGED
@@ -215,6 +215,24 @@ end
|
|
215
215
|
```
|
216
216
|
|
217
217
|
|
218
|
+
## Publishing the gem to Rubygems
|
219
|
+
|
220
|
+
1. As per our code agreements, all code changes to this gem are required to be made via pull request with final approval from at least one Give Lively engineer.
|
221
|
+
|
222
|
+
2. When creating a pull request, ensure that your code changes include an update to the gem's [version number](https://github.com/givelively/gl_command/blob/main/lib/gl_command/version.rb) using [semantic versioning](https://semver.org/)
|
223
|
+
|
224
|
+
3. After getting approval, merge your changes to `main`.
|
225
|
+
|
226
|
+
4. Once your CI build finishes successfully, pull the latest version of `main` locally.
|
227
|
+
|
228
|
+
5. Run the command `gem build`. This bundles the relevant files from the gem and prepares it to be published to [rubygems.org](https://rubygems.org/).
|
229
|
+
|
230
|
+
6. This will create a new file locally that looks like `gl_command-<new_gem_version_number>.gem`.
|
231
|
+
|
232
|
+
7. Run `gem push gl_command-<new_gem_version_number>.gem` to publish the new version
|
233
|
+
|
234
|
+
**NOTE: only the gem owners listed on rubygems can publish new versions**
|
235
|
+
|
218
236
|
---
|
219
237
|
|
220
238
|
This library is influenced by [interactors](https://github.com/collectiveidea/interactor) and inspired by the [Command Pattern](https://en.wikipedia.org/wiki/Command_pattern).
|
data/lib/gl_command/callable.rb
CHANGED
@@ -6,6 +6,8 @@ require 'gl_command/validatable'
|
|
6
6
|
|
7
7
|
module GLCommand
|
8
8
|
class Callable
|
9
|
+
include GLCommand::Validatable
|
10
|
+
ALWAYS_RAISE_ERRORS = ENV['GL_COMMAND_ALWAYS_RAISE'] == 'true'
|
9
11
|
DEFAULT_OPTS = { raise_errors: false, skip_unknown_parameters: true, in_chain: false }.freeze
|
10
12
|
RESERVED_WORDS = (DEFAULT_OPTS.keys + GLCommand::ChainableContext.reserved_words).sort.freeze
|
11
13
|
|
@@ -25,7 +27,7 @@ module GLCommand
|
|
25
27
|
|
26
28
|
# DEFAULT_OPTS contains skip_unknown_parameters: true - so it raises on call
|
27
29
|
# (rather than in context initialize) to make errors more legible
|
28
|
-
opts = DEFAULT_OPTS.merge(raise_errors: args.delete(:raise_errors),
|
30
|
+
opts = DEFAULT_OPTS.merge(raise_errors: args.delete(:raise_errors) || ALWAYS_RAISE_ERRORS,
|
29
31
|
in_chain: args.delete(:in_chain)).compact
|
30
32
|
# args are passed in in perform_call(args) so that invalid args raise in a legible place
|
31
33
|
new(build_context(**args.merge(opts))).perform_call(args)
|
@@ -101,8 +103,6 @@ module GLCommand
|
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
104
|
-
include GLCommand::Validatable
|
105
|
-
|
106
106
|
attr_reader :context
|
107
107
|
|
108
108
|
def initialize(context = nil)
|
data/lib/gl_command/chainable.rb
CHANGED
@@ -41,7 +41,7 @@ module GLCommand
|
|
41
41
|
|
42
42
|
commands.map do |command|
|
43
43
|
cargs = context.chain_arguments_and_returns.slice(*command.arguments)
|
44
|
-
.merge(context.opts_hash).merge(in_chain:
|
44
|
+
.merge(context.opts_hash).merge(in_chain: context)
|
45
45
|
|
46
46
|
# using _result to make sure it doesn't cause naming conflicts with other uses of result
|
47
47
|
_result = command.call(**cargs)
|
data/lib/gl_command/context.rb
CHANGED
@@ -22,7 +22,7 @@ module GLCommand
|
|
22
22
|
{ raise_errors: raise_errors? }
|
23
23
|
end
|
24
24
|
|
25
|
-
attr_reader :klass, :error
|
25
|
+
attr_reader :klass, :error, :in_chain
|
26
26
|
attr_writer :full_error_message
|
27
27
|
|
28
28
|
# If someone calls #errors, they expect to get the errors! Include the non-validation error, if it exists
|
@@ -35,10 +35,6 @@ module GLCommand
|
|
35
35
|
false
|
36
36
|
end
|
37
37
|
|
38
|
-
def in_chain?
|
39
|
-
@in_chain
|
40
|
-
end
|
41
|
-
|
42
38
|
def returns
|
43
39
|
@klass.returns.index_with { |rattr| send(rattr) }
|
44
40
|
end
|
data/lib/gl_command/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gl_command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Give Lively
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|