Class: Redmine::Config
Constant Summary collapse
- DEFAULT_PATH =
File.join(Dir.home, ".redmine")
- DEFAULT_FILE =
"config.yml"
- DEFAULT_CONFIG =
{ :key => nil }
Instance Method Summary collapse
- #domain ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
Constructor.
- #key ⇒ Object
- #location ⇒ Object
-
#path ⇒ Object
Path where to store data.
- #protocol ⇒ Object
- #to_hash ⇒ Object
-
#update ⇒ Object
Write current config to disc.
Methods included from Debug
Constructor Details
#initialize(options = {}) ⇒ Config
Constructor
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/redmine/config.rb', line 15 def initialize( = {}) = { :debug => false, :domain => nil, :key => nil, :config => File.join(DEFAULT_PATH, DEFAULT_FILE), :path => nil, :protocol => "http" }.merge() @debug = [:debug] @config_path = [:config] || File.join([:path] || DEFAULT_PATH, DEFAULT_FILE) config = read_config(@config_path) @config = { :key => [:key] || config[:key], :domain => [:domain] || config[:domain], :protocol => [:protocol] || config[:protocol], :path => DEFAULT_PATH || config[:path] } update if @config != config end |
Instance Method Details
#domain ⇒ Object
43 44 45 |
# File 'lib/redmine/config.rb', line 43 def domain @config[:domain] end |
#key ⇒ Object
39 40 41 |
# File 'lib/redmine/config.rb', line 39 def key @config[:key] end |
#location ⇒ Object
56 57 58 |
# File 'lib/redmine/config.rb', line 56 def location @config_path end |
#path ⇒ Object
Path where to store data
52 53 54 |
# File 'lib/redmine/config.rb', line 52 def path @config[:path] end |
#protocol ⇒ Object
47 48 49 |
# File 'lib/redmine/config.rb', line 47 def protocol @config[:protocol] end |
#to_hash ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/redmine/config.rb', line 65 def to_hash { :debug => debug?, :key => key, :domain => domain, :protocol => protocol } end |
#update ⇒ Object
Write current config to disc
61 62 63 |
# File 'lib/redmine/config.rb', line 61 def update update_config(@config, @config_path) end |