straight_shooter 0.0.1

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/FIXME ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Nathan Herald
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,25 @@
1
+ Taking screenshots of websites is now easy
2
+ ==========================================
3
+
4
+ ## Prerequisites
5
+
6
+ * Ruby > 1.8.6
7
+ * Rubygems
8
+ * Qt4 (with WebKit)
9
+ * xvfb
10
+
11
+ See the ubuntu-setup.sh file for a nice script to install everything you need for you.
12
+
13
+ ## Install
14
+
15
+ sudo gem install straight_shooter
16
+
17
+ ## Usage
18
+
19
+ xvfb-run -a straight_shooter http://google.com result.png
20
+
21
+ ## TODO
22
+
23
+ * Make it possible to start xvfb if it's not already running and have Qt use it for rendering
24
+ * How to run without xvfb?
25
+ * Prereq install instructions for more platforms
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "straight_shooter"
8
+ gem.summary = %Q{Taking screenshots of web sites is no longer hard}
9
+ gem.description = %Q{Takes screenshots of sites using WebKit and Qt}
10
+ gem.email = "nathan@myobie.com"
11
+ gem.homepage = "http://github.com/myobie/straight_shooter"
12
+ gem.authors = ["Nathan Herald"]
13
+ gem.add_development_dependency "bacon", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.pattern = 'spec/**/*_spec.rb'
25
+ spec.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |spec|
31
+ spec.libs << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :spec => :check_dependencies
42
+
43
+ task :default => :spec
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "straight_shooter #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/TODO ADDED
File without changes
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,7 @@
1
+ require "straight_shooter/page"
2
+
3
+ unless ARGV.length > 0
4
+ puts "usage: xvfb-run -a straight_shooter http://google.com result.png"
5
+ end
6
+
7
+ Page.new(ARGV[0], ARGV[1]).load!
@@ -0,0 +1 @@
1
+ require "straight_shooter/page"
@@ -0,0 +1,59 @@
1
+ require "Qt"
2
+ require "qtwebkit"
3
+
4
+ class Page < Qt::Object
5
+
6
+ slots 'started()', 'render(bool)'
7
+
8
+ attr_accessor :url, :filename, :web, :page
9
+
10
+ def app
11
+ @app ||= Qt::Application.new(ARGV)
12
+ end
13
+
14
+ def initialize(url, filename = nil)
15
+ super()
16
+
17
+ new_app
18
+
19
+ self.url = url
20
+ self.filename = filename ? filename.gsub(/.png$/, "") + ".png" : url.split("//").last.split("/").first + ".png"
21
+
22
+ self.web = Qt::WebView.new
23
+ self.page = web.page
24
+
25
+ connect(web, SIGNAL("loadStarted()"), self, SLOT('started()'))
26
+ connect(web, SIGNAL("loadFinished(bool)"), self, SLOT('render(bool)'))
27
+ end
28
+
29
+ def load
30
+ web.load(Qt::Url.new(url))
31
+ end
32
+ alias load! load
33
+
34
+ def started
35
+ puts "Loading #{url}..."
36
+ end
37
+
38
+ def render(ok)
39
+ if ok
40
+ puts "Rendering..."
41
+ frame = page.current_frame
42
+ page.set_viewport_size(frame.contents_size)
43
+ image = Qt::Image.new(page.viewport_size, Qt::Image::Format_ARGB32)
44
+ paint = Qt::Painter.new(image)
45
+ frame.render(paint)
46
+ paint.end
47
+ image.save(filename) ? puts("Saved to #{filename}") : puts("Failed to save")
48
+ else
49
+ puts "Page failed to load. No image was saved."
50
+ end
51
+
52
+ quit_app
53
+ end
54
+
55
+ def quit_app
56
+ app.quit
57
+ end
58
+
59
+ end
data/ubuntu-setup.sh ADDED
@@ -0,0 +1,31 @@
1
+
2
+ # sudo aptitude install ssh
3
+ # sudo /etc/init.d/ssh reload
4
+
5
+ mkdir sources
6
+
7
+ sudo aptitude -y update
8
+ sudo aptitude -y safe-upgrade
9
+ sudo aptitude -y full-upgrade
10
+ sudo aptitude -y install build-essential cmake wget ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8
11
+
12
+ sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
13
+ sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
14
+ sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
15
+ sudo ln -s /usr/bin/irb1.8 /usr/bin/irb
16
+
17
+ cd sources
18
+ wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
19
+ tar xzf rubygems-1.3.5.tgz
20
+ cd rubygems-1.3.5
21
+ sudo ruby setup.rb
22
+ cd ../..
23
+
24
+ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
25
+
26
+ sudo gem update
27
+ sudo gem update --system
28
+
29
+ sudo aptitude install -y libqt4-core libqt4-dbg libqt4-dev libqt4-deb-dbg libqt4-gui libqt4-network libqt4-ruby libqt4-ruby1.8 libqt4-ruby1.8-dev libqt4-webkit libqt4-webkit-dbg libqt4-xml lsb-qt4 qt4-dev-tools qt4-dev-tools-dbg qt4-qmake qt4-qtconfig xvfb
30
+
31
+ sudo gem install straight_shooter
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: straight_shooter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Herald
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-12 00:00:00 -05:00
13
+ default_executable: straight_shooter
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bacon
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Takes screenshots of sites using WebKit and Qt
26
+ email: nathan@myobie.com
27
+ executables:
28
+ - straight_shooter
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.markdown
34
+ - TODO
35
+ files:
36
+ - FIXME
37
+ - LICENSE
38
+ - README.markdown
39
+ - Rakefile
40
+ - TODO
41
+ - VERSION
42
+ - bin/straight_shooter
43
+ - lib/straight_shooter.rb
44
+ - lib/straight_shooter/page.rb
45
+ - ubuntu-setup.sh
46
+ has_rdoc: true
47
+ homepage: http://github.com/myobie/straight_shooter
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --charset=UTF-8
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.5
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Taking screenshots of web sites is no longer hard
74
+ test_files: []
75
+