capit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +5 -0
- data/Rakefile +2 -0
- data/capit.gemspec +20 -0
- data/lib/capit.rb +5 -0
- data/lib/capit/capture.rb +53 -0
- data/lib/capit/version.rb +3 -0
- metadata +63 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/capit.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'capit/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "capit"
|
7
|
+
s.version = CapIt::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ezekiel Templin"]
|
10
|
+
s.email = ["ezkl@me.com"]
|
11
|
+
s.homepage = "http://github.com/meadvillerb/capit"
|
12
|
+
s.summary = %q{Easy screen captures with the help of CutyCapt}
|
13
|
+
s.description = %q{ Easy screen captures with the help of CutyCapt. Very much a WIP.
|
14
|
+
Install instructions, examples, etc coming very soon. }
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
data/lib/capit.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'postrank-uri'
|
2
|
+
|
3
|
+
module CapIt
|
4
|
+
class << self
|
5
|
+
def Capture url, options = {}
|
6
|
+
CapIt::Capture.new(url, options).capture
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Capture
|
11
|
+
attr_reader :url
|
12
|
+
attr_accessor :folder, :filename, :user_agent, :max_wait, :delay
|
13
|
+
|
14
|
+
def initialize url, options = {}
|
15
|
+
@url = PostRank::URI.clean(url)
|
16
|
+
@folder = options[:folder] || Dir.pwd
|
17
|
+
@filename = options[:filename] || "capit.jpg"
|
18
|
+
@user_agent = options[:user_agent] || "CapIt! [http://github.com/meadvillerb/capit]"
|
19
|
+
@max_wait = options[:max_wait] || 15000
|
20
|
+
@delay = options[:delay]
|
21
|
+
end
|
22
|
+
|
23
|
+
def capture
|
24
|
+
`#{capture_command}`
|
25
|
+
FileTest.exists?("#{@folder}/#{@filename}")
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
def determine_os
|
30
|
+
case RUBY_PLATFORM
|
31
|
+
when /darwin/ then :mac
|
32
|
+
when /linux/ then :linux
|
33
|
+
else :error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def capture_command
|
38
|
+
cmd = "CutyCapt"
|
39
|
+
cmd += " --url='#{@url}'"
|
40
|
+
cmd += " --out='#{@folder}/#{@filename}'"
|
41
|
+
cmd += " --max-wait=#{@max_wait}"
|
42
|
+
cmd += " --delay=#{@delay}" if @delay
|
43
|
+
cmd += " --user-agent='#{@user_agent}'"
|
44
|
+
|
45
|
+
if determine_os == :linux
|
46
|
+
xvfb = 'xvfb-run --server-args="-screen 0, 1024x768x24" '
|
47
|
+
xvfb.concat(cmd)
|
48
|
+
else
|
49
|
+
cmd
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ezekiel Templin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-24 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: " Easy screen captures with the help of CutyCapt. Very much a WIP. \n Install instructions, examples, etc coming very soon. "
|
18
|
+
email:
|
19
|
+
- ezkl@me.com
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- Gemfile
|
29
|
+
- Rakefile
|
30
|
+
- capit.gemspec
|
31
|
+
- lib/capit.rb
|
32
|
+
- lib/capit/capture.rb
|
33
|
+
- lib/capit/version.rb
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://github.com/meadvillerb/capit
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
requirements: []
|
56
|
+
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.6.2
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Easy screen captures with the help of CutyCapt
|
62
|
+
test_files: []
|
63
|
+
|