1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Move code that compiles Webkit into separate file to support Ruby 1.9.2

Closes #15
This commit is contained in:
Joshua Clayton 2011-04-15 17:19:26 -04:00
parent 87a00ab672
commit 827c3fc054
6 changed files with 93 additions and 79 deletions

View file

@ -1,5 +1,4 @@
source "http://rubygems.org"
gem "rake"
gem "rspec", :require => false
gem "capybara"
gem "sinatra", :require => false

View file

@ -50,6 +50,5 @@ PLATFORMS
DEPENDENCIES
capybara
rake
rspec
sinatra

View file

@ -1,66 +1,54 @@
require 'fileutils'
unless ENV["BUILD"]
require 'rubygems'
require 'bundler/setup'
require 'rspec/core/rake_task'
require 'rake/gempackagetask'
end
require 'rubygems'
require 'bundler/setup'
require 'rspec/core/rake_task'
require 'rake/gempackagetask'
require 'capybara_webkit_builder'
desc "Generate a Makefile using qmake"
file 'Makefile' do
sh("qmake -spec macx-g++")
CapybaraWebkitBuilder.makefile
end
desc "Regenerate dependencies using qmake"
task :qmake => 'Makefile' do
sh("make qmake")
CapybaraWebkitBuilder.qmake
end
desc "Build the webkit server"
task :build => :qmake do
sh("make")
FileUtils.mkdir("bin") unless File.directory?("bin")
if File.exist?("src/webkit_server.app")
FileUtils.cp("src/webkit_server.app/Contents/MacOS/webkit_server", "bin", :preserve => true)
else
FileUtils.cp("src/webkit_server", "bin", :preserve => true)
end
CapybaraWebkitBuilder.build
end
file 'bin/webkit_server' => :build
unless ENV["BUILD"]
RSpec::Core::RakeTask.new do |t|
RSpec::Core::RakeTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
t.rspec_opts = "--format progress"
end
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|
eval("$specification = begin; #{IO.read('capybara-webkit.gemspec')}; end")
Rake::GemPackageTask.new($specification) do |package|
package.need_zip = true
package.need_tar = true
end
end
gem_file = "pkg/#{$specification.name}-#{$specification.version}.gem"
gem_file = "pkg/#{$specification.name}-#{$specification.version}.gem"
desc "Build and install the latest gem"
task :install => :gem do
desc "Build and install the latest gem"
task :install => :gem do
sh("gem install --local #{gem_file}")
end
end
desc "Build and release the latest gem"
task :release => :gem do
desc "Build and release the latest gem"
task :release => :gem do
sh("gem push #{gem_file}")
end
end
desc "Generate a new command called NAME"
task :generate_command do
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"
@ -86,6 +74,4 @@ unless ENV["BUILD"]
File.open("src/find_command.h", "a") do |file|
file.write("CHECK_COMMAND(#{name})")
end
end
end

View file

@ -10,7 +10,6 @@ Gem::Specification.new do |s|
s.rubygems_version = "1.3.5"
s.summary = "Headless Webkit driver for Capybara"
s.add_runtime_dependency "capybara", "~> 0.4.1"
s.add_runtime_dependency "rake"
s.extensions = "extconf.rb"
end

View file

@ -1,2 +1,2 @@
system("rake build BUILD=true")
require File.join(File.expand_path(File.dirname(__FILE__)), "lib", "capybara_webkit_builder")
CapybaraWebkitBuilder.build_all

View file

@ -0,0 +1,31 @@
require "fileutils"
module CapybaraWebkitBuilder
extend self
def makefile
system("qmake -spec macx-g++")
end
def qmake
system("make qmake")
end
def build
system("make")
FileUtils.mkdir("bin") unless File.directory?("bin")
if File.exist?("src/webkit_server.app")
FileUtils.cp("src/webkit_server.app/Contents/MacOS/webkit_server", "bin", :preserve => true)
else
FileUtils.cp("src/webkit_server", "bin", :preserve => true)
end
end
def build_all
makefile
qmake
build
end
end