wattics-api-client 0.1.2 → 0.1.3
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 +4 -4
- data/lib/wattics-api-client/config.rb +3 -0
- data/lib/wattics-api-client/processor.rb +19 -3
- data/lib/wattics-api-client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05dc9ac9ee69309e01450065e7d1fed92be3315a
|
4
|
+
data.tar.gz: 309da9bac68f9c17af7c54fbce1b1acfc5822664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f81b1e36c485bdb274c9e60a878a713283e17336bf04ac07f43ef01788f800837d54ec30cd056f0fe797e39b21896bac91b860d0303ac93ac7217fea8fffe89
|
7
|
+
data.tar.gz: f6a8e7a883ea1b630375f4096b86b1aa1c6f83d0c446efd68513b220a15c00653a8692e59ac32b780100500204ead78288d633d08483ce4c7222cef23ddd36f1
|
@@ -2,6 +2,7 @@ class Config
|
|
2
2
|
attr_reader :environment, :uri, :username, :password
|
3
3
|
PRODUCTION = 'https://web-collector.wattics.com/measurements/v2/unifiedjson/'.freeze
|
4
4
|
DEVELOPMENT = 'https://dev-web-collector.wattics.com/measurements/v2/unifiedjson/'.freeze
|
5
|
+
TEST = 'http://localhost:8080/measurements/v2/unifiedjson/'.freeze
|
5
6
|
def initialize(environment, username, password)
|
6
7
|
@environment = environment
|
7
8
|
@uri = environment(environment)
|
@@ -14,6 +15,8 @@ class Config
|
|
14
15
|
PRODUCTION
|
15
16
|
elsif environment == :DEVELOPMENT
|
16
17
|
DEVELOPMENT
|
18
|
+
elsif environment == :TEST
|
19
|
+
TEST
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
@@ -44,11 +44,22 @@ class Processor
|
|
44
44
|
@agent.report_sent_measurement(@measurement, @response)
|
45
45
|
end
|
46
46
|
if !@agent.nil? && @response.code >= 400
|
47
|
-
|
47
|
+
if defined?(Rails).nil?
|
48
|
+
@logger.error("Could not send #{@measurement}, Server Response: #{Nokogiri::HTML(@response.body).xpath('//h1').text}")
|
49
|
+
else
|
50
|
+
Rails.logger.error("Could not send #{@measurement}, Server Response: #{Nokogiri::HTML(@response.body).xpath('//h1').text}")
|
51
|
+
print "Could not send #{@measurement}, Server Response: #{Nokogiri::HTML(@response.body).xpath('//h1').text}")
|
52
|
+
end
|
48
53
|
end
|
49
54
|
break
|
50
55
|
rescue StandardError => e
|
51
|
-
|
56
|
+
|
57
|
+
if defined?(Rails).nil?
|
58
|
+
@logger.error("Could not send #{@measurement}, Error: #{e}")
|
59
|
+
else
|
60
|
+
Rails.logger.error("Could not send #{@measurement}, Error: #{e}")
|
61
|
+
print "Could not send #{@measurement}, Error: #{e}"
|
62
|
+
end
|
52
63
|
sleep 60
|
53
64
|
end
|
54
65
|
end
|
@@ -57,6 +68,11 @@ class Processor
|
|
57
68
|
end
|
58
69
|
end
|
59
70
|
rescue StandardError => e
|
60
|
-
|
71
|
+
if defined?(Rails).nil?
|
72
|
+
@logger.error("Thread stopped unexpectedly: #{e.message}")
|
73
|
+
else
|
74
|
+
Rails.logger.error("Thread stopped unexpectedly: #{e.message}")
|
75
|
+
puts "Thread stopped unexpectedly: #{e.message}"
|
76
|
+
end
|
61
77
|
end
|
62
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wattics-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wattics
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.6.
|
177
|
+
rubygems_version: 2.6.11
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: This gem connects with Wattics API
|