numerousapp 1.2.6 → 1.2.7

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/numerousapp.rb +30 -16
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dae231f126ef9c4f0a71673a575a27321fa5223
4
- data.tar.gz: 4eab62238a84dc5994552b80bd88177f2a464a92
3
+ metadata.gz: d84cedd80341e019f0e486dd57c265ef46df5379
4
+ data.tar.gz: c362a7d857fdc212c4e3f6b23dee841ce6d170ec
5
5
  SHA512:
6
- metadata.gz: d2c669133e594e0af1dbf72f786ec58b7d10b6f58c0155a619837ccbe4538e15fdb5365f230f4c9a174e484e3a9d94de13cf0c1b5978c1b0f20b946d1e4490cc
7
- data.tar.gz: 651b29f1f3ba7423174149329a421c035ce6b26012d48499e51bd92a3803ef8f9953c2f3a045b5ed459d22c6cfbd7f3eeb847639cb2ec124ffa743e98a08a2d8
6
+ metadata.gz: 867a746bce44f34bea1b7b451ed93d07c0bbe3d1aa1a11d076dba317f32d81b85bec44947b5c00b5e3b37cf078288668e04fbde5ad968e8a600f416a1277b00e
7
+ data.tar.gz: a5ef9a2db1b91f00290400fe6efe114705792ed7f0726c8be1e75a027f7fb584e3b747d44a2008f88b9d3a5a6949af9eba42fa23ca43a39faba5f00de299d295
@@ -121,7 +121,7 @@ class NumerousClientInternals
121
121
  # @return [String] FQDN of the target NumerousApp server.
122
122
  #
123
123
  # @!attribute [r] debugLevel
124
- # @return [Fixnum] Current debugging level; use debug() method to change.
124
+ # @return [Fixnum] Current debugging level; change via debug() method
125
125
  #
126
126
  def initialize(apiKey=nil, server:'api.numerousapp.com',
127
127
  throttle:nil, throttleData:nil)
@@ -142,11 +142,12 @@ class NumerousClientInternals
142
142
  @filterDuplicates = true # see discussion elsewhere
143
143
  @need_restart = true # port will be opened in simpleAPI
144
144
 
145
- # throttling.
146
- # The arbitraryMaximum is just that: under no circumstances will we retry
145
+ # Throttling:
146
+ #
147
+ # arbitraryMaximum is just that: under no circumstances will we retry
147
148
  # any particular request more than that. Tough noogies.
148
149
  #
149
- # the throttlePolicy "tuple" is:
150
+ # throttlePolicy "tuple" is:
150
151
  # [ 0 ] - Proc
151
152
  # [ 1 ] - specific data for Proc
152
153
  # [ 2 ] - "up" tuple for chained policy
@@ -157,7 +158,8 @@ class NumerousClientInternals
157
158
  #
158
159
  @arbitraryMaximumTries = 10
159
160
  voluntary = { voluntary: 40, volmaxdelay: 5}
160
- # you can keep the dflt throttle but just alter the voluntary param, this way:
161
+ # you can keep the dflt throttle but just alter the voluntary
162
+ # parameters, this way:
161
163
  if throttleData and not throttle
162
164
  voluntary = voluntary.merge(throttleData)
163
165
  end
@@ -166,7 +168,7 @@ class NumerousClientInternals
166
168
  @throttlePolicy = [throttle, throttleData, @throttlePolicy]
167
169
  end
168
170
 
169
- @statistics = Hash.new { |h, k| h[k] = 0 } # statistics are "infotainment"
171
+ @statistics = Hash.new { |h, k| h[k] = 0 } # stats are "infotainment"
170
172
  @debugLevel = 0
171
173
 
172
174
  end
@@ -179,7 +181,7 @@ class NumerousClientInternals
179
181
  #
180
182
  # @return [String] Human-appropriate string representation.
181
183
  def to_s()
182
- oid = (2 * self.object_id).to_s(16) # XXX "2*" makes it match native to_s
184
+ oid = (2 * self.object_id).to_s(16) # XXX "2*" matches native to_s
183
185
  return "<Numerous {#{@serverName}} @ 0x#{oid}>"
184
186
  end
185
187
 
@@ -223,7 +225,7 @@ class NumerousClientInternals
223
225
 
224
226
  protected
225
227
 
226
- VersionString = '20150811-1.2.6'
228
+ VersionString = '20150904-1.2.7'
227
229
 
228
230
  MethMap = {
229
231
  GET: Net::HTTP::Get,
@@ -242,7 +244,7 @@ class NumerousClientInternals
242
244
  rslt = {}
243
245
  rslt[:httpMethod] = whichOp
244
246
 
245
- # Build the substitutions from the defaults (if any) and non-nil kwargs.
247
+ # Build the substitutions from defaults (if any) and non-nil kwargs.
246
248
  # Note: we are carefully making copies of the underlying dictionaries
247
249
  # so you get your own private context returned to you
248
250
  substitutions = (info[:defaults]||{}).clone
@@ -605,7 +607,6 @@ class NumerousClientInternals
605
607
  #
606
608
  # The policy this implements:
607
609
  # * if "getting close" to the limit, arbitrarily delay ourselves.
608
- # See ComputeVoluntaryDelay above for details on that policy
609
610
  #
610
611
  # * if we truly got spanked with "Too Many Requests"
611
612
  # then delay the amount of time the server told us to delay.
@@ -1660,10 +1661,13 @@ class NumerousMetric < NumerousClientInternals
1660
1661
  #
1661
1662
  # @param [Fixnum|Float] newval Required. Value to be written.
1662
1663
  #
1663
- # @param [Boolean] onlyIf
1664
- # Optional (keyword arg). Only creates an event at the server
1665
- # if the newval is different from the current value. Raises
1666
- # NumerousMetricConflictError if there is no change in value.
1664
+ # @param [Boolean|String] onlyIf
1665
+ # Optional (keyword arg). Default is false.
1666
+ # If this is true or the string 'IGNORE' then the server only creates
1667
+ # a metric event if the newval is different from the current value.
1668
+ # If onlyIf=true then this RaisesNumerousMetricConflictError if there
1669
+ # is no change in value. If onlyIf is 'IGNORE' then the "conflict" error
1670
+ # is silently ignored (probably the more common usage case).
1667
1671
  #
1668
1672
  # @param [Boolean] add
1669
1673
  # Optional (keyword arg). Sends the "action: ADD" attribute which
@@ -1691,7 +1695,11 @@ class NumerousMetric < NumerousClientInternals
1691
1695
  #
1692
1696
  def write(newval, onlyIf:false, add:false, dictionary:false, updated:nil)
1693
1697
  j = { 'value' => newval }
1694
- if onlyIf
1698
+ if onlyIf != false
1699
+ if not [ true, 'IGNORE' ].include? onlyIf
1700
+ # onlyIf must be false, true, or "IGNORE"
1701
+ raise ArgumentError, 'onlyIf must be false, true, or "IGNORE"'
1702
+ end
1695
1703
  j['onlyIfChanged'] = true
1696
1704
  end
1697
1705
  if add
@@ -1722,8 +1730,14 @@ class NumerousMetric < NumerousClientInternals
1722
1730
  rescue NumerousError => e
1723
1731
  # if onlyIf was specified and the error is "conflict"
1724
1732
  # (meaning: no change), raise ConflictError specifically
1733
+ # or ignore it if you specified onlyIf="IGNORE"
1725
1734
  if onlyIf and e.code == 409
1726
- raise NumerousMetricConflictError.new("No Change", e.details)
1735
+ if onlyIf != 'IGNORE'
1736
+ raise NumerousMetricConflictError.new("No Change", e.details)
1737
+ else
1738
+ # forge a pseudo-result because you asked for it
1739
+ v = { 'value'=>newval, 'unchanged'=>true }
1740
+ end
1727
1741
  else
1728
1742
  raise e # never mind, plain NumerousError is fine
1729
1743
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numerousapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Webber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-11 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Classes implementing the NumerousApp REST APIs for metrics. Requires
14
14
  Ruby 2.x