gate 0.5.0 → 0.6.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/.circleci/config.yml +1 -0
- data/lib/gate/command.rb +8 -3
- data/lib/gate/version.rb +1 -1
- 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: a55abc2888e46b9345e003c22968f96278c3d0f6
|
4
|
+
data.tar.gz: afa0cac795d0ed611cf439e768054e6d1d674333
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46e1efff76afae5d352120c80352f34f8a3c60ac4f4af36a0d71f657bee958de34e9c32c0337cb19421f83b83145f5261539ca6daea102e3727bf93dadacf1be
|
7
|
+
data.tar.gz: ac0d2d2bafa5866d47c2b29f8ed5c43939cd5a64b388e72d6fcc357c7c0bd4c74593630417aab039a65cf6e4c9778c10ca2d271934a97ce11a1313a67885c6bb
|
data/.circleci/config.yml
CHANGED
data/lib/gate/command.rb
CHANGED
@@ -3,6 +3,8 @@ module Gate
|
|
3
3
|
SchemaAlreadyRegistered = Class.new(StandardError)
|
4
4
|
SchemaNotDefined = Class.new(StandardError)
|
5
5
|
|
6
|
+
attr_reader :result
|
7
|
+
|
6
8
|
class InvalidCommand < StandardError
|
7
9
|
attr_reader :errors
|
8
10
|
|
@@ -10,11 +12,14 @@ module Gate
|
|
10
12
|
@errors = errors
|
11
13
|
super("Invalid command")
|
12
14
|
end
|
15
|
+
|
16
|
+
def full_message
|
17
|
+
errors.values.join(", ")
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
def self.included(base)
|
16
22
|
base.send(:extend, ClassMethods)
|
17
|
-
base.send(:attr_reader, :result)
|
18
23
|
end
|
19
24
|
|
20
25
|
def initialize(data)
|
@@ -24,7 +29,7 @@ module Gate
|
|
24
29
|
module ClassMethods
|
25
30
|
def schema(&block)
|
26
31
|
if block_given?
|
27
|
-
raise SchemaAlreadyRegistered if
|
32
|
+
raise SchemaAlreadyRegistered if instance_variable_defined?(:@schema)
|
28
33
|
@schema = Dry::Validation.Form(&block)
|
29
34
|
@schema.rules.keys.each do |name|
|
30
35
|
define_method(name) do
|
@@ -39,7 +44,7 @@ module Gate
|
|
39
44
|
|
40
45
|
def with(input)
|
41
46
|
result = schema.(input)
|
42
|
-
raise InvalidCommand, result.messages if result.failure?
|
47
|
+
raise InvalidCommand, result.messages(full: true) if result.failure?
|
43
48
|
new result.output
|
44
49
|
end
|
45
50
|
end
|
data/lib/gate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Dudulski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-validation
|