easy_transilien 0.0.2 → 0.0.4

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
2
  SHA1:
3
- metadata.gz: 3f38e80b6d65fc6f6036b5b5ec6fe55f328573f0
4
- data.tar.gz: 639281a6923ea1021b1e3510988c2a52170e7606
3
+ metadata.gz: d0f3e75eec981ffaa1bcb9eb609904855e53fabf
4
+ data.tar.gz: f43ece58c36e86416f8c277e8342d2949a2d0000
5
5
  SHA512:
6
- metadata.gz: da79f81f3bb47b36f461942d6ebd417f71200309dccce052cf0525833846199a70f57f8b9a4f168d4b71e8956ace737455397815d26f561fad5dfb6d243515ec
7
- data.tar.gz: 7986a3e5d632b673ec70f6b4df56dc750ff53ab29cc145efe2722a009815d5c47252c6f847e6a3577c5029c29e20f5c190f5909e543545bf1189436ef65996ec
6
+ metadata.gz: 0db76307217b2cef514905c2bcc95211cce4bc53276e3487738de7d4d57ed60e55fca852709696e2895685d78c85b177145c72f99c81d826edd83001fbab012d
7
+ data.tar.gz: 63c81f059d66998e0ebe909d9e22c36d4a49461112488666034bffc60c15858a3516e347526754b446dab201c90e7c8524038b46fa01d9236b9e5ac63fa1c784
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile.lock CHANGED
@@ -1,30 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_transilien (0.0.2)
5
- transilien_microservices (~> 0.0.5)
4
+ easy_transilien (0.0.3)
5
+ transilien_microservices (~> 0.0.6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  celluloid (0.15.2)
11
11
  timers (~> 1.1.0)
12
- coderay (1.0.9)
13
- diff-lcs (1.2.4)
12
+ coderay (1.1.0)
13
+ diff-lcs (1.2.5)
14
14
  faraday (0.8.8)
15
15
  multipart-post (~> 1.2.0)
16
- ffi (1.9.2)
16
+ ffi (1.9.3)
17
17
  formatador (0.2.4)
18
- guard (2.2.2)
18
+ guard (2.2.5)
19
19
  formatador (>= 0.2.4)
20
20
  listen (~> 2.1)
21
21
  lumberjack (~> 1.0)
22
22
  pry (>= 0.9.12)
23
23
  thor (>= 0.18.1)
24
- guard-rspec (4.0.3)
25
- guard (>= 2.1.1)
26
- rspec (~> 2.14)
27
- listen (2.2.0)
24
+ guard-rspec (4.2.3)
25
+ guard (~> 2.1)
26
+ rspec (>= 2.14, < 4.0)
27
+ listen (2.4.0)
28
28
  celluloid (>= 0.15.2)
29
29
  rb-fsevent (>= 0.9.3)
30
30
  rb-inotify (>= 0.9)
@@ -32,33 +32,33 @@ GEM
32
32
  method_source (0.8.2)
33
33
  mini_portile (0.5.2)
34
34
  multipart-post (1.2.0)
35
- nokogiri (1.6.0)
35
+ nokogiri (1.6.1)
36
36
  mini_portile (~> 0.5.0)
37
- pry (0.9.12.2)
38
- coderay (~> 1.0.5)
37
+ pry (0.9.12.4)
38
+ coderay (~> 1.0)
39
39
  method_source (~> 0.8)
40
40
  slop (~> 3.4)
41
- pry-doc (0.4.6)
41
+ pry-doc (0.5.1)
42
42
  pry (>= 0.9)
43
43
  yard (>= 0.8)
44
- rb-fsevent (0.9.3)
45
- rb-inotify (0.9.2)
44
+ rb-fsevent (0.9.4)
45
+ rb-inotify (0.9.3)
46
46
  ffi (>= 0.5.0)
47
47
  rspec (2.14.1)
48
48
  rspec-core (~> 2.14.0)
49
49
  rspec-expectations (~> 2.14.0)
50
50
  rspec-mocks (~> 2.14.0)
51
51
  rspec-core (2.14.7)
52
- rspec-expectations (2.14.3)
52
+ rspec-expectations (2.14.4)
53
53
  diff-lcs (>= 1.1.3, < 2.0)
54
54
  rspec-mocks (2.14.4)
55
- slop (3.4.6)
55
+ slop (3.4.7)
56
56
  thor (0.18.1)
57
57
  timers (1.1.0)
58
- transilien_microservices (0.0.5)
58
+ transilien_microservices (0.0.6)
59
59
  faraday (>= 0.8.4)
60
60
  nokogiri (>= 1.5.5)
61
- yard (0.8.7.2)
61
+ yard (0.8.7.3)
62
62
 
63
63
  PLATFORMS
64
64
  ruby
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = "https://github.com/ook/easy_transilien"
14
14
  gem.license = 'MIT'
15
15
 
16
- gem.add_runtime_dependency('transilien_microservices', '~> 0.0.5') # Hey, it's a wrapper, so we must wrap it ;)
16
+ gem.add_runtime_dependency('transilien_microservices', '~> 0.0.6') # Hey, it's a wrapper, so we must wrap it ;)
17
17
 
18
18
  gem.files = `git ls-files`.split($/)
19
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -60,7 +60,7 @@ module EasyTransilien
60
60
  end
61
61
 
62
62
  def codes
63
- @codes ||= ms_lines.map(&:code).flatten.uniq.sort.reject { |code| code.length != 1 } # DEV NOTE lines with more than 1 letter are special lines for "travaux"
63
+ @codes ||= ms_lines.map(&:code).flatten.uniq.sort#.reject { |code| code.length != 1 } # DEV NOTE lines with more than 1 letter are special lines for "travaux"
64
64
  end
65
65
 
66
66
  def ms_lines
@@ -56,7 +56,7 @@ module EasyTransilien
56
56
  end
57
57
 
58
58
  def codes
59
- @codes ||= ms_stop_area.lines.map(&:code).flatten.uniq.sort.reject { |c| c.length != 1 } # DEV NOTE lines with more than 1 letter are special lines for "travaux"
59
+ @codes ||= ms_stop_area.lines.map(&:code).flatten.uniq.sort#.reject { |c| c.length != 1 } # DEV NOTE lines with more than 1 letter are special lines for "travaux"
60
60
  end
61
61
 
62
62
  def coord(format = :gps)
@@ -3,8 +3,8 @@ module EasyTransilien
3
3
  # This class give you the differents Train from one point to an other point, on the same Transilien::Route, in the Time boudaries you
4
4
  # gave.
5
5
  #
6
- # The key method id Trip.find(from, to, at, last)
7
- # You can let [at] and [last] params empty: in that case [at] will be right now, and [last] will be in 1 hour later than [at]
6
+ # The key method id Trip.find(from, to, options)
7
+ # You can let options[at] and options[last] params empty: in that case [at] will be right now, and [last] will be in 1 hour later than [at]
8
8
  #
9
9
  # A trip is the EasyTransilien representation from Transilien::VehicleJourney
10
10
  class Trip
@@ -12,7 +12,7 @@ module EasyTransilien
12
12
  attr_accessor :from_station, :to_station, :from_stop, :to_stop, :access_time
13
13
  attr_accessor :start_time, :arrival_time
14
14
  attr_accessor :mission
15
- attr_accessor :journey
15
+ attr_accessor :ms_journey
16
16
 
17
17
  attr_accessor :at
18
18
  attr_accessor :stops
@@ -20,7 +20,24 @@ module EasyTransilien
20
20
  class << self
21
21
 
22
22
  # Find
23
- def find(from, to , at = Time.new, last = nil )
23
+ # Options:
24
+ # * at (default Time.new)
25
+ # * last (default at + 3600)
26
+ # * whole_day: if true, override at and last with respectively 00:01 and 00:00
27
+ # * return: if true, invert from and to
28
+ def find(from, to , options= {})
29
+ at = last = nil
30
+ if options[:whole_day]
31
+ now = Time.new
32
+ at = Time.new(now.year, now.month, now.day, 0, 0, 1)
33
+ last = at + 86400
34
+ end
35
+ if options[:return]
36
+ from_was = from
37
+ from = to
38
+ to = from_was
39
+ end
40
+ at ||= Time.new
24
41
  raise "at params MUST be a valid Time instance. Given: #{at.inspect}" unless at.is_a?(Time)
25
42
  last ||= at + 3600
26
43
  raise "last params MUST be a valid Time instance. Given: #{last.inspect}" unless last.is_a?(Time)
@@ -50,8 +67,10 @@ module EasyTransilien
50
67
  item.to_stop = item.stops.select { |ts| ts.station_external_code == to_station.external_code }.first
51
68
  next if item.from_stop.nil? || item.to_stop.nil? # drop item if this journey doesn't deserve our from_stop or to_stop
52
69
  item.access_time = journey.access_time
53
- item.journey = journey
70
+ item.ms_journey = journey
54
71
  item.mission = journey.name
72
+ item.start_time = item.from_stop.ms_stop.stop_time.time
73
+ item.arrival_time = item.to_stop.ms_stop.stop_time.time
55
74
 
56
75
  trips << item
57
76
 
@@ -73,6 +92,10 @@ module EasyTransilien
73
92
  to_station.name
74
93
  end
75
94
 
95
+ def line_code
96
+ ms_journey.route.line.code
97
+ end
98
+
76
99
  def to_s
77
100
  "[#{mission}] #{from_stop} -> #{to_stop}"
78
101
  end
@@ -1,3 +1,3 @@
1
1
  module EasyTransilien
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/spec/station_spec.rb CHANGED
@@ -13,16 +13,17 @@ describe EasyTransilien::Station do
13
13
  (col.length > 0).should be_true
14
14
  end
15
15
 
16
- it 'should get Line for a Station' do
16
+ it 'should get at least a Line for a Station' do
17
17
  station = EasyTransilien::Station.find('Val d\'Argenteuil').first
18
18
  station.lines.is_a?(Array).should be_true
19
+ (station.lines.length > 0).should be_true
19
20
  station.lines[0].is_a?(EasyTransilien::Line).should be_true
20
21
  end
21
22
 
22
- it 'should get line_letters for a Station' do
23
+ it 'should get at least one line_letters for a Station' do
23
24
  station = EasyTransilien::Station.find('Val d\'Argenteuil').first
24
25
  station.codes.is_a?(Array).should be_true
25
- station.codes.length.should eq(1)
26
+ (station.codes.length > 0).should be_true
26
27
  station.codes[0].is_a?(String).should be_true
27
28
  station.codes[0].should eql('J')
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_transilien
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Lecavelier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-23 00:00:00.000000000 Z
11
+ date: 2014-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: transilien_microservices
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.5
19
+ version: 0.0.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.5
26
+ version: 0.0.6
27
27
  description: 'Access SNCF Transilien micro-services datan the easy way: enable access
28
28
  to their theoric offer.'
29
29
  email:
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - .gitignore
36
+ - .rspec
36
37
  - .ruby-version
37
38
  - Gemfile
38
39
  - Gemfile.lock