gyazo_spector 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gyazo_spector.gemspec +36 -0
- data/lib/gyazo_spector/client.rb +52 -0
- data/lib/gyazo_spector/version.rb +3 -0
- data/lib/gyazo_spector.rb +11 -0
- metadata +217 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91f989f94e9e7061100f20b593d3f67e0bede51c
|
4
|
+
data.tar.gz: ae0eff1e014d67a0adebff162f01ea7ab4177e12
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2daabab23fc52ac0cde3efe6476e79119f7f93f12a15d297f4bb9e9478f7dfaa602af6647170117b1048cca88fcc322ff9e61336f2a6e5391ef6a1486e56ef81
|
7
|
+
data.tar.gz: 938c147a6f436bc8184c35dc56ae035d5b76d5b159be367105f1170c6e316bd71543904c7ceafbdacb0c39725b47290c931afd19b0dabba1c929a81ed1ff8418
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.1
|
5
|
+
before_install: gem install bundler -v 1.13.1
|
6
|
+
notifications:
|
7
|
+
slack:
|
8
|
+
secure: VbC0pS+ezz8BdM7VYOt0RHee1KOXXqtkrLPphGHMZCNYNUwRdTpW5U92JLmDskUsbxp3dLy5zIP5zF8YRJ9q9ShR1KWSriN1sgmPZQ9hD3fqlxAF5Pa+buZJAaRi/z+FeZj7Qty6B9cJsH6mPEwIjVnaVOmZDG08K7i9LHQRS6RVQIaG4vusx5jTxqmXHOsOvG8sHO6W5ewh+TcL0/kk2rc7+xtgNHXzcg33ocsURAn5OY7I8qImiK4cUxj2M0QrEwWSed5RfkmpiFTvcgpUyV6an1FStdaM3evddhy6i4bLUltqih6zP5z9NnHiyr+LrE5AVWsi/Hbv7PkSdXnQ1lYdE7Oft2hxiRHNQd3pMepYUwUDi7v2u9apsc4juA69nGe+j00UKzRMC9ypk0WWx05zgkULpEIxcrZJdFOjSBXh6fCwhAjKRxxh2BQJwGOJ02RbdKeEfTxnpA3Gmm5WnDpWbhWKeb61njGKZy/r01FLjgqpmwUPqe39ObtF6hOLOCcmGmNOh9A9/SJXMAnP0S0mgfvjFC6wL/wNoCFlO8XZulkSHDYTsEmR7OEOCtXofK2/abGQxufyY2tWN+A+5juxP8+Yk4ZtEDqnF0+ekuhCCS+wMrJ1ZidquQ2Z0caazJWhRujDYL4wC3KL+tb3uxkuaPotXh326WDtkN0H4b4=
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 TODO: Write your name
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# GyazoSpector [![Build Status](https://travis-ci.org/send/gyazo_spector.svg?branch=master)](https://travis-ci.org/send/gyazo_spector)
|
2
|
+
|
3
|
+
GyazoSpector is a Gyazo client for uploading a screenshot of any web page.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'gyazo_spector'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install gyazo_spector
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
client = GyazoSpector::Client.new
|
25
|
+
client.capture('http://example.com')
|
26
|
+
client.upload!
|
27
|
+
```
|
28
|
+
|
29
|
+
For uploading to another Gyazo-compatible server, then like below.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
client = GyazoSpector::Client.new(
|
33
|
+
site: 'http://gyazo.example.com',
|
34
|
+
endpoint: '/path/to/endpoint'
|
35
|
+
)
|
36
|
+
```
|
37
|
+
|
38
|
+
For capturing seleted elements.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
client.capture('http://example.com', selector: '#main > p')
|
42
|
+
```
|
43
|
+
|
44
|
+
execute js function before capturing.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
client.capture(url) do |page|
|
48
|
+
page.execute_script("example_function('001')")
|
49
|
+
sleep(3)
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gyazo_spector.
|
62
|
+
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
67
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'gyazo_spector'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gyazo_spector/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'gyazo_spector'
|
8
|
+
spec.version = GyazoSpector::VERSION
|
9
|
+
spec.authors = ['SAKAI, Kazuaki']
|
10
|
+
spec.email = ['kaz.july.7@gmail.com']
|
11
|
+
|
12
|
+
spec.summary =
|
13
|
+
'GyazoSpector is a Gyazo client for uploading a screenshots of a web page.'
|
14
|
+
spec.description =
|
15
|
+
'GyazoSpector capture full or part of a web page, upload to another server.'
|
16
|
+
spec.homepage = 'https://github.com/send/gyazo_spector'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'capybara', '~> 2.10'
|
25
|
+
spec.add_dependency 'faraday', '< 0.10', '>= 0.7.4'
|
26
|
+
spec.add_dependency 'nokogiri', '~> 1.6'
|
27
|
+
spec.add_dependency 'poltergeist', '~> 1.11'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.44'
|
33
|
+
spec.add_development_dependency 'simplecov', '~> 0.12'
|
34
|
+
spec.add_development_dependency 'travis', '~> 1.8'
|
35
|
+
spec.add_development_dependency 'webmock', '~> 2.1'
|
36
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GyazoSpector
|
4
|
+
# concreate implemtation of Client
|
5
|
+
class Client
|
6
|
+
CONTENT_TYPE = 'image/png'.freeze
|
7
|
+
DEFAULT_SITE = 'http://gyazo.com'.freeze
|
8
|
+
DEFAULT_ENDPOINT = '/'.freeze
|
9
|
+
DEFAULT_POLTERGEIST_OPTIONS = {
|
10
|
+
js_errors: false,
|
11
|
+
timeout: 1000,
|
12
|
+
debug: false
|
13
|
+
}.freeze
|
14
|
+
DEFAULT_SELECTOR = :css
|
15
|
+
|
16
|
+
attr_reader :site, :endpoint, :session, :imagedata
|
17
|
+
|
18
|
+
def initialize(opts = {})
|
19
|
+
@site = opts.delete(:site) || DEFAULT_SITE
|
20
|
+
@endpoint = opts.delete(:endpoint) || DEFAULT_ENDPOINT
|
21
|
+
Capybara.default_selector = opts.delete(:selector) || DEFAULT_SELECTOR
|
22
|
+
|
23
|
+
Capybara.register_driver :poltergeist do |app|
|
24
|
+
Capybara::Poltergeist::Driver.new(
|
25
|
+
app, DEFAULT_POLTERGEIST_OPTIONS.merge(opts)
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def session
|
31
|
+
@session ||= Capybara::Session.new(:poltergeist)
|
32
|
+
end
|
33
|
+
|
34
|
+
def capture(url, options = {})
|
35
|
+
session.visit(url)
|
36
|
+
yield(session) if block_given?
|
37
|
+
@imagedata = Base64.decode64(session.driver.render_base64(:png, options))
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def upload!
|
42
|
+
Faraday.new(site) do |client|
|
43
|
+
client.request :multipart
|
44
|
+
client.request :url_encoded
|
45
|
+
client.adapter Faraday.default_adapter
|
46
|
+
end.post(
|
47
|
+
endpoint,
|
48
|
+
imagedata: Faraday::UploadIO.new(StringIO.new(imagedata), CONTENT_TYPE)
|
49
|
+
).body
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'capybara'
|
3
|
+
require 'capybara/poltergeist'
|
4
|
+
require 'faraday'
|
5
|
+
require 'nokogiri'
|
6
|
+
|
7
|
+
# GyazoSpector is a Gyazo client for capturing web site.
|
8
|
+
module GyazoSpector
|
9
|
+
require 'gyazo_spector/version'
|
10
|
+
require 'gyazo_spector/client'
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gyazo_spector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SAKAI, Kazuaki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.10'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.7.4
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.10'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.7.4
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.6'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.6'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: poltergeist
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.11'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.11'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: bundler
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.13'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.13'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '10.0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '10.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rspec
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '3.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rubocop
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0.44'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0.44'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: simplecov
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0.12'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0.12'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: travis
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '1.8'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '1.8'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: webmock
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '2.1'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '2.1'
|
173
|
+
description: GyazoSpector capture full or part of a web page, upload to another server.
|
174
|
+
email:
|
175
|
+
- kaz.july.7@gmail.com
|
176
|
+
executables: []
|
177
|
+
extensions: []
|
178
|
+
extra_rdoc_files: []
|
179
|
+
files:
|
180
|
+
- ".gitignore"
|
181
|
+
- ".rspec"
|
182
|
+
- ".travis.yml"
|
183
|
+
- Gemfile
|
184
|
+
- LICENSE.txt
|
185
|
+
- README.md
|
186
|
+
- Rakefile
|
187
|
+
- bin/console
|
188
|
+
- bin/setup
|
189
|
+
- gyazo_spector.gemspec
|
190
|
+
- lib/gyazo_spector.rb
|
191
|
+
- lib/gyazo_spector/client.rb
|
192
|
+
- lib/gyazo_spector/version.rb
|
193
|
+
homepage: https://github.com/send/gyazo_spector
|
194
|
+
licenses:
|
195
|
+
- MIT
|
196
|
+
metadata: {}
|
197
|
+
post_install_message:
|
198
|
+
rdoc_options: []
|
199
|
+
require_paths:
|
200
|
+
- lib
|
201
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
requirements:
|
203
|
+
- - ">="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
requirements: []
|
212
|
+
rubyforge_project:
|
213
|
+
rubygems_version: 2.5.1
|
214
|
+
signing_key:
|
215
|
+
specification_version: 4
|
216
|
+
summary: GyazoSpector is a Gyazo client for uploading a screenshots of a web page.
|
217
|
+
test_files: []
|