poundpay 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,13 +7,13 @@ Poundpay is a payments platform for marketplaces
7
7
 
8
8
  1. Add the following to your Gemfile
9
9
 
10
- gem 'poundpay', '~> 0.2.0'
10
+ gem 'poundpay', '~> 0.2.1'
11
11
 
12
12
  2. At the command prompt, install the gem with bundler
13
13
 
14
14
  bundle install
15
15
 
16
- 3. Add your configuration to config/poundpay.yml in your Rails project
16
+ 3. Create the file config/poundpay.yml and add your configurations
17
17
 
18
18
  development:
19
19
  developer_sid: DV0383d447360511e0bbac00264a09ff3c
@@ -25,7 +25,11 @@ Poundpay is a payments platform for marketplaces
25
25
  developer_sid: DV8dd93f0f3c6411e0863f00264a09ff3c
26
26
  auth_token: d8c4ea1bafd3fcac8c1062a72c22bcdb09321deb1041df257165cd6449def0de
27
27
 
28
- 4. Protect your callback controller
28
+ 4. Create the file initializers/poundpay.rb and add the following
29
+
30
+ Poundpay.configure_from_yaml "config/poundpay.yml"
31
+
32
+ 5. Protect your callback controller
29
33
 
30
34
  before_filter :verify_poundpay_callback
31
35
 
@@ -1,6 +1,10 @@
1
- if defined? Rails and Rails.root.join("config", "poundpay.yml").exist?
1
+ if defined? Rails
2
2
  module Poundpay
3
- @rails_config = YAML::load_file(Rails.root.join("config", "poundpay.yml"))[Rails.env]
4
- Poundpay.configure_from_hash(@rails_config)
3
+ def self.configure_from_yaml(path)
4
+ pathname = Pathname.new Rails.root.join(path)
5
+ raise ArgumentError.new "File does not exist: #{pathname.to_s}" unless pathname.exist?
6
+ config = YAML::load_file(pathname)[Rails.env]
7
+ Poundpay.configure_from_hash(config)
8
+ end
5
9
  end
6
10
  end
@@ -1,3 +1,3 @@
1
1
  module Poundpay
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/poundpay.rb CHANGED
@@ -13,13 +13,9 @@ module Poundpay
13
13
  attr_writer :api_version
14
14
 
15
15
  def configure(developer_sid, auth_token)
16
- if not developer_sid
17
- raise ArgumentError.new "developer_sid is required"
18
- end
19
-
20
- if not auth_token
21
- raise ArgumentError.new "auth_token is required"
22
- end
16
+ warn "warning: Poundpay is already configured" if configured?
17
+ raise ArgumentError.new "developer_sid is required" unless developer_sid
18
+ raise ArgumentError.new "auth_token is required" unless auth_token
23
19
 
24
20
  unless developer_sid.start_with? "DV"
25
21
  raise ArgumentError.new "developer_sid should start with 'DV'. Make sure " \
@@ -1,44 +1,47 @@
1
1
  require 'poundpay'
2
2
 
3
3
  describe Poundpay do
4
+ module Rails
5
+ end
6
+
4
7
  after (:each) do
5
8
  Poundpay.clear_config!
6
9
  end
7
10
 
8
11
  it "should automatically load config if exists" do
12
+ load File.expand_path("../../../lib/poundpay/rails.rb", __FILE__)
13
+
9
14
  module Rails
10
- class << self
11
- def root
12
- Pathname(File.expand_path("../../fixtures", __FILE__))
13
- end
14
-
15
- def env
16
- "development"
17
- end
15
+ def self.root
16
+ Pathname(File.expand_path("../../fixtures", __FILE__))
17
+ end
18
+
19
+ def self.env
20
+ "development"
18
21
  end
19
22
  end
20
-
23
+
21
24
  Poundpay.configured?.should be_false
22
- load File.expand_path("../../../lib/poundpay/rails.rb", __FILE__)
25
+ Poundpay.configure_from_yaml "config/poundpay.yml"
23
26
  Poundpay.configured?.should be_true
24
27
  Poundpay::Resource.password.should == "development_auth_token"
25
28
  end
26
29
 
27
30
  it "should not do anything if config does not exist" do
31
+ load File.expand_path("../../../lib/poundpay/rails.rb", __FILE__)
32
+
28
33
  module Rails
29
- class << self
30
- def root
31
- Pathname(File.expand_path("wrong_directory", __FILE__))
32
- end
33
-
34
- def env
35
- "development"
36
- end
34
+ def self.root
35
+ Pathname(File.expand_path("../../fixtures", __FILE__))
36
+ end
37
+
38
+ def self.env
39
+ "development"
37
40
  end
38
41
  end
39
-
42
+
40
43
  Poundpay.configured?.should be_false
41
- load File.expand_path("../../../lib/poundpay/rails.rb", __FILE__)
44
+ expect { Poundpay.configure_from_yaml "wrong_path" }.to raise_error(ArgumentError, /wrong_path/)
42
45
  Poundpay.configured?.should be_false
43
46
  Poundpay::Resource.password.should == nil
44
47
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matin Tamizi