konbikol 0.1.0 → 0.1.1
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/Gemfile.lock +2 -2
- data/README.md +22 -19
- data/lib/konbikol/ticket.rb +51 -15
- 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: 8a97ce970519977318814eb7f2534781025a41959d3c3d40fda185a1117344b5
|
4
|
+
data.tar.gz: 81a9d5f0b0da7ad398038a44b005b84e100a56c8ace60050c28925689f78906f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f79b29563d9b82c8038f21cf8105e242bb9a9bc7885834a1f228a50dc16814f9c8b6879e95a8fd706f868b3d2af3e8bc613d5cfb34bccf07cba13ae484d8a20
|
7
|
+
data.tar.gz: cdcee30ed86946f2f7bb04bde087587f0f3aa6854e70a1d5fecd004611ecb7c42b7b9477c576ae94e1f23b2856e5a509e7192e2a6a29fcc037cd65d94419db77
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,42 @@
|
|
1
1
|
# Konbikol
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Converts PKP Intercity PDF train tickets to iCalendar events.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'konbikol'
|
7
|
+
```
|
8
|
+
gem install konbikol
|
13
9
|
```
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
11
|
+
## Usage
|
20
12
|
|
21
|
-
|
13
|
+
```
|
14
|
+
konbikol file.pdf
|
15
|
+
```
|
22
16
|
|
23
|
-
|
17
|
+
This will try to open file.pdf, convert it to a ticket, then save it to a temporary directory and
|
18
|
+
then attempt to open that file (given that there's `open` command in your path).
|
24
19
|
|
25
|
-
|
20
|
+
By default on macOS, this will result in Calendar asking you about what calendar you want to add the
|
21
|
+
event to. Well, at least that's what happens for me since I have more than one calendar.
|
26
22
|
|
27
23
|
## Development
|
28
24
|
|
29
|
-
After checking out the repo, run `
|
25
|
+
After checking out the repo, run `bundle` to install dependencies. Then, run `rake test` to run the
|
26
|
+
tests.
|
30
27
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new
|
28
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new
|
29
|
+
version, update the version number in `version.rb`, and then run `bundle exec rake release`, which
|
30
|
+
will create a git tag for the version, push git commits and tags, and push the `.gem` file to
|
31
|
+
[rubygems.org](https://rubygems.org).
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/ravicious/konbikol. This
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ravicious/konbikol. This
|
36
|
+
project is intended to be a safe, welcoming space for collaboration, and contributors are expected
|
37
|
+
to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
38
|
|
37
39
|
## Code of Conduct
|
38
40
|
|
39
|
-
Everyone interacting in the Konbikol project’s codebases, issue trackers, chat rooms and mailing
|
41
|
+
Everyone interacting in the Konbikol project’s codebases, issue trackers, chat rooms and mailing
|
42
|
+
lists is expected to follow the [code of conduct](https://github.com/ravicious/konbikol/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/konbikol/ticket.rb
CHANGED
@@ -50,12 +50,12 @@ module Konbikol
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def departure_time
|
53
|
-
|
53
|
+
departure.fetch(:time)
|
54
54
|
end
|
55
55
|
|
56
56
|
# The format is `dd.mm` E.g. `23.04`.
|
57
57
|
def departure_date
|
58
|
-
|
58
|
+
departure.fetch(:date)
|
59
59
|
end
|
60
60
|
|
61
61
|
def departure_datetime
|
@@ -72,15 +72,15 @@ module Konbikol
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def departure_station
|
75
|
-
|
75
|
+
departure.fetch(:station)
|
76
76
|
end
|
77
77
|
|
78
78
|
def arrival_time
|
79
|
-
|
79
|
+
arrival.fetch(:time)
|
80
80
|
end
|
81
81
|
|
82
82
|
def arrival_date
|
83
|
-
|
83
|
+
arrival.fetch(:date)
|
84
84
|
end
|
85
85
|
|
86
86
|
def arrival_datetime
|
@@ -97,19 +97,19 @@ module Konbikol
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def arrival_station
|
100
|
-
|
100
|
+
arrival.fetch(:station)
|
101
101
|
end
|
102
102
|
|
103
103
|
def carriage
|
104
|
-
|
104
|
+
arrival.fetch(:carriage)
|
105
105
|
end
|
106
106
|
|
107
107
|
def seat
|
108
|
-
|
108
|
+
departure.fetch(:seat)
|
109
109
|
end
|
110
110
|
|
111
111
|
def train
|
112
|
-
|
112
|
+
departure.fetch(:train)
|
113
113
|
end
|
114
114
|
|
115
115
|
def purchase_time
|
@@ -122,12 +122,48 @@ module Konbikol
|
|
122
122
|
|
123
123
|
attr_reader :ticket_text
|
124
124
|
|
125
|
-
def
|
126
|
-
@
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
125
|
+
def departure
|
126
|
+
return @departure if @departure
|
127
|
+
line = ticket_text.lines[departure_line_index].split(/\s{2,}/)
|
128
|
+
|
129
|
+
raw_train = line[3]
|
130
|
+
train = raw_train.split(' ').first(2).join(' ')
|
131
|
+
|
132
|
+
# If everything's fine, the departure line should look somewhat like this:
|
133
|
+
#
|
134
|
+
# Foo 22.12 13:08 TLK 1111 123 25 o 48,00 zł
|
135
|
+
#
|
136
|
+
# But sometimes the train ID is too long and there's just one space between the train column
|
137
|
+
# and the distance column:
|
138
|
+
#
|
139
|
+
# Foo 22.12 13:08 TLK 11111 123 25 o 48,00 zł
|
140
|
+
# ^ here
|
141
|
+
#
|
142
|
+
# This causes troubles for us because we assume that there are at least two spaces between
|
143
|
+
# columns, so we have to accommodate for that.
|
144
|
+
is_there_just_one_space_between_train_and_distance = raw_train.split(' ').size != 2
|
145
|
+
seat = is_there_just_one_space_between_train_and_distance ? line[4] : line[5]
|
146
|
+
|
147
|
+
@departure = {
|
148
|
+
station: line[0],
|
149
|
+
date: line[1],
|
150
|
+
time: line[2],
|
151
|
+
train: train,
|
152
|
+
seat: seat,
|
153
|
+
}
|
154
|
+
end
|
155
|
+
|
156
|
+
def arrival
|
157
|
+
return @arrival if @arrival
|
158
|
+
|
159
|
+
line = ticket_text.lines[departure_line_index + 1].split(/\s{2,}/)
|
160
|
+
|
161
|
+
@arrival = {
|
162
|
+
station: line[0],
|
163
|
+
date: line[1],
|
164
|
+
time: line[2],
|
165
|
+
carriage: line[3],
|
166
|
+
}
|
131
167
|
end
|
132
168
|
|
133
169
|
def departure_line_index
|
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.1
|
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: 2018-
|
11
|
+
date: 2018-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|