superbot 0.1.11 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f71e13691620164c6f8ccb20568412b28edd9fbf6a8c8284dd7f1ba728dbdecf
4
- data.tar.gz: afb80afe5c87473d1bd43b33b5d2a4bf5306f6577b01f415055a5ca33fd0e8dd
3
+ metadata.gz: 9130be23f8c384feeb29aad1623e0c08ecedb5441549699040c8a8d9b708f1bc
4
+ data.tar.gz: 6eb48db3777f14e3838efdf3ba6dbbb2d51612445d536a6fee1772246f937a58
5
5
  SHA512:
6
- metadata.gz: '09789a18105dba7f043de350645a527a299dcc86525a62ee99b31b3ca805dfb7c6ec8c13f2b5fee8c31df2da6a721ffd51c88f119e729bc25db9bab07e1ddb39'
7
- data.tar.gz: f3ec0a6cba8bf4f2986d8c96767dccfe7853acaf3cdfcc026dec2332043f77e24761875207fcc2bd0b4b4dd405a9a7cbc60fb61d8ce626886d178b8d49b08ca0
6
+ metadata.gz: 4facd70408337b5f902820c46cd600b5605b819107372272874cb5e69bff60c5f094fb1c0b4a5f2f76cd676282d5c48404aac042a3a7ec8529670dc9e5f9c65a
7
+ data.tar.gz: b607d07c9e60828908dcfc8141926e118eae9863c52ada868e32bc3107a05449a9902e0b81673398c3abcbb96c1dc71333bb209996027cf0b081b6545dac53cd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superbot (0.1.11)
4
+ superbot (0.1.12)
5
5
  clamp (= 1.2.1)
6
6
  kommando (~> 0.1)
7
7
  launchy (= 2.4.3)
@@ -15,9 +15,12 @@ module Superbot
15
15
  exit(0)
16
16
  end
17
17
 
18
- subcommand ["new"], "Create a new project", NewCommand
19
18
  subcommand ["version"], "Show version information", VersionCommand
20
19
  subcommand ["teleport"], "Open a teleport for superbots", TeleportCommand
20
+ if ENV['SUPERBOT_FEAT_PROJECT'] == 'true'
21
+ subcommand ["new"], "Create a new project", NewCommand
22
+ subcommand ["run"], "Run a project", RunCommand
23
+ end
21
24
 
22
25
  def self.run
23
26
  super
@@ -1,9 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "superbot/cloud/cli/cloud/validations"
4
+
3
5
  module Superbot
4
6
  module CLI
5
7
  class TeleportCommand < Clamp::Command
6
8
  include Superbot::Validations
9
+ include Superbot::Cloud::Validations
7
10
 
8
11
  option ['--browser'], 'BROWSER', "Browser type to use. Can be either local or cloud", default: 'cloud' do |browser|
9
12
  validates_browser_type browser
@@ -11,6 +14,8 @@ module Superbot
11
14
  option ['--region'], 'REGION', 'Region for remote webdriver'
12
15
 
13
16
  def execute
17
+ require_login unless browser == 'local'
18
+
14
19
  @web = Superbot::Web.new(webdriver_type: browser, region: region)
15
20
  @web.run_async_after_running!
16
21
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Superbot
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.12"
5
5
  end
data/lib/superbot/web.rb CHANGED
@@ -62,7 +62,7 @@ module Superbot
62
62
  headers instance.all_headers(response)
63
63
  response.body
64
64
  rescue StandardError => e
65
- error_message = "Remote webdriver doesn't responding"
65
+ error_message = "Remote webdriver doesn't respond"
66
66
  puts error_message, e
67
67
  halt 500, { message: error_message }.to_json
68
68
  end
@@ -99,6 +99,8 @@ module Superbot
99
99
  Net::HTTP.new(uri.hostname, uri.port).start do |http|
100
100
  http.read_timeout = Superbot.cloud_timeout
101
101
  http.request(req)
102
+ end.tap do |response|
103
+ output_response_errors(response)
102
104
  end
103
105
  end
104
106
 
@@ -122,6 +124,15 @@ module Superbot
122
124
  request.env.map { |header, value| [header[5..-1].split("_").map(&:capitalize).join('-'), value] if header.start_with?("HTTP_") }.compact.to_h
123
125
  end
124
126
 
127
+ def output_response_errors(response)
128
+ return unless response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)
129
+
130
+ parsed_body = JSON.parse(response.body, symbolize_names: true)
131
+ puts "Error: #{parsed_body[:error]}"
132
+ rescue JSON::ParserError
133
+ puts "Request to webdriver failed with status: #{response.code}"
134
+ end
135
+
125
136
  def run!
126
137
  @sinatra.run_async!
127
138
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Superbots