amazon_auth 0.4.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bd3624417b3a13baad3a2812cf7bdc6f874966e69290b3e5dce2bfb748b4a9a
4
- data.tar.gz: fff02f6937501b76a01d16a9de7b9ade90b02b2e4ac5de8448b58293a69b8579
3
+ metadata.gz: 2616112a7c77ce7a370145836360fc55df643716450e6222d95affa6c1b942ec
4
+ data.tar.gz: e96f0dad4d371aeaf0c6bd7dc325cd252fea806e992c322aceef88e01e5c7cc4
5
5
  SHA512:
6
- metadata.gz: 3dfdb0bf93116a962ab13314f7342837bb920371d35f9e0cb1ab26754d9b65d23237b2de6263d6621b2eb1dc3631f6ebe262c457695192882edf41d304090060
7
- data.tar.gz: 3a72e83fc180ee2028b5b4b0382f0b290d631a233eb9aae4a71827c9eae7d90f91701b672c16a98066dcf7567c70aa27539faf6ec2c3e7c6ef2249af7549667b
6
+ metadata.gz: a18f9d6ce597e2c12a96bdf6748bc8eda365533f8d5daebd968282a58dfb330cf12adfc7c057b529b1b5e20a05a9c61e9a41ba5cf8c0922b27db921f656f0f4a
7
+ data.tar.gz: 99b3832589d28b9e4eebf5bf4fc3fe590ecc5b57ec6031a5b5e4854d472add8d700b1abf118d10d9dfb441454d1ce2152c6d95220726b474e446f200b7d8b1db
@@ -0,0 +1,21 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ test:
5
+ parameters:
6
+ ruby-version:
7
+ type: string
8
+ docker:
9
+ - image: cimg/ruby:<< parameters.ruby-version >>-browsers
10
+ steps:
11
+ - checkout
12
+ - run: bundle install
13
+ - run: bundle exec rspec
14
+
15
+ workflows:
16
+ all-tests:
17
+ jobs:
18
+ - test:
19
+ matrix:
20
+ parameters:
21
+ ruby-version: ["2.7.5", "3.0.3"]
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # AmazonAuth
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/amazon_auth.svg)](https://badge.fury.io/rb/amazon_auth)
4
- [![Build Status](https://travis-ci.org/kyamaguchi/amazon_auth.svg?branch=master)](https://travis-ci.org/kyamaguchi/amazon_auth)
4
+ [![CircleCI](https://circleci.com/gh/kyamaguchi/amazon_auth.svg?style=svg)](https://circleci.com/gh/kyamaguchi/amazon_auth)
5
5
 
6
6
  Sign In Amazon using Capybara and Selenium
7
7
 
@@ -31,7 +31,7 @@ Or install it yourself as:
31
31
 
32
32
  Before running, you need to **download chromedriver**.
33
33
  And you may need to **update chromedriver regularly**.
34
- Please download latest chromedriver_xxx.zip from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH.
34
+ Please download latest chromedriver_xxx.zip from https://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH.
35
35
 
36
36
  ```
37
37
  mv ~/Downloads/chromedriver /usr/local/bin/
@@ -120,31 +120,12 @@ client = AmazonAuth::Client.new(debug: true)
120
120
 
121
121
  ### Use Firefox
122
122
 
123
- This gem may not work with newer versions of Firefox.
124
- Check README of [capybara](https://github.com/teamcapybara/capybara).
125
-
126
- Firefox (<= 47.0.2) may work better.
127
-
128
- [Download Firefox](https://ftp.mozilla.org/pub/firefox/releases/)
129
- Don't forget to disable automatic updates of Firefox.
130
-
131
- You may also need geckodriver.
132
- This may need to be older depending on the version of selenium-webdriver.
133
-
134
- [Download geckodriver](https://github.com/mozilla/geckodriver/releases)
135
-
136
- If the browser doesn't work, try selenium-webdriver version '~> 2.0' or different version of geckodriver/Firefox.
137
-
138
123
  In console,
139
124
 
140
125
  ```
141
126
  client = AmazonAuth::Client.new(driver: :firefox)
142
127
  ```
143
128
 
144
- ## TODO
145
-
146
- - [Idea] Hook `submit_signin_form` after every `visit` and `click` action
147
-
148
129
  ## Development
149
130
 
150
131
  Use _.env.development_ instead of _.env_ in development.
@@ -29,7 +29,9 @@ module AmazonAuth
29
29
  session.visit url
30
30
  debug "Visiting #{url}"
31
31
  restore_cookies if keep_cookie?
32
- if (link = links_for('a').find{|l| l =~ %r{\A/gp/navigation/redirector.html} })
32
+ if session.current_url.include?('/ap/signin')
33
+ debug "current_url: [#{session.current_url}]"
34
+ elsif (link = find_sign_in_link)
33
35
  debug "link: [#{link}]"
34
36
  session.visit(link)
35
37
  end
@@ -105,6 +107,24 @@ module AmazonAuth
105
107
  session.has_selector?('#auth-captcha-image-container')
106
108
  end
107
109
 
110
+ def find_sign_in_link
111
+ m1 = session.html.match(%r{(/ap/signin[^'"]+)['"]})
112
+ return CGI.unescapeHTML(m1[1]) if m1
113
+
114
+ # Maybe the following patterns are deprecated
115
+ link = links_for('a').find{|l| l =~ %r{\A/gp/navigation/redirector.html} }
116
+ if link
117
+ debug "Found a link [#{link}]"
118
+ return link
119
+ end
120
+ m2 = session.html.match(%r{'(/gp/navigation/redirector.html[^']+)'})
121
+ if m2
122
+ debug "Found a link (.html.match) [#{m2[1]}]"
123
+ return m2[1]
124
+ end
125
+ nil
126
+ end
127
+
108
128
  private
109
129
 
110
130
  def login
@@ -1,3 +1,3 @@
1
1
  module AmazonAuth
2
- VERSION = "0.4.6"
2
+ VERSION = "0.7.0"
3
3
  end
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.4.6
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuho Yamaguchi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-27 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -158,9 +158,9 @@ executables:
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
+ - ".circleci/config.yml"
161
162
  - ".gitignore"
162
163
  - ".rspec"
163
- - ".travis.yml"
164
164
  - Gemfile
165
165
  - LICENSE.txt
166
166
  - README.md
@@ -181,7 +181,7 @@ homepage: https://github.com/kyamaguchi/amazon_auth
181
181
  licenses:
182
182
  - MIT
183
183
  metadata: {}
184
- post_install_message:
184
+ post_install_message:
185
185
  rdoc_options: []
186
186
  require_paths:
187
187
  - lib
@@ -196,8 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubygems_version: 3.0.8
200
- signing_key:
199
+ rubygems_version: 3.1.6
200
+ signing_key:
201
201
  specification_version: 4
202
202
  summary: Login amazon.
203
203
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.8
5
- - 2.6.6
6
- - 2.7.1
7
- before_install: gem install bundler