superbot 0.1.1 → 0.1.2
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 +38 -2
- data/exe/superbot +8 -0
- data/lib/superbot/capybara/convert.rb +37 -0
- data/lib/superbot/capybara/runner.rb +64 -0
- data/lib/superbot/cli/root_command.rb +6 -0
- data/lib/superbot/version.rb +1 -1
- data/lib/superbot/web.rb +4 -3
- data/superbot.gemspec +1 -0
- metadata +25 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1d99d87e748e4f70a3a9ccd7eaa049f7ad78de501c83343e24b21b52d1a32f11
         | 
| 4 | 
            +
              data.tar.gz: 2cb9d36d9e1f36e8a85e11665b4cf54c459d57387739337c77e0eacf33e23242
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a040b5c8d44141bd5c6fca9ddb4d477793207b42981ed40c326346a02ef61691a5b7b8c0ea23edb708863b34d9a59b26cb7dddd419da7bcd287e50b79da7d68b
         | 
| 7 | 
            +
              data.tar.gz: 3fa1e7e58ff704e764907729c5b5586a0c3743dc512616f19d4688065a8c39a9c8a356628d7463c55c86e47944485870b19833b47cd501c19a40b74c54b457db
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                superbot (0.1. | 
| 4 | 
            +
                superbot (0.1.2)
         | 
| 5 5 | 
             
                  clamp (= 1.2.1)
         | 
| 6 6 | 
             
                  launchy (= 2.4.3)
         | 
| 7 7 | 
             
                  sinatra (= 2.0.3)
         | 
| @@ -13,7 +13,22 @@ GEM | |
| 13 13 | 
             
              specs:
         | 
| 14 14 | 
             
                addressable (2.5.2)
         | 
| 15 15 | 
             
                  public_suffix (>= 2.0.2, < 4.0)
         | 
| 16 | 
            +
                archive-zip (0.11.0)
         | 
| 17 | 
            +
                  io-like (~> 0.3.0)
         | 
| 16 18 | 
             
                ast (2.4.0)
         | 
| 19 | 
            +
                capybara (3.6.0)
         | 
| 20 | 
            +
                  addressable
         | 
| 21 | 
            +
                  mini_mime (>= 0.1.3)
         | 
| 22 | 
            +
                  nokogiri (~> 1.8)
         | 
| 23 | 
            +
                  rack (>= 1.6.0)
         | 
| 24 | 
            +
                  rack-test (>= 0.6.3)
         | 
| 25 | 
            +
                  xpath (~> 3.1)
         | 
| 26 | 
            +
                childprocess (0.9.0)
         | 
| 27 | 
            +
                  ffi (~> 1.0, >= 1.0.11)
         | 
| 28 | 
            +
                chromedriver-helper (1.2.0)
         | 
| 29 | 
            +
                  archive-zip (~> 0.10)
         | 
| 30 | 
            +
                  nokogiri (~> 1.8)
         | 
| 31 | 
            +
                cjsonci (0.1.0)
         | 
| 17 32 | 
             
                clamp (1.2.1)
         | 
| 18 33 | 
             
                coderay (1.1.2)
         | 
| 19 34 | 
             
                diff-lcs (1.3)
         | 
| @@ -38,6 +53,7 @@ GEM | |
| 38 53 | 
             
                guard-rubocop (1.3.0)
         | 
| 39 54 | 
             
                  guard (~> 2.0)
         | 
| 40 55 | 
             
                  rubocop (~> 0.20)
         | 
| 56 | 
            +
                io-like (0.3.0)
         | 
| 41 57 | 
             
                json (2.1.0)
         | 
| 42 58 | 
             
                kommando (0.1.2)
         | 
| 43 59 | 
             
                launchy (2.4.3)
         | 
| @@ -48,8 +64,12 @@ GEM | |
| 48 64 | 
             
                  ruby_dep (~> 1.2)
         | 
| 49 65 | 
             
                lumberjack (1.0.13)
         | 
| 50 66 | 
             
                method_source (0.9.0)
         | 
| 67 | 
            +
                mini_mime (1.0.1)
         | 
| 68 | 
            +
                mini_portile2 (2.3.0)
         | 
| 51 69 | 
             
                mustermann (1.0.3)
         | 
| 52 70 | 
             
                nenv (0.3.0)
         | 
| 71 | 
            +
                nokogiri (1.8.4)
         | 
| 72 | 
            +
                  mini_portile2 (~> 2.3.0)
         | 
| 53 73 | 
             
                notiffany (0.1.1)
         | 
| 54 74 | 
             
                  nenv (~> 0.1)
         | 
| 55 75 | 
             
                  shellany (~> 0.0)
         | 
| @@ -66,6 +86,8 @@ GEM | |
| 66 86 | 
             
                rack (2.0.5)
         | 
| 67 87 | 
             
                rack-protection (2.0.3)
         | 
| 68 88 | 
             
                  rack
         | 
| 89 | 
            +
                rack-test (1.1.0)
         | 
| 90 | 
            +
                  rack (>= 1.0, < 3)
         | 
| 69 91 | 
             
                rainbow (3.0.0)
         | 
| 70 92 | 
             
                rake (10.5.0)
         | 
| 71 93 | 
             
                rb-fsevent (0.10.3)
         | 
| @@ -93,6 +115,10 @@ GEM | |
| 93 115 | 
             
                  unicode-display_width (~> 1.0, >= 1.0.1)
         | 
| 94 116 | 
             
                ruby-progressbar (1.9.0)
         | 
| 95 117 | 
             
                ruby_dep (1.5.0)
         | 
| 118 | 
            +
                rubyzip (1.2.2)
         | 
| 119 | 
            +
                selenium-webdriver (3.14.0)
         | 
| 120 | 
            +
                  childprocess (~> 0.5)
         | 
| 121 | 
            +
                  rubyzip (~> 1.2)
         | 
| 96 122 | 
             
                shellany (0.0.1)
         | 
| 97 123 | 
             
                simplecov (0.16.1)
         | 
| 98 124 | 
             
                  docile (~> 1.1)
         | 
| @@ -105,9 +131,18 @@ GEM | |
| 105 131 | 
             
                  rack-protection (= 2.0.3)
         | 
| 106 132 | 
             
                  tilt (~> 2.0)
         | 
| 107 133 | 
             
                sinatra-silent (0.0.1)
         | 
| 134 | 
            +
                superbot-capybara (360.0.0)
         | 
| 135 | 
            +
                  capybara (= 3.6.0)
         | 
| 136 | 
            +
                  cjsonci (= 0.1.0)
         | 
| 137 | 
            +
                  superbot-selenium-webdriver (= 314.2.5)
         | 
| 138 | 
            +
                superbot-selenium-webdriver (314.2.5)
         | 
| 139 | 
            +
                  chromedriver-helper (= 1.2.0)
         | 
| 140 | 
            +
                  selenium-webdriver (= 3.14.0)
         | 
| 108 141 | 
             
                thor (0.20.0)
         | 
| 109 142 | 
             
                tilt (2.0.8)
         | 
| 110 143 | 
             
                unicode-display_width (1.3.3)
         | 
| 144 | 
            +
                xpath (3.1.0)
         | 
| 145 | 
            +
                  nokogiri (~> 1.8)
         | 
| 111 146 | 
             
                zaru (0.2.0)
         | 
| 112 147 |  | 
| 113 148 | 
             
            PLATFORMS
         | 
| @@ -126,6 +161,7 @@ DEPENDENCIES | |
| 126 161 | 
             
              rubocop (~> 0.53)
         | 
| 127 162 | 
             
              simplecov (~> 0.16)
         | 
| 128 163 | 
             
              superbot!
         | 
| 164 | 
            +
              superbot-capybara
         | 
| 129 165 |  | 
| 130 166 | 
             
            BUNDLED WITH
         | 
| 131 | 
            -
               1.16. | 
| 167 | 
            +
               1.16.4
         | 
    
        data/exe/superbot
    CHANGED
    
    | @@ -9,4 +9,12 @@ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path) | |
| 9 9 | 
             
            STDOUT.sync = true
         | 
| 10 10 |  | 
| 11 11 | 
             
            require 'superbot'
         | 
| 12 | 
            +
            %w(cloud local).each do |gem_ext|
         | 
| 13 | 
            +
              begin
         | 
| 14 | 
            +
                require "superbot/#{gem_ext}"
         | 
| 15 | 
            +
              rescue LoadError
         | 
| 16 | 
            +
                p # do nothing
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| 19 | 
            +
             | 
| 12 20 | 
             
            Superbot::CLI::RootCommand.run
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Superbot
         | 
| 4 | 
            +
              module Capybara
         | 
| 5 | 
            +
                class Convert
         | 
| 6 | 
            +
                  def initialize(json)
         | 
| 7 | 
            +
                    @json = JSON.parse(json, symbolize_names: true)
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def self.call(json)
         | 
| 11 | 
            +
                    new(json).call
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def call
         | 
| 15 | 
            +
                    converted_json&.tap { |script| Superbot::Capybara::Runner.run(script) }
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  attr_accessor :json
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  private
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def convert_action(action)
         | 
| 23 | 
            +
                    case action[:type]
         | 
| 24 | 
            +
                    when 'visit'      then "visit '#{action[:url]}'"
         | 
| 25 | 
            +
                    when 'click'      then "click_on '#{action[:selector]}'"
         | 
| 26 | 
            +
                    when 'scroll'     then
         | 
| 27 | 
            +
                      "page.execute_script('window.scrollBy(0,' + (page.execute_script('return document.body.scrollHeight') * #{action[:amountPercent]} / 100).to_s + ')')"
         | 
| 28 | 
            +
                    when 'resolution' then "page.driver.browser.manage.window.resize_to(#{action[:resolution].join(',')})"
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def converted_json
         | 
| 33 | 
            +
                    json.map { |action| convert_action(action) }.join('; ')
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,64 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'kommando'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Superbot
         | 
| 6 | 
            +
              module Capybara
         | 
| 7 | 
            +
                class Runner
         | 
| 8 | 
            +
                  def initialize(script)
         | 
| 9 | 
            +
                    @script = script
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def self.run(*args)
         | 
| 13 | 
            +
                    new(*args).run
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def run
         | 
| 17 | 
            +
                    run_script
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  private
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  attr_accessor :script
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def run_script
         | 
| 25 | 
            +
                    gem 'superbot-capybara'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    k = Kommando.new "sb-capybara"
         | 
| 28 | 
            +
                    k.in.writeln({ eval: script }.to_json)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    finished = false
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    k.out.once(/{"type":"ok".*\n/) do
         | 
| 33 | 
            +
                      puts "Test succeed"
         | 
| 34 | 
            +
                      finished = true
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    k.out.once(/{"type":"error".*\n/) do
         | 
| 38 | 
            +
                      begin
         | 
| 39 | 
            +
                        parsed_error = JSON.parse(k.out.lines.last, symbolize_names: true)
         | 
| 40 | 
            +
                        error_message = parsed_error[:message]
         | 
| 41 | 
            +
                        puts "Test failed with #{error_message}"
         | 
| 42 | 
            +
                      end
         | 
| 43 | 
            +
                      finished = true
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    k.run_async
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    loop do
         | 
| 49 | 
            +
                      break if finished
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                      sleep 0.001
         | 
| 52 | 
            +
                    end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    begin
         | 
| 55 | 
            +
                      k.kill
         | 
| 56 | 
            +
                    rescue Timeout::Error
         | 
| 57 | 
            +
                      p # do nothing
         | 
| 58 | 
            +
                    end
         | 
| 59 | 
            +
                  rescue Gem::LoadError
         | 
| 60 | 
            +
                    puts "superbot-capybara not installed"
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
            end
         | 
| @@ -19,6 +19,12 @@ module Superbot | |
| 19 19 | 
             
                    warn exc.message
         | 
| 20 20 | 
             
                    warn exc.backtrace.join("\n")
         | 
| 21 21 | 
             
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def subcommand_missing(name)
         | 
| 24 | 
            +
                    return super unless %w(cloud local).include?(name)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    abort "Subcommand '#{name}' requires gem superbot-#{name} to be installed"
         | 
| 27 | 
            +
                  end
         | 
| 22 28 | 
             
                end
         | 
| 23 29 | 
             
              end
         | 
| 24 30 | 
             
            end
         | 
    
        data/lib/superbot/version.rb
    CHANGED
    
    
    
        data/lib/superbot/web.rb
    CHANGED
    
    | @@ -2,6 +2,8 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'sinatra'
         | 
| 4 4 | 
             
            require "sinatra/silent"
         | 
| 5 | 
            +
            require_relative "capybara/convert"
         | 
| 6 | 
            +
            require_relative "capybara/runner"
         | 
| 5 7 |  | 
| 6 8 | 
             
            module Superbot
         | 
| 7 9 | 
             
              class Web
         | 
| @@ -28,9 +30,7 @@ module Superbot | |
| 28 30 | 
             
                  end
         | 
| 29 31 |  | 
| 30 32 | 
             
                  @sinatra.post "/__superbot/v1/convert" do
         | 
| 31 | 
            -
                     | 
| 32 | 
            -
             | 
| 33 | 
            -
                    "visit 'http://example.com'\n#{body.inspect}"
         | 
| 33 | 
            +
                    Superbot::Capybara::Convert.call(request.body.read)
         | 
| 34 34 | 
             
                  end
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| @@ -45,6 +45,7 @@ module Superbot | |
| 45 45 |  | 
| 46 46 | 
             
                  loop do
         | 
| 47 47 | 
             
                    break if @sinatra.running?
         | 
| 48 | 
            +
             | 
| 48 49 | 
             
                    sleep 0.001
         | 
| 49 50 | 
             
                  end
         | 
| 50 51 | 
             
                end
         | 
    
        data/superbot.gemspec
    CHANGED
    
    | @@ -46,6 +46,7 @@ Gem::Specification.new do |spec| | |
| 46 46 | 
             
              spec.add_development_dependency "simplecov", "~> 0.16"
         | 
| 47 47 | 
             
              spec.add_development_dependency "parallel_tests", "~> 2.22"
         | 
| 48 48 | 
             
              spec.add_development_dependency "excon", "~> 0.62"
         | 
| 49 | 
            +
              spec.add_development_dependency 'superbot-capybara', '~> 360.0', '>= 360.0.0'
         | 
| 49 50 |  | 
| 50 51 | 
             
              spec.add_development_dependency "guard", "~> 2.14"
         | 
| 51 52 | 
             
              spec.add_development_dependency "guard-rspec", "~> 4.7"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: superbot
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Superbots
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-10-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: clamp
         | 
| @@ -192,6 +192,26 @@ dependencies: | |
| 192 192 | 
             
                - - "~>"
         | 
| 193 193 | 
             
                  - !ruby/object:Gem::Version
         | 
| 194 194 | 
             
                    version: '0.62'
         | 
| 195 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 196 | 
            +
              name: superbot-capybara
         | 
| 197 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 198 | 
            +
                requirements:
         | 
| 199 | 
            +
                - - "~>"
         | 
| 200 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 201 | 
            +
                    version: '360.0'
         | 
| 202 | 
            +
                - - ">="
         | 
| 203 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 204 | 
            +
                    version: 360.0.0
         | 
| 205 | 
            +
              type: :development
         | 
| 206 | 
            +
              prerelease: false
         | 
| 207 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 208 | 
            +
                requirements:
         | 
| 209 | 
            +
                - - "~>"
         | 
| 210 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 211 | 
            +
                    version: '360.0'
         | 
| 212 | 
            +
                - - ">="
         | 
| 213 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 214 | 
            +
                    version: 360.0.0
         | 
| 195 215 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 196 216 | 
             
              name: guard
         | 
| 197 217 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -261,6 +281,8 @@ files: | |
| 261 281 | 
             
            - bin/setup
         | 
| 262 282 | 
             
            - exe/superbot
         | 
| 263 283 | 
             
            - lib/superbot.rb
         | 
| 284 | 
            +
            - lib/superbot/capybara/convert.rb
         | 
| 285 | 
            +
            - lib/superbot/capybara/runner.rb
         | 
| 264 286 | 
             
            - lib/superbot/cli.rb
         | 
| 265 287 | 
             
            - lib/superbot/cli/new_command.rb
         | 
| 266 288 | 
             
            - lib/superbot/cli/root_command.rb
         | 
| @@ -291,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 291 313 | 
             
                  version: '0'
         | 
| 292 314 | 
             
            requirements: []
         | 
| 293 315 | 
             
            rubyforge_project: 
         | 
| 294 | 
            -
            rubygems_version: 2.7. | 
| 316 | 
            +
            rubygems_version: 2.7.6
         | 
| 295 317 | 
             
            signing_key: 
         | 
| 296 318 | 
             
            specification_version: 4
         | 
| 297 319 | 
             
            summary: Superbot Testing
         |