lib/import.rb in doit-0.2.8 vs lib/import.rb in doit-0.3.0
- old
+ new
@@ -1,34 +1,35 @@
require 'pathname'
require 'erb'
-class Import
+Import = Object.new
+class << Import
- def self.script; @script; end
- def self.config; @config; end
+ def script; @script; end
+ def config; @config; end
- def self.init(name)
+ def init(name)
@script = read(name)
@config = ERB.new(read("#{name}.yml") || '').result
info
end
# returns Hash { 'pull' => '/home/dk/.doit/pull', ... }
- def self.list
+ def list
@list ||= list2
end
- def self.info
+ def info
return unless Doit.options[:verbose]
My.verbose "SCRIPT", @script
My.verbose "CONFIG(yml)", @config
end
private
- def self.list2
+ def list2
res = {}
Pathname.pwd.descend { |dir|
doit_dir = dir + '.doit'
next unless File.directory?(doit_dir)
@@ -44,14 +45,14 @@
lst.each { |itm| res[File.basename(itm)] = itm }
}
res
end
- def self.read(name)
+ def read(name)
try_ascend(".doit/#{name}")
end
- def self.try_ascend(filename)
+ def try_ascend(filename)
Pathname.pwd.ascend { |dir|
str = dir + filename
return File.read(str) if File.exists?(str)
}
nil