Class: Externals::App
- Inherits:
-
Object
- Object
- Externals::App
- Defined in:
- lib/externals/app.rb
Instance Method Summary collapse
- #config ⇒ Object
- #freeze(filter = nil) ⇒ Object (also: #fr)
-
#initialize(base_dir) ⇒ App
constructor
A new instance of App.
- #run(action, filter_str = nil) ⇒ Object
- #status(filter = nil) ⇒ Object (also: #st)
- #unfreeze(filter = nil) ⇒ Object (also: #un)
Constructor Details
#initialize(base_dir) ⇒ App
Returns a new instance of App.
4 5 6 |
# File 'lib/externals/app.rb', line 4 def initialize(base_dir) @base_dir = base_dir end |
Instance Method Details
#config ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/externals/app.rb', line 8 def config return @config if @config config_path = ['config/externals.yml', '.externals.yml'].detect do |file| File.exists? File.(@base_dir + '/' + file) end @config = YamlConfig.new(@base_dir, config_path) end |
#freeze(filter = nil) ⇒ Object Also known as: fr
16 17 18 |
# File 'lib/externals/app.rb', line 16 def freeze(filter = nil) config.each_repo(filter) { |r| r.freeze } end |
#run(action, filter_str = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/externals/app.rb', line 20 def run(action, filter_str = nil) available_actions = %w(st status fr freeze un unfreeze) if available_actions.include?(action) filter = Regexp.new(filter_str) if filter_str send(action, filter) else puts "Usage: externals (#{available_actions.join(':')}) optional_regex_string" end end |
#status(filter = nil) ⇒ Object Also known as: st
30 31 32 |
# File 'lib/externals/app.rb', line 30 def status(filter = nil) config.each_repo(filter) { |r| r.status } end |
#unfreeze(filter = nil) ⇒ Object Also known as: un
34 35 36 |
# File 'lib/externals/app.rb', line 34 def unfreeze(filter = nil) config.each_repo(filter) { |r| r.unfreeze } end |