Class: Mvn2::CommandTypes

Inherits:
Object
  • Object
show all
Extended by:
PluginType, TypeHelper
Defined in:
lib/mvn2/plugin.rb

Class Method Summary collapse

Class Method Details

.def_commandObject



112
113
114
115
116
117
# File 'lib/mvn2/plugin.rb', line 112

def self.def_command
  def_command_flag
  def_command_goal
  register_type(:operation_name) { |list| get_name(list) || 'Operation' }
  register_type(:clean_block) { |list| basic_type(list) }
end

.def_command_flagObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/mvn2/plugin.rb', line 119

def self.def_command_flag
  register_type(:command_flag) { |list|
    options = Plugins.get_var :options
    flags   = []
    list.each { |flag|
      if flag[:block].nil?
        flags << " #{flag[:options][:flag]}" if flag_boolean(flag, options)
      else
        flag[:block].call(options, flags)
      end
    }
    flags.join
  }
end

.def_command_goalObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/mvn2/plugin.rb', line 134

def self.def_command_goal
  register_type(:goal_override) { |list|
    options        = Plugins.get_var :options
    full_overrides = complex_filter(list.select { |v| v[:options][:override_all] }.sort_by { |v| -v[:options][:priority] }, options, :goal)
    if full_overrides.nil? || full_overrides.empty?
      goals = complex_filter(list.select { |v| !v[:options][:override_all] }.sort_by { |v| v[:options][:order] }, options, :goal)
      goals = ['install'] if (goals - ['clean']).empty?
      goals = ['clean'] + goals unless goals.include?('clean')
      goals = goals - ['clean'] if Plugins.get(:clean_block)
      goals.join(' ')
    else
      full_overrides.first
    end
  }
end