Module: Koi
Defined Under Namespace
Classes: Command, Database, Entity
Constant Summary
collapse
- Path =
{root: ".koi", db: ".koi/database.yml", paths: ".koi/paths"}
Class Method Summary
collapse
Class Method Details
.init(dir = Dir.pwd) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/koi.rb', line 10
def self.init dir = Dir.pwd
unless init?
FileUtils.mkdir File.join(dir, Path[:root])
FileUtils.touch File.join(dir, Path[:db])
FileUtils.mkdir File.join(ENV['HOME'], Path[:root]) rescue nil
File.open(File.join(ENV['HOME'], Path[:paths]), 'a+') do |f|
f.write File.expand_path(dir).to_s
end
end
end
|
.init!(dir = Dir.pwd) ⇒ Object
21
22
23
24
|
# File 'lib/koi.rb', line 21
def self.init! dir = Dir.pwd
FileUtils.rm_rf File.join(dir, Path[:root])
init dir
end
|
.init?(dir = root) ⇒ Boolean
26
27
28
|
# File 'lib/koi.rb', line 26
def self.init? dir = root
File.exist? File.join(dir, Path[:db]) if dir
end
|
.root ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/koi.rb', line 40
def self.root
path = Dir.pwd.split('/').reject {|d| d.empty? }
(path.size + 1).times do
if Koi.init? (sub = File.join('/', *path))
return sub
end
path.pop
end
return nil
end
|
.run(*args) ⇒ Object
30
31
32
33
34
|
# File 'lib/koi.rb', line 30
def self.run *args
cmd = Command.new(args.first, args[1..-1])
cmd[:silent] = true
cmd.run
end
|
.version ⇒ Object
36
37
38
|
# File 'lib/koi.rb', line 36
def self.version
File.read(File.join(File.dirname(__FILE__), '..', 'VERSION')).strip
end
|