Skip to content
Browse files

Initial gem

  • Loading branch information...
1 parent 52ff473 commit 9e27f7d6f41228e2bb641560369ad49b9b943277 @jferris jferris committed Feb 26, 2011
Showing with 65 additions and 37 deletions.
  1. +1 −0 .gitignore
  2. +46 −35 Rakefile
  3. +14 −0 capybara-webkit.gemspec
  4. +2 −0 extconf.rb
  5. +2 −1 lib/capybara/driver/webkit/browser.rb
  6. +0 −1 spec/spec_helper.rb
View
1 .gitignore
@@ -10,3 +10,4 @@ qrc_*
*.app
moc_*.cpp
.bundle
+pkg
View
81 Rakefile
@@ -2,35 +2,7 @@ require 'rubygems'
require 'bundler/setup'
require 'fileutils'
require 'rspec/core/rake_task'
-
-desc "Generate a new command called NAME"
-task :generate_command do
- name = ENV['NAME'] or raise "Provide a name with NAME="
-
- header = "src/#{name}.h"
- source = "src/#{name}.cpp"
-
- %w(h cpp).each do |extension|
- File.open("templates/Command.#{extension}", "r") do |source_file|
- contents = source_file.read
- contents.gsub!("NAME", name)
- File.open("src/#{name}.#{extension}", "w") do |target_file|
- target_file.write(contents)
- end
- end
- end
-
- Dir.glob("src/*.pro").each do |project_file_name|
- project = IO.read(project_file_name)
- project.gsub!(/^(HEADERS = .*)/, "\\1 #{name}.h")
- project.gsub!(/^(SOURCES = .*)/, "\\1 #{name}.cpp")
- File.open(project_file_name, "w") { |file| file.write(project) }
- end
-
- File.open("src/find_command.h", "a") do |file|
- file.write("CHECK_COMMAND(#{name})")
- end
-end
+require 'rake/gempackagetask'
desc "Generate a Makefile using qmake"
file 'Makefile' do
@@ -55,11 +27,50 @@ task :build => :qmake do
end
end
-RSpec::Core::RakeTask.new do |t|
- t.pattern = "spec/{*_spec.rb,**/*_spec.rb}"
- t.rspec_opts = "--format progress"
-end
+file 'bin/webkit_server' => :build
+
+unless ENV["BUILD"]
+ RSpec::Core::RakeTask.new do |t|
+ t.pattern = "spec/{*_spec.rb,**/*_spec.rb}"
+ t.rspec_opts = "--format progress"
+ end
-desc "Default: build and run all specs"
-task :default => [:build, :spec]
+ desc "Default: build and run all specs"
+ task :default => [:build, :spec]
+
+ eval("$specification = begin; #{IO.read('capybara-webkit.gemspec')}; end")
+ Rake::GemPackageTask.new($specification) do |package|
+ package.need_zip = true
+ package.need_tar = true
+ end
+
+ desc "Generate a new command called NAME"
+ task :generate_command do
+ name = ENV['NAME'] or raise "Provide a name with NAME="
+
+ header = "src/#{name}.h"
+ source = "src/#{name}.cpp"
+
+ %w(h cpp).each do |extension|
+ File.open("templates/Command.#{extension}", "r") do |source_file|
+ contents = source_file.read
+ contents.gsub!("NAME", name)
+ File.open("src/#{name}.#{extension}", "w") do |target_file|
+ target_file.write(contents)
+ end
+ end
+ end
+
+ Dir.glob("src/*.pro").each do |project_file_name|
+ project = IO.read(project_file_name)
+ project.gsub!(/^(HEADERS = .*)/, "\\1 #{name}.h")
+ project.gsub!(/^(SOURCES = .*)/, "\\1 #{name}.cpp")
+ File.open(project_file_name, "w") { |file| file.write(project) }
+ end
+
+ File.open("src/find_command.h", "a") do |file|
+ file.write("CHECK_COMMAND(#{name})")
+ end
+ end
+end
View
14 capybara-webkit.gemspec
@@ -0,0 +1,14 @@
+Gem::Specification.new do |s|
+ s.name = "capybara-webkit"
+ s.version = "0.1.0"
+ s.authors = ["thoughtbot", "Joe Ferris", "Jason Morrison", "Tristan Dunn"]
+ s.email = "support@thoughtbot.com"
+ s.files = Dir['[A-Z]*', 'lib/**/*.rb', 'spec/**/*.rb', '**/*.pro', 'src/*.cpp', 'src/*.h', 'src/*.qrc', 'src/*.pro', 'src/*.js', "extconf.rb", "bin/*"]
+ s.homepage = "http://github.com/thoughtbot/capybara-webkit"
+ s.require_path = "lib"
+ s.rubygems_version = "1.3.5"
+ s.summary = "Headless Webkit driver for Capybara"
+ s.add_runtime_dependency "capybara", "~> 0.4.1"
+ s.extensions = "extconf.rb"
+end
+
View
2 extconf.rb
@@ -0,0 +1,2 @@
+system("rake build BUILD=true")
+
View
3 lib/capybara/driver/webkit/browser.rb
@@ -52,7 +52,8 @@ def execute_script(script)
private
def start_server
- @pid = fork { exec("webkit_server") }
+ server_path = File.expand_path("../../../../../bin/webkit_server", __FILE__)
+ @pid = fork { exec(server_path) }
at_exit { Process.kill("INT", @pid) }
end
View
1 spec/spec_helper.rb
@@ -4,7 +4,6 @@
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
$LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
-ENV["PATH"] = ENV["PATH"] + ":" + File.join(PROJECT_ROOT, "bin")
Dir[File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')].each { |file| require(file) }

0 comments on commit 9e27f7d

Please sign in to comment.
Something went wrong with that request. Please try again.