numerousapp 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/numerousapp.rb +25 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3a77c2d75609a18065360ad1de49b131a8ce75e
|
4
|
+
data.tar.gz: 476884887a6b37b9cf3c4f9bafc37124e62d996a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = '
|
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
|
-
|
338
|
-
|
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
|
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
|
-
#
|
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.
|
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-
|
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
|