oa-webmoney 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/CHANGES ADDED
@@ -0,0 +1,3 @@
1
+ 0.1.0
2
+ * Refactored to respect omniauth 1.0.1
3
+ * options syntax changed
data/Gemfile CHANGED
@@ -1,14 +1,4 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
1
+ source 'https://rubygems.org'
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
-
9
- group :development do
10
- gem "rspec", "~> 2.5.0"
11
- gem "bundler", "~> 1.0.0"
12
- gem "jeweler", "~> 1.5.2"
13
- gem 'webmoney', '~> 0.0.10'
14
- end
3
+ # Specify your gem's dependencies in oa-webmoney.gemspec
4
+ gemspec
@@ -1,4 +1,6 @@
1
- Copyright (c) 2011 Anton
1
+ Copyright (c) 2011 Anton Orel
2
+
3
+ MIT License
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -26,9 +26,14 @@ and add code below to created migration:
26
26
 
27
27
  devise.rb
28
28
 
29
- config.omniauth :webmoney, :credentials => { :site_holder_wmid => 'your_site_wmid',
30
- :app_rids => { 'localhost' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
31
- 'example.com' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }}, :mode => Rails.env)
29
+ config.omniauth :webmoney,
30
+ :credentials => {
31
+ :site_holder_wmid => 'your_site_wmid',
32
+ :app_rids => {
33
+ 'localhost' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
34
+ 'example.com' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }},
35
+ :env => Rails.env,
36
+ :wm_instance => Rails.webmoney #optional, if you have already used webmoney gem instance in your app
32
37
 
33
38
  user.rb
34
39
 
@@ -36,10 +41,10 @@ user.rb
36
41
 
37
42
  def self.find_for_webmoney_oauth(access_token, signed_in_resource=nil)
38
43
  data = access_token['extra']
39
- if user = User.find_by_wmid(data[:WmLogin_WMID])
44
+ if user = User.find_by_wmid(data['WmLogin_WMID'])
40
45
  user
41
46
  else # Create an user with a stub password.
42
- User.create!(:email => "#{data[:WmLogin_WMID]}@wmkeeper.com", :password => Devise.friendly_token[0,20])
47
+ User.create!(:email => "#{data['WmLogin_WMID']}@wmkeeper.com", :password => Devise.friendly_token[0,20])
43
48
  end
44
49
  end
45
50
 
data/Rakefile CHANGED
@@ -1,45 +1,2 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "oa-webmoney"
16
- gem.homepage = "http://github.com/skyeagle/oa-webmoney"
17
- gem.license = "MIT"
18
- gem.summary = %Q{Webmoney}
19
- gem.description = %Q{Webmoney}
20
- gem.email = "eagle.anton@gmail.com"
21
- gem.authors = ["Anton"]
22
- # Include your dependencies below. Runtime dependencies are required when using your gem,
23
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
- gem.add_runtime_dependency 'webmoney', '~> 0.0.10'
25
- gem.add_development_dependency 'rspec', '> 2.5.02.5.0'
26
- end
27
- Jeweler::RubygemsDotOrgTasks.new
28
-
29
- require 'rspec/core'
30
- require 'rspec/core/rake_task'
31
- RSpec::Core::RakeTask.new(:spec) do |spec|
32
- spec.pattern = FileList['spec/**/*_spec.rb']
33
- end
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "oa-webmoney #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/lib/oa-webmoney.rb CHANGED
@@ -1,6 +1,7 @@
1
+ require 'oa-webmoney/version'
2
+
1
3
  module OmniAuth
2
4
  module Strategies
3
- # tell OmniAuth to load our strategy
4
5
  autoload :Webmoney, 'oa-webmoney/webmoney'
5
6
  end
6
7
  end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Webmoney
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -1,5 +1,6 @@
1
1
  require 'omniauth/core'
2
2
  require 'webmoney'
3
+
3
4
  module OmniAuth
4
5
  module Strategies
5
6
  class Webmoney
@@ -44,22 +45,16 @@ module OmniAuth
44
45
 
45
46
  :canceled => "Authorization was canceled by user"
46
47
  }
47
- attr_reader :credentials, :mode, :wm_instance
48
48
 
49
- def initialize(app, opts = {})
50
- @credentials = opts[:credentials]
51
- @mode = opts[:mode]
52
- @wm_instance = if defined?(Rails)
53
- Rails.webmoney
54
- else
55
- WmLib.new(:wmid => @credentials[:site_holder_wmid])
56
- end
57
- super(app, :webmoney, opts)
58
- end
49
+ option :credentials
50
+ option :env, :production
51
+ option :wm_instance
52
+ option :fields, [:WmLogin_Ticket, :WmLogin_UrlID, :WmLogin_Expire, :WmLogin_AuthType,
53
+ :WmLogin_LastAccess, :WmLogin_Created, :WmLogin_WMID, :WmLogin_UserAddress]
59
54
 
60
55
  def request_phase
61
56
  r = Rack::Response.new
62
- r.redirect "https://login.wmtransfer.com/GateKeeper.aspx?RID=#{credentials[:app_rids][request.host]}"
57
+ r.redirect "https://login.wmtransfer.com/GateKeeper.aspx?RID=#{options[:credentials][:app_rids][request.host]}"
63
58
  r.finish
64
59
  end
65
60
 
@@ -68,27 +63,19 @@ module OmniAuth
68
63
  return fail!(:canceled, ERROR_MESSAGES[:canceled])
69
64
  end
70
65
 
71
- @wminfo =
72
- { :WmLogin_Ticket => request.params["WmLogin_Ticket"],
73
- :WmLogin_UrlID => request.params["WmLogin_UrlID"],
74
- :WmLogin_Expire => request.params["WmLogin_Expires"],
75
- :WmLogin_AuthType => request.params["WmLogin_AuthType"],
76
- :WmLogin_LastAccess => request.params["WmLogin_LastAccess"],
77
- :WmLogin_Created => request.params["WmLogin_Created"],
78
- :WmLogin_WMID => request.params["WmLogin_WMID"],
79
- :WmLogin_UserAddress => request.params["WmLogin_UserAddress"] }
80
-
81
66
  # work around for local development
82
- ip_to_check = %w(development test).include?(mode) ? @wminfo[:WmLogin_UserAddress] : request.ip
67
+ ip_to_check = [:development, :test].include?(options[:env].to_sym) ? extra[:WmLogin_UserAddress] : request.ip
68
+
69
+ check_req_params = extra.merge({:remote_ip => ip_to_check})
83
70
 
84
- check_req_params = @wminfo.merge({:remote_ip => ip_to_check})
71
+ options[:wm_instance] ||= WmLib.new(:wmid => options[:credentials][:site_holder_wmid])
85
72
 
86
73
  begin
87
- response = wm_instance.request(:login, check_req_params)[:retval]
74
+ response = options[:wm_instance].request(:login, check_req_params)[:retval]
88
75
  rescue Errno::ECONNRESET, Errno::ECONNREFUSED, Timeout::Error => e
89
76
  response = -2
90
77
  rescue ::Webmoney::ResultError => e
91
- response = wm_instance.error
78
+ response = options[:wm_instance].error
92
79
  end
93
80
 
94
81
  status = case response
@@ -116,10 +103,15 @@ module OmniAuth
116
103
  super
117
104
  end
118
105
 
119
- def auth_hash
120
- OmniAuth::Utils.deep_merge(super(), {
121
- 'uid' => @wminfo[:WmLogin_WMID],
122
- 'extra' => @wminfo})
106
+ def uid
107
+ extra[:WmLogin_WMID]
108
+ end
109
+
110
+ def extra
111
+ options.fields.inject({}) do |hash, field|
112
+ hash[field] = request.params[field.to_s]
113
+ hash
114
+ end
123
115
  end
124
116
  end
125
117
  end
data/oa-webmoney.gemspec CHANGED
@@ -1,72 +1,20 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/oa-webmoney/version', __FILE__)
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{oa-webmoney}
8
- s.version = "0.0.3"
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Anton Orel"]
6
+ gem.email = ["eagle.anton@gmail.com"]
7
+ gem.description = %q{OmniAuth Webmoney Strategy}
8
+ gem.summary = %q{OmniAuth Webmoney Strategy}
9
+ gem.homepage = %q{http://github.com/skyeagle/oa-webmoney}
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Anton"]
12
- s.date = %q{2011-03-01}
13
- s.description = %q{Webmoney}
14
- s.email = %q{eagle.anton@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "lib/oa-webmoney.rb",
29
- "lib/oa-webmoney/webmoney.rb",
30
- "oa-webmoney.gemspec",
31
- "spec/oa-webmoney_spec.rb",
32
- "spec/spec_helper.rb"
33
- ]
34
- s.homepage = %q{http://github.com/skyeagle/oa-webmoney}
35
- s.licenses = ["MIT"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{Webmoney}
39
- s.test_files = [
40
- "spec/oa-webmoney_spec.rb",
41
- "spec/spec_helper.rb"
42
- ]
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "oa-webmoney"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Webmoney::VERSION
43
17
 
44
- if s.respond_to? :specification_version then
45
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
- s.specification_version = 3
47
-
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<rspec>, ["~> 2.5.0"])
50
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
52
- s.add_development_dependency(%q<webmoney>, ["~> 0.0.10"])
53
- s.add_runtime_dependency(%q<webmoney>, ["~> 0.0.10"])
54
- s.add_development_dependency(%q<rspec>, ["> 2.5.02.5.0"])
55
- else
56
- s.add_dependency(%q<rspec>, ["~> 2.5.0"])
57
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
59
- s.add_dependency(%q<webmoney>, ["~> 0.0.10"])
60
- s.add_dependency(%q<webmoney>, ["~> 0.0.10"])
61
- s.add_dependency(%q<rspec>, ["> 2.5.02.5.0"])
62
- end
63
- else
64
- s.add_dependency(%q<rspec>, ["~> 2.5.0"])
65
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
- s.add_dependency(%q<webmoney>, ["~> 0.0.10"])
68
- s.add_dependency(%q<webmoney>, ["~> 0.0.10"])
69
- s.add_dependency(%q<rspec>, ["> 2.5.02.5.0"])
70
- end
18
+ gem.add_runtime_dependency 'webmoney', ['~> 0.0.12']
19
+ gem.add_development_dependency 'bundler', ["~> 1.1.rc.2"]
71
20
  end
72
-
metadata CHANGED
@@ -1,170 +1,77 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: oa-webmoney
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
12
- - Anton
7
+ authors:
8
+ - Anton Orel
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-03-01 00:00:00 +03:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: rspec
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ~>
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 2
29
- - 5
30
- - 0
31
- version: 2.5.0
32
- type: :development
33
- prerelease: false
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: bundler
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ~>
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 1
44
- - 0
45
- - 0
46
- version: 1.0.0
47
- type: :development
48
- prerelease: false
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: jeweler
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ~>
56
- - !ruby/object:Gem::Version
57
- segments:
58
- - 1
59
- - 5
60
- - 2
61
- version: 1.5.2
62
- type: :development
63
- prerelease: false
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
66
15
  name: webmoney
67
- requirement: &id004 !ruby/object:Gem::Requirement
16
+ requirement: &21749840 !ruby/object:Gem::Requirement
68
17
  none: false
69
- requirements:
18
+ requirements:
70
19
  - - ~>
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- - 0
75
- - 10
76
- version: 0.0.10
77
- type: :development
78
- prerelease: false
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: webmoney
82
- requirement: &id005 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ~>
86
- - !ruby/object:Gem::Version
87
- segments:
88
- - 0
89
- - 0
90
- - 10
91
- version: 0.0.10
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.12
92
22
  type: :runtime
93
23
  prerelease: false
94
- version_requirements: *id005
95
- - !ruby/object:Gem::Dependency
96
- name: rspec
97
- requirement: &id006 !ruby/object:Gem::Requirement
24
+ version_requirements: *21749840
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &21749320 !ruby/object:Gem::Requirement
98
28
  none: false
99
- requirements:
100
- - - ">"
101
- - !ruby/object:Gem::Version
102
- segments:
103
- - 2
104
- - 5
105
- - 2
106
- - 5
107
- - 0
108
- version: 2.5.02.5.0
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.rc.2
109
33
  type: :development
110
34
  prerelease: false
111
- version_requirements: *id006
112
- description: Webmoney
113
- email: eagle.anton@gmail.com
35
+ version_requirements: *21749320
36
+ description: OmniAuth Webmoney Strategy
37
+ email:
38
+ - eagle.anton@gmail.com
114
39
  executables: []
115
-
116
40
  extensions: []
117
-
118
- extra_rdoc_files:
119
- - LICENSE.txt
120
- - README.md
121
- files:
122
- - .document
123
- - .rspec
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - CHANGES
124
45
  - Gemfile
125
- - Gemfile.lock
126
- - LICENSE.txt
46
+ - LICENSE
127
47
  - README.md
128
48
  - Rakefile
129
- - VERSION
130
49
  - lib/oa-webmoney.rb
50
+ - lib/oa-webmoney/version.rb
131
51
  - lib/oa-webmoney/webmoney.rb
132
52
  - oa-webmoney.gemspec
133
- - spec/oa-webmoney_spec.rb
134
- - spec/spec_helper.rb
135
- has_rdoc: true
136
53
  homepage: http://github.com/skyeagle/oa-webmoney
137
- licenses:
138
- - MIT
54
+ licenses: []
139
55
  post_install_message:
140
56
  rdoc_options: []
141
-
142
- require_paths:
57
+ require_paths:
143
58
  - lib
144
- required_ruby_version: !ruby/object:Gem::Requirement
59
+ required_ruby_version: !ruby/object:Gem::Requirement
145
60
  none: false
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- hash: -329519907
150
- segments:
151
- - 0
152
- version: "0"
153
- required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
66
  none: false
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- segments:
159
- - 0
160
- version: "0"
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
161
71
  requirements: []
162
-
163
72
  rubyforge_project:
164
- rubygems_version: 1.3.7
73
+ rubygems_version: 1.8.10
165
74
  signing_key:
166
75
  specification_version: 3
167
- summary: Webmoney
168
- test_files:
169
- - spec/oa-webmoney_spec.rb
170
- - spec/spec_helper.rb
76
+ summary: OmniAuth Webmoney Strategy
77
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/Gemfile.lock DELETED
@@ -1,30 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.2)
5
- git (1.2.5)
6
- jeweler (1.5.2)
7
- bundler (~> 1.0.0)
8
- git (>= 1.2.5)
9
- rake
10
- nokogiri (1.4.4)
11
- rake (0.8.7)
12
- rspec (2.5.0)
13
- rspec-core (~> 2.5.0)
14
- rspec-expectations (~> 2.5.0)
15
- rspec-mocks (~> 2.5.0)
16
- rspec-core (2.5.1)
17
- rspec-expectations (2.5.0)
18
- diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.5.0)
20
- webmoney (0.0.10)
21
- nokogiri
22
-
23
- PLATFORMS
24
- ruby
25
-
26
- DEPENDENCIES
27
- bundler (~> 1.0.0)
28
- jeweler (~> 1.5.2)
29
- rspec (~> 2.5.0)
30
- webmoney (~> 0.0.10)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.3
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "OaWebmoney" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end
data/spec/spec_helper.rb DELETED
@@ -1,12 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'oa-webmoney'
5
-
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
12
- end