Module: Dre

Defined in:
app/main.rb,
app/inputs.rb,
app/arguments.rb,
app/configuration.rb

Class Method Summary collapse

Class Method Details

.configuration_onObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/configuration.rb', line 8

def configuration_on
  @configuration.on_handler(:root_path,
    lambda do
      r_path = DragonrubyEgg::Executable.find_root_path
      unless r_path
        DragonrubyEgg::Event.print('ROOT-PATH',
          "No DragonRuby root path has been found."
        )
        DragonrubyEgg::Event.print('WARNING',
          "Please set the root path using the -sr " +
          "or --set-root argument."
        )
      end
      return r_path
    end
  ) do |is_end, r_path|
    unless is_end
      DragonrubyEgg::Event.print('ROOT-PATH',
        "The root path has not been set and so the analysis " +
        "of the root path is performed."
      )
    else
      DragonrubyEgg::Event.print('SET', "root_path: #{r_path}")
    end
  end
end

.main_stateObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/main.rb', line 29

def main_state
  if options_empty?
    DragonrubyEgg::Executable.dragonruby(@options[:path])
  elsif @options[:is_docs]
    DragonrubyEgg::Executable.docs()
  elsif @options[:is_egg]
    DragonrubyEgg::Executable.egg()
  elsif @options[:install]
    if @options[:path]
      DragonrubyEgg::Executable.install(@options[:install], @options[:path])
    else
      DragonrubyEgg::Event.print('WARNING', "A working path must " +
        "be defined to install the module.")
    end
  elsif @options[:new]
    DragonrubyEgg::Executable.new_project(@options[:new], @options[:path])
  end
end

.options_empty?Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
# File 'app/arguments.rb', line 52

def self.options_empty?
  @options.each do |k, v|
    if k != :path and v
      return false
    end
  end
  return true
end

.root_path_stateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/main.rb', line 13

def root_path_state
  sym = :root_path
  root_path = @options[sym]
  if root_path
    if root_path == ''
      DragonrubyEgg::Event.print('WARNING', "An empty string for" +
        "the root path is not acceptable.")
      @configuration.delete(sym)
      configuration_on()
    else
      @configuration.parse(sym, root_path)
      DragonrubyEgg::Event.print('SET', "#{sym.to_s}: #{root_path.to_s}")
    end
  end
end