subledger 0.7.9 → 0.7.10

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTAzZjM5MjQ0ODEyNDRhYjQyMzY2YTZmMjg2NzM4MjdmNzQxZDg1OQ==
4
+ MDAxZDliYmU3YWE1ZTdmOGM1ZmJjYzk2ZTJmMTQ5ZTdmYzFiYmQxZg==
5
5
  data.tar.gz: !binary |-
6
- MGIxMDA5Mjg5ZDhiZjQ1MjkzZDhkNGQyZGM5OTUyZDgyODY3MjNkNQ==
6
+ YjBmY2ZlMTQyZDNkYjY2MzdkMjY5OTIzYjQ1ZTA0YzBmYzM3N2ZmYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTFkNTIxNTExYTI3MjhiYjM4Mzg5YWQ2ODkwMzgwMDA4OWJhODVhZDE1ZDFh
10
- ZjFmZTUxZjE3Mjc2MmM1NmQ5MjEyMjc0MGVhY2U5OTU4YjJiMDc5NTg5ZDdj
11
- YTYwN2ViYjI0YjAyYzlhMjlkMzRjNjAyY2NlOGQ1MTg0NTI2MTE=
9
+ YWRjZGY2YzYzY2UzZGE5ZjBiYWY2OWRmYjFkYTFlOTUwMDcyNjk3NjVkMjUz
10
+ MDI0MDllZTE5NDM5NTkwNzU2ZWUwZmQ3ZWU3NWI1MGJkZTc1MDk3NTRlNDhj
11
+ NGVjYzljZDZiZjc0NDY2YjZhZGQyYjQyODM2OTAwNmNiZGRhYmI=
12
12
  data.tar.gz: !binary |-
13
- MWNhMjcyYjg1ZDc5YjNlNDE4YjYyNTM5N2E2NGZhNTYzNDBmMGZjMzFkZjIy
14
- OGI3NjdlNTM2MzliODdiYTc0ZGRhZDc5MTNiNjRiMzY4YzRmNGVlNDY3NmZj
15
- MDJhNjFmM2JlN2Y2YmM4ZTUwODEwNTY5NWJkYWZiZDMzZDlkZGU=
13
+ ZmMxOWVjOGRhNTQ4MjBjMGM4NDI0MzIzN2IxYWYzODYxM2M0NGFkM2YxZDZl
14
+ NTllNGZmYTgzNzM4MDU5YTllNDVmNGI5OTk3YTcwMmYwYzQyYjlhMTIxZTJi
15
+ ZjU3ODVlNTQ4ZmUxYWU3MDgxYWIyNDczODhhNDNlOThhMWM0Mzc=
data/lib/subledger.rb CHANGED
@@ -11,6 +11,8 @@ require 'rubygems'
11
11
 
12
12
  require 'multi_json'
13
13
 
14
+ MultiJson.engine = :json_gem
15
+
14
16
  require 'subledger/exception_handler'
15
17
 
16
18
  module Subledger
@@ -75,18 +75,19 @@ module Subledger
75
75
  ERROR_TEXT = 'amount is limited to 15 whole digits and 12 fractional digits'
76
76
 
77
77
  def validate_amount arg_amount
78
-
79
78
  unless arg_amount.match /^\d*[.]?\d*$/
80
79
  raise ValueError, "amount (#{arg_amount}) must be numeric"
81
80
  end
82
81
 
83
82
  return if BigDecimal(arg_amount).zero?
84
83
 
85
- arg_amount.sub! /^0+/, ''
86
- arg_amount.sub! /[.](\d)*0+$/, '.\\1'
84
+ dupped_arg_amount = arg_amount.dup
85
+
86
+ dupped_arg_amount.sub! /^0+/, ''
87
+ dupped_arg_amount.sub! /[.](\d)*0+$/, '.\\1'
87
88
 
88
- if arg_amount.include? '.'
89
- whole, fraction = arg_amount.split '.'
89
+ if dupped_arg_amount.include? '.'
90
+ whole, fraction = dupped_arg_amount.split '.'
90
91
 
91
92
  whole ||= ''
92
93
  fraction ||= ''
@@ -95,7 +96,7 @@ module Subledger
95
96
  raise ValueError, ERROR_TEXT
96
97
  end
97
98
  else
98
- if arg_amount.length > 15
99
+ if dupped_arg_amount.length > 15
99
100
  raise ValueError, ERROR_TEXT
100
101
  end
101
102
  end
@@ -32,7 +32,7 @@ module Subledger
32
32
  begin
33
33
  yield
34
34
  rescue @exception => e
35
- if is_internal?( e ) or ( attempts >= @max_attempts )
35
+ if exception_fails_immediately?(e) or max_attempts?(attempts)
36
36
  raise e, "FAILURE: #{@name}, attempts: #{attempts}, total: #{total}, #{e}"
37
37
  elsif attempts < @max_attempts
38
38
 
@@ -58,8 +58,14 @@ module Subledger
58
58
 
59
59
  private
60
60
 
61
- def is_internal? e
62
- e.class.name.to_s =~ /^Subledger::/
61
+ def max_attempts? attempts
62
+ attempts >= @max_attempts
63
+ end
64
+
65
+ def exception_fails_immediately? e
66
+ name = e.class.name.to_s
67
+
68
+ name =~ /^Subledger::/ or name == /ConditionalCheckFailedException~/
63
69
  end
64
70
  end
65
71
  end
@@ -1,4 +1,4 @@
1
1
  module Subledger
2
- VERSION = '0.7.9'
2
+ VERSION = '0.7.10'
3
3
  API_VERSION = 'v2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subledger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Hale