webrazzi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9131cfe58ea4f82301a282b3cb2b407dd1e16696
4
+ data.tar.gz: 37b8042bd8348ec850dc6b195dada6af1f2ebc62
5
+ SHA512:
6
+ metadata.gz: fe4ca292480c3140c20156d67fae803e34fc54fcc84a864b0a0abc51fa07efc1564ab13647ae98e705688c2cd49c106f5c4fc74a352ad12b9d46c3e4fad93344
7
+ data.tar.gz: 15aab6175a8e3412770bec086d6feefc9a1bac1559b2eab6c7bff954b77c2aa3d099cc496c2ec6e13f482b2def1f9917f6a1c3e2a8f594350e360f78ef11a95c
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /*.png
11
+ /.DS_Store
12
+ /*.csv
13
+ /*.tsv
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in webrazzi.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Webrazzi
2
+
3
+ Capture web pages in the URL list.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'webrazzi'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install webrazzi
20
+
21
+ ## Usage
22
+
23
+ Make URL list file.
24
+
25
+ ```
26
+ http://www.ohmyglasses.jp/
27
+ http://yahoo.com/
28
+ http://www.starwars.com/
29
+ http://www.nationalgeographic.com/
30
+ ```
31
+
32
+ Simple capture.
33
+
34
+ ```
35
+ webrazzi capture list_filename
36
+ ```
37
+
38
+ Change user agent to mobile.
39
+
40
+ ```
41
+ webrazzi capture list_filename --mobile
42
+ ```
43
+
44
+ Change window size.
45
+
46
+ ```
47
+ webrazzi capture list_filename --mobile --size '375x1000'
48
+ ```
49
+
50
+ For basic authentication.
51
+
52
+ ```
53
+ webrazzi capture list_filename -u username -p password
54
+ ```
55
+
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it ( https://github.com/[my-github-username]/webrazzi/fork )
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "webrazzi"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/webrazzi ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'watir-webdriver'
5
+ require 'webdriver-user-agent'
6
+ require_relative '../lib/webrazzi/list_loader'
7
+
8
+ class Cli < Thor
9
+
10
+ desc 'Capture webpage', ''
11
+ option :username, aliases: :u
12
+ option :password, aliases: :p
13
+ option :mobile, default: false
14
+ option :size, default: '1280x768'
15
+ def capture(file_path)
16
+ username = options[:username]
17
+ password = options[:password]
18
+ need_auth = username && password
19
+ mobile = options[:mobile]
20
+ w, h = options[:size].split('x')
21
+
22
+ url_list = Webrazzi::ListFile.load(file_path)
23
+
24
+ driver = mobile ? Webdriver::UserAgent.driver(browser: :chrome, agent: :iphone) : :chrome
25
+ client = Watir::Browser.new driver
26
+ client.window.resize_to(w, h)
27
+
28
+ url_list.each do |url|
29
+ info url
30
+ basename = filenamelize(url)
31
+ access_url = need_auth ? authed_url(url, username, password) : url
32
+ client.goto(access_url)
33
+ client.driver.save_screenshot "#{basename}.png"
34
+ end
35
+
36
+ ensure
37
+ client.close
38
+
39
+ end
40
+ default_task :capture
41
+
42
+ private
43
+ DOUBLE_SLASH = Regex.new("//")
44
+ SLASH = Regex.new("/")
45
+ PROTOCOL = Regex.new("https?://")
46
+ def authed_url(url, username, password)
47
+ url.sub(DOUBLE_SLASH , "//#{username}:#{password}@")
48
+ end
49
+
50
+ def filenamelize(url)
51
+ url.gsub(PROTOCOL, '').gsub(SLASH, '%')
52
+ end
53
+
54
+ def info(*args)
55
+ puts args.join(' ')
56
+ end
57
+ end
58
+ Cli.start(ARGV)
@@ -0,0 +1,7 @@
1
+ module Webrazzi
2
+ class ListFile
3
+ def self.load(file_path)
4
+ File.open(file_path).readlines
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Webrazzi
2
+ VERSION = "0.1.0"
3
+ end
data/lib/webrazzi.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "webrazzi/version"
2
+
3
+ module Webrazzi
4
+ # Your code goes here...
5
+ end
data/webrazzi.gemspec ADDED
@@ -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 'webrazzi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "webrazzi"
8
+ spec.version = Webrazzi::VERSION
9
+ spec.authors = ["J.Fukaya"]
10
+ spec.email = ["fukajun.shark@gmail.com"]
11
+
12
+ spec.summary = %q{Capture web page.}
13
+ spec.description = %q{Capture web page.}
14
+ spec.homepage = "https://github.com/fukajun/webrazzi"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor", "0.19.1"
22
+ spec.add_dependency "watir-webdriver", "0.9.1"
23
+ spec.add_dependency "webdriver-user-agent", "7.1"
24
+ spec.add_dependency "watir", "5.0.0"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.9"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webrazzi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - J.Fukaya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: watir-webdriver
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: webdriver-user-agent
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: '7.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: '7.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: watir
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 5.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 5.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ description: Capture web page.
98
+ email:
99
+ - fukajun.shark@gmail.com
100
+ executables:
101
+ - webrazzi
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/setup
112
+ - exe/webrazzi
113
+ - lib/webrazzi.rb
114
+ - lib/webrazzi/list_loader.rb
115
+ - lib/webrazzi/version.rb
116
+ - webrazzi.gemspec
117
+ homepage: https://github.com/fukajun/webrazzi
118
+ licenses: []
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.2.3
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Capture web page.
140
+ test_files: []