sugoi_webpage_capture 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +43 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +7 -0
- data/lib/sugoi_webpage_capture.rb +21 -0
- data/lib/sugoi_webpage_capture/screenshot.rb +20 -0
- data/lib/sugoi_webpage_capture/version.rb +3 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/sugoi_webpage_capture_spec.rb +37 -0
- data/sugoi_webpage_capture.gemspec +28 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fea7595d6443eb7afdde2e7eb6e4b09e64ffb4c0
|
4
|
+
data.tar.gz: b5717b975e3d6a715f571bdc294a110a542f2a21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 339d5cf7fee1a9170e5659bbc2f0042ea17dbf45c6302b5e2ae17bb0b851bb8231c642ff6d2035dcb8fa6b73827b6b1c37839da1f22e91e714c2611488e882e5
|
7
|
+
data.tar.gz: 3425125785218067d163550f62a9d9bd2a1141db5667b933093bf956ae7e052af77e7fcb9fd912418c07c88a9b2d68ed78d6bd1d90c79abe605b500cf472ee45
|
data/.gitignore
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.bundle
|
11
|
+
*.so
|
12
|
+
*.o
|
13
|
+
*.a
|
14
|
+
mkmf.log
|
15
|
+
*.rbc
|
16
|
+
*.sassc
|
17
|
+
.sass-cache
|
18
|
+
capybara-*.html
|
19
|
+
.rspec
|
20
|
+
.rvmrc
|
21
|
+
.ruby-version
|
22
|
+
/.bundle
|
23
|
+
/vendor/bundle
|
24
|
+
/log/*
|
25
|
+
/tmp/*
|
26
|
+
/db/*.sqlite3
|
27
|
+
/public/system/*
|
28
|
+
/coverage/
|
29
|
+
/spec/tmp/*
|
30
|
+
**.orig
|
31
|
+
rerun.txt
|
32
|
+
pickle-email-*.html
|
33
|
+
.project
|
34
|
+
.rvmrc
|
35
|
+
.rspec
|
36
|
+
*~
|
37
|
+
._*
|
38
|
+
config/database.yml
|
39
|
+
*.swp
|
40
|
+
.DS_Store
|
41
|
+
public/assets/
|
42
|
+
vendor/bundler/
|
43
|
+
screenlog.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 jiikko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# SugoiWebpageCapture
|
2
|
+
Simple webpage capture, using selenium.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'sugoi_webpage_capture'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install sugoi_webpage_capture
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require "sugoi_webpage_capture"
|
24
|
+
|
25
|
+
screenshot = SugoiWebpageCapture::Screenshot.new
|
26
|
+
tempfile = screenshot.capture(captured_url) # return captured image.
|
27
|
+
tempfile.unlink
|
28
|
+
```
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( https://github.com/[my-github-username]/sugoi_webpage_capture/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'capybara/dsl'
|
2
|
+
require "selenium-webdriver"
|
3
|
+
require "sugoi_webpage_capture/version"
|
4
|
+
require "sugoi_webpage_capture/screenshot"
|
5
|
+
|
6
|
+
module SugoiWebpageCapture
|
7
|
+
BROWSERS = {
|
8
|
+
firefox: :selenium,
|
9
|
+
chrome: :selenium_chrome
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.init(browser)
|
13
|
+
raise("not found browser") unless BROWSERS.key?(browser)
|
14
|
+
|
15
|
+
Capybara.run_server = false
|
16
|
+
Capybara.register_driver BROWSERS[browser] do |app|
|
17
|
+
Capybara::Selenium::Driver.new(app, browser: browser)
|
18
|
+
end
|
19
|
+
Capybara.current_driver = BROWSERS[browser]
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SugoiWebpageCapture
|
2
|
+
class Screenshot
|
3
|
+
include Capybara::DSL
|
4
|
+
|
5
|
+
def initialize(browser: :firefox)
|
6
|
+
SugoiWebpageCapture.init(browser)
|
7
|
+
end
|
8
|
+
|
9
|
+
def capture(captured_url)
|
10
|
+
page.current_window.resize_to(1024, 768)
|
11
|
+
|
12
|
+
tempfile = Tempfile.new(["ss", ".png"])
|
13
|
+
visit captured_url
|
14
|
+
yield(self) if block_given?
|
15
|
+
# TODO Chtome full size capture
|
16
|
+
page.driver.save_screenshot(tempfile, full: true)
|
17
|
+
tempfile
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SugoiWebpageCapture do
|
4
|
+
it 'has a version number' do
|
5
|
+
expect(SugoiWebpageCapture::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "webdriber" do
|
9
|
+
context 'firefox' do
|
10
|
+
describe 'within' do
|
11
|
+
it 'be success' do
|
12
|
+
screenshot = SugoiWebpageCapture::Screenshot.new
|
13
|
+
tempfile = screenshot.capture("http://search.yahoo.co.jp") do |x|
|
14
|
+
x.fill_in 'yschsp', with: "あげぽよ"
|
15
|
+
x.find(".b").click
|
16
|
+
end
|
17
|
+
expect(tempfile).to be_a Tempfile
|
18
|
+
expect(Capybara.current_driver).to eq :selenium
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'be success' do
|
23
|
+
screenshot = SugoiWebpageCapture::Screenshot.new
|
24
|
+
expect(screenshot.capture("http://google.com")).to be_a Tempfile
|
25
|
+
expect(Capybara.current_driver).to eq :selenium
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'chrome' do
|
30
|
+
it 'be success' do
|
31
|
+
screenshot = SugoiWebpageCapture::Screenshot.new(browser: :chrome)
|
32
|
+
expect(Capybara.current_driver).to eq :selenium_chrome
|
33
|
+
expect(screenshot.capture("http://google.com")).to be_a Tempfile
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sugoi_webpage_capture/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sugoi_webpage_capture"
|
8
|
+
spec.version = SugoiWebpageCapture::VERSION
|
9
|
+
spec.authors = ["jiikko"]
|
10
|
+
spec.email = ["n905i.1214@gmail.com"]
|
11
|
+
spec.description = %q{Webpage capture.}
|
12
|
+
spec.summary = %q{Webpage capture, using selenium.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
|
25
|
+
spec.add_dependency 'capybara'
|
26
|
+
spec.add_dependency 'selenium-webdriver'
|
27
|
+
spec.add_dependency 'chromedriver-helper'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sugoi_webpage_capture
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jiikko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: selenium-webdriver
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: chromedriver-helper
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Webpage capture.
|
98
|
+
email:
|
99
|
+
- n905i.1214@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/sugoi_webpage_capture.rb
|
112
|
+
- lib/sugoi_webpage_capture/screenshot.rb
|
113
|
+
- lib/sugoi_webpage_capture/version.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- spec/sugoi_webpage_capture_spec.rb
|
116
|
+
- sugoi_webpage_capture.gemspec
|
117
|
+
homepage: ''
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.4.5
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Webpage capture, using selenium.
|
141
|
+
test_files:
|
142
|
+
- spec/spec_helper.rb
|
143
|
+
- spec/sugoi_webpage_capture_spec.rb
|