lib/skippy/config.rb in skippy-0.4.1.a vs lib/skippy/config.rb in skippy-0.4.2.a
- old
+ new
@@ -33,10 +33,11 @@
def push(key_path, value)
item = get_item(key_path)
item = set_item(key_path, []) if item.nil?
raise ArgumentError, 'key path is not an Array' unless item.is_a?(Array)
+
item << value
end
def export(target_path)
json = JSON.pretty_generate(self)
@@ -50,10 +51,11 @@
nil
end
def save
raise MissingPathError if path.nil?
+
export(path)
end
def path=(new_path)
@path = Pathname.new(new_path)
@@ -115,12 +117,14 @@
end
def get_item(key_path)
parts = key_parts(key_path)
return nil if parts.empty?
+
item = self
parts.each { |key|
return nil if item.nil?
+
item = item[key]
}
item
end