chromium-browser 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +50 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/chromium.gemspec +17 -0
- data/lib/chromium.rb +72 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4dd09f74d686c48e58977248317f275ecbee5e83
|
4
|
+
data.tar.gz: 94e3e405f298472dfe25626dcb1c13fd8000886a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80433fa1b30b967ad8e6f96e93a1ae9b16380c2846c007a20aab6e90b26b19d1b50852edd201d15c477ba3e1be6a39fbd4bce22ba3724685b69582c1c3926e67
|
7
|
+
data.tar.gz: a6aca67b1d38aa4b5be9d5310d2894fe965ebe8a16b6bad59c559d8d42a9eca08bf7e4a1510a0395f8e32438b69aea63a250b2cd712353a74e2693867c8b47e6
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 mits
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# chromium
|
data/chromium.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.author = 'Piotr Krajewski'
|
3
|
+
s.email = 'mits87@gmail.com'
|
4
|
+
|
5
|
+
s.name = 'chromium-browser'
|
6
|
+
s.version = '0.0.3'
|
7
|
+
s.summary = 'Chromium client handler'
|
8
|
+
s.license = 'MIT'
|
9
|
+
|
10
|
+
s.description = <<-EOF
|
11
|
+
The Chromium client handler.
|
12
|
+
EOF
|
13
|
+
|
14
|
+
s.requirements = 'chromium'
|
15
|
+
s.homepage = 'https://github.com/mits87/chromium'
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
end
|
data/lib/chromium.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
class Chromium
|
4
|
+
attr_reader :settings, :display, :tmp_dir, :pid
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@tmp_dir = options.fetch :tmp_dir, "/tmp/.chromium-#{SecureRandom.hex(6)}"
|
8
|
+
@display = options.fetch :display, 0
|
9
|
+
@settings = options.fetch :settings, []
|
10
|
+
|
11
|
+
window_size = `DISPLAY=:#{@display} $(which xdotool) getdisplaygeometry`.strip.gsub ' ', ','
|
12
|
+
window_size = '7000,7000' unless window_size
|
13
|
+
|
14
|
+
@pid = nil
|
15
|
+
@settings = %W(
|
16
|
+
--start-maximized
|
17
|
+
--incognito
|
18
|
+
--no-first-run
|
19
|
+
--no-sandbox
|
20
|
+
--disable
|
21
|
+
--disable-java
|
22
|
+
--disable-translate
|
23
|
+
--disable-infobars
|
24
|
+
--disable-suggestions-service
|
25
|
+
--disable-save-password-bubble
|
26
|
+
--allow-running-insecure-content
|
27
|
+
--ignore-certificate-errors
|
28
|
+
--ignore-urlfetcher-cert-requests
|
29
|
+
--disable-gpu
|
30
|
+
--new-window
|
31
|
+
--force-device-scale-factor=1
|
32
|
+
--window-position=0,0
|
33
|
+
--auto-ssl-client-auth
|
34
|
+
--use-fake-ui-for-media-stream
|
35
|
+
--kiosk
|
36
|
+
--window-size=#{window_size}
|
37
|
+
--disk-cache-dir=#{@tmp_dir}/cache/
|
38
|
+
--user-data-dir=#{@tmp_dir}/user_data/
|
39
|
+
) | @settings
|
40
|
+
|
41
|
+
dispatch
|
42
|
+
end
|
43
|
+
|
44
|
+
def navigate_to(url)
|
45
|
+
out_pipe, in_pipe = IO.pipe
|
46
|
+
@pid = Process.spawn "DISPLAY=:#{@display} $(which chromium) #{@settings.join(' ')} #{url}", err: in_pipe
|
47
|
+
raise Headless::Exception.new("Chromium did not launch - something's wrong") unless @pid
|
48
|
+
Process.detach @pid
|
49
|
+
ensure
|
50
|
+
in_pipe.close
|
51
|
+
end
|
52
|
+
|
53
|
+
def running?
|
54
|
+
Process.getpgid(@pid) && true
|
55
|
+
rescue Errno::ESRCH
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
def quit
|
60
|
+
Process.kill 'TERM', @pid
|
61
|
+
Process.wait @pid
|
62
|
+
FileUtils.rm_rf @tmp_dir, force: true
|
63
|
+
rescue
|
64
|
+
# no such process; assume it's already killed
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def dispatch
|
70
|
+
FileUtils.mkdir_p %W(#{@tmp_dir}/cache/ #{@tmp_dir}/user_data/), mode: 0777
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chromium-browser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piotr Krajewski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: " The Chromium client handler.\n"
|
14
|
+
email: mits87@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- Gemfile
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- chromium.gemspec
|
24
|
+
- lib/chromium.rb
|
25
|
+
homepage: https://github.com/mits87/chromium
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements:
|
44
|
+
- chromium
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.6.12
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: Chromium client handler
|
50
|
+
test_files: []
|