Class: Nucleon::Action::Project::Add

Inherits:
Object
  • Object
show all
Includes:
Mixin::Action::Project, Mixin::Action::Push
Defined in:
lib/nucleon/action/project/add.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin::Action::Push

#push, #push_config

Methods included from Mixin::Action::Project

#project_config, #project_load

Class Method Details

.describeObject


Info



13
14
15
# File 'lib/nucleon/action/project/add.rb', line 13

def self.describe
  super(:project, :add, 700)
end

Instance Method Details

#argumentsObject




54
55
56
# File 'lib/nucleon/action/project/add.rb', line 54

def arguments
  [ :sub_path, :sub_reference ]
end

#configureObject


Settings



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
46
47
48
49
50
# File 'lib/nucleon/action/project/add.rb', line 20

def configure
  super do    
    codes :project_failure,
          :add_failure,
          :push_failure
    
    register :path, :str, Dir.pwd        
    
    register :sub_path, :str, nil
    register :sub_reference, :str, nil do |value|
      success = true
      if info = Nucleon.plugin_class(:nucleon, :project).translate_reference(value)
        if ! Nucleon.loaded_plugins(:nucleon, :project).keys.include?(info[:provider].to_sym)
          warn('nucleon.core.mixin.action.project.errors.project_reference', { 
            :value     => value, 
            :provider  => info[:provider],  
            :reference => info[:reference],
            :url       => info[:url],
            :revision  => info[:revision] 
          })
          success = false
        end
      end
      success
    end      
    register :editable, :bool, false
    
    project_config
    push_config
  end
end

#executeObject


Action operations



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/nucleon/action/project/add.rb', line 61

def execute
  super do
    info('nucleon.action.project.add.start')
    
    if project = project_load(settings[:path], false)
      sub_info = project.translate_reference(settings[:sub_reference], settings[:editable])
      sub_path = settings[:sub_path]
        
      if sub_info
        sub_url      = sub_info[:url]
        sub_revision = sub_info[:revision]
      else
        sub_url      = settings[:sub_reference]
        sub_revision = nil
      end
        
      if project.add_subproject(sub_path, sub_url, sub_revision)
        myself.status = code.push_failure unless push(project)
      else
        myself.status = code.add_failure
      end
    else
      myself.status = code.project_failure               
    end
  end
end