ryanb / private_pub

Handle pub/sub messaging through private channels in Rails using Faye.
MIT License
864 stars 228 forks source link

Load configuration from YAML file #7

Closed BinaryMuse closed 13 years ago

BinaryMuse commented 13 years ago

(This is further implementation of pull request #6 based on the comments there.)

This patch removes the initializer from the generator and instead instructs the gem to load its configuration via a YAML configuration file. The file can contain just settings:

server: http://example.com/faye
secret_token: SECRET_TOKEN
signature_expiration: 600

or may contain environments:

development:
  server: http://dev.local:9292/faye
  secret_token: DEVELOPMENT_SECRET_TOKEN
  signature_expiration: 600
production:
  server: http://example.com/faye
  secret_token: PRODUCTION_SECRET_TOKEN
  signature_expiration: 600

By default, faye.ru loads the environment based on the RACK_ENV environment variable, which is set via the -E flag when running rackup.

Let me know if I overlooked anything!

ryanb commented 13 years ago

Thanks, looks good. I'll get this pulled in a bit later.

I'm wondering though if we should use RAILS_ENV instead of RACK_ENV. Even though it is a rack app, it should always match the Rails environment to ensure it loads the yaml file consistently. Also the production environment is required by Faye to get eventmachine stuff working in Thin so using RACK_ENV doesn't have much use.

It should also default to "development" like Rails does.

BinaryMuse commented 13 years ago

Ah, good call, that makes perfect sense. I'll push the changes shortly.

nhocki commented 13 years ago

This is great. I've closed my pull request as this one is much better :-)