numerousapp 1.0.0 → 1.0.1

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 +25 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bdd91b07bfb89bd80ad1a1ab27e1ca922b50e43
4
- data.tar.gz: c94f71b9997951d8ad71f906bd1410905ef90f10
3
+ metadata.gz: e3a77c2d75609a18065360ad1de49b131a8ce75e
4
+ data.tar.gz: 476884887a6b37b9cf3c4f9bafc37124e62d996a
5
5
  SHA512:
6
- metadata.gz: 6eef3a14e6f0342a39062943b155e7bca3222747ad4d9f15049f3194ce0c464379da64c81a87b76cdf9196cf77c1282dc337996fa5495e962223bd705503a310
7
- data.tar.gz: 3222957cbdcea1304bad84c199cf2aa3767066eb4b52f048494bc65207018c78f98a9b92a914ba12aa26bdeb352a88c29c8b97dd94e15c1ece41d1b97050df00
6
+ metadata.gz: 83f23c276bbe85ae08b7f39a0b7654c3f3d27b113297e697fc59b0a060b818f1ba5f21f5bd912073bcd78649499db51124bc5944d177657c84b1072e0f34148c
7
+ data.tar.gz: c7f931711ca03bbc166010e95073b95984c211f5d5e25a3ea511dab521ed03d3641a8eb92a6f0eed394d6b1d356ec52a6ddc108a247cc514ed385477d9a93fb2
data/lib/numerousapp.rb CHANGED
@@ -174,7 +174,7 @@ class NumerousClientInternals
174
174
 
175
175
  protected
176
176
 
177
- VersionString = '20150123-1.0.0'
177
+ VersionString = '20150125-1.0.1'
178
178
 
179
179
  MethMap = {
180
180
  GET: Net::HTTP::Get,
@@ -239,6 +239,16 @@ class NumerousClientInternals
239
239
  end
240
240
  private :makeboundary
241
241
 
242
+ # helper function to extract header field integer or return -1
243
+ def getElseM1(d, k)
244
+ if d.key? k
245
+ return d[k].to_i
246
+ else
247
+ return -1
248
+ end
249
+ end
250
+ private :getElseM1
251
+
242
252
 
243
253
  # ALL api exchanges with the Numerous server go through here except
244
254
  # for getRedirect() which is a special case (hack) for photo URLs
@@ -334,8 +344,9 @@ class NumerousClientInternals
334
344
  end
335
345
 
336
346
  # invoke the rate-limiting policy
337
- rateRemain = resp['x-rate-limit-remaining'].to_i
338
- rateReset = resp['x-rate-limit-reset'].to_i
347
+
348
+ rateRemain = getElseM1(resp, 'x-rate-limit-remaining')
349
+ rateReset = getElseM1(resp, 'x-rate-limit-reset')
339
350
  @statistics[:rateRemaining] = rateRemain
340
351
  @statistics[:rateReset] = rateReset
341
352
 
@@ -519,12 +530,12 @@ class NumerousClientInternals
519
530
  #
520
531
  # td is the data you supplied as "throttleData" to the Numerous() constructor
521
532
  # up is a tuple useful for calling the original system throttle policy:
522
- # up[0] is the function pointer
533
+ # up[0] is the Proc
523
534
  # up[1] is the td for *that* function
524
535
  # up[2] is the "up" for calling *that* function
525
536
  # ... so after you do your own thing if you then want to defer to the
526
537
  # built-in throttle policy you can
527
- # return send(up[0], nr, tparams, up[1], up[2])
538
+ # up[0].call(nr, tparams, up[1], up[2])
528
539
  #
529
540
  # It's really (really really) important to understand the return value and
530
541
  # the fact that we are invoked AFTER each request:
@@ -548,6 +559,7 @@ class NumerousClientInternals
548
559
  rateleft = tparams[:rateRemaining]
549
560
  attempt = tparams[:attempt] # note: is zero on very first try
550
561
  stats = tparams[:statistics]
562
+ stats[:throttleDefaultCalls] += 1
551
563
 
552
564
  if attempt > 0
553
565
  stats[:throttleMultipleAttempts] += 1
@@ -832,6 +844,13 @@ class Numerous < NumerousClientInternals
832
844
  raise ArgumentError
833
845
  end
834
846
 
847
+ # if you specified STRING and sent a regexp... or vice versa
848
+ if matchType == 'STRING' and labelspec.instance_of?(Regexp)
849
+ labelspec = labelspec.source
850
+ elsif matchType != 'STRING' and not labelspec.instance_of?(Regexp)
851
+ labelspec = /#{labelspec}/
852
+ end
853
+
835
854
  self.metrics do |m|
836
855
  if matchType == 'STRING' # exact full match required
837
856
  if m['label'] == labelspec
@@ -1027,16 +1046,9 @@ class NumerousMetric < NumerousClientInternals
1027
1046
  @nr = nr
1028
1047
  end
1029
1048
  attr_reader :id
1049
+ attr_reader :nr
1030
1050
 
1031
1051
 
1032
- #
1033
- # Obtain the {Numerous} server object associated with a metric.
1034
- # @return [Numerous]
1035
- #
1036
- def getServer()
1037
- return @nr
1038
- end
1039
-
1040
1052
  APIInfo = {
1041
1053
  # read/update/delete a metric
1042
1054
  metric: {
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.0.0
4
+ version: 1.0.1
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-01-23 00:00:00.000000000 Z
11
+ date: 2015-01-25 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