capit 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1,48 @@
1
- rvm use --create 1.9.2@capit
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p125@capit"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.10.3" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ if [[ -s Gemfile ]] && {
38
+ ! builtin command -v bundle >/dev/null ||
39
+ builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
40
+ }
41
+ then
42
+ printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ gem install bundler
44
+ fi
45
+ if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ then
47
+ bundle install | grep -vE '^Using|Your bundle is complete'
48
+ fi
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ before_install:
7
+ - sudo apt-get install cutycapt
8
+ before_script:
9
+ - "export DISPLAY=:99.0"
10
+ - "sh -e /etc/init.d/xvfb start"
11
+ notifications:
12
+ irc:
13
+ - "irc.freenode.org#mdvlrb"
data/Gemfile CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- group :test do
6
- gem 'rspec'
7
- gem 'yard'
5
+ gemspec
6
+
7
+ group :development do
8
8
  gem 'simplecov', :require => false
9
+ gem 'yard', :require => false
9
10
  gem 'guard'
10
- gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
11
- gem 'growl'
12
- gem 'guard-bundler'
11
+ gem 'growl', :require => false
13
12
  gem 'guard-rspec'
13
+ gem 'rake', :require => false
14
14
  end
15
15
 
16
- gemspec
16
+
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
8
8
  s.version = CapIt::VERSION
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Ezekiel Templin"]
11
- s.email = ["ezkl@me.com"]
11
+ s.email = ["zeke@templ.in"]
12
12
  s.date = %q{2012-01-13}
13
- s.homepage = "http://github.com/meadvillerb/capit"
13
+ s.homepage = "http://github.com/ezkl/capit"
14
14
  s.summary = %q{Easy screen captures with the help of CutyCapt}
15
15
  s.description = %q{CapIt provides a simple Ruby interface to Björn Höhrmann's CutyCapt.}
16
16
 
@@ -23,5 +23,5 @@ 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')
26
+ s.add_development_dependency('rspec', "~> 2.9.0")
27
27
  end
@@ -30,7 +30,7 @@ module CapIt
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, :cutycapt_path
33
+ attr_accessor :folder, :filename, :user_agent, :max_wait, :delay, :output, :cutycapt_path, :min_width, :min_height
34
34
 
35
35
  # Initialize a new Capture
36
36
  # @param [String] url The URL we want to capture.
@@ -52,6 +52,8 @@ module CapIt
52
52
  @max_wait = options[:max_wait] || 15000
53
53
  @delay = options[:delay]
54
54
  @cutycapt_path = options[:cutycapt_path] || determine_cutycapt_path
55
+ @min_width = options[:min_width] || 1024
56
+ @min_height = options[:min_height] || 768
55
57
 
56
58
  valid_extension?(@filename)
57
59
  end
@@ -111,15 +113,22 @@ module CapIt
111
113
  cmd += " --max-wait=#{@max_wait}"
112
114
  cmd += " --delay=#{@delay}" if @delay
113
115
  cmd += " --user-agent='#{@user_agent}'"
116
+ cmd += " --min-width='#{@min_width}'"
117
+ cmd += " --min-height='#{@min_height}'"
118
+
114
119
 
115
- if determine_os == :linux
116
- xvfb = 'xvfb-run --server-args="-screen 0, 1024x768x24" '
120
+ if determine_os == :linux and check_xvfb
121
+ xvfb = 'xvfb-run --server-args="-screen 99, 1024x768x24" '
117
122
  xvfb.concat(cmd)
118
123
  else
119
124
  cmd
120
125
  end
121
126
  end
122
127
 
128
+ def check_xvfb
129
+ !(`which xvfb-run`.empty?)
130
+ end
131
+
123
132
  def determine_cutycapt_path
124
133
  `which CutyCapt`.strip or `which cutycapt`.strip
125
134
  end
@@ -5,5 +5,5 @@ module CapIt
5
5
  #
6
6
  # The version number
7
7
  #
8
- VERSION = "0.3.1"
8
+ VERSION = "0.3.2"
9
9
  end
@@ -20,6 +20,8 @@ describe CapIt do
20
20
  specify { @capit.filename.should == "capit.jpeg" }
21
21
  specify { @capit.user_agent.should == "CapIt! [http://github.com/meadvillerb/capit]" }
22
22
  specify { @capit.max_wait.should == 15000 }
23
+ specify { @capit.min_width.should == 1024 }
24
+ specify { @capit.min_height.should == 768 }
23
25
  end
24
26
  end
25
27
 
@@ -72,11 +74,19 @@ describe CapIt do
72
74
  subject { @capit }
73
75
 
74
76
  context "when platform is Linux" do
75
- it "should add the xvfb prefix" do
77
+ it "should add the xvfb prefix if xvfb-run available" do
78
+ @capit.stub(:check_xvfb).and_return(:true)
76
79
  with_constants :RUBY_PLATFORM => "linux" do
77
80
  @capit.capture_command.should match /^xvfb/
78
81
  end
79
82
  end
83
+
84
+ it 'should not add the xvfb prefix if xvfb-run not available' do
85
+ CapIt::Capture.stub(:check_xvfb).and_return(:false)
86
+ with_constants :RUBY_PLATFORM => "linux" do
87
+ @capit.capture_command.should_not match /^xvfb/
88
+ end
89
+ end
80
90
  end
81
91
 
82
92
  context "when platform is Mac" do
@@ -1,9 +1,3 @@
1
1
  # encoding: UTF-8
2
- require 'simplecov'
3
- SimpleCov.start do
4
- coverage_dir 'coverage'
5
- add_filter 'spec/'
6
- end
7
-
8
2
  Dir[File.expand_path('support', File.dirname(__FILE__)) + "/**/*.rb"].each { |f| require f }
9
3
  require 'capit'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,18 +13,23 @@ date: 2012-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2157649580 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 2.9.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2157649580
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.9.0
25
30
  description: CapIt provides a simple Ruby interface to Björn Höhrmann's CutyCapt.
26
31
  email:
27
- - ezkl@me.com
32
+ - zeke@templ.in
28
33
  executables: []
29
34
  extensions: []
30
35
  extra_rdoc_files:
@@ -35,6 +40,7 @@ files:
35
40
  - .gitignore
36
41
  - .rbenv-version
37
42
  - .rvmrc
43
+ - .travis.yml
38
44
  - .yardopts
39
45
  - Gemfile
40
46
  - Guardfile
@@ -51,7 +57,7 @@ files:
51
57
  - spec/support/deferred_garbage_collection.rb
52
58
  - spec/support/temporary_folder_helper.rb
53
59
  - spec/support/with_constants.rb
54
- homepage: http://github.com/meadvillerb/capit
60
+ homepage: http://github.com/ezkl/capit
55
61
  licenses: []
56
62
  post_install_message:
57
63
  rdoc_options: []
@@ -63,15 +69,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
69
  - - ! '>='
64
70
  - !ruby/object:Gem::Version
65
71
  version: '0'
72
+ segments:
73
+ - 0
74
+ hash: 1815721631992732020
66
75
  required_rubygems_version: !ruby/object:Gem::Requirement
67
76
  none: false
68
77
  requirements:
69
78
  - - ! '>='
70
79
  - !ruby/object:Gem::Version
71
80
  version: '0'
81
+ segments:
82
+ - 0
83
+ hash: 1815721631992732020
72
84
  requirements: []
73
85
  rubyforge_project:
74
- rubygems_version: 1.8.15
86
+ rubygems_version: 1.8.21
75
87
  signing_key:
76
88
  specification_version: 3
77
89
  summary: Easy screen captures with the help of CutyCapt