class Milkode::YamlFileWrapper

Public Class Methods

create(path = ".") click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 20
def self.create(path = ".")
  yf = yaml_file(path)
  raise YAMLAlreadyExist.new if FileTest.exist? yf
  obj = YamlFileWrapper.new(yf, MilkodeYaml.new)
  obj.save
  return obj
end
load(path = ".") click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 28
def self.load(path = ".")
  yf = yaml_file(path)
  raise YAMLNotExist.new unless FileTest.exist? yf
  open(yf) do |f|
    return YamlFileWrapper.new(yf, MilkodeYaml.new(f.read()))
  end
end
load_if(path = ".") click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 36
def self.load_if(path = ".")
  begin
    load(path)
  rescue YAMLNotExist
    nil
  end
end
new(yaml_file, data) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 44
def initialize(yaml_file, data)
  @yaml_file = yaml_file
  @data = data
  migrate
end
yaml_file(path) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 16
def self.yaml_file(path)
  Dbdir.yaml_path(path)
end

Public Instance Methods

add(package) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 66
def add(package)
  @data.add package
end
contents() click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 50
def contents
  @data.contents
end
find_dir(dir) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 62
def find_dir(dir)
  @data.find_dir(dir)
end
find_name(name) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 54
def find_name(name)
  @data.find_name(name)
end
global_gitignore() click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 101
def global_gitignore
  @data.global_gitignore
end
match_all(keyword) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 58
def match_all(keyword)
  @data.match_all(keyword)
end
migrate() click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 94
def migrate
  if (@data.migrate)
    puts "milkode.yaml is old '#{version}'. Convert to '#{MilkodeYaml::MILKODE_YAML_VERSION}'."
    save
  end
end
package_root(dir) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 82
def package_root(dir)
  @data.package_root(dir)
end
remove(package) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 74
def remove(package)
  @data.remove package
end
remove_all() click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 78
def remove_all
  @data.remove_all
end
save() click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 86
def save
  open(@yaml_file, "w") { |f| f.write(@data.dump) }
end
set_global_gitignore(filename) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 105
def set_global_gitignore(filename)
  @data.set_global_gitignore(filename)
end
update(package) click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 70
def update(package)
  @data.update package
end
version() click to toggle source
# File lib/milkode/cdstk/yaml_file_wrapper.rb, line 90
def version
  @data.version
end