ryanb / private_pub

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

Allow the option to use another yml file #93

Open vandamon opened 10 years ago

vandamon commented 10 years ago

I was trying to test my app over LAN, but I am unable to run private_pub both on local machine and host machine with different configuration. Because it always uses the private_pub.yml file. Would be great if I can use another file such private_pub_on_lan.yml.

coorasse commented 10 years ago

Can't you just edit the file? o_0

Alessandro Rodi

On Sat, Jan 25, 2014 at 11:57 AM, vandamon notifications@github.com wrote:

I was trying to test my app over LAN, but I am unable to run private_pub both on local machine and host machine with different configuration. Because it always uses the private_pub.yml file. Would be great if I can use another file such private_pub_on_lan.yml.

— Reply to this email directly or view it on GitHubhttps://github.com/ryanb/private_pub/issues/93 .

gregmolnar commented 10 years ago

You can use any config file you want. Just load the appropriate config in private_pub.ru by setting some condition:

if lan? # check here if your app is on lan.
  PrivatePub.load_config(File.expand_path("../config/private_pub_lan.yml", __FILE__), ENV["RAILS_ENV"] || "development")
else
  PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
end
run PrivatePub.faye_app
vandamon commented 10 years ago

@gregmolnar Even if I change this line

PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")

to (without any conditions)

PrivatePub.load_config(File.expand_path("../config/private_pub_lan.yml", __FILE__), ENV["RAILS_ENV"] || "development")

it still picks up the config from private_pub.yml, as long as the file is there. Because of this: https://github.com/ryanb/private_pub/blob/7ad77617b1f48980d6f114bc96018f2964a07bdc/lib/private_pub/engine.rb#L7

Also, if you know, please let me know how to pass a dynamic variable to a rackup file. I don't see any option for that.

gregmolnar commented 10 years ago

Well spotted. I didn't now about that part. The issue is this repo is abandoned by Ryan. Otherwise it would be a quick fix.