Top Level Namespace

Defined Under Namespace

Modules: Utilikilt

Instance Method Summary collapse

Instance Method Details

#check_prereqs_and_adviseObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'ext/check_for_node/extconf.rb', line 20

def check_prereqs_and_advise
  return nil if executable? 'node'

  generic_advice = "\nUtilikilt uses node.js to serve up your files, but you don't appear to have it installed.\n"
  if executable? 'brew'
    return [generic_advice,"However it does look like you have homebrew available.","To install node simply run `brew install node`, then try to install the utilikilt gem again."].join("\n")
  elsif `uname` =~ /Darwin/
    return [generic_advice,%Q{The easiest way to install node is using a package manager called homebrew. You can get started with homebrew by visting http://bit.ly/getbrew, or just run the following from the command line:},%Q{/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"},"",%Q{Once homebrew is installed you can install node.js with a simple `brew install node` from the command line. After that, try installing the utilikilt gem again.}].join("\n")
  else
    return [generic_advice,"Please install node.js and then try to install the utilikilt gem again."].join("\n")
  end
end

#emulate_extension_installObject

tricks rubygems into believeing that the extension compiled and worked out. This function lifted straight out of the zerg_support gem rubygems.org/gems/zerg_support



3
4
5
6
7
8
9
10
11
12
13
# File 'ext/check_for_node/extconf.rb', line 3

def emulate_extension_install
  extension_name = "utilikilt"
  File.open('Makefile', 'w') { |f| f.write "all:\n\ninstall:\n\n" }
  File.open('make', 'w') do |f|
    f.write '#!/bin/sh'
    f.chmod f.stat.mode | 0111
  end
  File.open(extension_name + '.so', 'w') {}
  File.open(extension_name + '.dll', 'w') {}
  File.open('nmake.bat', 'w') { |f| }
end

#executable?(exe) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'ext/check_for_node/extconf.rb', line 16

def executable?( exe )
  system "command -v #{exe} >/dev/null 2>&1"
end

#install_node_packageObject



34
35
36
37
38
# File 'ext/check_for_node/extconf.rb', line 34

def install_node_package
  puts 'installing utilikilt npm package...'
  system *%w{npm install utilikilt}, {:chdir => "../../"}
  puts '...utilikilt npm package installed'
end