Skip to content

Commit

Permalink
add memory file and few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jul 13, 2015
1 parent 2ff9c76 commit b53ec36
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion library/general/src/lib/config_file/grub_model.rb
Expand Up @@ -8,6 +8,7 @@ module ConfigFile
class GrubModel < BaseModel
def initialize(file_class: File)
super(PARSER, PATH, file_class: file_class)
self.data = {}
end

def os_prober_enabled?
Expand Down Expand Up @@ -37,7 +38,7 @@ def disable_recovery_entry

def enable_recovery_entry(kernel_params)
data["GRUB_DISABLE_RECOVERY"] ||= {}
data["GRUB_DISABLE_RECOVERY"][:value] = "true"
data["GRUB_DISABLE_RECOVERY"][:value] = "false"
data["GRUB_DISABLE_RECOVERY"][:commented_out] = false
data["GRUB_CMDLINE_LINUX_RECOVERY"] ||= {}
data["GRUB_CMDLINE_LINUX_RECOVERY"][:value] = kernel_params
Expand Down
6 changes: 4 additions & 2 deletions library/general/src/lib/config_file/key_value_parser.rb
Expand Up @@ -26,8 +26,10 @@ def self.parse(raw_string)
def self.serialize(data)
data.each_with_object("") do |pair, res|
key, content = pair
content[:comments].each do |comment|
res << "# #{comment}\n"
if content[:comments]
content[:comments].each do |comment|
res << "# #{comment}\n"
end
end
prefix = content[:commented_out] ? "#" : ""
res << "#{prefix}#{key}=#{content[:value]}\n"
Expand Down
17 changes: 17 additions & 0 deletions library/general/src/lib/config_file/memory_file.rb
@@ -0,0 +1,17 @@
module ConfigFile
class MemoryFile
attr_accessor :content

def initialize(content = "")
@content = content
end

def read(path)
@content.dup
end

def write(path, content)
@content = content
end
end
end

0 comments on commit b53ec36

Please sign in to comment.