Class: Milkode::YamlFileWrapper
- Inherits:
-
Object
- Object
- Milkode::YamlFileWrapper
show all
- Defined in:
- lib/milkode/cdstk/yaml_file_wrapper.rb
Defined Under Namespace
Classes: YAMLAlreadyExist, YAMLNotExist
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(yaml_file, data) ⇒ YamlFileWrapper
Returns a new instance of YamlFileWrapper.
45
46
47
48
49
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 45
def initialize(yaml_file, data)
@yaml_file = yaml_file
@data = data
migrate
end
|
Class Method Details
.create(path = ".") ⇒ Object
.load(path = ".") ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 29
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 = ".") ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 37
def self.load_if(path = ".")
begin
load(path)
rescue YAMLNotExist
nil
end
end
|
.yaml_file(path) ⇒ Object
17
18
19
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 17
def self.yaml_file(path)
Dbdir.yaml_path(path)
end
|
Instance Method Details
#add(package) ⇒ Object
67
68
69
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 67
def add(package)
@data.add package
end
|
#contents ⇒ Object
51
52
53
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 51
def contents
@data.contents
end
|
#find_dir(dir) ⇒ Object
63
64
65
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 63
def find_dir(dir)
@data.find_dir(dir)
end
|
#find_name(name) ⇒ Object
55
56
57
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 55
def find_name(name)
@data.find_name(name)
end
|
#global_gitignore ⇒ Object
102
103
104
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 102
def global_gitignore
@data.global_gitignore
end
|
#match_all(keyword) ⇒ Object
59
60
61
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 59
def match_all(keyword)
@data.match_all(keyword)
end
|
#migrate ⇒ Object
95
96
97
98
99
100
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 95
def migrate
if (@data.migrate)
puts "milkode.yaml is old '#{version}'. Convert to '#{MilkodeYaml::MILKODE_YAML_VERSION}'."
save
end
end
|
#package_root(dir) ⇒ Object
83
84
85
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 83
def package_root(dir)
@data.package_root(dir)
end
|
#remove(package) ⇒ Object
75
76
77
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 75
def remove(package)
@data.remove package
end
|
#remove_all ⇒ Object
79
80
81
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 79
def remove_all
@data.remove_all
end
|
#save ⇒ Object
87
88
89
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 87
def save
open(@yaml_file, "w") { |f| f.write(@data.dump) }
end
|
#set_global_gitignore(filename) ⇒ Object
106
107
108
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 106
def set_global_gitignore(filename)
@data.set_global_gitignore(filename)
end
|
#update(package) ⇒ Object
71
72
73
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 71
def update(package)
@data.update package
end
|
#version ⇒ Object
91
92
93
|
# File 'lib/milkode/cdstk/yaml_file_wrapper.rb', line 91
def version
@data.version
end
|