wunderground 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.0
data/lib/wunderground.rb CHANGED
@@ -13,7 +13,13 @@ class Wunderground
13
13
 
14
14
  attr_accessor :api_key, :timeout, :throws_exceptions, :language
15
15
 
16
- def initialize(api_key = nil, extra_params = {})
16
+ def initialize(*args)
17
+ extra_params = {}
18
+ if !args.nil?
19
+ api_key = args.first if args.first.is_a?(String)
20
+ extra_params = args.last if args.last.is_a?(Hash)
21
+ end
22
+
17
23
  @api_key = api_key || ENV['WUNDERGROUND_API_KEY'] || ENV['WUNDERGROUND_APIKEY'] || self.class.api_key
18
24
  @timeout = extra_params[:timeout] || 30
19
25
  @throws_exceptions = extra_params[:throws_exceptions] || false
@@ -24,19 +24,6 @@ class TestWunderground < Test::Unit::TestCase
24
24
  assert_equal(60,@wunderground.timeout)
25
25
  assert_equal('FR',@wunderground.language)
26
26
  end
27
- should "set an API key from the 'WUNDERGROUND_API_KEY' ENV variable" do
28
- ENV['WUNDERGROUND_API_KEY'] = @api_key
29
- @wunderground = Wunderground.new
30
- assert_equal(@api_key, @wunderground.api_key)
31
- ENV.delete('WUNDERGROUND_API_KEY')
32
- end
33
-
34
- should "set an API key from the 'WUNDERGROUND_APIKEY' ENV variable" do
35
- ENV['WUNDERGROUND_APIKEY'] = @api_key
36
- @wunderground = Wunderground.new
37
- assert_equal(@api_key, @wunderground.api_key)
38
- ENV.delete('WUNDERGROUND_APIKEY')
39
- end
40
27
 
41
28
  should "set an API key via setter" do
42
29
  @wunderground = Wunderground.new
@@ -50,6 +37,32 @@ class TestWunderground < Test::Unit::TestCase
50
37
  @wunderground.timeout = timeout
51
38
  assert_equal(timeout, @wunderground.timeout)
52
39
  end
40
+
41
+ context "ENV api key" do
42
+ setup do
43
+ ENV['WUNDERGROUND_API_KEY'] = @api_key
44
+ end
45
+
46
+ teardown do
47
+ ENV.delete('WUNDERGROUND_API_KEY')
48
+ end
49
+
50
+ should "set an API key from the 'WUNDERGROUND_API_KEY' ENV variable" do
51
+ @wunderground = Wunderground.new
52
+ assert_equal(@api_key, @wunderground.api_key)
53
+ end
54
+
55
+ should "set an API key from the 'WUNDERGROUND_APIKEY' ENV variable" do
56
+ @wunderground = Wunderground.new
57
+ assert_equal(@api_key, @wunderground.api_key)
58
+ end
59
+
60
+ should "set timeout and language in constructor" do
61
+ @wunderground = Wunderground.new(timeout: 60, language: 'FR')
62
+ assert_equal(60,@wunderground.timeout)
63
+ assert_equal('FR',@wunderground.language)
64
+ end
65
+ end
53
66
  end
54
67
 
55
68
  context "api url" do
data/wunderground.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wunderground"
8
- s.version = "1.0.1"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Winfred Nadeau"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderground
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -188,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  segments:
190
190
  - 0
191
- hash: -4516707908487803297
191
+ hash: 961218802401752725
192
192
  required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements: