Module: Toggles
- Extended by:
- Toggles
- Included in:
- Toggles
- Defined in:
- lib/toggles.rb,
lib/toggles/version.rb,
lib/toggles/configuration.rb
Defined Under Namespace
Classes: Configuration, StatResult
Constant Summary
collapse
- VERSION =
'0.4.0'
Instance Method Summary
collapse
Instance Method Details
#configuration ⇒ Object
21
22
23
|
# File 'lib/toggles.rb', line 21
def configuration
@configuration ||= Configuration.new
end
|
15
16
17
18
19
|
# File 'lib/toggles.rb', line 15
def configure
@stat_tuple ||= StatResult.new(0, 0)
yield configuration
init
end
|
#init ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/toggles.rb', line 25
def init
return unless Dir.exist? configuration.features_dir
top_level = File.realpath(configuration.features_dir)
top_level_p = Pathname.new(top_level)
Feature.features.clear
Dir[File.join(top_level, '**/*.{yaml,yml}')].each do |abspath|
path = Pathname.new(abspath).relative_path_from(top_level_p).to_s
features = path.split('/')[0..-2].inject(Feature.features) { |a, e| a[e.to_sym] ||= {} }
feature_key = File.basename(path, File.extname(path)).to_sym
features[feature_key] = Feature::Permissions.from_yaml(abspath)
end
stbuf = File.stat(top_level)
@stat_tuple = StatResult.new(stbuf.ino, stbuf.mtime)
end
|
#reinit_if_changed ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/toggles.rb', line 44
def reinit_if_changed
return unless Dir.exist? configuration.features_dir
top_level = File.realpath(configuration.features_dir)
stbuf = File.stat(top_level)
stat_tuple = StatResult.new(stbuf.ino, stbuf.mtime)
init if @stat_tuple != stat_tuple
end
|