konbikol 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/konbikol/ticket.rb +17 -6
- data/lib/konbikol/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17cccb076cc787892f8df8c875b185157f1b8a31e6c0987f824a61c2f1fd2697
|
4
|
+
data.tar.gz: 7b6158a9a144621adbd1366ee9d66f2355610493b4ac32e3d4a9db1df30d6857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96cd820e81c2935cbfa98765398ae05a92b7b8db75344c390908fb364ed1574651fd23c881e79e6a614d12808494bd77e5003c7819a884d65b852df51859da48
|
7
|
+
data.tar.gz: 26a41d9cb65744e6fd67b7fd00f0dffebf5c9d4400cb5ed6b13314a8ceea92f64fd670a0aa81207fbc99b08606b66e8bad03728f171664a94728b9d2d8805e7f
|
data/Gemfile.lock
CHANGED
data/lib/konbikol/ticket.rb
CHANGED
@@ -113,8 +113,12 @@ module Konbikol
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def purchase_time
|
116
|
+
return @purchase_time if @purchase_time
|
117
|
+
|
118
|
+
line = find_next_non_empty_line_below_line_matching_regex(/Zapłacono i wystawiono dnia/)
|
119
|
+
|
116
120
|
@purchase_time ||= Time.parse(
|
117
|
-
|
121
|
+
line.split(/\s{2,}/).last.match(/(.+)\(.+/)[1]
|
118
122
|
)
|
119
123
|
end
|
120
124
|
|
@@ -167,16 +171,23 @@ module Konbikol
|
|
167
171
|
end
|
168
172
|
|
169
173
|
def departure_line_index
|
170
|
-
|
174
|
+
@departure_line_index ||= find_index_of_next_non_empty_line_below_line_matching_regex(/Stacja\s+Data\s+Godzina/)
|
175
|
+
end
|
171
176
|
|
177
|
+
def find_index_of_next_non_empty_line_below_line_matching_regex(regex)
|
172
178
|
lines_with_index = ticket_text.lines.each_with_index
|
173
|
-
|
179
|
+
index_of_line_matching_regex = lines_with_index.find { |line, _| line =~ regex }.last
|
174
180
|
|
175
|
-
# Find the next line after the
|
176
|
-
|
177
|
-
.slice(
|
181
|
+
# Find the next line after the matching line that's not empty.
|
182
|
+
lines_with_index.to_a
|
183
|
+
.slice(index_of_line_matching_regex + 1, lines_with_index.size)
|
178
184
|
.find { |line, _| !line.strip.empty? }
|
179
185
|
.last
|
180
186
|
end
|
187
|
+
|
188
|
+
def find_next_non_empty_line_below_line_matching_regex(regex)
|
189
|
+
index = find_index_of_next_non_empty_line_below_line_matching_regex(regex)
|
190
|
+
ticket_text.lines[index]
|
191
|
+
end
|
181
192
|
end
|
182
193
|
end
|
data/lib/konbikol/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konbikol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Cieślak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|