Mercurial > rsstweet
changeset 73:e9a6019a34ea
Avoid using constant. Use global instead =D
author | nanaya <me@myconan.net> |
---|---|
date | Fri, 13 May 2016 04:52:20 +0900 |
parents | 257910c60eb3 |
children | bdc723f05119 |
files | README.md app/models/tweet.rb config/application.rb config/config_init.rb |
diffstat | 4 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/README.md Fri May 13 04:32:21 2016 +0900 +++ b/README.md Fri May 13 04:52:20 2016 +0900 @@ -38,6 +38,8 @@ - `RT_MEMCACHED_SERVERS` (separate multiple servers with comma) +Alternatively, create a config file. Read `config/config_init.rb` for hints. + License -------
--- a/app/models/tweet.rb Fri May 13 04:32:21 2016 +0900 +++ b/app/models/tweet.rb Fri May 13 04:52:20 2016 +0900 @@ -19,7 +19,7 @@ def initialize(twitter_id) @client = Twitter::REST::Client.new do |config| - CFG[:twitter].each do |cfg_key, cfg_value| + $cfg[:twitter].each do |cfg_key, cfg_value| config.public_send("#{cfg_key}=", cfg_value) end end
--- a/config/application.rb Fri May 13 04:32:21 2016 +0900 +++ b/config/application.rb Fri May 13 04:52:20 2016 +0900 @@ -34,8 +34,8 @@ config.secret_key_base = "herp a derp" config.session_store :disabled - if CFG[:memcached_servers] - config.cache_store = :mem_cache_store, CFG[:memcached_servers], { :namespace => "rsstweet" } + if $cfg[:memcached_servers] + config.cache_store = :mem_cache_store, $cfg[:memcached_servers], { :namespace => "rsstweet" } end end end
--- a/config/config_init.rb Fri May 13 04:32:21 2016 +0900 +++ b/config/config_init.rb Fri May 13 04:52:20 2016 +0900 @@ -1,4 +1,4 @@ -CFG = { +$cfg = { :twitter => { :consumer_key => ENV["RT_CONSUMER_KEY"], :consumer_secret => ENV["RT_CONSUMER_SECRET"], @@ -11,3 +11,5 @@ config_local = File.expand_path("../config_local_#{Rails.env}.rb", __FILE__) require config_local if File.exist? config_local + +$cfg.freeze