meteoub-gem 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,20 +1,21 @@
1
- Copyright (c) 2013 Josep
1
+ The MIT License (MIT)
2
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:
3
+ Copyright (c) 2009 - 2013 Josep
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
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:
13
11
 
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.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ ### meteoub-gem
2
+
3
+ A rewrite of the MeteoUB library which gets, parses and stores weather data from *infomet.am.ub.es*: [www.dat](http://infomet.am.ub.es/campbell/www.dat) and [maxmin.dat](http://infomet.am.ub.edu/campbell/maxmin.dat)
4
+
5
+ ### License
6
+
7
+ The MIT License (MIT)
8
+
9
+ Copyright (c) 2009 - 2013 Josep
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in
19
+ all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ THE SOFTWARE.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/bin/meteoub CHANGED
@@ -10,3 +10,5 @@ require 'meteoub-gem'
10
10
 
11
11
  dades = MeteoUB::Data.new
12
12
  p dades.temperature
13
+ p dades.temperature_max, dades.datetime_max
14
+ p dades.temperature_min, dades.datetime_min
data/lib/meteoub-gem.rb CHANGED
@@ -3,7 +3,8 @@ require 'date'
3
3
  require 'active_record'
4
4
 
5
5
  module MeteoUB
6
- DATA_URL = 'http://infomet.am.ub.es/campbell/www.dat'
6
+ DATA_URL = 'http://infomet.am.ub.es/campbell/www.dat'
7
+ MAXMIN_URL = 'http://infomet.am.ub.edu/campbell/maxmin.dat'
7
8
 
8
9
  class Data
9
10
  attr_accessor :data_uri
@@ -20,14 +21,20 @@ module MeteoUB
20
21
  attr_accessor :max_wind_speed
21
22
  attr_accessor :max_wind_speed_km_h
22
23
  attr_accessor :windrose
24
+ attr_accessor :temperature_max
25
+ attr_accessor :datetime_max
26
+ attr_accessor :temperature_min
27
+ attr_accessor :datetime_min
23
28
 
24
29
  def initialize(params = {})
25
- @data_uri = URI(DATA_URL)
30
+ @data_uri = URI(DATA_URL)
31
+ @maxmin_uri = URI(MAXMIN_URL)
26
32
  parse if get
27
33
  end
28
34
 
29
35
  def get
30
- @raw_data = Net::HTTP.get(@data_uri).split("\n")
36
+ @raw_data = Net::HTTP.get(@data_uri).split("\n")
37
+ @raw_maxmin = Net::HTTP.get(@maxmin_uri).split("\n")
31
38
  true
32
39
  rescue
33
40
  false
@@ -45,6 +52,8 @@ module MeteoUB
45
52
  @max_wind_speed = @raw_data[12].to_f
46
53
  @max_wind_speed_km_h = @max_wind_speed * 3.6
47
54
  @windrose = parse_windrose(@raw_data[13].to_f)
55
+ @temperature_max, @datetime_max = parse_maxmin(@raw_maxmin[0])
56
+ @temperature_min, @datetime_min = parse_maxmin(@raw_maxmin[1])
48
57
  end
49
58
 
50
59
  def parse_date(date_raw)
@@ -55,6 +64,15 @@ module MeteoUB
55
64
  end
56
65
  DateTime.strptime(@raw_data[0] + " #{hour}:#{minutes} UTC", "%d-%m-%y %k:%M %Z")
57
66
  end
67
+ def parse_maxmin(maxmin_raw)
68
+ temperature, time, date = maxmin_raw.split(" ")
69
+ hour, minutes = time.split(":")
70
+ if minutes == 60
71
+ minutes = 0
72
+ hour += 1
73
+ end
74
+ [temperature.to_f, DateTime.strptime("#{date} #{hour}:#{minutes} UTC", "%Y%m%d %k:%M %Z")]
75
+ end
58
76
 
59
77
  # http://cbc.riocean.com/wstat/012006rose.html
60
78
  def parse_windrose(windrose_raw)
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "meteoub-gem"
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Josep"]
12
+ s.date = "2013-05-02"
13
+ s.description = "A rewrite of the MeteoUB library wich gets, parses and stores weather data from infomet.am.ub.es"
14
+ s.email = "apuratepp@gmail.com"
15
+ s.executables = ["meteoub"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/meteoub",
29
+ "lib/meteoub-gem.rb",
30
+ "meteoub-gem.gemspec",
31
+ "test/helper.rb",
32
+ "test/test_meteoub-gem.rb"
33
+ ]
34
+ s.homepage = "http://github.com/apuratepp/meteoub-gem"
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = "1.8.24"
38
+ s.summary = "A rewrite of the MeteoUB library wich gets, parses and stores weather data from infomet.am.ub.es"
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<activerecord>, [">= 0"])
45
+ s.add_runtime_dependency(%q<json>, [">= 0"])
46
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
47
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
48
+ s.add_development_dependency(%q<bundler>, [">= 0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<activerecord>, [">= 0"])
53
+ s.add_dependency(%q<json>, [">= 0"])
54
+ s.add_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_dependency(%q<rdoc>, [">= 0"])
56
+ s.add_dependency(%q<bundler>, [">= 0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
58
+ s.add_dependency(%q<rcov>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<activerecord>, [">= 0"])
62
+ s.add_dependency(%q<json>, [">= 0"])
63
+ s.add_dependency(%q<shoulda>, [">= 0"])
64
+ s.add_dependency(%q<rdoc>, [">= 0"])
65
+ s.add_dependency(%q<bundler>, [">= 0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ end
69
+ end
70
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meteoub-gem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josep
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-03-28 00:00:00 Z
18
+ date: 2013-05-02 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -125,17 +125,18 @@ extensions: []
125
125
 
126
126
  extra_rdoc_files:
127
127
  - LICENSE.txt
128
- - README.rdoc
128
+ - README.md
129
129
  files:
130
130
  - .document
131
131
  - Gemfile
132
132
  - Gemfile.lock
133
133
  - LICENSE.txt
134
- - README.rdoc
134
+ - README.md
135
135
  - Rakefile
136
136
  - VERSION
137
137
  - bin/meteoub
138
138
  - lib/meteoub-gem.rb
139
+ - meteoub-gem.gemspec
139
140
  - test/helper.rb
140
141
  - test/test_meteoub-gem.rb
141
142
  homepage: http://github.com/apuratepp/meteoub-gem
data/README.rdoc DELETED
@@ -1,9 +0,0 @@
1
- = meteoub-gem
2
-
3
- A rewrite of the MeteoUB library wich gets, parses and stores weather data from [infomet.am.ub.es](http://infomet.am.ub.es/campbell/www.dat)
4
-
5
- == Copyright
6
-
7
- Copyright (c) 2013 Josep. See LICENSE.txt for
8
- further details.
9
-