gate 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c5b6793497535f1a64c445c3dc79f96d51ab755
4
- data.tar.gz: 8cb64c61b215efbb182cf7a8bc830d1c0d2e5f66
3
+ metadata.gz: a55abc2888e46b9345e003c22968f96278c3d0f6
4
+ data.tar.gz: afa0cac795d0ed611cf439e768054e6d1d674333
5
5
  SHA512:
6
- metadata.gz: 522271efbce236d5a3b71fd5c695dd59fe2a21b823482bba9979481636dafe3247b4dbd5462998500a7e0df74f0546669d7886df80c3e5765dedb26de8b139c0
7
- data.tar.gz: e6d172ccbee95ec78413c106a6c7fac857f092e11d6eaeaa353e5dc3b9d0a303ee264f2b2bcf42e771c869528682f95f0883ad0cf0704b4c4dd22ca873191c59
6
+ metadata.gz: 46e1efff76afae5d352120c80352f34f8a3c60ac4f4af36a0d71f657bee958de34e9c32c0337cb19421f83b83145f5261539ca6daea102e3727bf93dadacf1be
7
+ data.tar.gz: ac0d2d2bafa5866d47c2b29f8ed5c43939cd5a64b388e72d6fcc357c7c0bd4c74593630417aab039a65cf6e4c9778c10ca2d271934a97ce11a1313a67885c6bb
data/.circleci/config.yml CHANGED
@@ -6,4 +6,5 @@ jobs:
6
6
  steps:
7
7
  - checkout
8
8
  - run: gem install bundler
9
+ - run: bundle install
9
10
  - run: bundle exec rake
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 @schema
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
@@ -1,3 +1,3 @@
1
1
  module Gate
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
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.5.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-03-15 00:00:00.000000000 Z
11
+ date: 2018-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation