capit 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ 1.9.3-p0
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm ruby-1.9.2
1
+ rvm use --create 1.9.2@capit
data/Gemfile CHANGED
@@ -3,14 +3,14 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  group :test do
6
- gem 'rspec', '~> 2.5.0'
7
- gem 'yard', '~> 0.6.5'
8
-
9
- gem 'simplecov', '~> 0.4.0', :require => false
10
- gem 'guard', '~> 0.3.0'
11
- gem 'growl', '~> 1.0.3'
12
- gem 'guard-bundler', '~> 0.1.2'
13
- gem 'guard-rspec', '~> 0.2.0'
6
+ gem 'rspec'
7
+ gem 'yard'
8
+ gem 'simplecov', :require => false
9
+ gem 'guard'
10
+ gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
11
+ gem 'growl'
12
+ gem 'guard-bundler'
13
+ gem 'guard-rspec'
14
14
  end
15
15
 
16
16
  gemspec
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'rspec', :version => 2, :cli => '-c' do
1
+ guard 'rspec', :version => 2, :cli => '--color --format nested' do
2
2
  watch(%r{^spec/.+_spec\.rb})
3
3
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
data/README.md CHANGED
@@ -6,7 +6,17 @@ CapIt provides a simple Ruby interface to Björn Höhrmann's
6
6
  Install CutyCapt
7
7
  ----------------
8
8
 
9
- ### Ubuntu/Debian
9
+ ### OSX (via Homebrew)
10
+
11
+ brew install cuty_capt
12
+
13
+
14
+ ### Ubuntu >= 11.04 & Debian >= 6.0
15
+
16
+ sudo apt-get install xvfb
17
+ sudo apt-get install cutycapt
18
+
19
+ ### Other Ubuntu/Debian
10
20
  (from [Setting up Headless XServer and CutyCapt on Ubuntu][2])
11
21
 
12
22
  sudo apt-get install xvfb
@@ -20,10 +30,6 @@ Install CutyCapt
20
30
 
21
31
  You'll also need to make sure the `CutyCapt` executable is in your PATH.
22
32
 
23
- ### OSX (via Homebrew)
24
-
25
- brew install cuty_capt
26
-
27
33
  Install CapIt
28
34
  -------------
29
35
  gem install capit
@@ -23,10 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.test_files = `git ls-files -- spec/*`.split("\n")
24
24
 
25
25
  s.require_paths = ["lib"]
26
- s.add_development_dependency('rspec', '~> 2.5.0')
27
- s.add_development_dependency('simplecov', '~> 0.4.0')
28
- s.add_development_dependency('guard', '~> 0.3.0')
29
- s.add_development_dependency('growl', '~> 1.0.3')
30
- s.add_development_dependency('guard-bundler', '~> 0.1.2')
31
- s.add_development_dependency('guard-rspec', '~> 0.2.0')
26
+ s.add_dependency("hike")
27
+ s.add_development_dependency('rspec')
32
28
  end
@@ -25,12 +25,12 @@ module CapIt
25
25
  class Capture
26
26
 
27
27
  # All extensions CutyCapt can use to infer format of output
28
- EXTENSIONS = /\A[\w\-]+\.(svg|ps|pdf|itext|html|rtree|png|jpeg|jpg|mng|tiff|gif|bmp|ppm|xvm|xpm)\z/i
28
+ EXTENSIONS = /\A[\w\-\.]+\.(svg|ps|pdf|itext|html|rtree|png|jpeg|jpg|mng|tiff|gif|bmp|ppm|xvm|xpm)\z/i
29
29
 
30
30
  # The URL of the page to be captured
31
31
  attr_reader :url
32
32
 
33
- attr_accessor :folder, :filename, :user_agent, :max_wait, :delay, :output
33
+ attr_accessor :folder, :filename, :user_agent, :max_wait, :delay, :output, :cutycapt_path
34
34
 
35
35
  # Initialize a new Capture
36
36
  # @param [String] url The URL we want to capture.
@@ -45,14 +45,14 @@ module CapIt
45
45
  # @raise InvalidExtensionError
46
46
  #
47
47
  def initialize url, options = {}
48
- cutycapt_installed?
49
- @url = url
50
- @folder = options[:folder] || Dir.pwd
51
- @filename = options[:filename] || "capit.jpeg"
52
- @user_agent = options[:user_agent] || "CapIt! [http://github.com/meadvillerb/capit]"
53
- @max_wait = options[:max_wait] || 15000
54
- @delay = options[:delay]
55
-
48
+ @url = url
49
+ @folder = options[:folder] || Dir.pwd
50
+ @filename = options[:filename] || "capit.jpeg"
51
+ @user_agent = options[:user_agent] || "CapIt! [http://github.com/meadvillerb/capit]"
52
+ @max_wait = options[:max_wait] || 15000
53
+ @delay = options[:delay]
54
+ @cutycapt_path = options[:cutycapt_path] || determine_cutycapt_path
55
+
56
56
  valid_extension?(@filename)
57
57
  end
58
58
 
@@ -106,7 +106,7 @@ module CapIt
106
106
  # @return [String]
107
107
  #
108
108
  def capture_command
109
- cmd = "CutyCapt --url='#{@url}'"
109
+ cmd = "#{@cutycapt_path} --url='#{@url}'"
110
110
  cmd += " --out='#{@folder}/#{@filename}'"
111
111
  cmd += " --max-wait=#{@max_wait}"
112
112
  cmd += " --delay=#{@delay}" if @delay
@@ -120,6 +120,10 @@ module CapIt
120
120
  end
121
121
  end
122
122
 
123
+ def determine_cutycapt_path
124
+ `which CutyCapt`.strip or `which cutycapt`.strip
125
+ end
126
+
123
127
  # Uses RUBY_PLATFORM to determine the operating system.
124
128
  # Not foolproof, but good enough for the time being.
125
129
  #
@@ -133,14 +137,5 @@ module CapIt
133
137
  else raise InvalidOSError, "CapIt currently only works on the Mac and Linux platforms"
134
138
  end
135
139
  end
136
-
137
- # Checks to see if CutyCapt is available in PATH.
138
- # Raises CutyCaptError if not.
139
- #
140
- # @return
141
- #
142
- def cutycapt_installed?
143
- raise CutyCaptError, "CutyCapt must be installed and available on PATH" if `which CutyCapt`.empty?
144
- end
145
140
  end
146
- end
141
+ end
@@ -5,5 +5,5 @@ module CapIt
5
5
  #
6
6
  # The version number
7
7
  #
8
- VERSION = "0.2.3"
8
+ VERSION = "0.3.0"
9
9
  end
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
4
  describe CapIt do
5
5
  it "should have a Convenience Method" do
6
6
  @folder = setup_temporary_folder
7
- @capit = CapIt::Capture("http://mdvlrb.com/", :filename => 'test-mdvlrb.png', :folder => @folder).should == @folder + "/test-mdvlrb.png"
7
+ @capit = CapIt::Capture("http://mdvlrb.com/", :filename => 'one.test-mdvlrb.png', :folder => @folder).should == @folder + "/one.test-mdvlrb.png"
8
8
  destroy_temporary_folder(@folder)
9
9
  end
10
10
 
@@ -13,7 +13,7 @@ describe CapIt do
13
13
  subject { @capit }
14
14
 
15
15
  describe "#initialize" do
16
- it { should respond_to :url, :folder, :filename, :user_agent, :max_wait, :delay }
16
+ it { should respond_to :url, :folder, :filename, :user_agent, :max_wait, :delay, :cutycapt_path }
17
17
 
18
18
  context "defaults" do
19
19
  specify { @capit.folder.should == Dir.pwd }
@@ -53,6 +53,20 @@ describe CapIt do
53
53
  end
54
54
  end
55
55
 
56
+ describe "#cutycapt_path=" do
57
+ it "should allow the user to set CutyCapt's path" do
58
+ capit = CapIt::Capture.new("http://mdvlrb.com/")
59
+ capit.cutycapt_path = "/usr/local/sbin/CutyCapt"
60
+ capit.cutycapt_path.should == "/usr/local/sbin/CutyCapt"
61
+ end
62
+ end
63
+
64
+ describe "#determine_cutycapt_path" do
65
+ it "should determine the appropriate path for the executable if possible" do
66
+ @capit.determine_cutycapt_path.should == "/usr/local/bin/CutyCapt"
67
+ end
68
+ end
69
+
56
70
  describe "#capture_command" do
57
71
  before { @capit = CapIt::Capture.new("http://mdvlrb.com/") }
58
72
  subject { @capit }
@@ -68,7 +82,7 @@ describe CapIt do
68
82
  context "when platform is Mac" do
69
83
  it "should not add the xvfb prefix" do
70
84
  with_constants :RUBY_PLATFORM => "darwin" do
71
- @capit.capture_command.should match /^CutyCapt/
85
+ @capit.capture_command.should match /CutyCapt/
72
86
  end
73
87
  end
74
88
  end
@@ -82,14 +96,6 @@ describe CapIt do
82
96
  end
83
97
  end
84
98
  end
85
-
86
- context "when CutyCapt executable is unavailable" do
87
- it "should raise an error" do
88
- with_environment_variable 'PATH' => "" do
89
- expect { CapIt::Capture.new("http://mdvlrb.com/") }.to raise_error(/CutyCapt/)
90
- end
91
- end
92
- end
93
99
  end
94
100
  end
95
101
  end
@@ -1,14 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  require 'simplecov'
3
-
4
3
  SimpleCov.start do
5
4
  coverage_dir 'coverage'
6
5
  add_filter 'spec/'
7
6
  end
8
7
 
9
- require 'rspec'
10
- require 'support/with_constants'
11
- require 'support/deferred_garbage_collection' # http://makandra.com/notes/950-speed-up-rspec-by-deferring-garbage-collection
12
- require 'support/temporary_folder_helper'
13
-
8
+ Dir[File.expand_path('support', File.dirname(__FILE__)) + "/**/*.rb"].each { |f| require f }
14
9
  require 'capit'
metadata CHANGED
@@ -1,96 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capit
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
4
5
  prerelease:
5
- version: 0.2.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Ezekiel Templin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-04-14 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rspec
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 2.5.0
24
- type: :development
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: simplecov
28
- prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
12
+ date: 2011-04-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hike
16
+ requirement: &2152919040 !ruby/object:Gem::Requirement
30
17
  none: false
31
- requirements:
32
- - - ~>
33
- - !ruby/object:Gem::Version
34
- version: 0.4.0
35
- type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: guard
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
39
23
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 0.3.0
46
- type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: growl
50
- prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 1.0.3
57
- type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: guard-bundler
61
- prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
24
+ version_requirements: *2152919040
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &2152918600 !ruby/object:Gem::Requirement
63
28
  none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 0.1.2
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
68
33
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: guard-rspec
72
34
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 0.2.0
79
- type: :development
80
- version_requirements: *id006
81
- description: "CapIt provides a simple Ruby interface to Bj\xC3\xB6rn H\xC3\xB6hrmann's CutyCapt."
82
- email:
35
+ version_requirements: *2152918600
36
+ description: CapIt provides a simple Ruby interface to Björn Höhrmann's CutyCapt.
37
+ email:
83
38
  - ezkl@me.com
84
39
  executables: []
85
-
86
40
  extensions: []
87
-
88
- extra_rdoc_files:
41
+ extra_rdoc_files:
89
42
  - README.md
90
43
  - LICENSE
91
- files:
44
+ files:
92
45
  - .gemtest
93
46
  - .gitignore
47
+ - .rbenv-version
94
48
  - .rvmrc
95
49
  - .yardopts
96
50
  - Gemfile
@@ -110,32 +64,29 @@ files:
110
64
  - spec/support/with_constants.rb
111
65
  homepage: http://github.com/meadvillerb/capit
112
66
  licenses: []
113
-
114
67
  post_install_message:
115
68
  rdoc_options: []
116
-
117
- require_paths:
69
+ require_paths:
118
70
  - lib
119
- required_ruby_version: !ruby/object:Gem::Requirement
71
+ required_ruby_version: !ruby/object:Gem::Requirement
120
72
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: "0"
125
- required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
78
  none: false
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: "0"
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
131
83
  requirements: []
132
-
133
84
  rubyforge_project:
134
- rubygems_version: 1.7.2
85
+ rubygems_version: 1.8.15
135
86
  signing_key:
136
87
  specification_version: 3
137
88
  summary: Easy screen captures with the help of CutyCapt
138
- test_files:
89
+ test_files:
139
90
  - spec/capit/capture_spec.rb
140
91
  - spec/capit_spec.rb
141
92
  - spec/spec_helper.rb