Class: Cerberus::AddCommand
- Inherits:
-
Object
- Object
- Cerberus::AddCommand
- Defined in:
- lib/cerberus/manager.rb
Constant Summary collapse
- EXAMPLE_CONFIG =
File.(File.dirname(__FILE__) + '/config.example.yml')
Instance Method Summary collapse
-
#initialize(path, cli_options = {}) ⇒ AddCommand
constructor
A new instance of AddCommand.
- #run ⇒ Object
Constructor Details
#initialize(path, cli_options = {}) ⇒ AddCommand
Returns a new instance of AddCommand.
13 14 15 |
# File 'lib/cerberus/manager.rb', line 13 def initialize(path, = {}) @path, @cli_options = path, HashWithIndifferentAccess.new() end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cerberus/manager.rb', line 17 def run scm_type = @cli_options[:scm] || Cerberus::SCM.guess_type(@path) || 'svn' scm = Cerberus::SCM.get(scm_type).new(@path, Config.new(nil, @cli_options)) say "Can't find any #{scm_type} application under #{@path}" unless scm.url application_name = @cli_options[:application_name] || extract_project_name(@path) create_example_config config_name = "#{HOME}/config/#{application_name}.yml" say "Application #{application_name} already present in Cerberus" if File.exists?(config_name) app_config = { 'scm' => { 'url' => scm.url, 'type' => scm_type }, 'publisher' => {'mail' => {'recipients' => @cli_options[:recipients]}} } app_config['builder'] = {'type' => @cli_options[:builder]} if @cli_options[:builder] dump_yml(config_name, app_config) puts "Application '#{application_name}' has been added to Cerberus successfully" unless @cli_options[:quiet] end |