Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[] method does not exist #5

Closed
timothyekl opened this issue May 23, 2012 · 3 comments · Fixed by #6
Closed

[] method does not exist #5

timothyekl opened this issue May 23, 2012 · 3 comments · Fixed by #6
Assignees

Comments

@timothyekl
Copy link
Contributor

According to the documentation at rubydoc.info, parseconfig 0.5.2 should provide parsed config values by indexing into a ParseConfig object. The snippet in question is under "synopsis":

require('rubygems')
require('parseconfig')
config = ParseConfig.new('/path/to/config/file')
puts config['log_file']
puts config['pid_file']

However, this method doesn't seem to exist on the ParseConfig object as it stands. In irb:

> require 'parseconfig'
> config = ParseConfig.new("local-file.conf")
> config['key'] # expect "value"
NoMethodError: undefined method `[]' for #<ParseConfig:0x007f99a481e0d0>
    from (irb):4
    from /usr/local/bin/irb:12:in `<main>'

Is this a documentation problem (out of date) or an issue with parseconfig itself? If it's the latter, I'll be happy to submit a pull request fixing the problem; I'm just not sure whether it's the documentation at fault, or how to fix it if it is.

@ghost ghost assigned derks May 24, 2012
@derks
Copy link
Member

derks commented May 24, 2012

Seems like this would be a doc typo... as you can't do that currently, but you can do:

$ irb

>> require('parseconfig')
=> true

>> config = ParseConfig.new('examples/demo.conf')
=> #"127.0.0.1", "group2"=>{"group_name"=>"daemons", "user_name"=>"rita"}, "group1"=>{"group_name"=>"daemons", "user_name"=>"johnny"}, "listen_port"=>"87345", "admin_email"=>"root@localhost"}>

>> config.params['group1']['user_name']
=> "johnny"

It would make sense to me to be able to call "config['groupX']['paramX']" ... but I'll be honest, I've been coding Python for a long time now and haven't touched ruby in years. I don't really know where to start to implement that in ruby.

Any suggestions, or pull requests would be appreciated... just keep in mind that any changes need to maintain compatibility with current functionality.

@timothyekl
Copy link
Contributor Author

I submitted a quick pull request in #6; it only adds functionality, so nothing existing should break.

If you don't mind, I may also try to write some quick tests, so future changes can be more assured of not breaking compatibility.

@derks derks closed this as completed in 6feee4a May 24, 2012
@derks
Copy link
Member

derks commented May 24, 2012

Tests would be awesome. Like I said its been a while since I've actively worked in Ruby which is the main reason I haven't made many improvements to this project. That and, there haven't been many requests from the community. Tests would be great however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants