superbot 0.1.4 → 0.1.5
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/Gemfile.lock +1 -1
- data/lib/superbot.rb +1 -1
- data/lib/superbot/cli/run_command.rb +2 -1
- data/lib/superbot/version.rb +1 -1
- data/lib/superbot/web.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61e129678c2b0dbe5b2b3917213fa1b9a757ac58d8e663029df774ea41eead31
|
|
4
|
+
data.tar.gz: 8fb4aa0d11093ad5f733dd2acc96cb2684fb5154aaf1ba03ab56232d42437432
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7591a876f26d01108159691d377c984a28a2083bcaedeae09929e3628969d2751e423a06474bbea8befabd220dbc4b22c36705bd1a83ad38c34dc19b0f0b7aa
|
|
7
|
+
data.tar.gz: 52f817ce561627e0d7f4c2d164267040416ed72034df3c836f4d858d217cc379e4ec0f8d111a54aa65f0612b33b5bb1b8dbc880fced488aad7cf30f599c0423f
|
data/Gemfile.lock
CHANGED
data/lib/superbot.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Superbot
|
|
4
4
|
WEBDRIVER_ENDPOINT = {
|
|
5
|
-
cloud: "http://
|
|
5
|
+
cloud: "http://webdriver.superbot.cloud:3000/webdriver/v1",
|
|
6
6
|
local: "http://127.0.0.1:9515"
|
|
7
7
|
}.freeze
|
|
8
8
|
private_constant :WEBDRIVER_ENDPOINT
|
|
@@ -13,11 +13,12 @@ module Superbot
|
|
|
13
13
|
validates_browser_type browser
|
|
14
14
|
end
|
|
15
15
|
option ['--region'], 'REGION', 'Region for remote webdriver'
|
|
16
|
+
option ['--auth-token'], 'AUTH_TOKEN', 'Cloud webdriver auth credentials', environment_variable: 'CLOUD_DRIVER_AUTH_TOKEN'
|
|
16
17
|
|
|
17
18
|
def execute
|
|
18
19
|
script = File.read(File.join(path, 'main.rb'))
|
|
19
20
|
|
|
20
|
-
webdriver_proxy = Superbot::Web.new(webdriver_endpoint: Superbot.webdriver_endpoint(browser))
|
|
21
|
+
webdriver_proxy = Superbot::Web.new(webdriver_endpoint: Superbot.webdriver_endpoint(browser), auth_token: auth_token)
|
|
21
22
|
webdriver_proxy.run_async_after_running!
|
|
22
23
|
puts "🤖 active"
|
|
23
24
|
|
data/lib/superbot/version.rb
CHANGED
data/lib/superbot/web.rb
CHANGED
|
@@ -9,7 +9,7 @@ require_relative "capybara/runner"
|
|
|
9
9
|
|
|
10
10
|
module Superbot
|
|
11
11
|
class Web
|
|
12
|
-
def initialize(webdriver_endpoint: nil)
|
|
12
|
+
def initialize(webdriver_endpoint: nil, auth_token: nil)
|
|
13
13
|
@sinatra = Sinatra.new
|
|
14
14
|
@sinatra.set :bind, "127.0.0.1"
|
|
15
15
|
@sinatra.set :silent_sinatra, true
|
|
@@ -40,8 +40,9 @@ module Superbot
|
|
|
40
40
|
return unless webdriver_endpoint
|
|
41
41
|
|
|
42
42
|
webdriver_uri = URI.parse(webdriver_endpoint)
|
|
43
|
+
@auth_token = auth_token
|
|
43
44
|
@request_settings = {
|
|
44
|
-
userinfo:
|
|
45
|
+
userinfo: @auth_token,
|
|
45
46
|
host: webdriver_uri.host,
|
|
46
47
|
port: webdriver_uri.port,
|
|
47
48
|
path: webdriver_uri.path
|
|
@@ -81,7 +82,7 @@ module Superbot
|
|
|
81
82
|
)
|
|
82
83
|
)
|
|
83
84
|
req = Net::HTTP.const_get(type).new(uri, new_headers.merge('Content-Type' => 'application/json'))
|
|
84
|
-
req.basic_auth(*@
|
|
85
|
+
req.basic_auth(*@auth_token.split(':')) if @auth_token
|
|
85
86
|
req.body = body.read
|
|
86
87
|
Net::HTTP.new(uri.hostname, uri.port).start do |http|
|
|
87
88
|
http.read_timeout = Superbot.cloud_timeout
|