transilien_microservices 0.0.4 → 0.0.5

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: 20e0e7dc6d98a822c8bed0e923d588dff8f689cf
4
- data.tar.gz: c870be01577916e48dadeffdb5aa8513db3aa211
3
+ metadata.gz: caede0548e4ec422c95b7aab1e44208b83c1777a
4
+ data.tar.gz: b681dcd08d7a1a694e765ed32a820ed26dfa30b9
5
5
  SHA512:
6
- metadata.gz: fcb53e0817ea9af54ed95702cd955e83dde5578f929f2f46599b59829bb20937190303b868108f47d6fb52c246133745d90feb53968b2cd30afdf5eb20a23cf3
7
- data.tar.gz: 6d93248d767a068fc6200fc3d23423bc5d2335688c849dca6c44d76b50baeb83059624e6d8233b557dd3e9cd754ee1a4bd704892987077d754a5c1b7db5de8b3
6
+ metadata.gz: ab94bdfb39014392cdc6162213c8aeb99d67abc51b4c07100c1b670f68bc1855f29b026b4910982ced27acb40d3d90242a33d01d4d392e644ec0f98fb462f649
7
+ data.tar.gz: 0c85c1556d918a2d5ae60a40aa2dac9cd7a56db6579a4fd990402c027cc380fc79e67437cdacf8b2f2d030f07d386557f1b2a27796960e5e07acae4a79ad5fcc
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
+ 0.0.5
2
+ * New: plenty of logical links to transverse object instances (ie: Transilien::Line -> #stop_areas #stop_points #routes, etc.)
3
+ * New: Transilien::RoutePoint that UFO between Route and StopArea and StopPoint...
4
+
1
5
  0.0.4
2
- * New: Transilien::Line#code give the Line code well known by customers
6
+ * New: Transilien::Line#code give the Line code well known by customers (Ok, I admit it: I need that info for EasyTransilien T_T)
3
7
 
4
8
  0.0.3
5
9
  * Bug fix: Transilien::Time#name now works
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- transilien_microservices (0.0.4)
4
+ transilien_microservices (0.0.5)
5
5
  faraday (>= 0.8.4)
6
6
  nokogiri (>= 1.5.5)
7
7
 
data/README.md CHANGED
@@ -6,7 +6,7 @@ Here is the original service documentation: http://test.data-sncf.com/index.php/
6
6
 
7
7
  These services let you know the theoric train times on the Transilien service.
8
8
 
9
- Disclamer: The gem only intends to implements the API. I'll create a "easy" wrapper to access these data in a convenient way very soon.
9
+ Disclamer: The gem only intends to implements the API. If you want a « logical » way to exploits SNCF data, see EasyTransilien gem: https://github.com/ook/easy_transilien
10
10
 
11
11
  ## Installation
12
12
 
@@ -19,4 +19,16 @@ class Transilien::Line < Transilien::MicroService
19
19
  def code
20
20
  payload['LineCode']
21
21
  end
22
+
23
+ def stop_points
24
+ @stop_points ||= Transilien::StopPoint.find(line_external_code: external_code)
25
+ end
26
+
27
+ def stop_areas
28
+ @stop_areas ||= Transilien::StopArea.find(line_external_code: external_code)
29
+ end
30
+
31
+ def routes
32
+ @routes ||= Transilien::Route.find(line_external_code: external_code)
33
+ end
22
34
  end
@@ -1,2 +1,9 @@
1
1
  class Transilien::Network < Transilien::MicroService
2
+ def lines
3
+ @lines ||= Transilien::Line.find(network_external_code: external_code)
4
+ end
5
+
6
+ def codes
7
+ @codes ||= lines.map(&:code).uniq.sort
8
+ end
2
9
  end
@@ -0,0 +1,5 @@
1
+ class Transilien::RoutePoint < Transilien::MicroService
2
+ def stop_point
3
+ @stop_point ||= Transilien::StopPoint.find(stop_point_external_code: payload.at('StopPoint').at('StopPointExternalCode'))
4
+ end
5
+ end
@@ -49,4 +49,16 @@ class Transilien::StopArea < Transilien::MicroService
49
49
  @hangs ||= payload.at('HangList').children
50
50
  end
51
51
 
52
+ def stop_points
53
+ @stop_points ||= Transilien::StopPoint.find(stop_area_external_code: external_code)
54
+ end
55
+
56
+ def lines
57
+ @lines ||= Transilien::Line.find(stop_area_external_code: external_code)
58
+ end
59
+
60
+ def codes
61
+ @codes ||= lines.map(&:code).reject {|c| c.length != 1}. uniq.sort
62
+ end
63
+
52
64
  end
@@ -1,3 +1,3 @@
1
1
  module Transilien
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -11,6 +11,7 @@ require "transilien/vehicle_journey.rb"
11
11
  require "transilien/mode.rb"
12
12
  require "transilien/company.rb"
13
13
  require "transilien/stop.rb"
14
+ require "transilien/route_point.rb"
14
15
 
15
16
  module Transilien
16
17
  def self.date(time)
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?><ActionLineList><Params Function="api"><SafeMode>0</SafeMode><action>PTReferential</action><RequestedType>linelist</RequestedType><lineexternalcode>DUA800854046</lineexternalcode><networkexternalcode>dua801;dua802;dua803;dua804;dua805;dua850;dua851;dua852;dua853;dua854;dua855</networkexternalcode><interface>1_10</interface><login>opendata</login></Params><LineList LineCount="1"><Line LineIdx="1628" LineId="1627" LineName="Gare St Lazare =&gt; Vernon VIA CONFLANS" LineCode="J" LineExternalCode="DUA800854046" LineAdditionalData="" SortOrder="1628" LineColor="000000" HasAdaptedRoute="0"><ModeType ModeTypeIdx="15" ModeTypeExternalCode="RapidTransit" ModeTypeName="Train de banlieue / RER"/><Network NetworkIdx="76" NetworkId="8" NetworkName="Paris St Lazare" NetworkExternalCode="DUA854"></Network><Forward ForwardName="A"><Direction><StopArea StopAreaIdx="0" StopAreaId="-1" StopAreaName="" StopAreaExternalCode="" MainStopArea="0" MultiModal="0" CarPark="0" MainConnection="0" AdditionalData="" ResaRailCode=""><City CityIdx="0" CityId="-1" CityName="" CityExternalCode="" CityCode=""><Country CountryIdx="0" CountryId="-1" CountryName="" CountryExternalCode=""/></City><Coord/></StopArea></Direction></Forward><Backward BackwardName=""><Direction><StopArea StopAreaIdx="0" StopAreaId="-1" StopAreaName="" StopAreaExternalCode="" MainStopArea="0" MultiModal="0" CarPark="0" MainConnection="0" AdditionalData="" ResaRailCode=""><City CityIdx="0" CityId="-1" CityName="" CityExternalCode="" CityCode=""><Country CountryIdx="0" CountryId="-1" CountryName="" CountryExternalCode=""/></City><Coord/></StopArea></Direction></Backward></Line></LineList><PagerInfo ResponseCount="1" ResponseStartIndex="0" TotalCount="1"/></ActionLineList>
data/spec/line_spec.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Transilien::Line do
4
+ before(:each) do
5
+ # This payload was generated from
6
+ # http://ms.api.transilien.com/?Action=LineList&LineExternalCode=DUA800854046
7
+ @line = Transilien::Line.from_node(Nokogiri.XML((Pathname.new('spec') + 'line_DUA800854046.xml').read).at('Line'), Time.now)
8
+ end
9
+
10
+ it 'should get a Line' do
11
+ @line.class.should eql(Transilien::Line)
12
+ end
13
+
14
+ it 'should have a code' do
15
+ @line.code.should eql('J')
16
+ end
17
+
18
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Transilien::StopArea do
4
+ before(:each) do
5
+ # This payload was generated from
6
+ # http://ms.api.transilien.com/?Action=StopAreaList&StopAreaExternalCode=DUA8738400
7
+ @sa = Transilien::StopArea.from_node(Nokogiri.XML((Pathname.new('spec') + 'stoparea_DUA8738400.xml').read).at('StopArea'), Time.now)
8
+ end
9
+
10
+ it 'should be a StopArea' do
11
+ @sa.class.should eq(Transilien::StopArea)
12
+ end
13
+
14
+ it 'should have at least a line' do
15
+ #puts @sa.lines.map { |l| l.name }.inspect
16
+ (@sa.lines.length >= 1).should be_true
17
+ end
18
+
19
+ it 'should have some codes, at least one' do
20
+ @sa.codes.is_a?(Array).should be_true
21
+ (@sa.codes.length > 0).should be_true
22
+ end
23
+
24
+ end
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?><ActionStopAreaList><Params Function="api"><SafeMode>0</SafeMode><action>PTReferential</action><RequestedType>stoparealist</RequestedType><stopareaexternalcode>DUA8738400</stopareaexternalcode><networkexternalcode>dua801;dua802;dua803;dua804;dua805;dua850;dua851;dua852;dua853;dua854;dua855</networkexternalcode><interface>1_10</interface><login>opendata</login></Params><StopAreaList StopAreaCount="1"><StopArea StopAreaIdx="306" StopAreaId="311" StopAreaName="GARE DE PARIS SAINT-LAZARE" StopAreaExternalCode="DUA8738400" MainStopArea="1" MultiModal="0" CarPark="0" MainConnection="1" AdditionalData="" ResaRailCode=""><City CityIdx="1" CityId="0" CityName="Paris" CityExternalCode="75056" CityCode="75004"><Country CountryIdx="1" CountryId="0" CountryName="France" CountryExternalCode="FRA"/></City><Coord><CoordX>599145,21</CoordX><CoordY>2430788,22</CoordY></Coord><HangList><Hang StopPointIdx="1019" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1024" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1021" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1023" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1022" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1016" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1003" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1014" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1004" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1001" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="999" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1017" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="998" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1009" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1006" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1020" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1010" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1018" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="997" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1008" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1007" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1011" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1013" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1000" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1015" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1005" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1002" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1012" Duration="0" ConnectionKind="14"/></HangList><ModeList ModeCount="3"><ModeType ModeTypeIdx="5" ModeTypeExternalCode="Bus" ModeTypeName="Bus"/><ModeType ModeTypeIdx="10" ModeTypeExternalCode="Metro" ModeTypeName="M�tro"/><ModeType ModeTypeIdx="15" ModeTypeExternalCode="RapidTransit" ModeTypeName="Train de banlieue / RER"/></ModeList></StopArea></StopAreaList><PagerInfo ResponseCount="1" ResponseStartIndex="0" TotalCount="1"/></ActionStopAreaList>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transilien_microservices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-10 00:00:00.000000000 Z
11
+ date: 2013-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -63,6 +63,7 @@ files:
63
63
  - lib/transilien/mode_type.rb
64
64
  - lib/transilien/network.rb
65
65
  - lib/transilien/route.rb
66
+ - lib/transilien/route_point.rb
66
67
  - lib/transilien/stop.rb
67
68
  - lib/transilien/stop_area.rb
68
69
  - lib/transilien/stop_point.rb
@@ -70,8 +71,12 @@ files:
70
71
  - lib/transilien/vehicle_journey.rb
71
72
  - lib/transilien/version.rb
72
73
  - lib/transilien_microservices.rb
74
+ - spec/line_DUA800854046.xml
75
+ - spec/line_spec.rb
73
76
  - spec/microservice_spec.rb
74
77
  - spec/spec_helper.rb
78
+ - spec/stop_area_spec.rb
79
+ - spec/stoparea_DUA8738400.xml
75
80
  - spec/time_spec.rb
76
81
  - spec/vehicle_journey_alone.xml
77
82
  - spec/vehicle_journey_spec.rb
@@ -101,8 +106,12 @@ signing_key:
101
106
  specification_version: 4
102
107
  summary: See http://test.data-sncf.com/index.php?p=transilien
103
108
  test_files:
109
+ - spec/line_DUA800854046.xml
110
+ - spec/line_spec.rb
104
111
  - spec/microservice_spec.rb
105
112
  - spec/spec_helper.rb
113
+ - spec/stop_area_spec.rb
114
+ - spec/stoparea_DUA8738400.xml
106
115
  - spec/time_spec.rb
107
116
  - spec/vehicle_journey_alone.xml
108
117
  - spec/vehicle_journey_spec.rb