Module: DailyConfig
Instance Method Summary collapse
- #config_init(config) ⇒ Object
- #database_config ⇒ Object
- #database_init ⇒ Object
- #env_hash ⇒ Object
- #hash ⇒ Object
- #load_classes ⇒ Object
- #rails_env ⇒ Object
- #rails_root ⇒ Object
- #set_env(env) ⇒ Object
- #set_root(root) ⇒ Object
- #subdirectory ⇒ Object
Instance Method Details
#config_init(config) ⇒ Object
50 51 52 53 54 |
# File 'lib/daily/daily_config.rb', line 50 def config_init(config) if !subdirectory.blank? config.assets.prefix = "/#{subdirectory}/assets" end end |
#database_config ⇒ Object
34 35 36 |
# File 'lib/daily/daily_config.rb', line 34 def database_config env_hash['database'] end |
#database_init ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/daily/daily_config.rb', line 38 def database_init db = database_config return if db.empty? Ruport::Query.add_source :default, :dsn => "dbi:#{db['adapter'].camelize}:database=#{db['database']};host=#{db['host']}", :user => "#{db['username']}", :password => "#{db['password']}" require File.('../activemetric', __FILE__) ActiveMetric::Base.establish_connection db end |
#env_hash ⇒ Object
25 26 27 |
# File 'lib/daily/daily_config.rb', line 25 def env_hash @env_hash ||= (hash[rails_env] || {}) end |
#hash ⇒ Object
21 22 23 |
# File 'lib/daily/daily_config.rb', line 21 def hash @hash ||= (YAML.load_file("#{rails_root}/config/daily.yml") || {}) end |
#load_classes ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/daily/daily_config.rb', line 56 def load_classes Dir[Rails.root.join("app/transforms/**/*.rb")].each { |f| require_dependency f } Dir[Rails.root.join("app/formatters/**/*.rb")].each { |f| require_dependency f } Dir[Rails.root.join("app/metrics/**/*.rb")].each { |f| require_dependency f } if defined? Daily::Engine Dir[Daily::Engine.root.join("app/transforms/**/*.rb")].each { |f| require_dependency f } Dir[Daily::Engine.root.join("app/formatters/**/*.rb")].each { |f| require_dependency f } Dir[Daily::Engine.root.join("app/metrics/**/*.rb")].each { |f| require_dependency f } Dir[Daily::Engine.root.join("lib/**/*.rb")].each { |f| require_dependency f } end end |
#rails_env ⇒ Object
16 17 18 19 |
# File 'lib/daily/daily_config.rb', line 16 def rails_env return @env if @env Rails.env end |
#rails_root ⇒ Object
11 12 13 14 |
# File 'lib/daily/daily_config.rb', line 11 def rails_root return @root if @root Rails.root end |
#set_env(env) ⇒ Object
7 8 9 |
# File 'lib/daily/daily_config.rb', line 7 def set_env(env) @env = env end |
#set_root(root) ⇒ Object
4 5 6 |
# File 'lib/daily/daily_config.rb', line 4 def set_root(root) @root = root end |
#subdirectory ⇒ Object
29 30 31 32 |
# File 'lib/daily/daily_config.rb', line 29 def subdirectory return "" if rails_env == "test" hash['subdirectory'] || env_hash['subdirectory'] || "" end |