caruby2go 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +92 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +9 -0
- data/bin/caruby2go +60 -0
- data/build +15 -0
- data/caruby2go.gemspec +35 -0
- data/lib/caruby2go.rb +42 -0
- data/lib/caruby2go/version.rb +3 -0
- data/test/test_caruby2go.rb +83 -0
- data/test/test_caruby2go_integration.rb +57 -0
- metadata +216 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6f22e4a39a7a340b3fb16a7be32939d306baf9f4
|
4
|
+
data.tar.gz: d2616acb3a170086305def7043567e4c3d8f6442
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e3bd82e81b475345e68d61bd077deaa41875f61ec0549a2a0c21ae2b451094fd80ca3323416656a2a04c6a1dcbdd69baa57c63affd7ce0f64850f21d02487d00
|
7
|
+
data.tar.gz: be82b50161024ef86b90155ad611062fe790b0957dd185cb8c935202ddc9ec801d7bfa162b2c703688e3d9af0cf5fe9bdf38f8f153ad115111b46252dc6c80f3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
caruby2go (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
celluloid (0.16.0)
|
10
|
+
timers (~> 4.0.0)
|
11
|
+
coderay (1.1.0)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
ffi (1.9.6)
|
14
|
+
formatador (0.2.5)
|
15
|
+
guard (2.12.4)
|
16
|
+
formatador (>= 0.2.4)
|
17
|
+
listen (~> 2.7)
|
18
|
+
lumberjack (~> 1.0)
|
19
|
+
nenv (~> 0.1)
|
20
|
+
notiffany (~> 0.0)
|
21
|
+
pry (>= 0.9.12)
|
22
|
+
shellany (~> 0.0)
|
23
|
+
thor (>= 0.18.1)
|
24
|
+
guard-compat (1.2.1)
|
25
|
+
guard-rspec (4.5.0)
|
26
|
+
guard (~> 2.1)
|
27
|
+
guard-compat (~> 1.1)
|
28
|
+
rspec (>= 2.99.0, < 4.0)
|
29
|
+
hitimes (1.2.2)
|
30
|
+
listen (2.8.5)
|
31
|
+
celluloid (>= 0.15.2)
|
32
|
+
rb-fsevent (>= 0.9.3)
|
33
|
+
rb-inotify (>= 0.9)
|
34
|
+
lumberjack (1.0.9)
|
35
|
+
method_source (0.8.2)
|
36
|
+
nenv (0.2.0)
|
37
|
+
notiffany (0.0.6)
|
38
|
+
nenv (~> 0.1)
|
39
|
+
shellany (~> 0.0)
|
40
|
+
pry (0.10.1)
|
41
|
+
coderay (~> 1.1.0)
|
42
|
+
method_source (~> 0.8.1)
|
43
|
+
slop (~> 3.4)
|
44
|
+
pry-nav (0.2.4)
|
45
|
+
pry (>= 0.9.10, < 0.11.0)
|
46
|
+
pry-remote (0.1.8)
|
47
|
+
pry (~> 0.9)
|
48
|
+
slop (~> 3.0)
|
49
|
+
rake (10.4.2)
|
50
|
+
rb-fsevent (0.9.4)
|
51
|
+
rb-inotify (0.9.5)
|
52
|
+
ffi (>= 0.5.0)
|
53
|
+
rspec (3.2.0)
|
54
|
+
rspec-core (~> 3.2.0)
|
55
|
+
rspec-expectations (~> 3.2.0)
|
56
|
+
rspec-mocks (~> 3.2.0)
|
57
|
+
rspec-core (3.2.1)
|
58
|
+
rspec-support (~> 3.2.0)
|
59
|
+
rspec-expectations (3.2.0)
|
60
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
+
rspec-support (~> 3.2.0)
|
62
|
+
rspec-mocks (3.2.1)
|
63
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
+
rspec-support (~> 3.2.0)
|
65
|
+
rspec-nc (0.2.0)
|
66
|
+
rspec (>= 2.9)
|
67
|
+
terminal-notifier (>= 1.4)
|
68
|
+
rspec-support (3.2.2)
|
69
|
+
shellany (0.0.1)
|
70
|
+
slop (3.6.0)
|
71
|
+
spy (0.4.1)
|
72
|
+
terminal-notifier (1.6.2)
|
73
|
+
thor (0.19.1)
|
74
|
+
timers (4.0.1)
|
75
|
+
hitimes
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
bundler (~> 1.7)
|
82
|
+
caruby2go!
|
83
|
+
guard
|
84
|
+
guard-rspec
|
85
|
+
pry
|
86
|
+
pry-nav
|
87
|
+
pry-remote
|
88
|
+
rake (~> 10.0)
|
89
|
+
rspec
|
90
|
+
rspec-nc
|
91
|
+
spy
|
92
|
+
thor
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 J2EEbbesen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Eric Ebbesen
|
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,44 @@
|
|
1
|
+
# caruby2go
|
2
|
+
|
3
|
+
caruby2go is a gem that exposes [the car2go api](https://code.google.com/p/car2go/wiki/index_v2_1).
|
4
|
+
|
5
|
+
For all operations you need to [get your own consumer key from car2go](https://www.car2go.com/en/austin/car2go-apps/).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'caruby2go'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install caruby2go
|
22
|
+
|
23
|
+
## Packaging
|
24
|
+
|
25
|
+
$ rake build
|
26
|
+
|
27
|
+
build (in this project's root) will build and install the gem locally.
|
28
|
+
|
29
|
+
## Local usage
|
30
|
+
The script requires you to set the CONSUMER_KEY environment variable to your car2Go consumer key
|
31
|
+
|
32
|
+
$ set CONSUMER_KEY=<your_consumer_key>
|
33
|
+
$ bin/caruby2go p kobenhavn
|
34
|
+
or
|
35
|
+
|
36
|
+
$ CONSUMER_KEY=<your_consumer_key> bin/caruby2go p kobenhavn
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/[my-github-username]/caruby2go/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/caruby2go
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require_relative '../lib/caruby2go.rb'
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
##
|
8
|
+
# Script for running the gem from the command line
|
9
|
+
class Caruby2goScript < Thor
|
10
|
+
RECORD_SEPARATOR = '========================================================='
|
11
|
+
desc 'vehicles CITY', 'get vehicles for CITY'
|
12
|
+
def vehicles(city)
|
13
|
+
call_api(city)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'locations', 'get Car2Go cities'
|
17
|
+
def locations
|
18
|
+
call_api
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'gasstations', 'get gas stations for CITY'
|
22
|
+
def gasstations(city)
|
23
|
+
call_api(city)
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'parkingspots', 'get parking spots for CITY'
|
27
|
+
def parkingspots(city)
|
28
|
+
call_api(city)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# this is set using an environment variable
|
34
|
+
def require_key
|
35
|
+
return if ENV['CONSUMER_KEY']
|
36
|
+
puts 'Set environment variable CONSUMER_KEY to your Car2Go consumer key.'
|
37
|
+
puts 'For example:'
|
38
|
+
puts ' $ CONSUMER_KEY=mykey bin/caruby2go v twincities'
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
def call_api(city = nil)
|
43
|
+
require_key
|
44
|
+
caruby2go = Caruby2go.new(ENV['CONSUMER_KEY'], city)
|
45
|
+
results = caruby2go.send("#{caller_locations(1, 1)[0].label}".to_sym)
|
46
|
+
pretty_print results
|
47
|
+
end
|
48
|
+
|
49
|
+
def pretty_print(records)
|
50
|
+
records.each do |record|
|
51
|
+
puts RECORD_SEPARATOR
|
52
|
+
record.each do |k, v|
|
53
|
+
puts "#{k}:: #{v}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
puts RECORD_SEPARATOR
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Caruby2goScript.start(ARGV)
|
data/build
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
build_return = `gem build caruby2go.gemspec`
|
5
|
+
|
6
|
+
gemfile = ''
|
7
|
+
lines = build_return.split "\n"
|
8
|
+
puts lines
|
9
|
+
lines.each do |line|
|
10
|
+
gemfile = line.split(' ')[1] if line.start_with? ' File: '
|
11
|
+
end
|
12
|
+
|
13
|
+
puts `gem install caruby2go`
|
14
|
+
|
15
|
+
FileUtils.mv(gemfile, './pkg/')
|
data/caruby2go.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'caruby2go/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'caruby2go'
|
8
|
+
spec.version = Caruby2go::VERSION
|
9
|
+
spec.authors = ['Eric Ebbesen']
|
10
|
+
spec.email = ['eebbesen.git@gmail.com']
|
11
|
+
spec.summary = 'Ruby gem that wraps the car2go API'
|
12
|
+
spec.description = 'Ruby gem that wraps the car2go API -- only supports the public API at present'
|
13
|
+
spec.homepage = 'https://github.com/eebbesen/caruby2go'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
|
26
|
+
# test
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
28
|
+
spec.add_development_dependency 'rspec-nc', '~> 3.2'
|
29
|
+
spec.add_development_dependency 'guard', '~> 2.12'
|
30
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.5'
|
31
|
+
spec.add_development_dependency 'pry', '~>0.10'
|
32
|
+
spec.add_development_dependency 'pry-remote', '~> 0.1'
|
33
|
+
spec.add_development_dependency 'pry-nav', '~> 0.2'
|
34
|
+
spec.add_development_dependency 'spy', '~> 0.4'
|
35
|
+
end
|
data/lib/caruby2go.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'caruby2go/version'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
##
|
6
|
+
# Wraps the Car2Go public API endpoints
|
7
|
+
class Caruby2go
|
8
|
+
CAR2GO_URI = 'https://www.car2go.com/api/v2.1'
|
9
|
+
|
10
|
+
def initialize(consumer_key, location = nil)
|
11
|
+
@consumer_key = consumer_key
|
12
|
+
@location = location
|
13
|
+
end
|
14
|
+
|
15
|
+
def gasstations # placemarks
|
16
|
+
issue_get(build_uri('gasstations'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def locations # location
|
20
|
+
issue_get(build_uri('locations'), 'location')
|
21
|
+
end
|
22
|
+
|
23
|
+
def parkingspots # placemarks
|
24
|
+
issue_get(build_uri('parkingspots'))
|
25
|
+
end
|
26
|
+
|
27
|
+
def vehicles # placemarks
|
28
|
+
issue_get(build_uri('vehicles'))
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def build_uri(endpoint)
|
34
|
+
loc_part = @location ? "loc=#{@location}" : nil
|
35
|
+
"#{CAR2GO_URI}/#{endpoint}?#{loc_part}&oauth_consumer_key=#{@consumer_key}&format=json"
|
36
|
+
end
|
37
|
+
|
38
|
+
def issue_get(uri, json_header = 'placemarks')
|
39
|
+
data = open(uri).read
|
40
|
+
JSON.parse(data)[json_header]
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require './lib/caruby2go'
|
3
|
+
require 'spy/integration'
|
4
|
+
|
5
|
+
class TestCaruby2go < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@caruby2go = Caruby2go.new('testkey', 'MPLS')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_initialize
|
11
|
+
assert_equal 'testkey', @caruby2go.instance_variable_get(:@consumer_key)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_build_uri_with_location
|
15
|
+
assert_equal 'https://www.car2go.com/api/v2.1/endpt?loc=MPLS&oauth_consumer_key=testkey&format=json',
|
16
|
+
@caruby2go.send(:build_uri, 'endpt')
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_build_uri_without_location
|
20
|
+
@caruby2go = Caruby2go.new('testkey')
|
21
|
+
assert_equal 'https://www.car2go.com/api/v2.1/endpt?&oauth_consumer_key=testkey&format=json',
|
22
|
+
@caruby2go.send(:build_uri, 'endpt')
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_vehicles
|
26
|
+
vehicles_json = '{"placemarks":[{"address":"Grand Ave 1600, 55105 St Paul",
|
27
|
+
"coordinates":[-93.16789,44.93999,0],"engineType":"CE",
|
28
|
+
"exterior":"GOOD","fuel":26,"interior":"GOOD",
|
29
|
+
"name":"AB6860","smartPhoneRequired":false,
|
30
|
+
"vin":"AAAAA0AA0AA000000"},
|
31
|
+
{"address":"West Kellogg Boulevard 15, 55102 St Paul",
|
32
|
+
"coordinates":[-93.093654,44.943895,0],"engineType":"CE",
|
33
|
+
"exterior":"GOOD","fuel":25,"interior":"GOOD",
|
34
|
+
"name":"AB6860","smartPhoneRequired":false,
|
35
|
+
"vin":"AAAAA1AA1AA111111"},
|
36
|
+
{"address":"South 5th Street 350, 55415 Minneapolis",
|
37
|
+
"coordinates":[-93.265769,44.976851,0],
|
38
|
+
"engineType":"CE","exterior":"GOOD","fuel":24,
|
39
|
+
"interior":"GOOD","name":"AB6860",
|
40
|
+
"smartPhoneRequired":false,"vin":"AAAAA2AA2AA222222"}]}'
|
41
|
+
run_mock(vehicles_json, :vehicles)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_locations
|
45
|
+
locations_json = '{"location":[{"countryCode":"DE","defaultLanguage":"de",
|
46
|
+
"locationId":1,"locationName":"Ulm",
|
47
|
+
"mapSection":{"center":{"latitude":48.398917,
|
48
|
+
"longitude":9.99139},
|
49
|
+
"lowerRight":{"latitude":48.3446,"longitude":10.0459},
|
50
|
+
"upperLeft":{"latitude":48.4383,"longitude":9.9146} },
|
51
|
+
"timezone":"Europe/Berlin"}]}'
|
52
|
+
run_mock(locations_json, :locations)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_get_parkingspots
|
56
|
+
parkingspots_json = '{"placemarks":[{"coordinates":[-97.750983,30.269577,0],
|
57
|
+
"name":"West Ave","totalCapacity":4,"usedCapacity":0,
|
58
|
+
"chargingPole":false},
|
59
|
+
{"coordinates":[-97.74225,30.265976,0],
|
60
|
+
"name":"100 East 4th Street","totalCapacity":4,
|
61
|
+
"usedCapacity":0,"chargingPole":true}]}'
|
62
|
+
run_mock(parkingspots_json, :parkingspots)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_get_gasstations
|
66
|
+
gasstations_json = '{"placemarks":[{"coordinates":[9.987988,48.358829,0],
|
67
|
+
"name":"Shell, Hauptstrasse 12"},
|
68
|
+
{"coordinates":[9.990183,48.404832,0],
|
69
|
+
"name":"Shell, Karlstrasse 38"}]}'
|
70
|
+
run_mock(gasstations_json, :gasstations)
|
71
|
+
end
|
72
|
+
|
73
|
+
def run_mock(json, method)
|
74
|
+
mock_open_uri = Minitest::Mock.new
|
75
|
+
mock_open_uri.expect(:read, json)
|
76
|
+
|
77
|
+
OpenURI.stub :open_uri, mock_open_uri do
|
78
|
+
@caruby2go.send(method)
|
79
|
+
end
|
80
|
+
|
81
|
+
mock_open_uri.verify
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require './lib/caruby2go'
|
3
|
+
require 'spy/integration'
|
4
|
+
|
5
|
+
class TestCaruby2goIngegration < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@caruby2go = Caruby2go.new(ENV['CONSUMER_KEY'], 'minneapolis')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_get_vehicles
|
11
|
+
vehicles_json = @caruby2go.vehicles
|
12
|
+
refute vehicles_json.first['address'].empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_get_locations
|
16
|
+
locations_json = @caruby2go.locations
|
17
|
+
refute locations_json.first['locationName'].empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_get_parkingspots
|
21
|
+
parkingspots_json = @caruby2go.parkingspots
|
22
|
+
refute parkingspots_json.first['coordinates'].empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_gasstations
|
26
|
+
@caruby2go = Caruby2go.new(ENV['CONSUMER_KEY'], 'kobenhavn')
|
27
|
+
gasstations_json = @caruby2go.gasstations
|
28
|
+
refute gasstations_json.first['coordinates'].empty?
|
29
|
+
end
|
30
|
+
|
31
|
+
# run when you need to validate cities/payloads
|
32
|
+
# this test is pretty slow, comparitively
|
33
|
+
def test_validate_cities
|
34
|
+
skip('this is a helper method for validating location names')
|
35
|
+
# ignored cities are ones for which I don't know the location code
|
36
|
+
# that the API accepts
|
37
|
+
ignored_cities = %w(chongqing koln cologne dusseldorf eugene honolulu
|
38
|
+
milan southbay)
|
39
|
+
cities = %w(amsterdam austin berlin calgary columbus denver firenze
|
40
|
+
frankfurt hamburg kobenhavn losangeles miami montreal muenchen
|
41
|
+
newyorkcity portland rheinland roma sandiego seattle stockholm
|
42
|
+
stuttgart torino toronto twincities vancouver washingtondc
|
43
|
+
wien)
|
44
|
+
|
45
|
+
cities.each do |city|
|
46
|
+
@caruby2go = Caruby2go.new(ENV['CONSUMER_KEY'], city)
|
47
|
+
puts "#{city}"
|
48
|
+
payload = @caruby2go.gasstations
|
49
|
+
puts "#{city}:\n#{payload}"
|
50
|
+
end
|
51
|
+
puts "Done with valid cities (#{cities.size})"
|
52
|
+
puts 'Did not look for the following cities as they have previously failed validation:'
|
53
|
+
ignored_cities.each do |city|
|
54
|
+
puts city
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: caruby2go
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Ebbesen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.19.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-nc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.12'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.12'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.5'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.5'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.10'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.10'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-remote
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.1'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.1'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-nav
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.2'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.2'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: spy
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.4'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.4'
|
167
|
+
description: Ruby gem that wraps the car2go API -- only supports the public API at
|
168
|
+
present
|
169
|
+
email:
|
170
|
+
- eebbesen.git@gmail.com
|
171
|
+
executables:
|
172
|
+
- caruby2go
|
173
|
+
extensions: []
|
174
|
+
extra_rdoc_files: []
|
175
|
+
files:
|
176
|
+
- ".gitignore"
|
177
|
+
- Gemfile
|
178
|
+
- Gemfile.lock
|
179
|
+
- LICENSE
|
180
|
+
- LICENSE.txt
|
181
|
+
- README.md
|
182
|
+
- Rakefile
|
183
|
+
- bin/caruby2go
|
184
|
+
- build
|
185
|
+
- caruby2go.gemspec
|
186
|
+
- lib/caruby2go.rb
|
187
|
+
- lib/caruby2go/version.rb
|
188
|
+
- test/test_caruby2go.rb
|
189
|
+
- test/test_caruby2go_integration.rb
|
190
|
+
homepage: https://github.com/eebbesen/caruby2go
|
191
|
+
licenses:
|
192
|
+
- MIT
|
193
|
+
metadata: {}
|
194
|
+
post_install_message:
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 2.4.5
|
211
|
+
signing_key:
|
212
|
+
specification_version: 4
|
213
|
+
summary: Ruby gem that wraps the car2go API
|
214
|
+
test_files:
|
215
|
+
- test/test_caruby2go.rb
|
216
|
+
- test/test_caruby2go_integration.rb
|