btw 0.2.1 → 0.3.0
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/bin/btw +26 -4
- 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: cb4aa9dd4187976cee0abce68a01b213a68a51d7
|
4
|
+
data.tar.gz: 15c3b7350b17f363250e63cca17c3fc047714a81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66ca3a1b4da2241bf10e9cf25f6843e7adc31399f73f68759193fbd76688fdf753f8629439a7c490661a0d960c3ab67f9598c3e29cf7f6d9bcd02d8ea160a3c7
|
7
|
+
data.tar.gz: ff6ad98d23fd4f3565947e209dd4936293e2c6135066066e384fb2a92f9d9ca7735d7fe9de5cddaadab1a39ac1ae79aef8b0a3d152d472b2970392fb967b2e40
|
data/bin/btw
CHANGED
@@ -44,19 +44,41 @@ if m = /\/(?<timestamp>.+)\//.match(input) and t = Chronic.parse(m[1])
|
|
44
44
|
end
|
45
45
|
|
46
46
|
unless timestamp
|
47
|
+
timestamps = []
|
47
48
|
words = input.split(" ")
|
48
49
|
i = 0
|
49
50
|
while i < words.size do
|
50
51
|
puts words[0..i].join(" ") if config[:debug]
|
51
52
|
t = Chronic.parse(words[0..i].join(" "), :endian_precedence => [:little, :middle])
|
52
53
|
puts "timestamp '#{timestamp}' found '#{t}'" if config[:debug]
|
53
|
-
if timestamp and t.nil?
|
54
|
-
break
|
55
|
-
elsif t
|
56
|
-
|
54
|
+
#if timestamp and t.nil?
|
55
|
+
#break
|
56
|
+
#elsif t
|
57
|
+
if t
|
58
|
+
timestamps << t
|
57
59
|
end
|
58
60
|
i += 1
|
59
61
|
end
|
62
|
+
i = 1
|
63
|
+
while i < words.size do
|
64
|
+
puts words[i..words.size].join(" ") if config[:debug]
|
65
|
+
t = Chronic.parse(words[i..words.size].join(" "), :endian_precedence => [:little, :middle])
|
66
|
+
puts "timestamp '#{timestamp}' found '#{t}'" if config[:debug]
|
67
|
+
if t
|
68
|
+
timestamps << t
|
69
|
+
end
|
70
|
+
i += 1
|
71
|
+
end
|
72
|
+
|
73
|
+
frequencies = timestamps.group_by {|e| e }.inject({}){ |h,(k,v)| h[k] = v.size; h }
|
74
|
+
max = frequencies.values.max
|
75
|
+
if frequencies.values.count(max) == 1
|
76
|
+
# use the most frequent
|
77
|
+
timestamp = frequencies.select{|k,v| v == max}.keys.first
|
78
|
+
else
|
79
|
+
# use the first value
|
80
|
+
timestamp = timestamps.first
|
81
|
+
end
|
60
82
|
end
|
61
83
|
|
62
84
|
unless timestamp
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: btw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fraser Scott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|