caltrain 0.0.5 → 0.0.6

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.
Files changed (3) hide show
  1. data/lib/caltrain.rb +14 -5
  2. data/spec/caltrain_spec.rb +4 -0
  3. metadata +3 -5
@@ -1,8 +1,17 @@
1
1
  class Caltrain
2
- TIMES_PATH = 'data/google_transit/stop_times.txt'
3
- TRIPS_PATH = 'data/google_transit/trips.txt'
4
-
5
2
  class << self
3
+ def base_dir
4
+ File.expand_path('..', File.dirname(__FILE__))
5
+ end
6
+
7
+ def times_path
8
+ "#{base_dir}/data/google_transit/stop_times.txt"
9
+ end
10
+
11
+ def trips_path
12
+ "#{base_dir}/data/google_transit/trips.txt"
13
+ end
14
+
6
15
  def upcoming_departures(loc, dir)
7
16
  times(loc, dir).select { |time| time > now }.sort
8
17
  end
@@ -28,11 +37,11 @@ class Caltrain
28
37
  end
29
38
 
30
39
  def all_times
31
- @all_times ||= File.read(TIMES_PATH).split(/[\n\r]+/)[1..-1].map { |line| line.gsub('"', '').split(/,+/) }
40
+ @all_times ||= File.read(times_path).split(/[\n\r]+/)[1..-1].map { |line| line.gsub('"', '').split(/,+/) }
32
41
  end
33
42
 
34
43
  def all_trips
35
- @all_trips ||= File.read(TRIPS_PATH).split(/[\n\r]+/)[1..-1].map { |line| line.gsub('"', '').split(/,+/) }.sort
44
+ @all_trips ||= File.read(trips_path).split(/[\n\r]+/)[1..-1].map { |line| line.gsub('"', '').split(/,+/) }.sort
36
45
  end
37
46
 
38
47
  def weekend?
@@ -9,6 +9,10 @@ describe Caltrain do
9
9
 
10
10
  after { Caltrain.clean! }
11
11
 
12
+ it 'has a base directory' do
13
+ Caltrain.base_dir.must_equal(File.expand_path('..', File.dirname(__FILE__)))
14
+ end
15
+
12
16
  describe 'trips' do
13
17
  it 'should parse trips.txt depending on the day of the week' do
14
18
  Caltrain.all_trips.first.must_equal(['101_20110701','ct_local_20110701','WD_20110701','San Francisco (Train 101)','0','cal_sj_sf'])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caltrain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha
16
- requirement: &2151812740 !ruby/object:Gem::Requirement
16
+ requirement: &2151812960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2151812740
24
+ version_requirements: *2151812960
25
25
  description: A command line tool to easily figure out when the next caltrain leaves.
26
26
  email: alexgenco@gmail.com
27
27
  executables:
@@ -48,8 +48,6 @@ post_install_message:
48
48
  rdoc_options: []
49
49
  require_paths:
50
50
  - lib
51
- - bin
52
- - data
53
51
  required_ruby_version: !ruby/object:Gem::Requirement
54
52
  none: false
55
53
  requirements: