easy_transilien 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +71 -0
- data/Guardfile +24 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +1 -0
- data/easy_transilien.gemspec +22 -0
- data/lib/easy_transilien.rb +9 -0
- data/lib/easy_transilien/easy.rb +10 -0
- data/lib/easy_transilien/station.rb +45 -0
- data/lib/easy_transilien/stop.rb +49 -0
- data/lib/easy_transilien/trip.rb +89 -0
- data/lib/easy_transilien/version.rb +3 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/station_spec.rb +17 -0
- data/spec/stop_spec.rb +18 -0
- data/spec/trip_spec.rb +8 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 96276f82ab18fe160b2ea7a3d6aad8ddbd6f127a
|
4
|
+
data.tar.gz: f0b09fce59b88a9fbe295c78a9f79bdc8221bb65
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82be3a630686b3cd01d7d65abb43f29bdb30c1543b25ca1f0b1e71ffa213ec6afbe68383eae3a1e5cda2e30ed7cb0febaacf48d81a873c1da3154676f45cd6e2
|
7
|
+
data.tar.gz: 089ccc1c974e956b2c961881fd6b5d5639ccf06cb62297b923693eed0aecb14b69156c076c974cac05d74e928a7f440b29246a4dafd2c73e75c78f81a3686a0b
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
easy_transilien (0.0.1)
|
5
|
+
transilien_microservices (~> 0.0.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
celluloid (0.15.2)
|
11
|
+
timers (~> 1.1.0)
|
12
|
+
coderay (1.0.9)
|
13
|
+
diff-lcs (1.2.4)
|
14
|
+
faraday (0.8.8)
|
15
|
+
multipart-post (~> 1.2.0)
|
16
|
+
ffi (1.9.2)
|
17
|
+
formatador (0.2.4)
|
18
|
+
guard (2.2.2)
|
19
|
+
formatador (>= 0.2.4)
|
20
|
+
listen (~> 2.1)
|
21
|
+
lumberjack (~> 1.0)
|
22
|
+
pry (>= 0.9.12)
|
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)
|
28
|
+
celluloid (>= 0.15.2)
|
29
|
+
rb-fsevent (>= 0.9.3)
|
30
|
+
rb-inotify (>= 0.9)
|
31
|
+
lumberjack (1.0.4)
|
32
|
+
method_source (0.8.2)
|
33
|
+
mini_portile (0.5.2)
|
34
|
+
multipart-post (1.2.0)
|
35
|
+
nokogiri (1.6.0)
|
36
|
+
mini_portile (~> 0.5.0)
|
37
|
+
pry (0.9.12.2)
|
38
|
+
coderay (~> 1.0.5)
|
39
|
+
method_source (~> 0.8)
|
40
|
+
slop (~> 3.4)
|
41
|
+
pry-doc (0.4.6)
|
42
|
+
pry (>= 0.9)
|
43
|
+
yard (>= 0.8)
|
44
|
+
rb-fsevent (0.9.3)
|
45
|
+
rb-inotify (0.9.2)
|
46
|
+
ffi (>= 0.5.0)
|
47
|
+
rspec (2.14.1)
|
48
|
+
rspec-core (~> 2.14.0)
|
49
|
+
rspec-expectations (~> 2.14.0)
|
50
|
+
rspec-mocks (~> 2.14.0)
|
51
|
+
rspec-core (2.14.7)
|
52
|
+
rspec-expectations (2.14.3)
|
53
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
54
|
+
rspec-mocks (2.14.4)
|
55
|
+
slop (3.4.6)
|
56
|
+
thor (0.18.1)
|
57
|
+
timers (1.1.0)
|
58
|
+
transilien_microservices (0.0.3)
|
59
|
+
faraday (>= 0.8.4)
|
60
|
+
nokogiri (>= 1.5.5)
|
61
|
+
yard (0.8.7.2)
|
62
|
+
|
63
|
+
PLATFORMS
|
64
|
+
ruby
|
65
|
+
|
66
|
+
DEPENDENCIES
|
67
|
+
easy_transilien!
|
68
|
+
guard-rspec
|
69
|
+
pry
|
70
|
+
pry-doc
|
71
|
+
rspec
|
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Thomas Lecavelier
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Transilien Microservices made EASY!
|
2
|
+
|
3
|
+
Ruby wrapper for transilien_microservices ruby gem: make data easy to fetch.
|
4
|
+
|
5
|
+
The original gem: http://rubygems.org/gems/transilien_microservices
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Gem developped with ruby 2.0.0, should work with ruby 1.9.3
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'easy_transilien'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install easy_transilien
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
- What do we want?
|
26
|
+
|
27
|
+
- Train times!
|
28
|
+
|
29
|
+
- How do we want them?
|
30
|
+
|
31
|
+
- Easily!
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# Transposition from TransilienMicroservices usage examples:
|
35
|
+
require 'easy_transilien'
|
36
|
+
|
37
|
+
stations = EasyTransilien::Station.find
|
38
|
+
val_arg_station = EasyTransilien::Station.find('val d\'argenteuil') # Access by name
|
39
|
+
# => [#<EasyTransilien::Station:0x007fd23dc9b398 @access_time=2013-11-19 13:03:07 +0100, @external_code="DUA8738179", @name="VAL D'ARGENTEUIL">]
|
40
|
+
val_arg_station = EasyTransilien::Station.find('val d\'arg') # Access by fragment
|
41
|
+
# => [#<EasyTransilien::Station:0x007fd23dcab0f8 @access_time=2013-11-19 13:03:07 +0100, @external_code="DUA8738179", @name="VAL D'ARGENTEUIL">]
|
42
|
+
val_arg_station = EasyTransilien::Station.find('DUA8738179') # Access by external_code
|
43
|
+
# => [#<EasyTransilien::Station:0x007fd23dce0fb0 @access_time=2013-11-19 13:03:07 +0100, @external_code="DUA8738179", @name="VAL D'ARGENTEUIL">]
|
44
|
+
# Note via @access_time that the Stations are cached
|
45
|
+
|
46
|
+
trips = EasyTransilien::Trip.find('val d\'argenteuil', 'paris saint-lazare')
|
47
|
+
# => [#<EasyTransilien::Trip …>, #<EasyTransilien::Trip …>…]
|
48
|
+
# Note: by default trips are fetch from Time.new to Time.new + 1.hour
|
49
|
+
|
50
|
+
# Maybe you want it at a certain time?
|
51
|
+
now = Time.new
|
52
|
+
trips = EasyTransilien::Trip.find('val d\'arg', 'paris sain', Time.local(now.year, now.month, now.day, 14, 42)) # you can search by fragment, exact match not required.
|
53
|
+
# => [<EasyTransilien::Trip:70166657121040 @access_time=2013-11-19 13:18:10 +0100 @mission=PACA @from_stop=VAL D'ARGENTEUIL@15:40, @to_stop=PARIS SAINT-LAZARE@15:55>, <EasyTransilien::Trip:70166657847860 @access_time=2013-11-19 13:18:10 +0100 @mission=PUCA @from_stop=VAL D'ARGENTEUIL@15:55, @to_stop=PARIS SAINT-LAZARE@16:10>, <EasyTransilien::Trip:70166663321140 @access_time=2013-11-19 13:18:10 +0100 @mission=POCI @from_stop=VAL D'ARGENTEUIL@16:09, @to_stop=PARIS SAINT-LAZARE@16:24>, <EasyTransilien::Trip:70166662894960 @access_time=2013-11-19 13:18:10 +0100 @mission=PUCA @from_stop=VAL D'ARGENTEUIL@16:25, @to_stop=PARIS SAINT-LAZARE@16:40>]
|
54
|
+
# End boundary not given, so it's "from"+1h
|
55
|
+
```
|
56
|
+
|
57
|
+
Easy isn't it?
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
66
|
+
|
67
|
+
NOTA: you're a beginner gem dev? This command may help you:
|
68
|
+
|
69
|
+
pry -Ilib -reasy_transilien
|
70
|
+
|
71
|
+
(you can replace pry with irb if you're not a good person…)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'easy_transilien/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "easy_transilien"
|
8
|
+
gem.version = EasyTransilien::VERSION
|
9
|
+
gem.authors = ["Thomas Lecavelier"]
|
10
|
+
gem.email = ["thomas-gems@lecavelier.name"]
|
11
|
+
gem.description = %q{Access SNCF Transilien micro-services datan the easy way: enable access to their theoric offer.}
|
12
|
+
gem.summary = %q{See https://github.com/ook/easy_transilien}
|
13
|
+
gem.homepage = "https://github.com/ook/easy_transilien"
|
14
|
+
gem.license = 'MIT'
|
15
|
+
|
16
|
+
gem.add_runtime_dependency('transilien_microservices', '~> 0.0.3') # Hey, it's a wrapper, so we must wrap it ;)
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module EasyTransilien
|
2
|
+
class Station
|
3
|
+
attr_accessor :name, :external_code, :access_time
|
4
|
+
|
5
|
+
class << self
|
6
|
+
# Get all available `Transilien::StopArea`
|
7
|
+
# == See:
|
8
|
+
# `transilien_microservices` gem
|
9
|
+
def all_stop_areas(options = {})
|
10
|
+
options[:force] ||= false
|
11
|
+
if options[:force] || @all_stop_areas.nil?
|
12
|
+
@all_stop_areas = ::Transilien::StopArea.find
|
13
|
+
end
|
14
|
+
@all_stop_areas
|
15
|
+
end
|
16
|
+
|
17
|
+
# Find a list of `Station` matching +criterium+.
|
18
|
+
# Valid keys:
|
19
|
+
# @param [String] criterium will try to match +name+ or +external_code+. Both case unsensitive.
|
20
|
+
def find(criterium = nil)
|
21
|
+
if criterium.is_a?(String)
|
22
|
+
regex = /#{criterium}/i
|
23
|
+
matching = all_stop_areas.reject { |sa| sa.name !~ regex && sa.external_code !~ regex }
|
24
|
+
return convert_stop_areas_to_stations(matching)
|
25
|
+
elsif criterium.is_a?(Station)
|
26
|
+
return [criterium]
|
27
|
+
elsif criterium.nil?
|
28
|
+
return convert_stop_areas_to_stations(all_stop_areas)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def convert_stop_areas_to_stations(stop_areas)
|
33
|
+
stop_areas.map do |sa|
|
34
|
+
item = new
|
35
|
+
item.name = sa.name
|
36
|
+
item.external_code = sa.external_code
|
37
|
+
item.access_time = sa.access_time
|
38
|
+
item
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module EasyTransilien
|
2
|
+
class Stop
|
3
|
+
include Comparable
|
4
|
+
attr_accessor :ms_stop
|
5
|
+
|
6
|
+
def access_time
|
7
|
+
ms_stop && ms_stop.access_time
|
8
|
+
end
|
9
|
+
|
10
|
+
def stop_time
|
11
|
+
@stop_time ||= ms_stop && ms_stop.stop_time
|
12
|
+
end
|
13
|
+
|
14
|
+
def station_name
|
15
|
+
@station_name ||= ms_stop && ms_stop.stop_point.name
|
16
|
+
end
|
17
|
+
|
18
|
+
def name_at_stop
|
19
|
+
ms_stop && ms_stop.name_at_stop
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop_point_idx
|
23
|
+
@stop_point_idx ||= ms_stop && ms_stop.stop_point.payload['StopPointIdx']
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def station_external_code
|
28
|
+
@station_external_code ||= ms_stop && ms_stop.stop_point.external_code
|
29
|
+
end
|
30
|
+
|
31
|
+
def time
|
32
|
+
now = Time.new
|
33
|
+
year = access_time && access_time.year || now.year
|
34
|
+
month = access_time && access_time.month || now.month
|
35
|
+
day = (access_time && access_time.day || now.day) + stop_time.day.to_i
|
36
|
+
Time.local(year, month, day, stop_time.hour, stop_time.minute)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
"#{station_name}#{"(#{name_at_stop})" if name_at_stop}@#{stop_time.day.to_i > 0 ? "(+#{stop_time.day.to_i})" : '' }#{'%02d' % stop_time.hour}:#{'%02d' % stop_time.minute}"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Comparable Stuff
|
44
|
+
def <=>(another)
|
45
|
+
self.time <=> another.time
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module EasyTransilien
|
2
|
+
# EasyTransilien::Trip
|
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
|
+
# gave.
|
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]
|
8
|
+
#
|
9
|
+
# A trip is the EasyTransilien representation from Transilien::VehicleJourney
|
10
|
+
class Trip
|
11
|
+
include Comparable
|
12
|
+
attr_accessor :from_station, :to_station, :from_stop, :to_stop, :access_time
|
13
|
+
attr_accessor :start_time, :arrival_time
|
14
|
+
attr_accessor :mission
|
15
|
+
attr_accessor :journey
|
16
|
+
|
17
|
+
attr_accessor :at
|
18
|
+
attr_accessor :stops
|
19
|
+
|
20
|
+
class << self
|
21
|
+
|
22
|
+
# Find
|
23
|
+
def find(from, to , at = Time.new, last = nil )
|
24
|
+
raise "at params MUST be a valid Time instance. Given: #{at.inspect}" unless at.is_a?(Time)
|
25
|
+
last ||= at + 3600
|
26
|
+
raise "last params MUST be a valid Time instance. Given: #{last.inspect}" unless last.is_a?(Time)
|
27
|
+
|
28
|
+
from_station = Station.find(from).first
|
29
|
+
to_station = Station.find(to).first
|
30
|
+
|
31
|
+
raise "Can't find a Station from #{from.inspect}" unless from_station
|
32
|
+
raise "Can't find a Station from #{to.inspect}" unless to_station
|
33
|
+
|
34
|
+
routes = Transilien::Route.find(stop_area_external_code: {and: [from_station.external_code, to_station.external_code] }, check_order: 1)
|
35
|
+
journeys = Transilien::VehicleJourney.find(route_external_code: routes.map(&:external_code), date: Transilien.date(at), start_time: Transilien.time(at), end_time: Transilien.time(last))
|
36
|
+
|
37
|
+
trips = []
|
38
|
+
|
39
|
+
journeys.each do |journey|
|
40
|
+
item = new
|
41
|
+
item.at = at
|
42
|
+
item.from_station = from_station
|
43
|
+
item.to_station = to_station
|
44
|
+
item.stops = journey.stops.map do |ms_stop|
|
45
|
+
s = EasyTransilien::Stop.new
|
46
|
+
s.ms_stop = ms_stop
|
47
|
+
s
|
48
|
+
end.sort
|
49
|
+
item.from_stop = item.stops.select { |ts| ts.station_external_code == from_station.external_code }.first
|
50
|
+
item.to_stop = item.stops.select { |ts| ts.station_external_code == to_station.external_code }.first
|
51
|
+
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
|
+
item.access_time = journey.access_time
|
53
|
+
item.journey = journey
|
54
|
+
item.mission = journey.name
|
55
|
+
|
56
|
+
trips << item
|
57
|
+
|
58
|
+
end
|
59
|
+
trips.sort
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def external_code
|
65
|
+
journey.external_code
|
66
|
+
end
|
67
|
+
|
68
|
+
def from_station_name
|
69
|
+
from_station.name
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_station_name
|
73
|
+
to_station.name
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_s
|
77
|
+
"[#{mission}] #{from_stop} -> #{to_stop}"
|
78
|
+
end
|
79
|
+
|
80
|
+
def inspect
|
81
|
+
"<EasyTransilien::Trip:#{object_id} @access_time=#{access_time} @mission=#{mission} @from_stop=#{from_stop}, @to_stop=#{to_stop}>"
|
82
|
+
end
|
83
|
+
|
84
|
+
def <=>(another)
|
85
|
+
self.from_stop.time <=> another.from_stop.time
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EasyTransilien::Station do
|
4
|
+
it 'should get some Station when searching for argenteuil' do
|
5
|
+
# This payload was generated from
|
6
|
+
# http://ms.api.transilien.com/?action=VehicleJourneyList&RouteExternalCode=DUA8008540420003%3BDUA8008540430008%3BDUA8008540430010%3BDUA8008540430005%3BDUA8008544000030%3BDUA8008540440001|or&Date=2013|10|24&StartTime=18|19&EndTime=18|21
|
7
|
+
col = EasyTransilien::Station.find('argenteuil')
|
8
|
+
col.is_a?(Array).should be_true
|
9
|
+
col.first.is_a?(EasyTransilien::Station).should be_true
|
10
|
+
col.length.should eql(2)
|
11
|
+
end
|
12
|
+
it 'should get all Station for empty search' do
|
13
|
+
col = EasyTransilien::Station.find
|
14
|
+
col.is_a?(Array).should be_true
|
15
|
+
(col.length > 0).should be_true
|
16
|
+
end
|
17
|
+
end
|
data/spec/stop_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
MS_STOP_PAYLOAD = "<Stop StopIdx=\"3856503\" StopPointIdx=\"37162\" VehicleJourneyIdx=\"326541\" HourNumber=\"0\" MinuteNumber=\"0\" DestinationPos=\"-1\" ODTIdx=\"0\" ODTPos=\"-1\" ValidityPatternSetCommentPos=\"0\" StopOrder=\"9\" VehicleIdx=\"0\">\n <StopTime>\n <TotalSeconds>52800</TotalSeconds>\n <Day>0</Day>\n <Hour>14</Hour>\n <Minute>40</Minute>\n </StopTime>\n <StopArrivalTime>\n <TotalSeconds>52740</TotalSeconds>\n <Day>0</Day>\n <Hour>14</Hour>\n <Minute>39</Minute>\n </StopArrivalTime>\n <StopPoint StopPointIdx=\"37162\" StopPointId=\"39732\" StopPointName=\"VAL D'ARGENTEUIL\" StopPointExternalCode=\"DUA8738179\" FareZone=\"4\">\n <StopPointAddress StopPointAddressName=\"\" StopPointAddressNumber=\"\" StopPointAddressTypeName=\"\"/>\n <Equipment Sheltered=\"False\" MIPAccess=\"False\" Elevator=\"False\" Escalator=\"False\" BikeAccepted=\"False\" BikeDepot=\"False\"/>\n <Mode ModeIdx=\"3\" ModeId=\"3\" ModeName=\"BUS\" ModeExternalCode=\"RATP\" ModeTypeExternalCode=\"Bus\"/>\n <City CityIdx=\"1102\" CityId=\"1101\" CityName=\"Argenteuil\" CityExternalCode=\"95018\" CityCode=\"95100\"/>\n <StopArea StopAreaIdx=\"15924\" StopAreaId=\"16639\" StopAreaName=\"VAL D'ARGENTEUIL\" StopAreaExternalCode=\"DUA8738179\" MainStopArea=\"1\" MultiModal=\"0\" CarPark=\"0\" MainConnection=\"0\" AdditionalData=\"\" ResaRailCode=\"\">\n <Coord>\n <CoordX>592262,31</CoordX>\n <CoordY>2439172,77</CoordY>\n </Coord>\n </StopArea>\n <Coord>\n <CoordX>592274,51</CoordX>\n <CoordY>2439127,18</CoordY>\n </Coord>\n </StopPoint>\n</Stop>"
|
4
|
+
|
5
|
+
Noko_Payload = Nokogiri.XML(MS_STOP_PAYLOAD)
|
6
|
+
|
7
|
+
describe EasyTransilien::Stop do
|
8
|
+
it 'should get valid #time from ms_stop' do
|
9
|
+
time = Time.new
|
10
|
+
ms_stop = Transilien::Stop.from_node(Noko_Payload, time)
|
11
|
+
|
12
|
+
es = EasyTransilien::Stop.new
|
13
|
+
es.ms_stop = ms_stop
|
14
|
+
es.is_a?(EasyTransilien::Stop).should be_true
|
15
|
+
es.time.is_a?(Time).should be_true
|
16
|
+
es.time.should eql(Time.local(time.year,time.month,time.day,14,40))
|
17
|
+
end
|
18
|
+
end
|
data/spec/trip_spec.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easy_transilien
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Lecavelier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: transilien_microservices
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.3
|
27
|
+
description: 'Access SNCF Transilien micro-services datan the easy way: enable access
|
28
|
+
to their theoric offer.'
|
29
|
+
email:
|
30
|
+
- thomas-gems@lecavelier.name
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- .ruby-version
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- Guardfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- easy_transilien.gemspec
|
44
|
+
- lib/easy_transilien.rb
|
45
|
+
- lib/easy_transilien/easy.rb
|
46
|
+
- lib/easy_transilien/station.rb
|
47
|
+
- lib/easy_transilien/stop.rb
|
48
|
+
- lib/easy_transilien/trip.rb
|
49
|
+
- lib/easy_transilien/version.rb
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
- spec/station_spec.rb
|
52
|
+
- spec/stop_spec.rb
|
53
|
+
- spec/trip_spec.rb
|
54
|
+
homepage: https://github.com/ook/easy_transilien
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.0.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: See https://github.com/ook/easy_transilien
|
78
|
+
test_files:
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/station_spec.rb
|
81
|
+
- spec/stop_spec.rb
|
82
|
+
- spec/trip_spec.rb
|
83
|
+
has_rdoc:
|