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.



5
6
7
8
9
10
# File 'lib/gitenv/controller.rb', line 5

def initialize(action, options)
  @action = action
  @options = options

  @config = Config.new
end

Instance Method Details

#runObject



12
13
14
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
# File 'lib/gitenv/controller.rb', line 12

def run
  check_config_file!

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

  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