excom 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/bin/console +2 -1
- data/excom.gemspec +2 -0
- data/lib/excom/plugins/args.rb +2 -2
- data/lib/excom/plugins/dry_types.rb +70 -0
- data/lib/excom/plugins/executable.rb +0 -3
- data/lib/excom/plugins/sentry.rb +2 -2
- data/lib/excom/version.rb +1 -1
- data/lib/excom.rb +12 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e2a4c4c2e30de13e0b49be35a9f54a798b902b5
|
4
|
+
data.tar.gz: c415fda36ef08ab72a157917717ab217a7033ae5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36cbeb14f6e1c366446787ea8c5b7475197180dd30bd99d8842328cd20071db59cabefb8dd2c9c390addd4040e7588b5a9484509a433eb156b70a10ab5700db4
|
7
|
+
data.tar.gz: c5d76e81aff3acbda0f7c28059f20ae46f778b465771ab52b2bbc04b46116e218a045a7982a0a36aeb8ab88fdb00d4033ebd9e2ec9ef7acacdf1e216fe20d26d
|
data/README.md
CHANGED
@@ -224,6 +224,9 @@ end
|
|
224
224
|
- [`:assertions`](https://github.com/akuzko/excom/wiki/Plugins#assertions) - Provides `assert` method that
|
225
225
|
can be used for different logic checks during command execution.
|
226
226
|
|
227
|
+
- [`:dry_types`](https://github.com/akuzko/excom/wiki/Plugins#dry-types) - Allows you to use
|
228
|
+
[dry-types](http://dry-rb.org/gems/dry-types/) attributes instead of default `args` and `opts`.
|
229
|
+
|
227
230
|
- [`:caching`](https://github.com/akuzko/excom/wiki/Plugins#caching) - Simple plugin that will prevent
|
228
231
|
re-execution of command if it already has been executed, and will immediately return result.
|
229
232
|
|
data/bin/console
CHANGED
data/excom.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.11"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "dry-types", "~> 0.12"
|
27
|
+
spec.add_development_dependency "dry-struct", "~> 0.4"
|
26
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
29
|
spec.add_development_dependency "rspec-its", "~> 1.2"
|
28
30
|
spec.add_development_dependency "pry"
|
data/lib/excom/plugins/args.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
module Excom
|
2
|
+
module Plugins::DryTypes
|
3
|
+
Plugins.register :dry_types, self
|
4
|
+
|
5
|
+
attr_accessor :attributes
|
6
|
+
protected :attributes=
|
7
|
+
|
8
|
+
def self.used(command_class, *)
|
9
|
+
require 'dry-types'
|
10
|
+
require 'dry-struct'
|
11
|
+
|
12
|
+
command_class.const_set(:Attributes, Class.new(Dry::Struct))
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(attrs)
|
16
|
+
@attributes = self.class::Attributes.new(attrs)
|
17
|
+
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize_clone(*)
|
22
|
+
@attributes = @attributes.dup
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_attributes(attrs)
|
27
|
+
clone.tap do |copy|
|
28
|
+
copy.attributes = self.class::Attributes.new(attributes.to_hash.merge(attrs))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# args and opts overloads
|
33
|
+
private def resolve_args!(args)
|
34
|
+
[nil, nil]
|
35
|
+
end
|
36
|
+
|
37
|
+
private def assert_valid_args!(*)
|
38
|
+
end
|
39
|
+
|
40
|
+
private def assert_valid_opts!(*)
|
41
|
+
end
|
42
|
+
|
43
|
+
def with_args(*)
|
44
|
+
fail "`with_args' method is not available with :dry_types plugin. use `with_attributes' method instead"
|
45
|
+
end
|
46
|
+
|
47
|
+
def with_opts(*)
|
48
|
+
fail "`with_opts' method is not available with :dry_types plugin. use `with_attributes' method instead"
|
49
|
+
end
|
50
|
+
|
51
|
+
module ClassMethods
|
52
|
+
def args(*)
|
53
|
+
fail "`args' method is not available with :dry_types plugin. use `attribute' method instead"
|
54
|
+
end
|
55
|
+
|
56
|
+
def opts(*)
|
57
|
+
fail "`args' method is not available with :dry_types plugin. use `attribute' method instead"
|
58
|
+
end
|
59
|
+
|
60
|
+
def attribute(name, *args)
|
61
|
+
const_get(:Attributes).send(:attribute, name, *args)
|
62
|
+
arg_methods.send(:define_method, name){ @attributes.send(name) }
|
63
|
+
end
|
64
|
+
|
65
|
+
def constructor_type(*args)
|
66
|
+
const_get(:Attributes).send(:constructor_type, *args)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/excom/plugins/sentry.rb
CHANGED
@@ -44,8 +44,8 @@ module Excom
|
|
44
44
|
command_class.sentry_class(_sentry_class)
|
45
45
|
end
|
46
46
|
|
47
|
-
def sentry_class(klass =
|
48
|
-
return self._sentry_class = klass unless klass
|
47
|
+
def sentry_class(klass = UNDEFINED)
|
48
|
+
return self._sentry_class = klass unless klass == UNDEFINED
|
49
49
|
return @sentry_class if defined? @sentry_class
|
50
50
|
|
51
51
|
@sentry_class =
|
data/lib/excom/version.rb
CHANGED
data/lib/excom.rb
CHANGED
@@ -7,4 +7,16 @@ module Excom
|
|
7
7
|
extend Plugins::Context::ExcomMethods
|
8
8
|
|
9
9
|
Sentry = Plugins::Sentry::Sentinel
|
10
|
+
|
11
|
+
UNDEFINED = Object.new.tap do |obj|
|
12
|
+
def obj.to_s
|
13
|
+
'UNDEFINED'.freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
def obj.inspect
|
17
|
+
'UNDEFINED'.freeze
|
18
|
+
end
|
19
|
+
|
20
|
+
obj.freeze
|
21
|
+
end
|
10
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Kuzko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-types
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dry-struct
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.4'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rspec
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +147,7 @@ files:
|
|
119
147
|
- lib/excom/plugins/assertions.rb
|
120
148
|
- lib/excom/plugins/caching.rb
|
121
149
|
- lib/excom/plugins/context.rb
|
150
|
+
- lib/excom/plugins/dry_types.rb
|
122
151
|
- lib/excom/plugins/executable.rb
|
123
152
|
- lib/excom/plugins/pluggable.rb
|
124
153
|
- lib/excom/plugins/rescue.rb
|