mityc-geoportal 0.0.1 → 0.0.2
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.
- data/License +20 -0
- data/README.md +25 -0
- data/lib/mityc-geoportal/measure.rb +11 -4
- data/lib/mityc-geoportal/version.rb +1 -1
- metadata +9 -7
data/License
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Vicente Reig Rincón de Arellano
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# mityc-geoportal
|
2
|
+
|
3
|
+
Provides access to the fuel prices published by the Spanish Government.
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
include Mityc::Geoportal
|
9
|
+
|
10
|
+
fuels = Fuel.all
|
11
|
+
|
12
|
+
fuels.each { |fuel|
|
13
|
+
puts "Downloading latest price update for #{fuel.name}..."
|
14
|
+
fuel.measures.each { |measure|
|
15
|
+
puts measure
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
provinces = Provinces.all
|
20
|
+
provinces.each { |province|
|
21
|
+
puts "Downloading cities for #{province.name}..."
|
22
|
+
cities = province.cities
|
23
|
+
}
|
24
|
+
|
25
|
+
```
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'iconv'
|
2
|
+
|
1
3
|
class Mityc::Geoportal::Measure
|
2
4
|
include HappyMapper, HTTParty
|
3
5
|
|
@@ -21,8 +23,7 @@ class Mityc::Geoportal::Measure
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def measured_at
|
24
|
-
@measured_at =
|
25
|
-
@measured_at = Date.new(*@measured_at)
|
26
|
+
@measured_at = Date.new(*transform_measured_at)
|
26
27
|
end
|
27
28
|
|
28
29
|
def public_sale
|
@@ -51,7 +52,7 @@ class Mityc::Geoportal::Measure
|
|
51
52
|
|
52
53
|
def margin
|
53
54
|
@margin = @margin.strip
|
54
|
-
if @margin =~
|
55
|
+
if @margin =~ /^i$/i
|
55
56
|
"left"
|
56
57
|
elsif @margin =~/^d$/i
|
57
58
|
"right"
|
@@ -69,11 +70,17 @@ class Mityc::Geoportal::Measure
|
|
69
70
|
end
|
70
71
|
protected
|
71
72
|
def measures_html
|
72
|
-
self.get('/searchTotal.do', query: query_params).body
|
73
|
+
response_body = self.get('/searchTotal.do', query: query_params).body
|
74
|
+
Iconv.iconv('UTF-8', 'ISO-8859-15', response_body).first
|
73
75
|
end
|
74
76
|
|
75
77
|
def query_params
|
76
78
|
{ tipoCons: 1, tipoBusqueda: 0, tipoCarburante: self.fuel_id }
|
77
79
|
end
|
78
80
|
end
|
81
|
+
|
82
|
+
protected
|
83
|
+
def transform_measured_at
|
84
|
+
@measured_at.split(/\//).map(&:to_i).reverse
|
85
|
+
end
|
79
86
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mityc-geoportal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: unhappymapper
|
16
|
-
requirement: &
|
16
|
+
requirement: &70254936698100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70254936698100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &70254936697680 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70254936697680
|
36
36
|
description: Simple wrapper to the fuel prices published by the Spanish Government
|
37
37
|
through http://geoportal.mityc.es/
|
38
38
|
email:
|
@@ -44,6 +44,8 @@ files:
|
|
44
44
|
- .gitignore
|
45
45
|
- .rvmrc
|
46
46
|
- Gemfile
|
47
|
+
- License
|
48
|
+
- README.md
|
47
49
|
- Rakefile
|
48
50
|
- lib/mityc-geoportal.rb
|
49
51
|
- lib/mityc-geoportal/city.rb
|
@@ -72,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
74
|
version: '0'
|
73
75
|
requirements: []
|
74
76
|
rubyforge_project: mityc-geoportal
|
75
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.10
|
76
78
|
signing_key:
|
77
79
|
specification_version: 3
|
78
80
|
summary: Provides access to the fuel prices published by the Spanish Government.
|