Skip to content

Commit 4e83cdf

Browse files
committed
Merge branch 'yonelacort-appid'
2 parents 2754893 + 97d7835 commit 4e83cdf

32 files changed

+1178
-76
lines changed

.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--color
2+
--require spec_helper
3+
--format documentation

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
source 'http://rubygems.org'
22

33
gem 'rspec'
4+
gem 'vcr'
5+
gem 'webmock'

Gemfile.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
GEM
22
remote: http://rubygems.org/
33
specs:
4+
addressable (2.3.6)
5+
crack (0.4.2)
6+
safe_yaml (~> 1.0.0)
47
diff-lcs (1.2.2)
58
rspec (2.13.0)
69
rspec-core (~> 2.13.0)
@@ -10,9 +13,16 @@ GEM
1013
rspec-expectations (2.13.0)
1114
diff-lcs (>= 1.1.3, < 2.0)
1215
rspec-mocks (2.13.0)
16+
safe_yaml (1.0.3)
17+
vcr (2.9.2)
18+
webmock (1.18.0)
19+
addressable (>= 2.3.6)
20+
crack (>= 0.3.2)
1321

1422
PLATFORMS
1523
ruby
1624

1725
DEPENDENCIES
1826
rspec
27+
vcr
28+
webmock

README.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,61 @@ Add the following to your **Gemfile**
1212

1313
## Usage
1414

15-
require 'open_weather'
1615

17-
# current weather APIs
16+
### Current weather information API
1817

19-
# get current weather by city name
20-
OpenWeather::Current.city("Cochin, IN")
18+
```ruby
19+
require 'open_weather'
2120

22-
# get current weather by city id
23-
OpenWeather::Current.city_id("1273874")
21+
# get current weather by city name
22+
OpenWeather::Current.city("Cochin, IN")
2423

25-
# get current weather by geocode. (lat, lon)
26-
OpenWeather::Current.geocode(9.94, 76.26)
24+
# get current weather by city id
25+
OpenWeather::Current.city_id("1273874")
2726

28-
# get the current weather in degrees celsius
29-
OpenWeather::Current.city("Cochin, IN", units: 'metric')
27+
# get current weather by geocode. (lat, lon)
28+
OpenWeather::Current.geocode(9.94, 76.26)
3029

31-
# weather forecast APIs
30+
# get the current weather in degrees celsius
31+
OpenWeather::Current.city("Cochin, IN", units: 'metric')
32+
```
3233

33-
# get weather forecast by city name
34-
OpenWeather::Forecast.city("Cochin, IN")
34+
Documentation about the current weather end-point:
35+
http://openweathermap.org/current
3536

36-
# get weather forecast by city name in fahrenheit
37-
OpenWeather::Forecast.city("Cochin, IN", units: 'imperial')
3837

39-
# get weather forecast by city id
40-
OpenWeather::Forecast.city_id("1273874")
38+
### Weather forecast API
39+
40+
```ruby
41+
require 'open_weather'
42+
43+
# get weather forecast by city name
44+
OpenWeather::Forecast.city("Cochin, IN")
45+
46+
# get weather forecast by city name in fahrenheit
47+
OpenWeather::Forecast.city("Cochin, IN", units: 'imperial')
48+
49+
# get weather forecast by city id
50+
OpenWeather::Forecast.city_id("1273874")
51+
52+
# get weather forecast by geocode. (lat, lon)
53+
OpenWeather::Forecast.geocode(9.94, 76.26)
54+
```
55+
56+
Doucumentation about the weather forecast end-point:
57+
http://openweathermap.org/forecast
58+
59+
#### Using the API key
60+
61+
```ruby
62+
# get current weather by city name
63+
options = { units: "metric", APPID: 1111111111 }
64+
OpenWeather::Current.city("Berlin, DE", options)
65+
```
66+
67+
How to get an API key and tips for an effective usage of the API:
68+
http://openweathermap.org/appid
4169

42-
# get weather forecast by geocode. (lat, lon)
43-
OpenWeather::Forecast.geocode(9.94, 76.26)
4470

4571
## Contributing
4672

lib/open_weather/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def success?
2424
private
2525

2626
def extract_options!(options)
27-
valid_options = [:lat, :lon, :city, :country, :id, :units]
27+
valid_options = [:lat, :lon, :city, :country, :id, :units, :APPID]
2828
options.keys.each { |k| options.delete(k) unless valid_options.include?(k) }
2929

3030
if options[:city] || options[:country]

lib/open_weather/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module OpenWeather
2-
VERSION = "0.9.2"
2+
VERSION = "0.10.0"
33
end

open_weather.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ Gem::Specification.new do |gem|
1414
gem.executables = gem.files.grep(/^bin/).map{ |f| File.basename(f) }
1515
gem.require_paths = ["lib"]
1616
gem.add_development_dependency "rspec"
17+
gem.add_development_dependency "vcr"
18+
gem.add_development_dependency "webmock"
1719
gem.add_runtime_dependency 'json'
1820
end

spec/fixtures/cassettes/api/current_city_id_invalid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/cassettes/api/current_city_id_valid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/cassettes/api/current_city_imperial_valid.yml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)