New Upstream Release - ruby-parseconfig

Ready changes

Summary

Merged new upstream version: 1.1.2 (was: 1.0.8).

Resulting package

Built on 2023-01-11T14:11 (took 4m43s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases ruby-parseconfig

Lintian Result

Diff

diff --git a/Changelog b/Changelog
index cd95b1f..946b10a 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,14 @@
+
+Wed Sep 29, 2021 - v1.1.1 (DEVELOPMENT - will be released as 1.1.2)
+- Dev and test against recent versions of Ruby (2.6+, 3.0+)
+- Docker development support
+- Remove tests for deprecated 'get_value()' method
+- Use Rspec 'expect' in place of 'should'
+
+Mon Sep 28, 2020 - v1.1.0
+- Add non-value option support.
+  Resolves Issue #11
+
 Mon Jan 25, 2016 - v1.0.8
 - Use backward compatible positional arguments (not named keyword arguments)
   Resolves Issue #31
diff --git a/LICENSE b/LICENSE
index 793aa3b..5e65cc2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,7 @@
 
 The MIT License:
 
-Copyright (c) 2006-2016 Data Folk Labs, LLC
+Copyright (c) 2006 Data Folk Labs, LLC
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 9ed147a..067ab16 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
 ParseConfig provides simple parsing of standard configuration files in the
 form of `param = value`.  It also supports nested `[group]` sections.
 
-[![Continuous Integration Status](https://secure.travis-ci.org/datafolklabs/ruby-parseconfig.png)](http://travis-ci.org/datafolklabs/ruby-parseconfig)
+[![Continuous Integration Status](https://app.travis-ci.com/datafolklabs/ruby-parseconfig.svg?branch=master)](https://app.travis-ci.com/github/datafolklabs/ruby-parseconfig)
 
 ## Installation
 
@@ -84,8 +84,56 @@ Access it with ParseConfig:
 
 ```
 
+## Development
+
+### Docker
+
+This project includes a `docker-compose` configuration that sets up all required services, and dependencies for development and testing.  This is the recommended path for local development, and is the only fully supported option.
+
+The following creates all required docker containers, and launches a BASH shell within the `parseconfig` dev container for development.
+```
+$ make dev
+
+|> parseconfig <| src #
+```
+
+The above is the equivalent of running:
+
+```
+$ docker-compose up -d
+
+$ docker-compose exec parseconfig /bin/bash
+```
+
+**Testing Alternative Versions of Ruby**
+
+The latest stable version of Ruby is the default, and target version accessible as the `parseconfig` container within Docker Compose.  For testing against alternative versions of Ruby, additional containers are created (ex: `parseconfig-rb26`, `parseconfig-rb27`, etc). You can access these containers via:
+
+```
+$ docker-compose ps
+               Name                    Command    State   Ports
+---------------------------------------------------------------
+ruby-parseconfig_parseconfig-rb26_1   /bin/bash   Up
+ruby-parseconfig_parseconfig-rb27_1   /bin/bash   Up
+ruby-parseconfig_parseconfig-rb30_1   /bin/bash   Up
+ruby-parseconfig_parseconfig_1        /bin/bash   Up
+
+
+$ docker-compose exec parseconfig-rb26 /bin/bash
+
+|> parseconfig-rb26 <| src #
+```
+
+### Running Unit Tests
+
+```
+$ make test
+```
+
+
 ## License
 
 The ParseConfig library is Open Source and distributed under the MIT license.
 Please see the LICENSE file included with this software.
 
+
diff --git a/debian/changelog b/debian/changelog
index aeff931..9b4b6ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-ruby-parseconfig (1.0.8-2) UNRELEASED; urgency=medium
+ruby-parseconfig (1.1.2-1) UNRELEASED; urgency=medium
 
   * Remove obsolete fields Contact, Name from debian/upstream/metadata
     (already present in machine-readable debian/copyright).
@@ -6,8 +6,9 @@ ruby-parseconfig (1.0.8-2) UNRELEASED; urgency=medium
   * Bump debhelper from old 12 to 13.
   * Update standards version to 4.5.1, no changes needed.
   * Update standards version to 4.6.2, no changes needed.
+  * New upstream release.
 
- -- Debian Janitor <janitor@jelmer.uk>  Sun, 23 Feb 2020 07:00:34 +0000
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 Jan 2023 14:06:47 -0000
 
 ruby-parseconfig (1.0.8-1) unstable; urgency=medium
 
diff --git a/lib/parseconfig.rb b/lib/parseconfig.rb
index 4283b15..e4047c0 100644
--- a/lib/parseconfig.rb
+++ b/lib/parseconfig.rb
@@ -17,9 +17,6 @@
 # config file
 
 class ParseConfig
-
-  Version = '1.0.8'
-
   attr_accessor :config_file, :params, :groups
 
   # Initialize the class with the path to the 'config_file'
@@ -28,81 +25,87 @@ class ParseConfig
   # the config file is 'param = value' then the itializer
   # will eval "@param = value"
   #
-  def initialize(config_file=nil, separator='=', comments=['#', ';'])
+  def initialize(config_file = nil, separator = '=', comments = ['#', ';'])
     @config_file = config_file
     @params = {}
     @groups = []
-    @splitRegex = '\s*' + separator + '\s*'
+    @split_regex = '\s*' + separator + '\s*'
     @comments = comments
 
-    if(self.config_file)
-      self.validate_config()
-      self.import_config()
-    end
+    return unless config_file
+
+    validate_config
+    import_config
   end
 
   # Validate the config file, and contents
-  def validate_config()
-    unless File.readable?(self.config_file)
-      raise Errno::EACCES, "#{self.config_file} is not readable"
-    end
+  def validate_config
+    return if File.readable?(config_file)
+
+    raise Errno::EACCES, "#{config_file} is not readable"
 
     # FIX ME: need to validate contents/structure?
   end
 
   # Import data from the config to our config object.
-  def import_config()
+  def import_config
     # The config is top down.. anything after a [group] gets added as part
     # of that group until a new [group] is found.
     group = nil
-    open(self.config_file) { |f| f.each_with_index do |line, i|
-      line.strip!
-
-      # force_encoding not available in all versions of ruby
-      begin
-        if i.eql? 0 and line.include?("\xef\xbb\xbf".force_encoding("UTF-8"))
-          line.delete!("\xef\xbb\xbf".force_encoding("UTF-8"))
+    open(config_file) do |f|
+      f.each_with_index do |line, i|
+        line.strip!
+
+        # force_encoding not available in all versions of ruby
+        begin
+          if i.eql? 0 && line.include?("\xef\xbb\xbf".force_encoding('UTF-8'))
+            line.delete!("\xef\xbb\xbf".force_encoding('UTF-8'))
+          end
+        rescue NoMethodError
         end
-      rescue NoMethodError
-      end
 
-      is_comment = false
-      @comments.each do |comment|
-        if (/^#{comment}/.match(line))
-          is_comment = true
-          break
+        is_comment = false
+        @comments.each do |comment|
+          if /^#{comment}/.match(line)
+            is_comment = true
+            break
+          end
         end
-      end
 
-      unless is_comment
-        if(/#{@splitRegex}/.match(line))
-          param, value = line.split(/#{@splitRegex}/, 2)
-          var_name = "#{param}".chomp.strip
-          value = value.chomp.strip
-          new_value = ''
-          if (value)
-            if value =~ /^['"](.*)['"]$/
-              new_value = $1
+        unless is_comment
+          if /#{@split_regex}/.match(line)
+            param, value = line.split(/#{@split_regex}/, 2)
+            var_name = param.to_s.chomp.strip
+            value = value.chomp.strip
+            new_value = ''
+            if value
+              if value =~ /^['"](.*)['"]$/
+                new_value = Regexp.last_match(1)
+              else
+                new_value = value
+              end
             else
-              new_value = value
+              new_value = ''
             end
-          else
-            new_value = ''
-          end
 
-          if group
-            self.add_to_group(group, var_name, new_value)
-          else
-            self.add(var_name, new_value)
+            if group
+              add_to_group(group, var_name, new_value)
+            else
+              add(var_name, new_value)
+            end
+          elsif /^\[(.+)\](\s*#{escaped_comment_regex}+.*)?$/.match(line).to_a != []
+            group = /^\[(.+)\](\s*#{escaped_comment_regex}+.*)?$/.match(line).to_a[1]
+            add(group, {})
+          elsif /\w+/.match(line)
+            add(line.to_s.chomp.strip, true)
           end
-
-        elsif(/^\[(.+)\]$/.match(line).to_a != [])
-          group = /^\[(.+)\]$/.match(line).to_a[1]
-          self.add(group, {})
-
         end
       end
-    end }
+    end
+  end
+
+  def escaped_comment_regex
+    /[#{Regexp.escape(@comments.join(''))}]/
   end
 
   # This method will provide the value held by the object "@param"
@@ -112,65 +115,63 @@ class ParseConfig
   # DEPRECATED - will be removed in future versions
   #
   def get_value(param)
-    puts "ParseConfig Deprecation Warning: get_value() is deprecated. Use " + \
+    puts 'ParseConfig Deprecation Warning: get_value() is deprecated. Use ' \
          "config['param'] or config['group']['param'] instead."
-    return self.params[param]
+    params[param]
   end
 
   # This method is a shortcut to accessing the @params variable
   def [](param)
-    return self.params[param]
+    params[param]
   end
 
   # This method returns all parameters/groups defined in a config file.
-  def get_params()
-    return self.params.keys
+  def get_params
+    params.keys
   end
 
   # List available sub-groups of the config.
-  def get_groups()
-    return self.groups
+  def get_groups
+    groups
   end
 
   # This method adds an element to the config object (not the config file)
   # By adding a Hash, you create a new group
   def add(param_name, value, override = false)
     if value.class == Hash
-      if self.params.has_key?(param_name)
-        if self.params[param_name].class == Hash
+      if params.key? param_name
+        if params[param_name].class == Hash
           if override
-            self.params[param_name] = value
+            params[param_name] = value
           else
-            self.params[param_name].merge!(value)
+            params[param_name].merge!(value)
           end
-        elsif self.params.has_key?(param_name)
-          if self.params[param_name].class != value.class
+        elsif params.key? param_name
+          if params[param_name].class != value.class
             raise ArgumentError, "#{param_name} already exists, and is of different type!"
           end
         end
       else
-        self.params[param_name] = value
+        params[param_name] = value
       end
-      if ! self.groups.include?(param_name)
-        self.groups.push(param_name)
+      unless groups.include?(param_name)
+        groups.push(param_name)
       end
     else
-      self.params[param_name] = value
+      params[param_name] = value
     end
   end
 
   # Add parameters to a group. Note that parameters with the same name
   # could be placed in different groups
   def add_to_group(group, param_name, value)
-    if ! self.groups.include?(group)
-      self.add(group, {})
-    end
-    self.params[group][param_name] = value
+    add(group, {}) unless groups.include?(group)
+    params[group][param_name] = value
   end
 
   # Writes out the config file to output_stream
-  def write(output_stream=STDOUT, quoted=true)
-    self.params.each do |name,value|
+  def write(output_stream = STDOUT, quoted = true)
+    params.each do |name, value|
       if value.class.to_s != 'Hash'
         if quoted == true
           output_stream.puts "#{name} = \"#{value}\""
@@ -181,9 +182,9 @@ class ParseConfig
     end
     output_stream.puts "\n"
 
-    self.groups.each do |group|
+    groups.each do |group|
       output_stream.puts "[#{group}]"
-      self.params[group].each do |param, value|
+      params[group].each do |param, value|
         if quoted == true
           output_stream.puts "#{param} = \"#{value}\""
         else
@@ -202,7 +203,7 @@ class ParseConfig
   # Returns true if ParseConfig are equivalent and false if they differ.
 
   def eql?(other)
-    self.params == other.params && self.groups == other.groups
+    params == other.params && groups == other.groups
   end
   alias == eql?
 end
diff --git a/lib/version.rb b/lib/version.rb
new file mode 100644
index 0000000..a85e243
--- /dev/null
+++ b/lib/version.rb
@@ -0,0 +1,3 @@
+module ParseConfig
+  VERSION = '1.1.2'.freeze
+end
diff --git a/parseconfig.gemspec b/parseconfig.gemspec
index 23bc84f..9fdda81 100644
--- a/parseconfig.gemspec
+++ b/parseconfig.gemspec
@@ -2,20 +2,21 @@
 # This file has been automatically generated by gem2tgz #
 #########################################################
 # -*- encoding: utf-8 -*-
-# stub: parseconfig 1.0.8 ruby lib
+# stub: parseconfig 1.1.2 ruby lib
 
 Gem::Specification.new do |s|
   s.name = "parseconfig".freeze
-  s.version = "1.0.8"
+  s.version = "1.1.2"
 
   s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
   s.require_paths = ["lib".freeze]
-  s.authors = ["BJ Dierkes".freeze]
-  s.date = "2016-01-25"
-  s.description = "ParseConfig provides simple parsing of standard configuration files in the form of 'param = value'.  It also supports nested [group] sections.".freeze
-  s.email = "derks@datafolklabs.com".freeze
-  s.files = ["Changelog".freeze, "LICENSE".freeze, "README.md".freeze, "lib/parseconfig.rb".freeze]
+  s.authors = ["BJ Dierkes".freeze, "Dmitry Shagin".freeze]
+  s.date = "2021-09-30"
+  s.description = "ParseConfig provides simple parsing of standardconfiguration files in the form of 'param = value'. It also supports nested [group] sections.".freeze
+  s.email = "team@datafolklabs.com".freeze
+  s.files = ["Changelog".freeze, "LICENSE".freeze, "README.md".freeze, "lib/parseconfig.rb".freeze, "lib/version.rb".freeze]
   s.homepage = "http://github.com/datafolklabs/ruby-parseconfig/".freeze
-  s.rubygems_version = "2.5.2.1".freeze
+  s.licenses = ["MIT".freeze]
+  s.rubygems_version = "2.7.6.2".freeze
   s.summary = "Config File Parser for Standard Unix/Linux Type Config Files".freeze
 end

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/lib/ruby/vendor_ruby/version.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/parseconfig-1.1.2.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/parseconfig-1.0.8.gemspec

No differences were encountered in the control files

More details

Full run details