velov 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/README.md +82 -17
- data/lib/velov.rb +5 -0
- data/lib/velov/station.rb +9 -1
- data/lib/velov/version.rb +1 -1
- data/spec/station_spec.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57fb179c3645ce9deadf22d1a5ab73d100b7a2d9
|
4
|
+
data.tar.gz: 8e9eb1b3254f3729ee67b7c3979fd4126f473bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd1a46125e1128e2cb5785f14339e6dcc075bc3b2060dc54910a5d31fe56c46fd0e5360d75622a091ed7654b5162e0f462c1806b5bfc85c71577a87ec14f215
|
7
|
+
data.tar.gz: f5bd27317ef9a7b87a082c4d8266f4189b53a1c5596290a8b6e3b6f64abac281f47f43fe9f4eeaf4f29a7ed113495c19f3f2b4e5849e5ce2f04905c8bbca341d
|
data/README.md
CHANGED
@@ -1,42 +1,107 @@
|
|
1
1
|
# Velov
|
2
2
|
|
3
|
-
Velov is a ruby wrapper for [Velov API](https://download.data.grandlyon.com/ws/smartdata/jcd_jcdecaux.jcdvelov.json) (Public Bike Sharing System of Lyon, France). This Wrapper allows you to play with objects like bike's stations !
|
3
|
+
Velov is a ruby wrapper for [Velov API](https://download.data.grandlyon.com/ws/smartdata/jcd_jcdecaux.jcdvelov.json) (Public Bike Sharing System of Lyon, France). This Wrapper allows you to play with objects like bike's stations !
|
4
|
+
|
5
|
+
[](http://badge.fury.io/rb/velov)
|
6
|
+
[](https://travis-ci.org/pbechu/velov)
|
7
|
+
[](https://coveralls.io/r/pbechu/velov?branch=master)
|
8
|
+
[](https://codeclimate.com/github/pbechu/velov)
|
9
|
+
[](https://gemnasium.com/pbechu/velov)
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
8
14
|
|
9
|
-
|
15
|
+
```ruby
|
16
|
+
gem 'velov'
|
17
|
+
```
|
10
18
|
|
11
19
|
And then execute:
|
12
20
|
|
13
|
-
|
21
|
+
```console
|
22
|
+
bundle install
|
23
|
+
```
|
14
24
|
|
15
25
|
Or install it yourself as:
|
16
26
|
|
17
|
-
|
27
|
+
```console
|
28
|
+
gem install velov
|
29
|
+
```
|
18
30
|
|
19
31
|
## Usage
|
20
32
|
|
21
|
-
###
|
22
|
-
|
23
|
-
|
24
|
-
|
33
|
+
### Start with the Velov API
|
34
|
+
|
35
|
+
Fetch data of all stations in one call:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
station_list = Velov::StationList.fetch
|
39
|
+
station_list.size # => 349
|
40
|
+
```
|
41
|
+
|
42
|
+
Navigate through the data with an Array of Station:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
stations = station_list.to_a
|
46
|
+
|
47
|
+
stations.each do |station|
|
48
|
+
puts station.name
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
### Play with stations
|
53
|
+
|
54
|
+
Find a specific station with its internal ID:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
station = Velov::Station.find_by_number(10117)
|
58
|
+
station.status # => "OPEN"
|
59
|
+
```
|
60
|
+
|
61
|
+
Want more attributes ? Try one of these for a station:
|
62
|
+
- number (internal ID)
|
63
|
+
- name
|
64
|
+
- address
|
65
|
+
- address_complement
|
66
|
+
- city
|
67
|
+
- district_number
|
68
|
+
- [bonus](http://www.velov.grandlyon.com/FAQ-Question-Reponse.59+M55f945504e2.0.html)
|
69
|
+
- position (some indications to find the station)
|
70
|
+
- lat (latitude)
|
71
|
+
- lng (longitude)
|
72
|
+
- bike_stands (count of bike stands at this station)
|
73
|
+
- status ("OPEN" or "CLOSED")
|
74
|
+
- available_bike_stands (free slots)
|
75
|
+
- available_bikes ([ready to ride ?](http://www.annivelov.fr/))
|
76
|
+
- availability_code (internal usage)
|
77
|
+
- availability_label (internal usage)
|
78
|
+
- last_update (last time data were updated)
|
79
|
+
|
80
|
+
### Use the data
|
81
|
+
|
82
|
+
Get reports for a list of stations:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
station_list.bike_stands # => 6832
|
86
|
+
station_list.available_bike_stands # => 3534
|
87
|
+
station_list.available_bikes # => 3022
|
88
|
+
```
|
89
|
+
|
90
|
+
Discover if you can reach a specific station:
|
25
91
|
|
26
|
-
|
27
|
-
|
28
|
-
|
92
|
+
```ruby
|
93
|
+
station.distance_to(45.8,4.9) # => 2.48 (km)
|
94
|
+
```
|
29
95
|
|
30
|
-
|
31
|
-
You can find a specific station with its ID:
|
96
|
+
Find the nearest stations around you:
|
32
97
|
|
33
|
-
|
34
|
-
|
35
|
-
|
98
|
+
```ruby
|
99
|
+
station_list.nearest(45.8,4.9)
|
100
|
+
```
|
36
101
|
|
37
102
|
## Contributing
|
38
103
|
|
39
|
-
1. Fork it
|
104
|
+
1. [Fork it](http://github.com/pbechu/velov/fork)
|
40
105
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
106
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
107
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/velov.rb
CHANGED
@@ -6,6 +6,7 @@ require "velov/version"
|
|
6
6
|
require "velov/api"
|
7
7
|
require "velov/station"
|
8
8
|
require "velov/station_list"
|
9
|
+
|
9
10
|
module Velov
|
10
11
|
# Define API Constants
|
11
12
|
NUMBER = 0
|
@@ -14,11 +15,15 @@ module Velov
|
|
14
15
|
ADDRESS_COMPLEMENT = 3
|
15
16
|
CITY = 4
|
16
17
|
DISTRICT_NUMBER = 5
|
18
|
+
BONUS = 6
|
19
|
+
POSITION = 7
|
17
20
|
LATITUDE = 8
|
18
21
|
LONGITUDE = 9
|
19
22
|
BIKE_STANDS = 10
|
20
23
|
STATUS = 11
|
21
24
|
AVAILABLE_BIKE_STANDS = 12
|
22
25
|
AVAILABLE_BIKES = 13
|
26
|
+
AVAILABILITY_CODE = 14
|
27
|
+
AVAILABILITY_LABEL = 15
|
23
28
|
LAST_UPDATE = 18
|
24
29
|
end
|
data/lib/velov/station.rb
CHANGED
@@ -8,12 +8,16 @@ module Velov
|
|
8
8
|
attribute :address_complement, String
|
9
9
|
attribute :city, String
|
10
10
|
attribute :district_number, Integer
|
11
|
+
attribute :bonus, Boolean
|
12
|
+
attribute :position, String
|
11
13
|
attribute :lat, Float
|
12
14
|
attribute :lng, Float
|
13
15
|
attribute :bike_stands, Integer
|
14
16
|
attribute :status, String
|
15
17
|
attribute :available_bike_stands, Integer
|
16
18
|
attribute :available_bikes, Integer
|
19
|
+
attribute :availability_code, Integer
|
20
|
+
attribute :availability_label, String
|
17
21
|
attribute :last_update, DateTime
|
18
22
|
|
19
23
|
def initialize(params)
|
@@ -23,12 +27,16 @@ module Velov
|
|
23
27
|
@address_complement = params[Velov::ADDRESS_COMPLEMENT]
|
24
28
|
@city = params[Velov::CITY]
|
25
29
|
@district_number = params[Velov::DISTRICT_NUMBER].to_i
|
30
|
+
@bonus = params[Velov::BONUS] == "Oui"
|
31
|
+
@position = params[Velov::POSITION]
|
26
32
|
@lat = params[Velov::LATITUDE].to_f
|
27
33
|
@lng = params[Velov::LONGITUDE].to_f
|
28
34
|
@bike_stands = params[Velov::BIKE_STANDS].to_i
|
29
35
|
@status = params[Velov::STATUS]
|
30
36
|
@available_bike_stands = params[Velov::AVAILABLE_BIKE_STANDS].to_i
|
31
37
|
@available_bikes = params[Velov::AVAILABLE_BIKES].to_i
|
38
|
+
@availability_code = params[Velov::AVAILABILITY_CODE].to_i
|
39
|
+
@availability_label = params[Velov::AVAILABILITY_LABEL]
|
32
40
|
@last_update = DateTime.parse(params[Velov::LAST_UPDATE])
|
33
41
|
end
|
34
42
|
|
@@ -38,7 +46,7 @@ module Velov
|
|
38
46
|
end
|
39
47
|
|
40
48
|
def distance_to(lat,lng)
|
41
|
-
Geocoder::Calculations.distance_between([@lat,@lng], [lat,lng])
|
49
|
+
Geocoder::Calculations.distance_between([@lat,@lng], [lat,lng], units: :km)
|
42
50
|
end
|
43
51
|
end
|
44
52
|
end
|
data/lib/velov/version.rb
CHANGED
data/spec/station_spec.rb
CHANGED
@@ -16,12 +16,16 @@ describe Velov::Station do
|
|
16
16
|
it { expect(@station.address_complement).to eq "None"}
|
17
17
|
it { expect(@station.city).to eq "VILLEURBANNE"}
|
18
18
|
it { expect(@station.district_number).to eq 117}
|
19
|
+
it { expect(@station.bonus).to eq false}
|
20
|
+
it { expect(@station.position).to eq "Centre de quartier, commerces"}
|
19
21
|
it { expect(@station.lat).to eq 45.7645636665294000}
|
20
22
|
it { expect(@station.lng).to eq 4.8923336071821100}
|
21
23
|
it { expect(@station.bike_stands).to eq 22}
|
22
24
|
it { expect(@station.status).to eq "OPEN"}
|
23
25
|
it { expect(@station.available_bike_stands).to eq 12}
|
24
26
|
it { expect(@station.available_bikes).to eq 10}
|
27
|
+
it { expect(@station.availability_code).to eq 1}
|
28
|
+
it { expect(@station.availability_label).to eq "Vert"}
|
25
29
|
it { expect(@station.last_update).to eq DateTime.new(2014,8,21,14,50,31) }
|
26
30
|
|
27
31
|
end
|
@@ -44,6 +48,6 @@ describe Velov::Station do
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
it { expect(@station.distance_to(45.8,4.9)).to eq
|
51
|
+
it { expect(@station.distance_to(45.8,4.9)).to eq 3.9849353849054903 }
|
48
52
|
end
|
49
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: velov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Baptiste Béchu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|