windward 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33f88a90556b980fac1775b2a744295d6b4b29b4
4
- data.tar.gz: d47801653da0910f13c79144463a3ca05326d787
3
+ metadata.gz: 69b97448b04a8beafab6cde631f40474979c031a
4
+ data.tar.gz: 0e66d1853a2526a3ef951137fbb1480e4c7eb4c6
5
5
  SHA512:
6
- metadata.gz: 1b518b1ffc825d21ea9adfe30a7e3a05bb599359993725919d6b44552f7c4099a28e066503cff4d590965dbc6b3a7a7e73fdf928b59af484d051f8c137e7d7ed
7
- data.tar.gz: a84e57dba6792eea5781e68e893deca48752c43623a5b4c802db4aae4684816fb57a08828d99128c2b1a34522c33c8288151a1ec95e3ac26f513ffc19a18d381
6
+ metadata.gz: fe8ab83df1b2010ec34c13e8dd9040e5fd5bdc830d3649b169a5007a7f7a904a862a21dc790da57fb50b541832568da666e268ffe738c0068462a3fa6638e8e2
7
+ data.tar.gz: cc1ee8d356bea3a09b74edc6fda3319b83125107d9652859a085ad98b3c60f25c6560e0aac556b2f2b915ea60b0c046faad75013a159be1f0a8f1e29f7f276d3
@@ -0,0 +1,135 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <cities>
3
+ <city>
4
+ <name>La Rochelle</name>
5
+ <zip_code>17300</zip_code>
6
+ </city>
7
+ <city>
8
+ <name>Toulouse</name>
9
+ <zip_code>31555</zip_code>
10
+ </city>
11
+ <city>
12
+ <name>Chaumont</name>
13
+ <zip_code>52121</zip_code>
14
+ </city>
15
+ <city>
16
+ <name>Marseille</name>
17
+ <zip_code>13055</zip_code>
18
+ </city>
19
+ <city>
20
+ <name>Strasbourg</name>
21
+ <zip_code>67482</zip_code>
22
+ </city>
23
+ <city>
24
+ <name>Nantes</name>
25
+ <zip_code>44109</zip_code>
26
+ </city>
27
+ <city>
28
+ <name>Ajaccio</name>
29
+ <zip_code>20004</zip_code>
30
+ </city>
31
+ <city>
32
+ <name>Tours</name>
33
+ <zip_code>37261</zip_code>
34
+ </city>
35
+ <city>
36
+ <name>Charleville-mézières</name>
37
+ <zip_code>08362</zip_code>
38
+ </city>
39
+ <city>
40
+ <name>Nîmes</name>
41
+ <zip_code>30007</zip_code>
42
+ </city>
43
+ <city>
44
+ <name>Rennes</name>
45
+ <zip_code>35238</zip_code>
46
+ </city>
47
+ <city>
48
+ <name>Quimper</name>
49
+ <zip_code>29019</zip_code>
50
+ </city>
51
+ <city>
52
+ <name>Pau</name>
53
+ <zip_code>64122</zip_code>
54
+ </city>
55
+ <city>
56
+ <name>Tarbes</name>
57
+ <zip_code>65440</zip_code>
58
+ </city>
59
+ <city>
60
+ <name>Lyon</name>
61
+ <zip_code>69123</zip_code>
62
+ </city>
63
+ <city>
64
+ <name>Mâcon</name>
65
+ <zip_code>71076</zip_code>
66
+ </city>
67
+ <city>
68
+ <name>Besançon</name>
69
+ <zip_code>25388</zip_code>
70
+ </city>
71
+ <city>
72
+ <name>Chambéry</name>
73
+ <zip_code>73054</zip_code>
74
+ </city>
75
+ <city>
76
+ <name>Perpignan</name>
77
+ <zip_code>66136</zip_code>
78
+ </city>
79
+ <city>
80
+ <name>Limoges</name>
81
+ <zip_code>87011</zip_code>
82
+ </city>
83
+ <city>
84
+ <name>Paris</name>
85
+ <zip_code>75101</zip_code>
86
+ </city>
87
+ <city>
88
+ <name>Amiens</name>
89
+ <zip_code>80561</zip_code>
90
+ </city>
91
+ <city>
92
+ <name>Nice</name>
93
+ <zip_code>06088</zip_code>
94
+ </city>
95
+ <city>
96
+ <name>Cherbourg</name>
97
+ <zip_code>50129</zip_code>
98
+ </city>
99
+ <city>
100
+ <name>Alençon</name>
101
+ <zip_code>61006</zip_code>
102
+ </city>
103
+ <city>
104
+ <name>Moulins</name>
105
+ <zip_code>03310</zip_code>
106
+ </city>
107
+ <city>
108
+ <name>Gap</name>
109
+ <zip_code>05061</zip_code>
110
+ </city>
111
+ <city>
112
+ <name>Aurillac</name>
113
+ <zip_code>15014</zip_code>
114
+ </city>
115
+ <city>
116
+ <name>Rouen</name>
117
+ <zip_code>76081</zip_code>
118
+ </city>
119
+ <city>
120
+ <name>Lille</name>
121
+ <zip_code>59350</zip_code>
122
+ </city>
123
+ <city>
124
+ <name>Metz</name>
125
+ <zip_code>57463</zip_code>
126
+ </city>
127
+ <city>
128
+ <name>Nevers</name>
129
+ <zip_code>58086</zip_code>
130
+ </city>
131
+ <city>
132
+ <name>Bordeaux</name>
133
+ <zip_code>33063</zip_code>
134
+ </city>
135
+ </cities>
data/lib/data/regions.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8" ?>
2
- <regions>
2
+ <provinces>
3
3
  <province>
4
4
  <id_departement>1</id_departement>
5
5
  <id_region>22</id_region>
@@ -800,4 +800,4 @@
800
800
  <name_province_uppercase>VAL D'OISE</name_province_uppercase>
801
801
  <province_slug>val-doise</province_slug>
802
802
  </province>
803
- </regions>
803
+ </provinces>
@@ -1,3 +1,3 @@
1
1
  module Windward
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/windward.rb CHANGED
@@ -2,36 +2,37 @@ require "windward/version"
2
2
  require 'mechanize'
3
3
 
4
4
  module Windward
5
-
5
+
6
6
  class Weather
7
7
 
8
8
  def initialize
9
9
  @departments = departments
10
+ @cities = cities
10
11
  @regions = load_data
11
12
  end
12
-
13
+
13
14
  def regions
14
15
  @regions.keys
15
16
  end
16
-
17
+
17
18
  def region(name)
18
19
  @regions[name]
19
20
  end
20
-
21
+
21
22
  def previsions(name)
22
23
  @regions[name]["previsions"]
23
24
  end
24
-
25
+
25
26
  def reload
26
27
  @regions = load_data
27
28
  end
28
-
29
+
29
30
  def self.root
30
31
  File.expand_path('../..',__FILE__)
31
32
  end
32
-
33
+
33
34
  private
34
-
35
+
35
36
  def departments
36
37
  doc = Nokogiri::XML(open(File.join Weather.root, "lib/data/regions.xml"))
37
38
  provinces = doc.root.xpath("province")
@@ -41,7 +42,17 @@ module Windward
41
42
  end
42
43
  departments
43
44
  end
44
-
45
+
46
+ def cities
47
+ doc = Nokogiri::XML(open(File.join Weather.root, "lib/data/cities.xml"))
48
+ data = doc.root.xpath("city")
49
+ cities = Hash.new
50
+ data.each do |p|
51
+ cities[p.at_xpath("zip_code").text] = p.at_xpath("name").text
52
+ end
53
+ cities
54
+ end
55
+
45
56
  def load_data
46
57
  a = Mechanize.new
47
58
  page = a.get('http://www.meteofrance.com/accueil')
@@ -63,13 +74,14 @@ module Windward
63
74
  temps = datum.css('span.picTemps').first.content.strip
64
75
  temper = datum.css('span.temper').first.content.strip
65
76
  department = @departments[datum['data-inseepp'][0..1]]
66
- previsions[department] = {"temps" => temps, "temper" => temper}
77
+ city = @cities[datum['data-inseepp'][0..4]]
78
+ previsions[department] = {"temps" => temps, "temper" => temper, "city" => city}
67
79
  end
68
80
  regions[name] = regions[name].merge({"previsions" => previsions})
69
81
  end
70
82
  regions
71
83
  end
72
-
84
+
73
85
  end
74
-
86
+
75
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: windward
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann VERY
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -65,6 +65,7 @@ files:
65
65
  - LICENSE.txt
66
66
  - README.md
67
67
  - Rakefile
68
+ - lib/data/cities.xml
68
69
  - lib/data/regions.xml
69
70
  - lib/windward.rb
70
71
  - lib/windward/version.rb
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.0.3
95
+ rubygems_version: 2.1.11
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: A parser for meteofrance.fr