mobilize-base 1.372 → 1.373

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/mobilize-base.rb CHANGED
@@ -23,18 +23,38 @@ module Mobilize
23
23
  def Base.config_dir
24
24
  ENV['MOBILIZE_CONFIG_DIR'] ||= "config/mobilize/"
25
25
  end
26
- def Base.config(config_name)
26
+ def Base.config_file(config_name)
27
27
  config_dir = begin
28
28
  "#{::Rails.root}/#{Base.config_dir}"
29
29
  rescue
30
30
  "#{Base.root}/#{Base.config_dir}"
31
31
  end
32
- yaml_path = "#{config_dir}#{config_name}.yml"
33
- if ::File.exists?(yaml_path)
34
- return ::YAML.load_file(yaml_path)[Base.env]
32
+ file = "#{config_dir}#{config_name}.yml"
33
+ raise "Could not find #{file}" unless ::File.exists?(file)
34
+ file
35
+ end
36
+ def Base.config_file_updated?(config_name)
37
+ @config_mtime ||= {}
38
+ mtime = File.mtime(Base.config_file(config_name))
39
+ if !@config_mtime[config_name] or @config_mtime[config_name] < mtime
40
+ @config_mtime[config_name] = mtime
41
+ return true
35
42
  else
36
- raise "Could not find #{config_name}.yml in #{config_dir}"
43
+ return false
44
+ end
45
+ end
46
+ def Base.config(config_name)
47
+ @config ||= {}
48
+ if !@config[config_name] or Base.config_file_updated?(config_name)
49
+ yaml_path = Base.config_file(config_name)
50
+ puts "reload config #{yaml_path}"
51
+ if ::File.exists?(yaml_path)
52
+ @config[config_name] = ::YAML.load_file(yaml_path)[Base.env]
53
+ else
54
+ raise "Could not find #{yaml_path}"
55
+ end
37
56
  end
57
+ @config[config_name]
38
58
  end
39
59
  def Base.env
40
60
  begin
@@ -1,5 +1,5 @@
1
1
  module Mobilize
2
2
  module Base
3
- VERSION = "1.372"
3
+ VERSION = "1.373"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobilize-base
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.372'
4
+ version: '1.373'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-12 00:00:00.000000000 Z
12
+ date: 2013-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -234,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
234
  version: '0'
235
235
  segments:
236
236
  - 0
237
- hash: 2925154195256949885
237
+ hash: 493655327491327709
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  none: false
240
240
  requirements:
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  segments:
245
245
  - 0
246
- hash: 2925154195256949885
246
+ hash: 493655327491327709
247
247
  requirements: []
248
248
  rubyforge_project: mobilize-base
249
249
  rubygems_version: 1.8.23