Class: Gitenv::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/gitenv/controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(action, options) ⇒ Controller

Returns a new instance of Controller.



7
8
9
10
11
12
13
# File 'lib/gitenv/controller.rb', line 7

def initialize action, options

  @action = action
  @options = options

  @config = Config.new
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gitenv/controller.rb', line 15

def run

  check_config_file!

  if !File.exist?(config_file) and !repository
    create_config_file!
  end

  repo = repository
  @config.from repo if repo && !repo.empty?

  load_config_file!

  #@config.from repository
  #check_repository!

  # load dot files by default
  #if @config.actions.empty?
  #  @config.symlink @config.dot_files
  #end

  #check_files!

  renderer = Renderer.new
  @config.actions.each do |a|
    a.each do |impl|
      impl.apply if @action == :apply
      puts renderer.render(impl)
    end
  end
end