multicity 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +29 -0
- data/lib/multicity/multicity_agent.rb +15 -2
- data/lib/multicity/version.rb +1 -1
- data/lib/multicity.rb +1 -5
- metadata +56 -86
- data/lib/multicity/agent_multicity.rb +0 -11
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Installation
|
2
|
+
=
|
3
|
+
gem install 'multicity'
|
4
|
+
|
5
|
+
Example
|
6
|
+
=
|
7
|
+
require 'multicity'
|
8
|
+
|
9
|
+
# Get all cars
|
10
|
+
agent = Multicity::Agent.new
|
11
|
+
cars = agent.get_cars
|
12
|
+
cars.each do |car|
|
13
|
+
puts car.id # => "1234"
|
14
|
+
puts car.license_plate # => "B-MC 1694"
|
15
|
+
puts car.model # => "Citroën C-Zero"
|
16
|
+
puts car.position # => {:lat => '52.5359483', :lon => '13.4432250'}
|
17
|
+
end
|
18
|
+
|
19
|
+
# get the price
|
20
|
+
Multicity::Agent.price 25 # => {:unit => 'EUR', :price => 7.50, :rate => :starter}
|
21
|
+
Multicity::Agent.price 25, :vielnutzer # => {:unit => 'EUR', :price => 6.00, :rate => :vielnutzer}
|
22
|
+
|
23
|
+
# get operation area
|
24
|
+
agent.get_operation_area # => array of lat/lon coordinates "[[52.464874, 13.405852], [52.466625, 13.425508], [52.467854, 13.435678],...]"
|
25
|
+
|
26
|
+
|
27
|
+
Contribute
|
28
|
+
=
|
29
|
+
Fork, implement, create tests and a pullrequest :)
|
@@ -20,7 +20,7 @@ module Multicity
|
|
20
20
|
# Returns an array of Multicity:Car
|
21
21
|
def get_cars
|
22
22
|
data = @agent.get(@@options[:url_list], headers).body
|
23
|
-
marker = data.scan(/"marker":\[(.*?)\],"/).first
|
23
|
+
marker = data.scan(/"marker":\[(.*?)\],"/).first.join
|
24
24
|
marker = marker.to_s.gsub(' ', ' ')
|
25
25
|
marker = JSON.parse("[#{marker}]")
|
26
26
|
marker.map! { |item| Car.new(item) }
|
@@ -37,12 +37,25 @@ module Multicity
|
|
37
37
|
coords = []
|
38
38
|
coordinates.strip.split("\n").each do |coordinate|
|
39
39
|
coordinate = coordinate.split ","
|
40
|
-
coords << [ coordinate[
|
40
|
+
coords << [ coordinate[1].to_f, coordinate[0].to_f ]
|
41
41
|
end
|
42
42
|
|
43
43
|
coords
|
44
44
|
end
|
45
45
|
|
46
|
+
def self.price duration, rate = :starter
|
47
|
+
duration = duration.to_f
|
48
|
+
rate = rate == :vielnutzer ? 2.0 : 2.5
|
49
|
+
if duration > 1440.0
|
50
|
+
price = (duration / 1440.0).floor * 39.00
|
51
|
+
price += (duration % 1440.0) / 10 * rate
|
52
|
+
else
|
53
|
+
price = (duration / 10.0).ceil * rate
|
54
|
+
end
|
55
|
+
|
56
|
+
{:price => price.round(2), :unit => 'EUR', :rate => rate }
|
57
|
+
end
|
58
|
+
|
46
59
|
private
|
47
60
|
|
48
61
|
def headers
|
data/lib/multicity/version.rb
CHANGED
data/lib/multicity.rb
CHANGED
metadata
CHANGED
@@ -1,129 +1,99 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: multicity
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 3
|
10
|
-
version: 1.1.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Simon Woker
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: &12702200 !ruby/object:Gem::Requirement
|
22
17
|
none: false
|
23
|
-
requirements:
|
18
|
+
requirements:
|
24
19
|
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 6
|
30
|
-
version: "1.6"
|
31
|
-
requirement: *id001
|
32
|
-
prerelease: false
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
33
22
|
type: :runtime
|
34
|
-
name: json
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
hash: 3
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
|
-
requirement: *id002
|
46
23
|
prerelease: false
|
47
|
-
|
24
|
+
version_requirements: *12702200
|
25
|
+
- !ruby/object:Gem::Dependency
|
48
26
|
name: mechanize
|
49
|
-
|
50
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
27
|
+
requirement: &12701580 !ruby/object:Gem::Requirement
|
51
28
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
requirement: *id003
|
60
|
-
prerelease: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
61
33
|
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *12701580
|
36
|
+
- !ruby/object:Gem::Dependency
|
62
37
|
name: xml-simple
|
63
|
-
|
64
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
38
|
+
requirement: &12700960 !ruby/object:Gem::Requirement
|
65
39
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
|
71
|
-
- 0
|
72
|
-
version: "0"
|
73
|
-
requirement: *id004
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
74
45
|
prerelease: false
|
75
|
-
|
46
|
+
version_requirements: *12700960
|
47
|
+
- !ruby/object:Gem::Dependency
|
76
48
|
name: rake
|
77
|
-
|
49
|
+
requirement: &12700260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *12700260
|
58
|
+
description: Wraps the Multicity JSON to use it nicely in your own environment. You
|
59
|
+
can use this Gem to read all cars that are available.
|
78
60
|
email: github@simonwoker.de
|
79
61
|
executables: []
|
80
|
-
|
81
62
|
extensions: []
|
82
|
-
|
83
63
|
extra_rdoc_files: []
|
84
|
-
|
85
|
-
files:
|
86
|
-
- lib/multicity/agent_multicity.rb
|
64
|
+
files:
|
87
65
|
- lib/multicity/multicity_agent.rb
|
88
66
|
- lib/multicity/multicity_car.rb
|
89
67
|
- lib/multicity/version.rb
|
90
68
|
- lib/multicity.rb
|
91
69
|
- LICENSE
|
92
70
|
- CHANGELOG.md
|
71
|
+
- README.md
|
93
72
|
homepage: https://github.com/swoker/multicity-ruby
|
94
73
|
licenses: []
|
95
|
-
|
96
74
|
post_install_message:
|
97
75
|
rdoc_options: []
|
98
|
-
|
99
|
-
require_paths:
|
76
|
+
require_paths:
|
100
77
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
79
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
segments:
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
segments:
|
108
85
|
- 0
|
109
|
-
|
110
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
hash: 442724271180259983
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
88
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
hash: 23
|
116
|
-
segments:
|
117
|
-
- 1
|
118
|
-
- 3
|
119
|
-
- 6
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
120
92
|
version: 1.3.6
|
121
93
|
requirements: []
|
122
|
-
|
123
94
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.8.
|
95
|
+
rubygems_version: 1.8.11
|
125
96
|
signing_key:
|
126
97
|
specification_version: 3
|
127
98
|
summary: Wrapper for the Multicity API
|
128
99
|
test_files: []
|
129
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class AgentMulticity
|
2
|
-
def load_all
|
3
|
-
agent = Multicity::Agent.new
|
4
|
-
cars = agent.get_cars
|
5
|
-
Sharable.transaction do
|
6
|
-
Sharable.delete_all :type_id => Tramobi::VALID_AGENTS["Multicity"], :city => "Berlin"
|
7
|
-
cars.each { |car| Sharable.from_multicity(car).save! }
|
8
|
-
end
|
9
|
-
cars.count
|
10
|
-
end
|
11
|
-
end
|