jonathantron-paypal 3.0.0pre3 → 3.0.0pre4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  = 3.0.0 (git)
2
2
 
3
+ Update spec task to use the new RSpec module name
4
+ Remove constant/class variable usage and use Thread specific configurations
3
5
  Start spec on Paypal::Helpers::Common.paypal_setup
4
6
  Fix specs for Paypal::Config
5
7
  Upgrade dev dependencies to use Rspec >= 2.0.0.a
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source :gemcutter
2
2
 
3
+ gem "bundler"
3
4
  gem "rack", ">= 1.0.0"
4
5
  gem "json_pure"
5
6
  gem "rake"
data/Gemfile.lock ADDED
@@ -0,0 +1,89 @@
1
+ ---
2
+ dependencies:
3
+ fakeweb:
4
+ group:
5
+ - :default
6
+ version: ">= 0"
7
+ require:
8
+ - fakeweb
9
+ bluecloth:
10
+ group:
11
+ - :default
12
+ version: ">= 0"
13
+ rake:
14
+ group:
15
+ - :default
16
+ version: ">= 0"
17
+ rspec:
18
+ group:
19
+ - :default
20
+ version: ">= 2.0.0.a"
21
+ yard:
22
+ group:
23
+ - :default
24
+ version: ">= 0"
25
+ rack:
26
+ group:
27
+ - :default
28
+ version: ">= 1.0.0"
29
+ rcov:
30
+ group:
31
+ - :default
32
+ version: ">= 0.9.8"
33
+ jeweler:
34
+ group:
35
+ - :default
36
+ version: ">= 0"
37
+ bundler:
38
+ group:
39
+ - :default
40
+ version: ">= 0"
41
+ json_pure:
42
+ group:
43
+ - :default
44
+ version: ">= 0"
45
+ nokogiri:
46
+ group:
47
+ - :default
48
+ version: ">= 0"
49
+ specs:
50
+ - rake:
51
+ version: 0.8.7
52
+ - bluecloth:
53
+ version: 2.0.7
54
+ - bundler:
55
+ version: 0.9.25
56
+ - diff-lcs:
57
+ version: 1.1.2
58
+ - fakeweb:
59
+ version: 1.2.8
60
+ - json_pure:
61
+ version: 1.4.3
62
+ - gemcutter:
63
+ version: 0.5.0
64
+ - git:
65
+ version: 1.2.5
66
+ - rubyforge:
67
+ version: 2.0.4
68
+ - jeweler:
69
+ version: 1.4.0
70
+ - nokogiri:
71
+ version: 1.4.2
72
+ - rack:
73
+ version: 1.2.1
74
+ - rcov:
75
+ version: 0.9.8
76
+ - rspec-core:
77
+ version: 2.0.0.beta.17
78
+ - rspec-expectations:
79
+ version: 2.0.0.beta.17
80
+ - rspec-mocks:
81
+ version: 2.0.0.beta.17
82
+ - rspec:
83
+ version: 2.0.0.beta.17
84
+ - yard:
85
+ version: 0.5.8
86
+ hash: f248241b76b1508705a1057a180c95c99716930f
87
+ sources:
88
+ - Rubygems:
89
+ uri: http://gemcutter.org
data/Rakefile CHANGED
@@ -27,8 +27,8 @@ rescue LoadError
27
27
  end
28
28
 
29
29
  require "rspec/core/rake_task"
30
- ::Rspec::Core::RakeTask.new(:spec)
31
- ::Rspec::Core::RakeTask.new(:rcov) do |spec|
30
+ ::RSpec::Core::RakeTask.new(:spec)
31
+ ::RSpec::Core::RakeTask.new(:rcov) do |spec|
32
32
  spec.rcov = true
33
33
  spec.rcov_opts = "--exclude spec/"
34
34
  end
@@ -0,0 +1,90 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{jonathantron-paypal}
8
+ s.version = "3.0.0pre4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jonathan Tron", "Joseph Halter", "Tobias Luetke"]
12
+ s.date = %q{2010-07-16}
13
+ s.description = %q{Integrate Paypal Express}
14
+ s.email = %q{jonathan@tron.name}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "CHANGELOG.md",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE",
26
+ "README.md",
27
+ "Rakefile",
28
+ "jonathantron-paypal.gemspec",
29
+ "lib/paypal.rb",
30
+ "lib/paypal/certs/paypal_sandbox.pem",
31
+ "lib/paypal/config.rb",
32
+ "lib/paypal/helpers/common.rb",
33
+ "lib/paypal/helpers/rails.rb",
34
+ "lib/paypal/notification.rb",
35
+ "lib/paypal/rails.rb",
36
+ "lib/paypal/version.rb",
37
+ "misc/PayPal - Instant Payment Notification - Technical Overview.pdf",
38
+ "misc/multiruby.sh",
39
+ "misc/paypal.psd",
40
+ "spec/config_spec.rb",
41
+ "spec/fixtures/business_cert.pem",
42
+ "spec/fixtures/business_key.pem",
43
+ "spec/helpers/common_spec.rb",
44
+ "spec/notification_spec.rb",
45
+ "spec/spec_helper.rb"
46
+ ]
47
+ s.homepage = %q{http://github.com/JonathanTron/paypal}
48
+ s.rdoc_options = ["--charset=UTF-8"]
49
+ s.require_paths = ["lib"]
50
+ s.rubygems_version = %q{1.3.6}
51
+ s.summary = %q{Paypal Express Integration}
52
+ s.test_files = [
53
+ "spec/config_spec.rb",
54
+ "spec/helpers/common_spec.rb",
55
+ "spec/notification_spec.rb",
56
+ "spec/spec_helper.rb"
57
+ ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<rack>, [">= 1.0.0"])
65
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0.a"])
66
+ s.add_development_dependency(%q<rcov>, [">= 0.9.8"])
67
+ s.add_development_dependency(%q<nokogiri>, [">= 0"])
68
+ s.add_development_dependency(%q<bluecloth>, [">= 0"])
69
+ s.add_development_dependency(%q<yard>, [">= 0"])
70
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
71
+ else
72
+ s.add_dependency(%q<rack>, [">= 1.0.0"])
73
+ s.add_dependency(%q<rspec>, [">= 2.0.0.a"])
74
+ s.add_dependency(%q<rcov>, [">= 0.9.8"])
75
+ s.add_dependency(%q<nokogiri>, [">= 0"])
76
+ s.add_dependency(%q<bluecloth>, [">= 0"])
77
+ s.add_dependency(%q<yard>, [">= 0"])
78
+ s.add_dependency(%q<fakeweb>, [">= 0"])
79
+ end
80
+ else
81
+ s.add_dependency(%q<rack>, [">= 1.0.0"])
82
+ s.add_dependency(%q<rspec>, [">= 2.0.0.a"])
83
+ s.add_dependency(%q<rcov>, [">= 0.9.8"])
84
+ s.add_dependency(%q<nokogiri>, [">= 0"])
85
+ s.add_dependency(%q<bluecloth>, [">= 0"])
86
+ s.add_dependency(%q<yard>, [">= 0"])
87
+ s.add_dependency(%q<fakeweb>, [">= 0"])
88
+ end
89
+ end
90
+
data/lib/paypal/config.rb CHANGED
@@ -1,24 +1,22 @@
1
1
  module Paypal
2
2
  module Config
3
- IPN_URL_SANDBOX = "https://www.sandbox.paypal.com/cgi-bin/webscr"
4
- IPN_URL_PRODUCTION = "https://www.paypal.com/cgi-bin/webscr"
3
+ def self.ipn_urls
4
+ Thread.current[:ipn_urls] ||= {
5
+ :sandbox => "https://www.sandbox.paypal.com/cgi-bin/webscr",
6
+ :production => "https://www.paypal.com/cgi-bin/webscr"
7
+ }
8
+ end
5
9
 
6
- @@mode = :sandbox
7
10
  def self.mode=(new_mode)
8
11
  raise ArgumentError.new("Paypal::Config.mode should be either :sandbox or :production (you tried to set it as : #{new_mode})") unless [:sandbox, :production].include?(new_mode.to_sym)
9
- @@mode = new_mode.to_sym
12
+ Thread.current[:mode] = new_mode.to_sym
10
13
  end
11
14
  def self.mode
12
- @@mode
15
+ Thread.current[:mode] ||= :sandbox
13
16
  end
14
17
 
15
18
  def self.ipn_url
16
- case @@mode
17
- when :sandbox
18
- IPN_URL_SANDBOX
19
- when :production
20
- IPN_URL_PRODUCTION
21
- end
19
+ ipn_urls[mode]
22
20
  end
23
21
 
24
22
  def self.ipn_validation_path
@@ -29,29 +27,27 @@ module Paypal
29
27
  "#{ipn_url}?cmd=_notify-validate"
30
28
  end
31
29
 
32
- @@paypal_sandbox_cert = File.read(File.join(File.dirname(__FILE__), 'certs', 'paypal_sandbox.pem'))
33
30
  def self.paypal_sandbox_cert=(new_cert)
34
- @@paypal_sandbox_cert = new_cert
31
+ Thread.current[:paypal_sandbox_cert] = new_cert
35
32
  end
36
33
  def self.paypal_sandbox_cert
37
- @@paypal_sandbox_cert
34
+ Thread.current[:paypal_sandbox_cert] ||= File.read(File.join(File.dirname(__FILE__), 'certs', 'paypal_sandbox.pem'))
38
35
  end
39
36
 
40
- @@paypal_production_cert = nil
41
37
  def self.paypal_production_cert=(new_cert)
42
- @@paypal_production_cert = new_cert
38
+ Thread.current[:paypal_production_cert] = new_cert
43
39
  end
44
40
  def self.paypal_production_cert
45
- @@paypal_production_cert
41
+ Thread.current[:paypal_production_cert]
46
42
  end
47
43
 
48
44
  def self.paypal_cert
49
- case @@mode
45
+ case mode
50
46
  when :sandbox
51
- @@paypal_sandbox_cert
47
+ paypal_sandbox_cert
52
48
  when :production
53
- raise StandardError.new("You should set Paypal::Config.paypal_production_cert with your paypal production certificate") if @@paypal_production_cert.nil?
54
- @@paypal_production_cert
49
+ raise StandardError.new("You should set Paypal::Config.paypal_production_cert with your paypal production certificate") unless paypal_production_cert
50
+ paypal_production_cert
55
51
  end
56
52
  end
57
53
  end
@@ -1,3 +1,3 @@
1
1
  module Paypal
2
- VERSION = "3.0.0pre3"
2
+ VERSION = "3.0.0pre4"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -2,12 +2,29 @@ require "spec_helper"
2
2
 
3
3
  describe Paypal::Config do
4
4
  after do
5
+ Thread.current.keys.each do |key|
6
+ Thread.current[key] = nil unless key =~ /^__.+__$/
7
+ end
5
8
  Paypal.class_eval do
6
9
  remove_const :Config if const_defined?(:Config)
7
10
  end
8
11
  load "paypal/config.rb"
9
12
  end
10
13
 
14
+ describe "ipn_urls" do
15
+ it "should define url for :production" do
16
+ Paypal::Config.ipn_urls[:production].should eql("https://www.paypal.com/cgi-bin/webscr")
17
+ end
18
+ it "should define url for :sandbox" do
19
+ Paypal::Config.ipn_urls[:sandbox].should eql("https://www.sandbox.paypal.com/cgi-bin/webscr")
20
+ end
21
+ it "should allow changing urls" do
22
+ url = "https://myownsandbox.com"
23
+ Paypal::Config.ipn_urls[:sandbox] = url
24
+ Paypal::Config.ipn_urls[:sandbox].should eql(url)
25
+ end
26
+ end
27
+
11
28
  describe "mode" do
12
29
  it "should be :sandbox by default" do
13
30
  Paypal::Config.mode.should eql(:sandbox)
@@ -151,4 +168,15 @@ jZJTylbJQ1b5PBBjGiP0PpK48cdF
151
168
  Paypal::Config.paypal_cert.should eql("TEST")
152
169
  end
153
170
  end
171
+
172
+ describe "in multithreaded environment" do
173
+ it "should not mix different thread values" do
174
+ t = Thread.new {
175
+ Paypal::Config.mode = :production
176
+ Paypal::Config.mode.should eql(:production)
177
+ }
178
+ t.join
179
+ Paypal::Config.mode.should eql(:sandbox)
180
+ end
181
+ end
154
182
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 0
8
- - 0pre3
9
- version: 3.0.0pre3
8
+ - 0pre4
9
+ version: 3.0.0pre4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Tron
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-04-21 00:00:00 +02:00
19
+ date: 2010-07-16 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -124,9 +124,11 @@ files:
124
124
  - .gitignore
125
125
  - CHANGELOG.md
126
126
  - Gemfile
127
+ - Gemfile.lock
127
128
  - LICENSE
128
129
  - README.md
129
130
  - Rakefile
131
+ - jonathantron-paypal.gemspec
130
132
  - lib/paypal.rb
131
133
  - lib/paypal/certs/paypal_sandbox.pem
132
134
  - lib/paypal/config.rb