urbanairship / ruby-library

A Ruby wrapper for the Urban Airship API.
Other
200 stars 117 forks source link

Add config class for gem #106

Closed bvicenzo closed 6 years ago

bvicenzo commented 7 years ago

Looking for this issue https://github.com/urbanairship/ruby-library/issues/96 i've built a way to make the gem configurable.

Starting from log parameters. But we can use this structure do make anything we could do as configurable options.

The way to use is very simple. In a Rails app, for example, we can create a file in config/initializers/urbanairship.rb with the following content.

Urbanairship.configure do |config|
  config.log_path = File.join(Rails.root, 'log')
  config.log_level = Logger::INFO
end

To do this, I'm based on these articles: https://robots.thoughtbot.com/mygem-configure-block http://lizabinante.com/blog/creating-a-configurable-ruby-gem/

rlepinski commented 7 years ago

@bvicenzo This PR looks great. I think its totally reasonable for the log level to default to info instead of debug. Could you make that change?

bvicenzo commented 7 years ago

@rlepinski Thanks! Sure. The change is here: https://github.com/urbanairship/ruby-library/pull/106/commits/ab6f5e08c52efb64a76a6f28a8e719de6d3b2436

bvicenzo commented 6 years ago

Guys, please, let me know if is missing something to go ahead with this PR.

danielvidal commented 6 years ago

@rlepinski Will this PR be merged in the next version?

pdxmele commented 6 years ago

We are looking at this now.