url2thumb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in url2thumb.gemspec
4
+ gemspec
5
+
6
+ gem "capybara-webkit"
7
+ gem "highline/import"
8
+ gem "thor"
9
+
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ url2thumb (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ capybara (2.2.0)
10
+ mime-types (>= 1.16)
11
+ nokogiri (>= 1.3.3)
12
+ rack (>= 1.0.0)
13
+ rack-test (>= 0.5.4)
14
+ xpath (~> 2.0)
15
+ capybara-webkit (1.1.0)
16
+ capybara (~> 2.0, >= 2.0.2)
17
+ json
18
+ json (1.8.1)
19
+ mime-types (2.0)
20
+ mini_portile (0.5.2)
21
+ nokogiri (1.6.1)
22
+ mini_portile (~> 0.5.0)
23
+ rack (1.5.2)
24
+ rack-test (0.6.2)
25
+ rack (>= 1.0)
26
+ rake (10.1.1)
27
+ xpath (2.0.0)
28
+ nokogiri (~> 1.3)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.3)
35
+ capybara-webkit
36
+ rake
37
+ url2thumb!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Stephen Hu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ url2thumb
2
+ =========
3
+
4
+ Ruby thumbnail generator, leverages capybara webkit to convert a url to image.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/url2thumb ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "url2thumb"
3
+
4
+ Url2thumb::CLI.start
5
+
data/lib/url2thumb.rb ADDED
@@ -0,0 +1,15 @@
1
+ require "capybara-webkit"
2
+ require "digest/md5"
3
+ require "highline/import"
4
+ require "thor"
5
+
6
+ require "url2thumb/capytool"
7
+ require "url2thumb/cli"
8
+ require "url2thumb/version"
9
+
10
+ module Url2thumb
11
+
12
+ PNGEXT = ".png".freeze
13
+
14
+ end
15
+
@@ -0,0 +1,43 @@
1
+ module Url2thumb
2
+
3
+ class Capytool
4
+ include Capybara::DSL
5
+
6
+ def initialize
7
+
8
+ Capybara.configure do |config|
9
+ config.run_server = false
10
+ config.default_driver
11
+ config.current_driver = :webkit
12
+ config.app = "generic"
13
+ config.app_host = ""
14
+ end
15
+
16
+ end
17
+
18
+ def to_thumbnail(url)
19
+
20
+ visit url
21
+
22
+ page.driver.resize_window( 1024, 768 )
23
+
24
+ hash = Digest::MD5.hexdigest(url)
25
+
26
+ filename = hash[0..8] + PNGEXT
27
+
28
+ unless File.exists?(filename)
29
+
30
+ page.save_screenshot( filename, width: 1024, height: 768 )
31
+
32
+ return true
33
+
34
+ end
35
+
36
+ return false
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
@@ -0,0 +1,17 @@
1
+ module Url2thumb
2
+
3
+ class CLI < Thor
4
+
5
+ desc( "capture", "capture url and convert into a thumbnail" )
6
+ def capture(url)
7
+
8
+ capy = Url2thumb::Capytool.new
9
+
10
+ capy.to_thumbnail(url)
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+
@@ -0,0 +1,3 @@
1
+ module Url2thumb
2
+ VERSION = "0.0.1"
3
+ end
data/url2thumb.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'url2thumb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "url2thumb"
8
+ spec.version = Url2thumb::VERSION
9
+ spec.authors = ["stephenhu"]
10
+ spec.email = ["epynonymous@outlook.com"]
11
+ spec.description = %q{Ruby thumbnail generator}
12
+ spec.summary = %q{Leverages capybara-webkit to convert urls to images}
13
+ spec.homepage = "https://github.io/stephenhu/url2thumb"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3"
22
+ spec.add_development_dependency "rake"
23
+ end
24
+
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: url2thumb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - stephenhu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Ruby thumbnail generator
47
+ email:
48
+ - epynonymous@outlook.com
49
+ executables:
50
+ - url2thumb
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - bin/url2thumb
61
+ - lib/url2thumb.rb
62
+ - lib/url2thumb/capytool.rb
63
+ - lib/url2thumb/cli.rb
64
+ - lib/url2thumb/version.rb
65
+ - url2thumb.gemspec
66
+ homepage: https://github.io/stephenhu/url2thumb
67
+ licenses:
68
+ - MIT
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.23
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Leverages capybara-webkit to convert urls to images
91
+ test_files: []