Module: Alis
- Defined in:
- lib/alis.rb,
lib/alis/cmd.rb,
lib/alis/alias.rb,
lib/alis/store.rb
Defined Under Namespace
Classes: Alias, Cmd, Store
Class Method Summary
collapse
Class Method Details
.alis_root_dir ⇒ Object
77
78
79
|
# File 'lib/alis.rb', line 77
def alis_root_dir
File.expand_path(File.dirname(__FILE__) + "/..")
end
|
.bin_dir ⇒ Object
57
58
59
|
# File 'lib/alis.rb', line 57
def bin_dir
File.join(user_dir, 'bin')
end
|
.env ⇒ Object
89
90
91
|
# File 'lib/alis.rb', line 89
def env
@env ||= (ENV['ALIS_ENV'] && ENV['ALIS_ENV'].to_sym || :user)
end
|
.env=(en) ⇒ Object
93
94
95
96
97
|
# 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 ⇒ Object
49
50
51
|
# File 'lib/alis.rb', line 49
def extend_path_str
"export PATH=#{bin_dir}:$PATH"
end
|
.full_path_for_cmd(cmd) ⇒ Object
40
41
42
43
44
45
46
47
|
# 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 ⇒ Object
73
74
75
|
# File 'lib/alis.rb', line 73
def home_dir
ENV['HOME']
end
|
.install!(modify_profile = true) ⇒ Object
16
17
18
19
20
21
|
# 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? ⇒ Boolean
31
32
33
34
35
36
37
38
|
# 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 ⇒ Object
85
86
87
|
# File 'lib/alis.rb', line 85
def lib_path
File.join(alis_root_dir, 'lib')
end
|
.profile_path ⇒ Object
53
54
55
|
# File 'lib/alis.rb', line 53
def profile_path
File.join(home_dir, '.bash_profile')
end
|
.store ⇒ Object
12
13
14
|
# File 'lib/alis.rb', line 12
def store
Store.instance
end
|
.store_file ⇒ Object
61
62
63
|
# File 'lib/alis.rb', line 61
def store_file
File.join(user_dir, 'store.yml')
end
|
.tpl_path ⇒ Object
81
82
83
|
# File 'lib/alis.rb', line 81
def tpl_path
File.join(lib_path, 'alis/cmd_template.rb')
end
|
.uninstall! ⇒ Object
23
24
25
26
27
28
29
|
# 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 ⇒ Object
65
66
67
|
# 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 ⇒ Object
69
70
71
|
# File 'lib/alis.rb', line 69
def user_lib_dir
File.join(user_dir, "lib")
end
|