transilien_microservices 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/Gemfile.lock +7 -5
- data/README.md +4 -0
- data/lib/transilien/micro_service.rb +4 -4
- data/lib/transilien/time.rb +19 -5
- data/lib/transilien/version.rb +1 -1
- data/spec/time_spec.rb +15 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 275d52cbd0e7cc220846b5a50a1895bd848f88ee
|
4
|
+
data.tar.gz: cd47565c07e423ae3bc9dd40a7c648fd02d92254
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 812002b01063d42f0993e3c611277cc72716da3779378abcb2290148565db77650024cbe35980da03da7f82c8158e13366850a978cf51a13cc0f49dd37768842
|
7
|
+
data.tar.gz: 81726f0c943acc405f91e5447cca27d43d2e5f8ed1bc7d6964c4134cbddb7b7786fb91aa04ed60fb3e4dd91912e8e5f1a2cee4bd0ca06f17f2a78c96201108f7
|
data/CHANGELOG
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
0.0.3
|
2
|
+
* Bug fix: Transilien::Time#name now works
|
3
|
+
* New : Transilien::Time#time convert instance into ruby Time instance
|
4
|
+
* Try to start documentation, Yard compatible
|
5
|
+
|
6
|
+
0.0.2
|
7
|
+
* Fix require path to ease gem usage
|
8
|
+
|
9
|
+
0.0.1
|
10
|
+
* Initial release. Just work
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
transilien_microservices (0.0.
|
4
|
+
transilien_microservices (0.0.3)
|
5
5
|
faraday (>= 0.8.4)
|
6
6
|
nokogiri (>= 1.5.5)
|
7
7
|
|
@@ -12,8 +12,8 @@ GEM
|
|
12
12
|
timers (~> 1.1.0)
|
13
13
|
coderay (1.0.9)
|
14
14
|
diff-lcs (1.1.3)
|
15
|
-
faraday (0.8.
|
16
|
-
multipart-post (~> 1.
|
15
|
+
faraday (0.8.8)
|
16
|
+
multipart-post (~> 1.2.0)
|
17
17
|
ffi (1.9.0)
|
18
18
|
formatador (0.2.4)
|
19
19
|
guard (2.1.1)
|
@@ -31,8 +31,10 @@ GEM
|
|
31
31
|
rb-inotify (>= 0.9)
|
32
32
|
lumberjack (1.0.4)
|
33
33
|
method_source (0.8.2)
|
34
|
-
|
35
|
-
|
34
|
+
mini_portile (0.5.2)
|
35
|
+
multipart-post (1.2.0)
|
36
|
+
nokogiri (1.6.0)
|
37
|
+
mini_portile (~> 0.5.0)
|
36
38
|
pry (0.9.12.2)
|
37
39
|
coderay (~> 1.0.5)
|
38
40
|
method_source (~> 0.8)
|
data/README.md
CHANGED
@@ -98,6 +98,10 @@ Transilien::VehicleJourney.find route_external_code: routes_stlaz_val.map(&:exte
|
|
98
98
|
|
99
99
|
Easier, isn't it? Now take every `Stop` and keep only your matching `StopArea`: you'll get your hours of departures and arrivals :)
|
100
100
|
|
101
|
+
## Documentation
|
102
|
+
|
103
|
+
You're reading it… Ok, have a look to http://rubydoc.info/gems/transilien_microservices for code documentation. Note: you'll get a better understanding of that implementations if your read API documentation, see first link.
|
104
|
+
|
101
105
|
## Contributing
|
102
106
|
|
103
107
|
1. Fork it
|
@@ -60,10 +60,10 @@ class Transilien::MicroService
|
|
60
60
|
|
61
61
|
self.filters = filters
|
62
62
|
response = self.http.get(action_param, params)
|
63
|
-
puts('== Request: ')
|
64
|
-
puts(action_param.inspect)
|
65
|
-
puts(params.inspect)
|
66
|
-
puts(response.env[:url].inspect)
|
63
|
+
#puts('== Request: ')
|
64
|
+
#puts(action_param.inspect)
|
65
|
+
#puts(params.inspect)
|
66
|
+
#puts(response.env[:url].inspect)
|
67
67
|
body = response.body
|
68
68
|
collection = []
|
69
69
|
doc = Nokogiri.XML(body)
|
data/lib/transilien/time.rb
CHANGED
@@ -1,20 +1,34 @@
|
|
1
|
+
# Represents Time in Transilien MS API
|
2
|
+
# Theorically, you NEVER had to instanciate them by yourself
|
3
|
+
# Note: +total_seconds+ and +day+ looks like mysteries for myself right now…
|
1
4
|
class Transilien::Time < Transilien::FakeMicroService
|
2
5
|
attr_accessor :total_seconds, :day, :hour, :minute
|
3
6
|
|
4
7
|
class << self
|
8
|
+
# Build a `Transilien::Time` from a Nokogiri::Node
|
5
9
|
def from_node(node, access_time)
|
6
10
|
item = new
|
7
11
|
item.payload = node
|
8
12
|
|
9
13
|
item.total_seconds = node.at('TotalSeconds').text
|
10
|
-
item.day = node.at('Day').text
|
11
|
-
item.hour = node.at('Hour').text
|
12
|
-
item.minute = node.at('Minute').text
|
14
|
+
item.day = node.at('Day').text.to_i
|
15
|
+
item.hour = node.at('Hour').text.to_i
|
16
|
+
item.minute = node.at('Minute').text.to_i
|
13
17
|
item
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
|
-
|
18
|
-
|
21
|
+
# String conversion of the instance.
|
22
|
+
# It aims only to permit caching (see Transilien::Microservice class)
|
23
|
+
# @return [String] representation of that instance
|
24
|
+
def name
|
25
|
+
"#{day}:#{hour}:#{minute}|#{total_seconds}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Convert this object to ruby `::Time`
|
29
|
+
# Since the current time is not known, set it to `Time.new` year, month and day
|
30
|
+
def time
|
31
|
+
now = Time.new
|
32
|
+
Time.local(now.year, now.month, now.day + day, hour, minute)
|
19
33
|
end
|
20
34
|
end
|
data/lib/transilien/version.rb
CHANGED
data/spec/time_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Transilien::Time do
|
4
|
+
it 'should convert to ::Time easily' do
|
5
|
+
tt = Transilien::Time.new
|
6
|
+
tt.day = 0
|
7
|
+
tt.hour = 14
|
8
|
+
tt.minute = 42
|
9
|
+
tt.time.is_a?(::Time).should be_true
|
10
|
+
now = Time.new
|
11
|
+
tt.time.should eql(Time.local(now.year, now.month, now.day, 14, 42))
|
12
|
+
tt.day = 1
|
13
|
+
tt.time.should eql(Time.local(now.year, now.month, now.day + 1, 14, 42))
|
14
|
+
end
|
15
|
+
end
|
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
|
+
version: 0.0.3
|
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-11-
|
11
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- .gitignore
|
50
50
|
- .rspec
|
51
51
|
- .ruby-version
|
52
|
+
- CHANGELOG
|
52
53
|
- Gemfile
|
53
54
|
- Gemfile.lock
|
54
55
|
- Guardfile
|
@@ -71,6 +72,7 @@ files:
|
|
71
72
|
- lib/transilien_microservices.rb
|
72
73
|
- spec/microservice_spec.rb
|
73
74
|
- spec/spec_helper.rb
|
75
|
+
- spec/time_spec.rb
|
74
76
|
- spec/vehicle_journey_alone.xml
|
75
77
|
- spec/vehicle_journey_spec.rb
|
76
78
|
- transilien_microservices.gemspec
|
@@ -101,6 +103,7 @@ summary: See http://test.data-sncf.com/index.php?p=transilien
|
|
101
103
|
test_files:
|
102
104
|
- spec/microservice_spec.rb
|
103
105
|
- spec/spec_helper.rb
|
106
|
+
- spec/time_spec.rb
|
104
107
|
- spec/vehicle_journey_alone.xml
|
105
108
|
- spec/vehicle_journey_spec.rb
|
106
109
|
has_rdoc:
|