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" source "http://rubygems.org"
gem "rake"
gem "rspec", :require => false gem "rspec", :require => false
gem "capybara" gem "capybara"
gem "sinatra", :require => false gem "sinatra", :require => false

View file

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

134
Rakefile
View file

@ -1,91 +1,77 @@
require 'fileutils' require 'rubygems'
require 'bundler/setup'
unless ENV["BUILD"] require 'rspec/core/rake_task'
require 'rubygems' require 'rake/gempackagetask'
require 'bundler/setup' require 'capybara_webkit_builder'
require 'rspec/core/rake_task'
require 'rake/gempackagetask'
end
desc "Generate a Makefile using qmake" desc "Generate a Makefile using qmake"
file 'Makefile' do file 'Makefile' do
sh("qmake -spec macx-g++") CapybaraWebkitBuilder.makefile
end end
desc "Regenerate dependencies using qmake" desc "Regenerate dependencies using qmake"
task :qmake => 'Makefile' do task :qmake => 'Makefile' do
sh("make qmake") CapybaraWebkitBuilder.qmake
end end
desc "Build the webkit server" desc "Build the webkit server"
task :build => :qmake do task :build => :qmake do
sh("make") CapybaraWebkitBuilder.build
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 end
file 'bin/webkit_server' => :build 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.pattern = "spec/**/*_spec.rb" t.rspec_opts = "--format progress"
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
gem_file = "pkg/#{$specification.name}-#{$specification.version}.gem"
desc "Build and install the latest gem"
task :install => :gem do
sh("gem install --local #{gem_file}")
end
desc "Build and release the latest gem"
task :release => :gem do
sh("gem push #{gem_file}")
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 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
gem_file = "pkg/#{$specification.name}-#{$specification.version}.gem"
desc "Build and install the latest gem"
task :install => :gem do
sh("gem install --local #{gem_file}")
end
desc "Build and release the latest gem"
task :release => :gem do
sh("gem push #{gem_file}")
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

View file

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