Module: CapybaraWebkitBuilder
- Extended by:
- CapybaraWebkitBuilder
- Included in:
- CapybaraWebkitBuilder
- Defined in:
- lib/capybara_webkit_builder.rb
Constant Summary collapse
- SUCCESS_STATUS =
0
- COMMAND_NOT_FOUND_STATUS =
127
Instance Method Summary collapse
- #build ⇒ Object
- #build_all ⇒ Object
- #clean ⇒ Object
- #default_configs ⇒ Object
- #default_qmake_binary ⇒ Object
- #make_bin ⇒ Object
- #makefile(*configs) ⇒ Object
- #os_spec ⇒ Object
- #path_to_binary ⇒ Object
- #qmake ⇒ Object
- #qmake_bin ⇒ Object
- #sh(command) ⇒ Object
- #spec ⇒ Object
Instance Method Details
#build ⇒ Object
75 76 77 78 79 80 |
# File 'lib/capybara_webkit_builder.rb', line 75 def build sh(make_bin) or return false FileUtils.mkdir("bin") unless File.directory?("bin") FileUtils.cp(path_to_binary, "bin", :preserve => true) end |
#build_all ⇒ Object
101 102 103 104 105 106 |
# File 'lib/capybara_webkit_builder.rb', line 101 def build_all makefile && qmake && build && clean end |
#clean ⇒ Object
82 83 84 85 86 |
# File 'lib/capybara_webkit_builder.rb', line 82 def clean File.open("Makefile", "w") do |file| file.print "all:\n\t@echo ok\ninstall:\n\t@echo ok" end end |
#default_configs ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/capybara_webkit_builder.rb', line 88 def default_configs configs = [] libpath = ENV["CAPYBARA_WEBKIT_LIBS"] cppflags = ENV["CAPYBARA_WEBKIT_INCLUDE_PATH"] if libpath configs << "LIBS += #{libpath}" end if cppflags configs << "INCLUDEPATH += #{cppflags}" end configs end |
#default_qmake_binary ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/capybara_webkit_builder.rb', line 23 def default_qmake_binary case RbConfig::CONFIG['host_os'] when /freebsd/ "qmake-qt4" else "qmake" end end |
#make_bin ⇒ Object
11 12 13 |
# File 'lib/capybara_webkit_builder.rb', line 11 def make_bin ENV['MAKE'] || 'make' end |
#makefile(*configs) ⇒ Object
56 57 58 59 60 |
# File 'lib/capybara_webkit_builder.rb', line 56 def makefile(*configs) configs += default_configs configs = configs.map { |config| config.shellescape}.join(" ") sh("#{qmake_bin} -spec #{spec} #{configs}") end |
#os_spec ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/capybara_webkit_builder.rb', line 32 def os_spec case RbConfig::CONFIG['host_os'] when /linux/ "linux-g++" when /freebsd/ "freebsd-g++" when /mingw32/ "win32-g++" else "macx-g++" end end |
#path_to_binary ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/capybara_webkit_builder.rb', line 66 def path_to_binary case RUBY_PLATFORM when /mingw32/ "src/debug/webkit_server.exe" else "src/webkit_server" end end |
#qmake ⇒ Object
62 63 64 |
# File 'lib/capybara_webkit_builder.rb', line 62 def qmake sh("#{make_bin} qmake") end |
#qmake_bin ⇒ Object
15 16 17 |
# File 'lib/capybara_webkit_builder.rb', line 15 def qmake_bin ENV['QMAKE'] || default_qmake_binary end |
#sh(command) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/capybara_webkit_builder.rb', line 45 def sh(command) system(command) success = $?.exitstatus == SUCCESS_STATUS if $?.exitstatus == COMMAND_NOT_FOUND_STATUS puts "Command '#{command}' not available" elsif !success puts "Command '#{command}' failed" end success end |
#spec ⇒ Object
19 20 21 |
# File 'lib/capybara_webkit_builder.rb', line 19 def spec ENV['SPEC'] || os_spec end |