numerousapp 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/numerousapp.rb +26 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7018d2d603b7836ff5ce90f71f2cdf324ffb60d9
4
- data.tar.gz: 4d7b0bd9d9e9d3307b0e68546dfced0e193ff457
3
+ metadata.gz: 2cb812bb5dd0b6ff8eff69717086072183b6f403
4
+ data.tar.gz: f597ff55c83c748b333c715552540ae42d4c04e0
5
5
  SHA512:
6
- metadata.gz: cb2e36d7ad7e315684c349c757097e1e1094e403535186abb76b874cb7ec804b92b58d7652c837d41cacc89138117bacdf77fafc509f98dff126f3c6a5134681
7
- data.tar.gz: 92a86c605f1357060f10a5fc1f0f6b1ddc846b281ab9c61cfd365f5df11a715d61eb25ddf3c5f2b39bc11badb62191eb915b80c6dbc08b340c0e645d54cd50f5
6
+ metadata.gz: 62356ae9378340d0e2b3d82c617804a6bda4c5ed538da960202ce49d38acd349c9d4e8c201e6666cd2e638cbd5ccddc5317285d857192d40efd848dcecd43f3f
7
+ data.tar.gz: 4162109867626e763f8a70cb6e8176ffe504904f186c90c1f416c0f4a8332545a5e55f8568b91b480cc4ff5c54609a939008a306ef96e58d26cd5cf24d4d7f31
data/lib/numerousapp.rb CHANGED
@@ -131,16 +131,16 @@ class NumerousClientInternals
131
131
  apiKey = Numerous.numerousKey()
132
132
  end
133
133
 
134
- @serverName = server
135
134
  @auth = { user: apiKey, password: "" }
136
135
  u = URI.parse("https://"+server)
137
- @http = Net::HTTP.new(server, u.port)
138
- @http.use_ssl = true # always required by NumerousApp
136
+ @serverName = server
137
+ @serverPort = u.port
139
138
 
140
139
  @agentString = "NW-Ruby-NumerousClass/" + VersionString +
141
140
  " (Ruby #{RUBY_VERSION}) NumerousAPI/v2"
142
141
 
143
142
  @filterDuplicates = true # see discussion elsewhere
143
+ @need_restart = true # port will be opened in simpleAPI
144
144
 
145
145
  # throttling.
146
146
  # The arbitraryMaximum is just that: under no circumstances will we retry
@@ -212,7 +212,7 @@ class NumerousClientInternals
212
212
 
213
213
  protected
214
214
 
215
- VersionString = '20150415-1.2.0'
215
+ VersionString = '20150617-1.2.1'
216
216
 
217
217
  MethMap = {
218
218
  GET: Net::HTTP::Get,
@@ -373,7 +373,29 @@ class NumerousClientInternals
373
373
  @statistics[:serverRequests] += 1
374
374
  t0 = Time.now
375
375
  begin
376
+
377
+ # see note immediately below re "need_restart"
378
+ # this is where the very FIRST start() happens but
379
+ # also where subsequent starts might be re-done after errors
380
+
381
+ if @need_restart or not @http.started?()
382
+
383
+ # starting a session turns on keep-alive...
384
+ @http = Net::HTTP.new(@serverName, @serverPort)
385
+ @http.use_ssl = true # always required by NumerousApp
386
+ @http = @http.start()
387
+ end
388
+
389
+ # A note on this need_restart true/false dance:
390
+ # I have to admit I'm not sure if this is necessary or if
391
+ # it is even a good/bad/irrelevant idea, but the concept
392
+ # here is that if an error is encountered we'll ditch
393
+ # the current start() session and make a new one next time
394
+
395
+ @need_restart = true # will redo session if raise out
376
396
  resp = @http.request(rq)
397
+ @need_restart = false
398
+
377
399
  rescue StandardError => e
378
400
  # it's PDB (pretty bogus) that we have to rescue
379
401
  # StandardError but the underlying http library can just throw
@@ -1332,7 +1354,6 @@ class NumerousMetric < NumerousClientInternals
1332
1354
  val = self['value']
1333
1355
  rslt += "'#{self['label']}' [#@id] = #{val}>"
1334
1356
  rescue NumerousError => x
1335
- puts(x.code)
1336
1357
  if x.code == 400
1337
1358
  rslt += "**INVALID-ID** '#@id'>"
1338
1359
  elsif x.code == 404
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.0
4
+ version: 1.2.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-04-15 00:00:00.000000000 Z
11
+ date: 2015-06-17 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