logstash-input-toggl 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a54e8b13e920b374dde9f8cff6a8b70c2116c0f
4
- data.tar.gz: 71ee9b11ebfb90ec582e2333765efe600b693817
3
+ metadata.gz: bb29322cb2e381ea48dabe689d09bb93bc025073
4
+ data.tar.gz: 68bd97095796d1b2e34e1a915a8116b289cb3752
5
5
  SHA512:
6
- metadata.gz: dc7af47f98e1f277e10c62574f8c6759974f5fc48dab062fe6ab6f014e0097a79d414521e58ac505a4edc97f0717d8ecb3a05a37607dea58b4e67e1245155e93
7
- data.tar.gz: 7636d1689d27ab5363abec29363f89c6e012034ecafcc2551a9a01ae103c05dc8885ac283f5f12fee5149a1d8912707c4a7d00d1bcd36c14bd26e918d33951c9
6
+ metadata.gz: b5016d29cfa2dbe98f5e5ef2eaa2087b73b8e000283e751cd2853dc89e044e10829f76f0f02736633c1ee2307d6c64c0f913bf706501f8be3639db913b14c2c8
7
+ data.tar.gz: 476c02a499feb106c738b18de92fe6d922d8204e2a5c98db0a4192fe08f00903d71a4f9e8c2d709bfed8cfe0a65392a2f5c6ce49aab438bdd4c0910c172f21f9
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/inputs/base"
3
3
  require "logstash/namespace"
4
- require "socket" # for Socket.gethostname
5
4
 
6
5
  # Pull time entries from detailed report Toggl API.
7
6
  #
@@ -46,6 +45,13 @@ class LogStash::Inputs::Toggl < LogStash::Inputs::Base
46
45
 
47
46
  @url = "https://toggl.com/reports/api/v2/details?workspace_id=#{ @workspace_id }&user_agent=#{ @user_agent }&#{ addon }"
48
47
  @logger.info? && @logger.info("Registering Toggl Input", :url => @url, :interval => @interval)
48
+
49
+ @connection = Faraday.new do |builder|
50
+ builder.use Faraday::Request::Retry
51
+ builder.use Faraday::Request::BasicAuthentication, @api_token, 'api_token'
52
+ builder.use Faraday::Response::Logger
53
+ builder.use Faraday::Adapter::NetHttp
54
+ end
49
55
  end # def register
50
56
 
51
57
  public
@@ -54,19 +60,12 @@ class LogStash::Inputs::Toggl < LogStash::Inputs::Base
54
60
  start = Time.now
55
61
  @logger.info? && @logger.info("Polling Toggl", :url => @url, :time => start)
56
62
 
57
- conn = Faraday.new do |builder|
58
- builder.use Faraday::Request::Retry
59
- builder.use Faraday::Request::BasicAuthentication, @api_token, 'api_token'
60
- builder.use Faraday::Response::Logger
61
- builder.use Faraday::Adapter::NetHttp
62
- end
63
-
64
63
  page = 1
65
64
 
66
65
  while true
67
66
  new_url = @url + "&page=#{ page }"
68
67
 
69
- response = conn.get new_url
68
+ response = @connection.get new_url
70
69
  result = JSON.parse(response.body)
71
70
 
72
71
  if result["data"].nil? || result["data"].empty?
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-toggl'
3
- s.version = '0.1.0'
3
+ s.version = '0.1.1'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Pull time entries from a detailed report Toggl API."
6
6
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-toggl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shoutem