module Alis

Public Class Methods

alis_root_dir() click to toggle source
# File lib/alis.rb, line 77
def alis_root_dir
  File.expand_path(File.dirname(__FILE__) + "/..")
end
bin_dir() click to toggle source
# File lib/alis.rb, line 57
def bin_dir
  File.join(user_dir, 'bin')
end
env() click to toggle source
# File lib/alis.rb, line 89
def env
  @env ||= (ENV['ALIS_ENV'] && ENV['ALIS_ENV'].to_sym || :user)
end
env=(en) click to toggle source
# File lib/alis.rb, line 93
def env=(en)
  en = en.to_sym
  raise "Not allowable value for env" unless [:user, :cucumber].include?(en)
  @env = en
end
extend_path_str() click to toggle source
# File lib/alis.rb, line 49
def extend_path_str
  "export PATH=#{bin_dir}:$PATH"
end
full_path_for_cmd(cmd) click to toggle source
# File lib/alis.rb, line 40
def full_path_for_cmd(cmd)
  paths = ENV['PATH'].split(':') - [bin_dir]
  paths.each do |path|
    full_path = File.join(path, cmd)
    return full_path if FileTest.executable?(full_path)
  end
  nil
end
home_dir() click to toggle source
# File lib/alis.rb, line 73
def home_dir
  ENV['HOME']
end
install!(modify_profile = true) click to toggle source
# File lib/alis.rb, line 16
def install!(modify_profile = true)
  if modify_profile
    File.open(profile_path, 'a'){|f| f.puts(extend_path_str)}
  end
  FileUtils.cp_r(lib_path, user_lib_dir)
end
installed?() click to toggle source
# File lib/alis.rb, line 31
def installed?
  File.open(profile_path, 'r') do |f| 
    f.each_line do |ln|
      return true if ln =~ /^#{Regexp.quote(extend_path_str)}/
    end
  end
  false
end
lib_path() click to toggle source
# File lib/alis.rb, line 85
def lib_path
  File.join(alis_root_dir, 'lib')
end
profile_path() click to toggle source
# File lib/alis.rb, line 53
def profile_path
  File.join(home_dir, '.bash_profile')
end
store() click to toggle source
# File lib/alis.rb, line 12
def store
  Store.instance
end
store_file() click to toggle source
# File lib/alis.rb, line 61
def store_file
  File.join(user_dir, 'store.yml')
end
tpl_path() click to toggle source
# File lib/alis.rb, line 81
def tpl_path
  File.join(lib_path, 'alis/cmd_template.rb')
end
uninstall!() click to toggle source
# File lib/alis.rb, line 23
def uninstall!
  content = File.read(profile_path) 
  content.sub!(/#{Regexp.quote(extend_path_str)}\n/m, '')
  File.open(profile_path, 'w'){|f| f.write(content)}

  FileUtils.rm_rf(user_lib_dir)
end
user_dir() click to toggle source
# File lib/alis.rb, line 65
def user_dir
  @user_dir ||= {:user => File.join(home_dir, '.alis'), :cucumber => ENV['ALIS_USER_DIR']}[env]
end
user_lib_dir() click to toggle source
# File lib/alis.rb, line 69
def user_lib_dir
  File.join(user_dir, "lib")
end