lib/cli/kit/ini.rb in cli-kit-3.1.0 vs lib/cli/kit/ini.rb in cli-kit-3.3.0
- old
+ new
@@ -13,12 +13,16 @@
# See the ini_test.rb file for more examples
#
class Ini
attr_accessor :ini
- def initialize(path = nil, default_section: nil, convert_types: true)
- @config = File.readlines(path) if path && File.exist?(path)
+ def initialize(path = nil, config: nil, default_section: nil, convert_types: true)
+ @config = if path && File.exist?(path)
+ File.readlines(path)
+ elsif config
+ config.lines
+ end
@ini = {}
@current_key = nil
@default_section = default_section
@convert_types = convert_types
end
@@ -37,10 +41,10 @@
elsif l.strip.empty?
@current_key = nil
# Otherwise set the values
else
- k, v = l.split('=').map(&:strip)
+ k, v = l.split('=', 2).map(&:strip)
set_val(k, v)
end
end
@ini
end