zvv-cli 0.1.1 → 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
- SHA1:
3
- metadata.gz: 777c903a2c90173b69cd59862ca8c003b71444c5
4
- data.tar.gz: 00ede3ddf90dc5cdde3e534dd9a6c7229a78d8d0
2
+ SHA256:
3
+ metadata.gz: 8beaff8e2a23d5324dbbc699caecec6952d9add84a0fba9ad7f646d092f53f82
4
+ data.tar.gz: b904773ebd70ec0db4aea799b2faeab3f0fe4d726e9e8619bc51d13238e737ee
5
5
  SHA512:
6
- metadata.gz: f719422c9297a4c32f9f2d55f42f83dacf7ec4429bc0d207507b9bde89f6f01308f27c4f14f158833fb8ebf5062a2d726e63900bd3035a091ba576aaffb201e5
7
- data.tar.gz: 718013646b054953415be891f577714010fec8515682e78af74bc30dd6e9df092af4feec248ca4886f98a623ec2dbf8aa549477b11bc133dafef40d3a94dc8dd
6
+ metadata.gz: 40f2955c405bd8dcf0c392fd57768ac3dcdb9d48b7285dfad38a4818dd3b59d2efc9c2b311f00d6dedfcb62d32b8f47d5e75aa5308105fb7ad1056d01b732190
7
+ data.tar.gz: 75f2feb32a96f75d0f27bf7eda25c05fe38f29fa4f9603a294c16c900d226d7c3cfffcb2f14ea23d1c607c75a186b15288ebc6c7db863dca0e249814d8fd4a4f
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  .idea
2
2
  .ruby-version
3
3
  Gemfile.lock
4
- .byebug_history
4
+ .byebug_history
5
+ pkg
6
+ .DS_Store
data/Gemfile CHANGED
@@ -1,10 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in zvv-cli.gemspec
4
- gemspec group: :development
5
-
6
- group :runtime do
7
- gem 'commander'
8
- gem 'transprt'
9
- gem 'colorize'
10
- end
3
+ gemspec
data/exe/zvv CHANGED
@@ -5,6 +5,7 @@ require 'rubygems'
5
5
  require 'commander'
6
6
  require 'transprt'
7
7
  require 'colorize'
8
+ require 'debug'
8
9
 
9
10
  require 'zvv/cli'
10
11
  require 'ostruct'
@@ -15,16 +16,6 @@ module Patches
15
16
  def strftime
16
17
  DateTime.iso8601(self).strftime('%H:%M')
17
18
  end
18
-
19
- def subzh
20
- gsub('Zürich', 'Zh').
21
- gsub('Bahnhof', 'Bhf')
22
- end
23
-
24
- def subcon
25
- tokens = split(' ')
26
- tokens[0][-1] + ' ' + tokens[1]
27
- end
28
19
  end
29
20
 
30
21
  refine Hash do
@@ -63,7 +54,7 @@ class App
63
54
  c.action do |args, options|
64
55
  time = args[2] || Time.now.to_s
65
56
 
66
- isArrivalTime = time.start_with?('@') || time.end_with?('@') ? 1 : 0
57
+ isArrivalTime = time.start_with?('@') || time.end_with?('@') ? '1' : '0'
67
58
  time = time.gsub('@', '')
68
59
 
69
60
  time += ':00' unless time.include? ':'
@@ -71,7 +62,7 @@ class App
71
62
  time += 24 * 60 ** 2 if time < Time.now # Look up tomorrow's connections
72
63
 
73
64
 
74
- connections = Transprt.connections(
65
+ connections = Transprt::Client.new.connections(
75
66
  from: args[0],
76
67
  to: args[1],
77
68
  date: time.strftime('%Y-%m-%d'),
@@ -79,13 +70,16 @@ class App
79
70
  isArrivalTime: isArrivalTime
80
71
  )
81
72
 
73
+ # pp connections[0]
74
+
82
75
  connections.to_ostruct.each_with_index do |c, i|
83
- puts ("%s %s ---> %s %s" % [c.from.station.name, c.from.departure.strftime, c.to.station.name, c.to.arrival.strftime]).subzh
76
+ duration_sec = (DateTime.iso8601(c.to.arrival).to_time - DateTime.iso8601(c.from.departure).to_time).to_int
77
+ puts ("%-20s %5s %2d:%02d %-20s %5s" % [c.from.station.name, c.from.departure.strftime, duration_sec / 60 ** 2, (duration_sec % 60 ** 2) / 60, c.to.station.name, c.to.arrival.strftime])
84
78
  c.sections.each do |s|
85
79
  if s.walk
86
- puts ("Walk (%s) to %s" % [s.walk.duration, s.departure.station.name]).subzh.light_black
80
+ puts ("Walk (%sm) to %s" % [s.walk.duration, s.departure.station.name]).light_black
87
81
  else
88
- puts ("%s %s -- %s --> %s %s" % [s.departure.station.name, s.departure.departure.strftime, s.journey.name.subcon, s.arrival.station.name, s.arrival.arrival.strftime]).subzh.light_black
82
+ puts ("%-20s %5s %2s%-3s %-20s %5s" % [s.departure.station.name, s.departure.departure.strftime, s.journey.category, s.journey.number[0..2], s.arrival.station.name, s.arrival.arrival.strftime]).light_black
89
83
  end
90
84
  end
91
85
  puts unless i == connections.length - 1
@@ -1,5 +1,5 @@
1
1
  module Zvv
2
2
  module Cli
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
data/lib/zvv/cli.rb CHANGED
@@ -4,9 +4,3 @@ if ENV['ZVV_DEBUG']
4
4
  require 'byebug'
5
5
  require 'pry-byebug'
6
6
  end
7
-
8
- module Zvv
9
- module Cli
10
- # Your code goes here...
11
- end
12
- end
data/zvv-cli.gemspec CHANGED
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  # TODO fork & update
30
30
  spec.add_dependency "commander"
31
- spec.add_dependency "transprt"
31
+ spec.add_dependency "transprt", "~> 0.2.2"
32
32
  spec.add_dependency "colorize"
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zvv-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PJK
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-31 00:00:00.000000000 Z
11
+ date: 2023-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: transprt
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 0.2.2
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 0.2.2
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: colorize
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -160,7 +160,7 @@ homepage: https://github.com/PJK/zvv-cli
160
160
  licenses:
161
161
  - MIT
162
162
  metadata: {}
163
- post_install_message:
163
+ post_install_message:
164
164
  rdoc_options: []
165
165
  require_paths:
166
166
  - lib
@@ -175,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
- rubyforge_project:
179
- rubygems_version: 2.5.1
180
- signing_key:
178
+ rubygems_version: 3.4.10
179
+ signing_key:
181
180
  specification_version: 4
182
181
  summary: CLI for Swiss public transport network
183
182
  test_files: []