Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ $ docker-compose ps
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-rb34_1 /bin/bash Up
ruby-parseconfig_parseconfig_1 /bin/bash Up


Expand All @@ -135,5 +136,3 @@ $ make test

The ParseConfig library is Open Source and distributed under the MIT license.
Please see the LICENSE file included with this software.


11 changes: 8 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
parseconfig: &DEFAULTS
image: "parseconfig:dev"
Expand All @@ -13,20 +12,26 @@ services:
- '.:/src'
working_dir: '/src'

parseconfig-rb34:
<<: *DEFAULTS
image: "parseconfig:dev-rb34"
build:
context: .
dockerfile: docker/Dockerfile.dev-rb34
parseconfig-rb30:
<<: *DEFAULTS
image: "parseconfig:dev-rb30"
build:
context: .
dockerfile: docker/Dockerfile.dev-rb30

parseconfig-rb27:
<<: *DEFAULTS
image: "parseconfig:dev-rb27"
build:
context: .
dockerfile: docker/Dockerfile.dev-rb27

parseconfig-rb26:
<<: *DEFAULTS
image: "parseconfig:dev-rb26"
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.0-alpine
FROM ruby:3.4-alpine
LABEL MAINTAINER="BJ Dierkes <derks@datafolklabs.com>"
ENV PS1="\[\e[0;33m\]|> parseconfig <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev-rb30
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ruby:3.0-alpine
LABEL MAINTAINER="BJ Dierkes <derks@datafolklabs.com>"
ENV PS1="\[\e[0;33m\]|> parseconfig-rb28 <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "
ENV PS1="\[\e[0;33m\]|> parseconfig-rb30 <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "

WORKDIR /src
RUN apk update \
Expand Down
16 changes: 16 additions & 0 deletions docker/Dockerfile.dev-rb34
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ruby:3.4-alpine
LABEL MAINTAINER="BJ Dierkes <derks@datafolklabs.com>"
ENV PS1="\[\e[0;33m\]|> parseconfig-rb34 <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "

WORKDIR /src
RUN apk update \
&& apk add \
musl-dev \
make \
vim \
bash \
&& ln -sf /usr/bin/vim /usr/bin/vi \
&& gem install rspec
COPY . /src
COPY docker/vimrc /root/.vimrc
CMD ["/bin/bash"]
19 changes: 11 additions & 8 deletions lib/parseconfig.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#
# Author:: BJ Dierkes <derks@datafolklabs.com>
# Copyright:: Copyright (c) 2006,2016 Data Folk Labs, LLC
Expand Down Expand Up @@ -29,7 +31,7 @@ def initialize(config_file = nil, separator = '=', comments = ['#', ';'])
@config_file = config_file
@params = {}
@groups = []
@split_regex = '\s*' + separator + '\s*'
@split_regex = /\s*#{Regexp.escape(separator)}\s*/
@comments = comments

return unless config_file
Expand All @@ -56,12 +58,13 @@ def import_config
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'))
if i.eql? 0
# force_encoding not available in all versions of ruby
begin
bom = (+"\xef\xbb\xbf").force_encoding('UTF-8')
line.delete!(bom) if line.include?(bom)
rescue NoMethodError
end
rescue NoMethodError
end

is_comment = false
Expand All @@ -73,8 +76,8 @@ def import_config
end

unless is_comment
if /#{@split_regex}/.match(line)
param, value = line.split(/#{@split_regex}/, 2)
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 = ''
Expand Down