kinchan 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +18 -3
- data/README.md +7 -5
- data/bin/bundle +114 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/kinchan.gemspec +2 -0
- data/lib/kinchan/version.rb +1 -1
- data/lib/kinchan.rb +30 -14
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93bc12b281b802a4d65f633687ea807eaa65fbb9002f1c4a7600a98ce39549e2
|
4
|
+
data.tar.gz: 6f9ff2796e4462c4f6d918dd602a0a348fde0783bcb2395a7832bb787df9b976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6951b48f5e47c2934295b49c7126d58b06f30970c3e59655f5b44ca5be7d916a5a2d3153994d9b874b3ae9a134e4c4cc2032f8ca057a1f614179b54cc181cbbf
|
7
|
+
data.tar.gz: ea72cab859176ca0c0d5cc16aa9c890c43cd33e68e4c36075bd7030ccf3d12f9345c22f549e48ba1ba59a5331141574f6416951b32a5908b82b5225fc4f6f01b
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,10 +9,24 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
childprocess (3.0.0)
|
12
|
-
|
12
|
+
diff-lcs (1.3)
|
13
|
+
rake (13.0.1)
|
13
14
|
require_all (3.0.0)
|
15
|
+
rspec (3.9.0)
|
16
|
+
rspec-core (~> 3.9.0)
|
17
|
+
rspec-expectations (~> 3.9.0)
|
18
|
+
rspec-mocks (~> 3.9.0)
|
19
|
+
rspec-core (3.9.1)
|
20
|
+
rspec-support (~> 3.9.1)
|
21
|
+
rspec-expectations (3.9.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.9.0)
|
24
|
+
rspec-mocks (3.9.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.9.0)
|
27
|
+
rspec-support (3.9.2)
|
14
28
|
rubyzip (2.0.0)
|
15
|
-
selenium-webdriver (3.142.
|
29
|
+
selenium-webdriver (3.142.7)
|
16
30
|
childprocess (>= 0.5, < 4.0)
|
17
31
|
rubyzip (>= 1.2.2)
|
18
32
|
|
@@ -21,7 +35,8 @@ PLATFORMS
|
|
21
35
|
|
22
36
|
DEPENDENCIES
|
23
37
|
kinchan!
|
24
|
-
rake (~>
|
38
|
+
rake (~> 13.0)
|
39
|
+
rspec (~> 3.9.0)
|
25
40
|
|
26
41
|
BUNDLED WITH
|
27
42
|
2.1.2
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# [Kinchan](https://itazuranakiss.fandom.com/wiki/Kinnosuke_Ikezawa)
|
2
|
-
## Composable browser automation
|
2
|
+
## Composable browser automation with Ruby.
|
3
3
|
|
4
4
|
### Requirements
|
5
5
|
|
@@ -77,7 +77,7 @@ That's all it takes to run a task. Kinchan handles the rest.
|
|
77
77
|
|
78
78
|
### Passing Data to a Task
|
79
79
|
|
80
|
-
A task's initialize
|
80
|
+
A task's initialize method can accept options, just don't forget to call super
|
81
81
|
|
82
82
|
e.g.
|
83
83
|
|
@@ -119,12 +119,14 @@ end
|
|
119
119
|
|
120
120
|
Task's do not need to be in the same scope, as long as the task exists Kinchan will find and run it when appropriate
|
121
121
|
|
122
|
+
### [Examples](https://github.com/sosodev/kinchan-examples)
|
123
|
+
|
122
124
|
### Setting Selenium Browser Options
|
123
125
|
|
124
126
|
before running your task you can modify the selenium browser options like so
|
125
127
|
|
126
128
|
```ruby
|
127
|
-
Kinchan
|
128
|
-
Kinchan
|
129
|
-
Kinchan
|
129
|
+
Kinchan.browser = :chrome
|
130
|
+
Kinchan.browser_options = Selenium::WebDriver::Chrome::Options.new
|
131
|
+
Kinchan.browser_options.add_argument('--headless')
|
130
132
|
```
|
data/bin/bundle
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||=
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version
|
67
|
+
end
|
68
|
+
|
69
|
+
def bundler_requirement
|
70
|
+
return "#{Gem::Requirement.default}.a" unless bundler_version
|
71
|
+
|
72
|
+
bundler_gem_version = Gem::Version.new(bundler_version)
|
73
|
+
|
74
|
+
requirement = bundler_gem_version.approximate_recommendation
|
75
|
+
|
76
|
+
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
|
77
|
+
|
78
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
79
|
+
|
80
|
+
requirement
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_bundler!
|
84
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
85
|
+
|
86
|
+
activate_bundler
|
87
|
+
end
|
88
|
+
|
89
|
+
def activate_bundler
|
90
|
+
gem_error = activation_error_handling do
|
91
|
+
gem "bundler", bundler_requirement
|
92
|
+
end
|
93
|
+
return if gem_error.nil?
|
94
|
+
require_error = activation_error_handling do
|
95
|
+
require "bundler/version"
|
96
|
+
end
|
97
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
98
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
99
|
+
exit 42
|
100
|
+
end
|
101
|
+
|
102
|
+
def activation_error_handling
|
103
|
+
yield
|
104
|
+
nil
|
105
|
+
rescue StandardError, LoadError => e
|
106
|
+
e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
m.load_bundler!
|
111
|
+
|
112
|
+
if m.invoked_as_script?
|
113
|
+
load Gem.bin_path("bundler", "bundle")
|
114
|
+
end
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/kinchan.gemspec
CHANGED
data/lib/kinchan/version.rb
CHANGED
data/lib/kinchan.rb
CHANGED
@@ -5,21 +5,37 @@ require 'selenium-webdriver'
|
|
5
5
|
require 'require_all'
|
6
6
|
|
7
7
|
module Kinchan
|
8
|
-
|
8
|
+
@browser = :chrome
|
9
|
+
@browser_options = nil
|
10
|
+
|
11
|
+
def self.browser
|
12
|
+
@browser
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.browser= b
|
16
|
+
@browser = b
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.browser_options
|
20
|
+
@browser_options
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.browser_options= bo
|
24
|
+
@browser_options = bo
|
25
|
+
end
|
9
26
|
|
10
27
|
class Task
|
11
28
|
singleton_class.send(:attr_accessor, :browser)
|
12
29
|
singleton_class.send(:attr_accessor, :browser_options)
|
13
30
|
singleton_class.send(:attr_reader, :descendants)
|
14
31
|
@descendants = []
|
15
|
-
@browser = :chrome
|
16
|
-
@browser_options = nil
|
17
|
-
@@browser_webdriver = nil
|
18
32
|
|
19
33
|
def initialize(**options)
|
20
34
|
@before_tasks = []
|
21
35
|
@after_tasks = []
|
22
36
|
@options = options
|
37
|
+
|
38
|
+
Task.start_browser
|
23
39
|
end
|
24
40
|
|
25
41
|
def self.inherited(subclass)
|
@@ -30,24 +46,24 @@ module Kinchan
|
|
30
46
|
Task.descendants.select { |task| task.name.split('::').last.downcase == task_symbol.to_s.downcase }[0]
|
31
47
|
end
|
32
48
|
|
49
|
+
def self.start_browser
|
50
|
+
if Kinchan.browser_options.nil?
|
51
|
+
@@browser_webdriver = Selenium::WebDriver.for Kinchan.browser
|
52
|
+
else
|
53
|
+
@@browser_webdriver = Selenium::WebDriver.for(Kinchan.browser, options: Kinchan.browser_options)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
33
57
|
def self.restart_browser
|
34
58
|
unless @@browser_webdriver.nil?
|
35
59
|
@@browser_webdriver.close
|
36
|
-
@@browser_webdriver = Selenium::WebDriver.for
|
60
|
+
@@browser_webdriver = Selenium::WebDriver.for Kinchan.browser
|
37
61
|
end
|
38
62
|
end
|
39
63
|
|
40
64
|
def execute(browser); end
|
41
65
|
|
42
66
|
def run
|
43
|
-
if @@browser_webdriver.nil?
|
44
|
-
if Task.browser_options.nil?
|
45
|
-
@@browser_webdriver = Selenium::WebDriver.for Task.browser
|
46
|
-
else
|
47
|
-
@@browser_webdriver = Selenium::WebDriver.for(Task.browser, options: Task.browser_options)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
67
|
@before_tasks.each do |task_hash|
|
52
68
|
task = Task.find_task(task_hash[:task])
|
53
69
|
task.new(**task_hash[:options]).public_send('run') unless task.nil?
|
@@ -63,4 +79,4 @@ module Kinchan
|
|
63
79
|
end
|
64
80
|
end
|
65
81
|
|
66
|
-
require_all 'tasks'
|
82
|
+
require_all 'tasks' if File.directory?('tasks')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinchan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle McGough
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.9.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.9.0
|
41
55
|
description: Composable browser automation with Ruby. Create, compose, and run tasks
|
42
56
|
that automate the browser with Selenium.
|
43
57
|
email:
|
@@ -48,12 +62,18 @@ extra_rdoc_files: []
|
|
48
62
|
files:
|
49
63
|
- ".gitignore"
|
50
64
|
- ".rakeTasks"
|
65
|
+
- ".rspec"
|
51
66
|
- Gemfile
|
52
67
|
- Gemfile.lock
|
53
68
|
- LICENSE.txt
|
54
69
|
- README.md
|
55
70
|
- Rakefile
|
71
|
+
- bin/bundle
|
56
72
|
- bin/console
|
73
|
+
- bin/htmldiff
|
74
|
+
- bin/ldiff
|
75
|
+
- bin/rake
|
76
|
+
- bin/rspec
|
57
77
|
- bin/setup
|
58
78
|
- kinchan.gemspec
|
59
79
|
- lib/kinchan.rb
|