postageapp 1.0.6 → 1.0.7

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.6
1
+ 1.0.7
data/lib/postageapp.rb CHANGED
@@ -26,6 +26,10 @@ module PostageApp
26
26
  # config.api_key = '1234567890abcdef'
27
27
  # config.recipient_override = 'test@test.test' if Rails.env.staging?
28
28
  # end
29
+ #
30
+ # If you do not want/need to initialize the gem in this way, you can use the environment
31
+ # variable POSTAGEAPP_API_KEY to set up your key.
32
+
29
33
  def configure
30
34
  yield configuration
31
35
  end
@@ -1,8 +1,5 @@
1
1
  class PostageApp::Configuration
2
2
 
3
- # The API key of your postageapp.com project
4
- attr_accessor :api_key
5
-
6
3
  # +true+ for https, +false+ for http connections (default: is +true+)
7
4
  attr_accessor :secure
8
5
 
@@ -68,6 +65,14 @@ class PostageApp::Configuration
68
65
 
69
66
  alias_method :secure?, :secure
70
67
 
68
+ def api_key=(key)
69
+ @api_key = key
70
+ end
71
+
72
+ def api_key
73
+ @api_key || ENV['POSTAGEAPP_API_KEY']
74
+ end
75
+
71
76
  def protocol
72
77
  @protocol || if secure?
73
78
  'https'
data/postageapp.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{postageapp}
8
- s.version = "1.0.6"
8
+ s.version = "1.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oleg Khabarov, The Working Group Inc"]
12
- s.date = %q{2010-09-08}
12
+ s.date = %q{2010-09-23}
13
13
  s.description = %q{Gem that interfaces with PostageApp.com service to send emails from web apps}
14
14
  s.email = %q{oleg@twg.ca}
15
15
  s.extra_rdoc_files = [
@@ -2,7 +2,7 @@ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class ConfigurationTest < Test::Unit::TestCase
4
4
 
5
- def test_intitialization_defaults
5
+ def test_initialization_defaults
6
6
  config = PostageApp::Configuration.new
7
7
 
8
8
  assert_equal true, config.secure
@@ -34,7 +34,7 @@ class ConfigurationTest < Test::Unit::TestCase
34
34
  assert_equal 999, config.port
35
35
  end
36
36
 
37
- def test_intitialization_for_secure
37
+ def test_initialization_for_secure
38
38
  config = PostageApp::Configuration.new
39
39
 
40
40
  config.secure = true
@@ -45,7 +45,7 @@ class ConfigurationTest < Test::Unit::TestCase
45
45
  assert config.secure?
46
46
  end
47
47
 
48
- def test_intialization_for_insecure
48
+ def test_initialization_for_insecure
49
49
  config = PostageApp::Configuration.new
50
50
 
51
51
  config.secure = false
@@ -56,6 +56,18 @@ class ConfigurationTest < Test::Unit::TestCase
56
56
  assert !config.secure?
57
57
  end
58
58
 
59
+ def test_initialization_with_env_api_key
60
+ ENV['POSTAGEAPP_API_KEY'] = 'env_api_key'
61
+
62
+ config = PostageApp::Configuration.new
63
+ assert_equal 'env_api_key', config.api_key
64
+
65
+ config.api_key = 'config_api_key'
66
+ assert_equal 'config_api_key', config.api_key
67
+
68
+ ENV['POSTAGEAPP_API_KEY'] = nil # must unset for other methods to run properly
69
+ end
70
+
59
71
  def test_method_url
60
72
  config = PostageApp::Configuration.new
61
73
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postageapp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 6
10
- version: 1.0.6
9
+ - 7
10
+ version: 1.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oleg Khabarov, The Working Group Inc
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-08 00:00:00 -04:00
18
+ date: 2010-09-23 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency