logstash-input-cloudflare_logs 0.1.2 → 0.1.3

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: 45cafa94e6ebef8b8bcf271e1c90ea4787f8e0de
4
- data.tar.gz: fb4aee6541e2ec1dc765240e48296e2009dff145
3
+ metadata.gz: 1a7139959102c50bbe70f6f32d2dcb94efc2e96b
4
+ data.tar.gz: 587e5c2f61b9292e99ed759bc31b0e59e492a245
5
5
  SHA512:
6
- metadata.gz: 0aa3b45c5560b8681ce038a68c922ea959eb8c25a8e1bd78d37cfe16e961e2c02a9d070797a7da3b15670145fe20d1f11c6d9d8d391376cd676254df182c2c74
7
- data.tar.gz: 793805bc645093a9fb92d734942cacfc02b829b772eb890ec99ab25b3936ddfda466a9addb027906aab42e483a88fb86faa3622d82189a7e9128ed66a5e00f5d
6
+ metadata.gz: f9a53497bf46c9536423aa72447daa280cffd7228f03afed4adaf78f94b067bc5c412f087846efc51391071b7ebf06b0fa1a4112070bea2c3a349c3fa87a8d2c
7
+ data.tar.gz: 531685c8afc186276dbd889705ceb2f489448a76bd39baa41ad02d870c8d912410312a93ab03463136dcc81c6fbdab9da9c08318a5186075357af25223eb6fe6
@@ -21,7 +21,11 @@ class CloudflareAccess
21
21
 
22
22
  def start_time
23
23
  if File.exist?(metadata_file)
24
- start_time = Time.parse(JSON.parse(File.read(metadata_file))['start_time']).to_datetime.rfc3339
24
+ begin
25
+ start_time = Time.parse(JSON.parse(File.read(metadata_file))['start_time']).to_datetime.rfc3339
26
+ rescue JSON::ParserError
27
+ start_time = (Time.now - (15 * 60)).to_datetime.rfc3339
28
+ end
25
29
  else
26
30
  start_time = (Time.now - (15 * 60)).to_datetime.rfc3339
27
31
  end
@@ -39,7 +43,7 @@ class CloudflareAccess
39
43
  if File.exist?(metadata_file)
40
44
  begin
41
45
  meta_data = JSON.parse(File.read(metadata_file))
42
- rescue
46
+ rescue JSON::ParserError
43
47
  end
44
48
  end
45
49
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-cloudflare_logs'
3
- s.version = '0.1.2'
3
+ s.version = '0.1.3'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = 'write cloudflare logs to logstash'
6
6
  s.description = 'Write cloudflare lgos to logstash.' \
@@ -21,6 +21,15 @@ describe CloudflareAccess do
21
21
  end
22
22
  end
23
23
 
24
+ it 'should return the default time meta file is there but is empty' do
25
+ `rm #{meta_filename}`
26
+ `touch #{meta_filename}`
27
+
28
+ Timecop.freeze do
29
+ expect(subject).to eq((Time.now - (15 * 60)).to_datetime.rfc3339)
30
+ end
31
+ end
32
+
24
33
  it 'should return the start time in the file if it is correct' do
25
34
  Timecop.freeze do
26
35
  File.open(meta_filename, 'w+') { |file| file.write({ start_time: Time.now - (24 * 60 * 60) }.to_json) }
@@ -1 +1 @@
1
- {"start_time":"2017-10-18 13:35:32 -0400"}
1
+ {"start_time":"2017-10-19 14:21:06 -0400"}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-cloudflare_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Moore