multicity 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012 Simon Woker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ module Multicity
2
+ class Agent
3
+
4
+ @@options = {
5
+ :url_list => 'https://kunden.multicity-carsharing.de/kundenbuchung/hal2ajax_process.php?zoom=10&lng1=&lat1=&lng2=&lat2=&stadtCache=&mapstation_id=&mapstadt_id=&verwaltungfirma=&centerLng=13.382322739257802&centerLat=52.50734843957503&searchmode=buchanfrage&with_staedte=false&buchungsanfrage=N&lat=52.50734843957503&lng=13.382322739257802&instant_access=J&open_end=J&objectname=multicitymarker&ignore_virtual_stations=J&before=null&after=null&ajxmod=hal2map&callee=getMarker',
6
+ :url_area => 'https://www.multicity-carsharing.de/wp-content/plugins/multicity_map/geschaeftsbereich.kml'
7
+ }
8
+
9
+ def get_cars
10
+ agent = Mechanize.new
11
+
12
+ data = agent.get(@@options[:url_list], headers).body
13
+ marker = data.scan(/"marker":\[(.*?)\],"/).first
14
+ marker = marker.to_s.gsub(' ', ' ')
15
+ marker = JSON.parse("[#{marker}]")
16
+ marker.map { |item| Car.new(item) }
17
+ end
18
+
19
+ private
20
+
21
+ def headers
22
+ {
23
+ "user-agent" => "Multicity Rubygem",
24
+ "content-type" => "application/x-www-form-urlencoded;charset=utf-8",
25
+ "accept-charset" => "utf-8"
26
+ }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ module Multicity
2
+ class Car
3
+ attr_reader :json
4
+ attr_accessor :position, :license_plate, :id, :model
5
+
6
+ # Example hash
7
+ # {"lat"=>"52.5359483", "hal2option"=>{"mouseout"=>"hideToolTip", "maxZoom"=>"", "clustername"=>"multicitycluster", "click"=>"showMarkerInfos", "id"=>"284964", "minZoom"=>"4", "tooltip"=>"'Citroën C-Zero (B-MC 1694)'", "bende"=>"1359122400", "StationInfoTyp"=>"HM_AUTO_INFO", "rclick"=>false, "dblclick"=>false, "objecttyp"=>"carpos", "objectname"=>"multicitymarker", "draggable"=>false, "mouseover"=>"showToolTip", "openinfo"=>"showMarkerInfos", "banfang"=>"1359118800"}, "iconName"=>"carIcon", "iconNameSelected"=>"carIconSelected", "lng"=>"13.4432250"}
8
+ def initialize hash
9
+ @json = hash
10
+
11
+ tooltip = json["hal2option"]["tooltip"].gsub "'", ""
12
+ if tooltip != "false"
13
+ self.position = { :lat => json["lat"], :lon => json["lng"] }
14
+ self.id = json["hal2option"]["id"]
15
+ tips = tooltip.split(" ")
16
+ if (tips.count == 2)
17
+ self.model = tips[0]
18
+ self.license_plate = tips[1].to_s.gsub("(", "").gsub(")", "")
19
+ else
20
+ self.model = "Citroën C-Zero"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Multicity
2
+ VERSION = "1.0.0"
3
+ end
data/lib/multicity.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'mechanize'
3
+ require 'json'
4
+
5
+ require 'multicity/multicity_car'
6
+ require 'multicity/multicity_agent'
7
+
8
+ module Multicity
9
+ $KCODE = "U"
10
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multicity
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Simon Woker
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-01-25 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ name: json
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 1
31
+ - 6
32
+ version: "1.6"
33
+ requirement: *id001
34
+ type: :runtime
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ name: mechanize
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ requirement: *id002
48
+ type: :runtime
49
+ - !ruby/object:Gem::Dependency
50
+ prerelease: false
51
+ name: rake
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirement: *id003
62
+ type: :development
63
+ description: Wraps the Multicity JSON to use it nicely in your own environment. You can use this Gem to read all cars that are available.
64
+ email: github@simonwoker.de
65
+ executables: []
66
+
67
+ extensions: []
68
+
69
+ extra_rdoc_files: []
70
+
71
+ files:
72
+ - lib/multicity/multicity_agent.rb
73
+ - lib/multicity/multicity_car.rb
74
+ - lib/multicity/version.rb
75
+ - lib/multicity.rb
76
+ - LICENSE
77
+ - CHANGELOG.md
78
+ homepage: https://github.com/swoker/multicity-ruby
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options: []
83
+
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 23
101
+ segments:
102
+ - 1
103
+ - 3
104
+ - 6
105
+ version: 1.3.6
106
+ requirements: []
107
+
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.24
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Wrapper for the Multicity API
113
+ test_files: []
114
+