Permalink
Browse files

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

Closes #15
  • Loading branch information...
1 parent 87a00ab commit 827c3fc054d182a8d40cadb11b01a95e673126ee @joshuaclayton joshuaclayton committed Apr 15, 2011
Showing with 81 additions and 67 deletions.
  1. +0 −1 Gemfile
  2. +0 −1 Gemfile.lock
  3. +48 −62 Rakefile
  4. +0 −1 capybara-webkit.gemspec
  5. +2 −2 extconf.rb
  6. +31 −0 lib/capybara_webkit_builder.rb
View
@@ -1,5 +1,4 @@
source "http://rubygems.org"
-gem "rake"
gem "rspec", :require => false
gem "capybara"
gem "sinatra", :require => false
View
@@ -50,6 +50,5 @@ PLATFORMS
DEPENDENCIES
capybara
- rake
rspec
sinatra
View
@@ -1,91 +1,77 @@
-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|
- t.pattern = "spec/**/*_spec.rb"
- t.rspec_opts = "--format progress"
- end
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = "spec/**/*_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
+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"
+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 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 "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="
+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"
+ 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
+ %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
+ 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
+ File.open("src/find_command.h", "a") do |file|
+ file.write("CHECK_COMMAND(#{name})")
end
end
-
@@ -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
@@ -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
@@ -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

0 comments on commit 827c3fc

Please sign in to comment.