Class: Giternal::App
- Inherits:
-
Object
- Object
- Giternal::App
- Defined in:
- lib/giternal/app.rb
Instance Method Summary collapse
- #config ⇒ Object
- #freezify(*dirs) ⇒ Object
-
#initialize(base_dir) ⇒ App
constructor
A new instance of App.
- #run(action, *args) ⇒ Object
- #unfreezify(*dirs) ⇒ Object
- #update(*dirs) ⇒ Object
Constructor Details
#initialize(base_dir) ⇒ App
Returns a new instance of App.
3 4 5 |
# File 'lib/giternal/app.rb', line 3 def initialize(base_dir) @base_dir = base_dir end |
Instance Method Details
#config ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/giternal/app.rb', line 54 def config return @config if @config config_file = ['config/giternal.yml', '.giternal.yml'].detect do |file| File.file? File.(@base_dir + '/' + file) end if config_file.nil? $stderr.puts "config/giternal.yml is missing" exit 1 end @config = YamlConfig.new(@base_dir, File.read(config_file)) end |
#freezify(*dirs) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/giternal/app.rb', line 19 def freezify(*dirs) if dirs.empty? config.each_repo {|r| r.freezify } else dirs.each do |dir| if repo = config.find_repo(dir) repo.freezify end end end end |
#run(action, *args) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/giternal/app.rb', line 43 def run(action, *args) case action when "freeze" freezify(*args) when "unfreeze" unfreezify(*args) else send(action, *args) end end |
#unfreezify(*dirs) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/giternal/app.rb', line 31 def unfreezify(*dirs) if dirs.empty? config.each_repo {|r| r.unfreezify } else dirs.each do |dir| if repo = config.find_repo(dir) repo.unfreezify end end end end |
#update(*dirs) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/giternal/app.rb', line 7 def update(*dirs) if dirs.empty? config.each_repo {|r| r.update } else dirs.each do |dir| if repo = config.find_repo(dir) repo.update end end end end |