Initial gem

This commit is contained in:
Joe Ferris 2011-02-26 18:28:42 -05:00
parent 52ff47388d
commit 9e27f7d6f4
6 changed files with 65 additions and 37 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ qrc_*
*.app
moc_*.cpp
.bundle
pkg

View File

@ -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"
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]
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
desc "Default: build and run all specs"
task :default => [:build, :spec]

14
capybara-webkit.gemspec Normal file
View File

@ -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

2
extconf.rb Normal file
View File

@ -0,0 +1,2 @@
system("rake build BUILD=true")

View File

@ -52,7 +52,8 @@ class Capybara::Driver::Webkit
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 File

@ -4,7 +4,6 @@ require 'rspec/autorun'
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) }