amazon_auth 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/lib/amazon_auth.rb +1 -0
- data/lib/amazon_auth/client.rb +8 -19
- data/lib/amazon_auth/extensions/session_extension.rb +23 -0
- data/lib/amazon_auth/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ca9c9fc3e71a8956687c5a35fa3641e3cd8a400
|
4
|
+
data.tar.gz: b675685190fe70eba55e31f324cb1ec9a2a57272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50b6d4cb570cd913512648a7093cd1828e00f55c6ed2d122e553718f31b529dc81350fb4683ac57006ae479138ffe597ba078464d7c8291f99e7ec7244feaaf8
|
7
|
+
data.tar.gz: ba7482249e22c31f8b1fddfd32fa18ce16bce868509d44a0f2fa75ff637b8e56b0dbca21b343b0a86dd15369c2e3e5f997b42bc16dfd416f9148d59f7259470b
|
data/lib/amazon_auth.rb
CHANGED
@@ -8,6 +8,7 @@ begin
|
|
8
8
|
rescue LoadError
|
9
9
|
end
|
10
10
|
require_relative "amazon_auth/version"
|
11
|
+
require_relative "amazon_auth/extensions/session_extension"
|
11
12
|
require_relative "amazon_auth/amazon_info"
|
12
13
|
require_relative "amazon_auth/capybara"
|
13
14
|
require_relative "amazon_auth/converter"
|
data/lib/amazon_auth/client.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module AmazonAuth
|
2
2
|
class Client
|
3
|
+
include AmazonAuth::SessionExtension
|
4
|
+
|
3
5
|
attr_accessor :initial_url
|
4
6
|
|
5
7
|
def initialize(options = {})
|
@@ -19,21 +21,9 @@ module AmazonAuth
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
@driver = options.fetch(:driver, :selenium)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
wait_for_selector(selector, options)
|
26
|
-
doc.css(selector).map{|e| e['href'] }
|
27
|
-
end
|
28
|
-
|
29
|
-
def wait_for_selector(selector, options = {})
|
30
|
-
options.fetch(:wait_time, 3).times do
|
31
|
-
if session.first(selector)
|
32
|
-
break
|
33
|
-
else
|
34
|
-
sleep(1)
|
35
|
-
end
|
36
|
-
end
|
24
|
+
rescue => e
|
25
|
+
puts "Please setup credentials of amazon_auth gem with folloing its instruction."
|
26
|
+
raise e
|
37
27
|
end
|
38
28
|
|
39
29
|
def sign_in
|
@@ -57,12 +47,15 @@ module AmazonAuth
|
|
57
47
|
end
|
58
48
|
|
59
49
|
def retry_signin_form_with_image_recognition
|
50
|
+
return true unless session.has_selector?('#signInSubmit')
|
60
51
|
session.fill_in 'ap_password', with: @password
|
61
52
|
if image_recognition_displayed?
|
62
53
|
input = ask "Got the prompt. Read characters from the image: "
|
63
54
|
session.fill_in 'auth-captcha-guess', with: input
|
64
55
|
end
|
56
|
+
sleep 1
|
65
57
|
session.click_on('signInSubmit')
|
58
|
+
sleep 2
|
66
59
|
end
|
67
60
|
|
68
61
|
def alert_displayed?
|
@@ -77,10 +70,6 @@ module AmazonAuth
|
|
77
70
|
@session ||= Capybara::Session.new(@driver)
|
78
71
|
end
|
79
72
|
|
80
|
-
def doc
|
81
|
-
Nokogiri.HTML(session.html)
|
82
|
-
end
|
83
|
-
|
84
73
|
# Hide instance variables of credentials on console
|
85
74
|
def inspect
|
86
75
|
to_s
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module AmazonAuth
|
2
|
+
module SessionExtension
|
3
|
+
|
4
|
+
def doc
|
5
|
+
Nokogiri.HTML(session.html)
|
6
|
+
end
|
7
|
+
|
8
|
+
def links_for(selector, options = {})
|
9
|
+
wait_for_selector(selector, options)
|
10
|
+
doc.css(selector).map{|e| e['href'] }
|
11
|
+
end
|
12
|
+
|
13
|
+
def wait_for_selector(selector, options = {})
|
14
|
+
options.fetch(:wait_time, 3).times do
|
15
|
+
if session.first(selector)
|
16
|
+
break
|
17
|
+
else
|
18
|
+
sleep(1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/amazon_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuho Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/amazon_auth/capybara.rb
|
161
161
|
- lib/amazon_auth/client.rb
|
162
162
|
- lib/amazon_auth/converter.rb
|
163
|
+
- lib/amazon_auth/extensions/session_extension.rb
|
163
164
|
- lib/amazon_auth/version.rb
|
164
165
|
homepage: https://github.com/kyamaguchi/amazon_auth
|
165
166
|
licenses:
|