Class: DInstaller::CmdlineArgs
- Inherits:
-
Object
- Object
- DInstaller::CmdlineArgs
- Defined in:
- lib/dinstaller/cmdline_args.rb
Overview
This class is responsible for reading DInstaller kernel cmdline options
Constant Summary collapse
- CMDLINE_PATH =
"/proc/cmdline"
- CMDLINE_PREFIX =
"dinst."
Instance Attribute Summary collapse
-
#config_url ⇒ Object
Returns the value of attribute config_url.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
-
.read_from(path) ⇒ Object
Reads the kernel command line options.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ CmdlineArgs
constructor
Constructor.
Constructor Details
#initialize(data = {}) ⇒ CmdlineArgs
Constructor
34 35 36 |
# File 'lib/dinstaller/cmdline_args.rb', line 34 def initialize(data = {}) @data = data end |
Instance Attribute Details
#config_url ⇒ Object
Returns the value of attribute config_url.
28 29 30 |
# File 'lib/dinstaller/cmdline_args.rb', line 28 def config_url @config_url end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
29 30 31 |
# File 'lib/dinstaller/cmdline_args.rb', line 29 def data @data end |
Class Method Details
.read_from(path) ⇒ Object
Reads the kernel command line options
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dinstaller/cmdline_args.rb', line 39 def self.read_from(path) = File.read(path) args = new({}) .split.each do |option| next unless option.start_with?(CMDLINE_PREFIX) key, value = option.split("=") key.gsub!(CMDLINE_PREFIX, "") # Omit config_url from Config options next args.config_url = value if key == "config_url" # TODO: Add some kind of schema or 'knowledge' of attribute types to convert them properly # by now we will just convert Boolean values value = normalize(value) if key.include?(".") section, key = key.split(".") args.data[section] = {} unless args.data.keys.include?(section) args.data[section][key] = value else args.data[key.gsub(CMDLINE_PREFIX, "")] = value end end args end |