verbalize 1.1.1 → 1.2.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: af1f862ae8c6cbaef0af29e87c01e805cd667be3
4
- data.tar.gz: 3080e524a6b251d8633dab8673951f75371058fa
3
+ metadata.gz: 1a62bdd3cdb29ee92c019943093d0808d2083531
4
+ data.tar.gz: 236446bbba2989ca23cab20956aeddedefd3b22b
5
5
  SHA512:
6
- metadata.gz: ec18ba755d82586787fa4dfea0220a5321092ee8aad1a2791eb6088e3fa19aef645375e1f5dd7a4808a2dd55556db6f0b5beaa5a362c9f054bf4decb823199d7
7
- data.tar.gz: 7abe67eebe6e6785b1e0ed92cd844a8819ff7cd7a3841f0b65655351ac57e36a376833446e3398052d95272df910ebf80996859d6d276b6479d4959a671ea98a
6
+ metadata.gz: d508c37312260b5916ffc08eb3d84fa73a7df7afe5220c143673d44d9cb384893a70281931f5c22aab1bd895eb29ed253ecb799c4442d788cf58da6e3ba2c0ba
7
+ data.tar.gz: 73e4886dd4c0f08ad21d7f7a134b8cb4949f34e4ef404f98a397ae5dbab338a62ff90613c0adb6772a7614ee9f3c6ba0834fde2638d6d99f470867b170f54480
data/.rubocop.yml CHANGED
@@ -6,3 +6,6 @@ Metrics/LineLength:
6
6
 
7
7
  Documentation:
8
8
  Enabled: false
9
+
10
+ Style/Alias:
11
+ EnforcedStyle: prefer_alias_method
data/README.md CHANGED
@@ -19,7 +19,9 @@ result = Add.call(a: 35, b: 7)
19
19
  result.outcome # => :ok
20
20
  result.value # => 42
21
21
  result.succeeded? # => true
22
+ result.success? # alias for succeeded? => true
22
23
  result.failed? # => false
24
+ result.failure? # alias for failed? => false
23
25
 
24
26
  outcome, value = Add.call(a: 35, b: 7)
25
27
  outcome # => :ok
data/lib/verbalize.rb CHANGED
@@ -73,7 +73,7 @@ module Verbalize
73
73
  def call!
74
74
  new.send(:call)
75
75
  rescue UncaughtThrowError => uncaught_throw_error
76
- fail_value = uncaught_throw_error.value.last
76
+ fail_value = uncaught_throw_error.value.value
77
77
  error = VerbalizeError.new("Unhandled fail! called with: #{fail_value.inspect}.")
78
78
  error.set_backtrace(uncaught_throw_error.backtrace[2..-1])
79
79
  raise error
@@ -12,7 +12,7 @@ module Verbalize
12
12
  <<-BODY.chomp
13
13
  new(#{initialize_keywords_and_values}).send(:#{method_name})
14
14
  rescue UncaughtThrowError => uncaught_throw_error
15
- error = VerbalizeError.new("Unhandled fail! called with: \#{uncaught_throw_error.value.last.inspect}.")
15
+ error = VerbalizeError.new("Unhandled fail! called with: \#{uncaught_throw_error.value.value.inspect}.")
16
16
  error.set_backtrace(uncaught_throw_error.backtrace[2..-1])
17
17
  raise error
18
18
  BODY
@@ -1,23 +1,24 @@
1
1
  module Verbalize
2
- class Result < Array
2
+ class Result
3
3
  def initialize(outcome:, value:)
4
- super([outcome, value])
4
+ @outcome = outcome
5
+ @value = value
5
6
  end
6
7
 
8
+ attr_reader :outcome, :value
9
+
7
10
  def succeeded?
8
11
  !failed?
9
12
  end
13
+ alias_method :success?, :succeeded?
10
14
 
11
15
  def failed?
12
16
  outcome == :error
13
17
  end
18
+ alias_method :failure?, :failed?
14
19
 
15
- def outcome
16
- first
17
- end
18
-
19
- def value
20
- last
20
+ def to_ary
21
+ [outcome, value]
21
22
  end
22
23
  end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module Verbalize
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verbalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler