cptec_inpe 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +12 -0
- data/README.md +12 -5
- data/Rakefile +4 -4
- data/cptec_inpe.gemspec +4 -1
- data/lib/cptec_inpe/utils.rb +6 -0
- data/lib/cptec_inpe/version.rb +1 -1
- data/lib/cptec_inpe.rb +37 -11
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29ac7b1643adb286b96e0e93734bbb08889e071e
|
4
|
+
data.tar.gz: a1527c9a4a1ce9c2e7034443d927b2c655317ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 312a38825d81e5340f7852c61f1402a1fc35519468976fec741d87ab5dfc90fd917a2a1f54bd7861ad46a32ab78a553c49625d0d6cd5f4a025492f3b06383fe9
|
7
|
+
data.tar.gz: 2e5d5f75bb8b31598592771509b0480ab6e64d75002409675411dcf4d57b501798486b4faacb697224662a402ea92446c2e8bfc25f1e187986c802be915a55fe
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.travis.yml
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
2
4
|
rvm:
|
3
5
|
- 2.2.2
|
6
|
+
|
7
|
+
script: 'bundle exec rake'
|
8
|
+
|
4
9
|
before_install: gem install bundler -v 1.10.5
|
10
|
+
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
recipients:
|
14
|
+
- tadeu.valentt@gemail.com
|
15
|
+
on_failure: change
|
16
|
+
on_success: never
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# CptecInpe
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/t4deu/cptec_inpe.svg?branch=master)](https://travis-ci.org/t4deu/cptec_inpe)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/t4deu/cptec_inpe/badge.svg?branch=master&service=github)](https://coveralls.io/github/t4deu/cptec_inpe?branch=master)
|
5
|
+
[![security](https://hakiri.io/github/t4deu/cptec_inpe/master.svg)](https://hakiri.io/github/t4deu/cptec_inpe/master)
|
4
6
|
|
5
|
-
|
7
|
+
Api Client gem for the CPTEC/INPE weather forecast.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -22,8 +24,14 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
```ruby
|
28
|
+
client = CptecInpe.new "Rio de janeiro"
|
26
29
|
|
30
|
+
client.location = "São Paulo" # Change current location
|
31
|
+
client.forecast # List of next days weather forecast
|
32
|
+
client.waves_today # Today waves forecast
|
33
|
+
client.waves_next_days # List of next days waves forecast
|
34
|
+
```
|
27
35
|
## Development
|
28
36
|
|
29
37
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -32,8 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
40
|
|
33
41
|
## Contributing
|
34
42
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
36
|
-
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/t4deu/cptec_inpe.
|
37
44
|
|
38
45
|
## License
|
39
46
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
3
|
|
4
|
-
Rake::TestTask.new(:
|
5
|
-
t.libs << "
|
4
|
+
Rake::TestTask.new(:spec) do |t|
|
5
|
+
t.libs << "spec"
|
6
6
|
t.libs << "lib"
|
7
|
-
t.test_files = FileList['
|
7
|
+
t.test_files = FileList['spec/**/*_spec.rb']
|
8
8
|
end
|
9
9
|
|
10
|
-
task :default => :
|
10
|
+
task :default => :spec
|
data/cptec_inpe.gemspec
CHANGED
@@ -22,5 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.10"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "minitest"
|
25
|
-
spec.add_development_dependency "
|
25
|
+
spec.add_development_dependency "minitest-reporters"
|
26
|
+
spec.add_development_dependency "coveralls"
|
27
|
+
|
28
|
+
spec.add_runtime_dependency "httparty", "~> 0.13.5"
|
26
29
|
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class Utils
|
2
|
+
def self.normalize(str)
|
3
|
+
str.tr("ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž",
|
4
|
+
"AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz").downcase
|
5
|
+
end
|
6
|
+
end
|
data/lib/cptec_inpe/version.rb
CHANGED
data/lib/cptec_inpe.rb
CHANGED
@@ -1,30 +1,52 @@
|
|
1
1
|
require "cptec_inpe/version"
|
2
|
-
require
|
2
|
+
require "cptec_inpe/utils"
|
3
|
+
require "httparty"
|
3
4
|
|
4
5
|
class CptecInpe
|
5
6
|
include HTTParty
|
6
7
|
|
7
|
-
attr_accessor :location
|
8
|
-
|
9
8
|
base_uri "servicos.cptec.inpe.br"
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
attr_reader :location_code
|
11
|
+
|
12
|
+
def initialize(str)
|
13
|
+
self.location = str unless str.nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
def location=(location)
|
17
|
+
city = find_location(location)
|
18
|
+
|
19
|
+
unless city.nil?
|
20
|
+
@location_code = city['id']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_location(location)
|
25
|
+
options = {
|
26
|
+
query: {
|
27
|
+
city: Utils.normalize(location)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
path = "#{base_path}/listaCidades"
|
32
|
+
cities = self.class.get(path, options)['cidades']
|
33
|
+
|
34
|
+
return if cities.nil?
|
35
|
+
return cities.first if cities['cidate'].is_a?(Array)
|
36
|
+
|
37
|
+
cities["cidade"]
|
13
38
|
end
|
14
39
|
|
15
40
|
def waves_today
|
16
|
-
|
17
|
-
self.class.get(path)
|
41
|
+
get "#{base_path}/cidade/%s/dia/0/ondas.xml"
|
18
42
|
end
|
19
43
|
|
20
44
|
def waves_next_days
|
21
|
-
|
22
|
-
self.class.get(path)
|
45
|
+
get "#{base_path}/cidade/%s/todos/tempos/ondas.xml"
|
23
46
|
end
|
24
47
|
|
25
48
|
def forecast
|
26
|
-
|
27
|
-
self.class.get(path)
|
49
|
+
get "#{base_path}/cidade/%s/previsao.xml"
|
28
50
|
end
|
29
51
|
|
30
52
|
private
|
@@ -32,4 +54,8 @@ class CptecInpe
|
|
32
54
|
def base_path
|
33
55
|
"/XML"
|
34
56
|
end
|
57
|
+
|
58
|
+
def get(path_format)
|
59
|
+
self.class.get(path_format % @location_code) unless @location_code.nil?
|
60
|
+
end
|
35
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cptec_inpe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadeu Valentt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-reporters
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: httparty
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,7 +87,7 @@ dependencies:
|
|
59
87
|
- - "~>"
|
60
88
|
- !ruby/object:Gem::Version
|
61
89
|
version: 0.13.5
|
62
|
-
type: :
|
90
|
+
type: :runtime
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
@@ -73,6 +101,7 @@ executables: []
|
|
73
101
|
extensions: []
|
74
102
|
extra_rdoc_files: []
|
75
103
|
files:
|
104
|
+
- ".coveralls.yml"
|
76
105
|
- ".gitignore"
|
77
106
|
- ".travis.yml"
|
78
107
|
- Gemfile
|
@@ -83,6 +112,7 @@ files:
|
|
83
112
|
- bin/setup
|
84
113
|
- cptec_inpe.gemspec
|
85
114
|
- lib/cptec_inpe.rb
|
115
|
+
- lib/cptec_inpe/utils.rb
|
86
116
|
- lib/cptec_inpe/version.rb
|
87
117
|
homepage: https://github.com/t4deu/cptec_inpe
|
88
118
|
licenses:
|