nucleon 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
 
2
2
  module Nucleon
3
3
  module Action
4
- class Extract < Plugin::Action
4
+ class Extract < Nucleon.plugin_class(:action)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
- # Action settings
7
+ # Settings
8
8
 
9
9
  def configure
10
10
  super do
@@ -35,7 +35,7 @@ class Extract < Plugin::Action
35
35
  end
36
36
 
37
37
  #-----------------------------------------------------------------------------
38
- # Action operations
38
+ # Operations
39
39
 
40
40
  def execute
41
41
  super do |node, network|
@@ -1,49 +1,53 @@
1
1
 
2
2
  module Nucleon
3
3
  module Action
4
- class Remove < Plugin::Action
4
+ class Remove < Nucleon.plugin_class(:action)
5
5
 
6
6
  include Mixin::Action::Project
7
7
  include Mixin::Action::Push
8
8
 
9
9
  #-----------------------------------------------------------------------------
10
- # Remove action interface
10
+ # Settings
11
11
 
12
- def normalize
13
- super('nucleon remove <subproject/path>')
14
-
15
- codes :project_failure => 20,
16
- :delete_failure => 21,
17
- :push_failure => 22
12
+ def configure
13
+ super do
14
+ codes :project_failure,
15
+ :delete_failure,
16
+ :push_failure
17
+
18
+ register :sub_path, :str, nil
19
+
20
+ project_config
21
+ push_config
22
+ end
18
23
  end
19
-
20
- #-----------------------------------------------------------------------------
21
- # Action operations
22
24
 
23
- def parse(parser)
24
- parser.arg_str(:sub_path, nil,
25
- 'nucleon.core.actions.remove.options.sub_path'
26
- )
27
- project_options(parser, true, true)
28
- push_options(parser, true)
25
+ #---
26
+
27
+ def ignore
28
+ [ :project_reference ]
29
29
  end
30
30
 
31
- #---
32
-
31
+ def arguments
32
+ [ :sub_path ]
33
+ end
34
+
35
+ #-----------------------------------------------------------------------------
36
+ # Operations
37
+
33
38
  def execute
34
- super do |node, network, status|
35
- info('nucleon.core.actions.remove.start')
39
+ super do |node, network|
40
+ info('nucleon.actions.remove.start')
36
41
 
37
42
  if project = project_load(Dir.pwd, false)
38
43
  if project.delete_subproject(settings[:sub_path])
39
- status = code.push_failure unless push(project)
44
+ myself.status = code.push_failure unless push(project)
40
45
  else
41
- status = code.delete_failure
46
+ myself.status = code.delete_failure
42
47
  end
43
48
  else
44
- status = code.project_failure
45
- end
46
- status
49
+ myself.status = code.project_failure
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -1,51 +1,51 @@
1
1
 
2
2
  module Nucleon
3
3
  module Action
4
- class Save < Plugin::Action
4
+ class Save < Nucleon.plugin_class(:action)
5
5
 
6
6
  include Mixin::Action::Project
7
7
  include Mixin::Action::Commit
8
8
  include Mixin::Action::Push
9
9
 
10
10
  #-----------------------------------------------------------------------------
11
- # Save action interface
11
+ # Settings
12
12
 
13
- def normalize
14
- super('nucleon save [ <file> ... ]')
15
-
16
- codes :project_failure => 20,
17
- :commit_failure => 21,
18
- :push_failure => 22
19
- end
20
-
21
- #-----------------------------------------------------------------------------
22
- # Action operations
23
-
24
- def parse(parser)
25
- parser.arg_array(:files, '.',
26
- 'nucleon.core.actions.save.options.files'
27
- )
28
- project_options(parser, true, false)
29
- commit_options(parser, false)
30
- push_options(parser, true)
13
+ def configure
14
+ super do
15
+ codes :project_failure,
16
+ :commit_failure,
17
+ :push_failure
18
+
19
+ register :files, :array, '.'
20
+
21
+ project_config
22
+ commit_config(false)
23
+ push_config
24
+ end
31
25
  end
32
26
 
33
27
  #---
28
+
29
+ def arguments
30
+ [ :files ]
31
+ end
32
+
33
+ #-----------------------------------------------------------------------------
34
+ # Operations
34
35
 
35
36
  def execute
36
- super do |node, network, status|
37
- info('nucleon.core.actions.save.start')
37
+ super do |node, network|
38
+ info('nucleon.actions.save.start')
38
39
 
39
40
  if project = project_load(Dir.pwd, false)
40
41
  if commit(project, settings[:files])
41
- status = code.push_failure unless push(project)
42
+ myself.status = code.push_failure unless push(project)
42
43
  else
43
- status = code.commit_failure
44
+ myself.status = code.commit_failure
44
45
  end
45
46
  else
46
- status = code.project_failure
47
+ myself.status = code.project_failure
47
48
  end
48
- status
49
49
  end
50
50
  end
51
51
  end
@@ -1,35 +1,30 @@
1
1
 
2
2
  module Nucleon
3
3
  module Action
4
- class Update < Plugin::Action
4
+ class Update < Nucleon.plugin_class(:action)
5
5
 
6
6
  include Mixin::Action::Project
7
7
 
8
8
  #-----------------------------------------------------------------------------
9
- # Update action interface
9
+ # Settings
10
10
 
11
- def normalize
12
- super('nucleon update')
13
-
14
- codes :project_failure => 20
11
+ def configure
12
+ super do
13
+ codes :project_failure
14
+
15
+ project_options
16
+ end
15
17
  end
16
18
 
17
19
  #-----------------------------------------------------------------------------
18
- # Action operations
19
-
20
- def parse(parser)
21
- project_options(parser, true, true)
22
- end
23
-
24
- #---
20
+ # Operations
25
21
 
26
22
  def execute
27
- super do |node, network, status|
28
- info('nucleon.core.actions.update.start')
23
+ super do |node, network|
24
+ info('nucleon.actions.update.start')
29
25
 
30
- project = project_load(Dir.pwd, true)
31
- status = code.project_failure unless project
32
- status
26
+ project = project_load(Dir.pwd, true)
27
+ myself.status = code.project_failure unless project
33
28
  end
34
29
  end
35
30
  end
@@ -399,7 +399,7 @@ class Git < Plugin::Project
399
399
  :flags => flags,
400
400
  :args => [ processed_remote, config.get(:revision, get(:revision, :master)) ]
401
401
  }
402
- }, config.get(:provider, :shell)).exec(config) do |op, command, data|
402
+ }, config.get(:provider, :bash)).exec(config) do |op, command, data|
403
403
  block_given? ? yield(op, command, data) : true
404
404
  end
405
405
 
@@ -430,7 +430,7 @@ class Git < Plugin::Project
430
430
  :flags => flags,
431
431
  :args => [ processed_remote, push_branch ]
432
432
  }
433
- }, config.get(:provider, :shell)).exec(config) do |op, command, data|
433
+ }, config.get(:provider, :bash)).exec(config) do |op, command, data|
434
434
  block_given? ? yield(op, command, data) : true
435
435
  end
436
436
 
@@ -0,0 +1,184 @@
1
+
2
+ #*******************************************************************************
3
+ # Nucleon
4
+ #
5
+ # Framework that provides a simple foundation for building distributively
6
+ # configured, extremely pluggable and extendable, and easily parallel
7
+ # applications.
8
+ #
9
+ # Author:: Adrian Webb (mailto:adrian.webb@coralnexus.com)
10
+ # License:: GPLv3
11
+
12
+ #-------------------------------------------------------------------------------
13
+ # Global namespace
14
+
15
+ module Kernel
16
+
17
+ def dbg(data, label = '')
18
+ # Invocations of this function should NOT be committed to the project
19
+ require 'pp'
20
+
21
+ puts '>>----------------------'
22
+ unless ! label || label.empty?
23
+ puts label
24
+ puts '---'
25
+ end
26
+ pp data
27
+ puts '<<'
28
+ end
29
+
30
+ #---
31
+
32
+ def nucleon_locate(command)
33
+ command = command.to_s
34
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
35
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
36
+ exts.each do |ext|
37
+ exe = File.join(path, "#{command}#{ext}")
38
+ return exe if File.executable?(exe)
39
+ end
40
+ end
41
+ return nil
42
+ end
43
+
44
+ #---
45
+
46
+ def nucleon_require(base_dir, name)
47
+ name = name.to_s
48
+ top_level_file = File.join(base_dir, "#{name}.rb")
49
+
50
+ require top_level_file if File.exists?(top_level_file)
51
+
52
+ directory = File.join(base_dir, name)
53
+
54
+ if File.directory?(directory)
55
+ Dir.glob(File.join(directory, '**', '*.rb')).each do |sub_file|
56
+ require sub_file
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ #-------------------------------------------------------------------------------
63
+ # Load paths
64
+
65
+ lib_dir = File.dirname(__FILE__)
66
+ core_dir = File.join(lib_dir, 'core')
67
+ mixin_dir = File.join(core_dir, 'mixin')
68
+ mixin_config_dir = File.join(mixin_dir, 'config')
69
+ mixin_action_dir = File.join(mixin_dir, 'action')
70
+ macro_dir = File.join(mixin_dir, 'macro')
71
+ util_dir = File.join(core_dir, 'util')
72
+ mod_dir = File.join(core_dir, 'mod')
73
+ plugin_dir = File.join(core_dir, 'plugin')
74
+
75
+ #-------------------------------------------------------------------------------
76
+ # Coral requirements
77
+
78
+ $:.unshift(lib_dir) unless $:.include?(lib_dir) || $:.include?(File.expand_path(lib_dir))
79
+
80
+ #---
81
+
82
+ require 'rubygems'
83
+
84
+ require 'optparse'
85
+ require 'pp'
86
+ require 'i18n'
87
+ require 'log4r'
88
+ require 'log4r/configurator'
89
+ require 'deep_merge'
90
+
91
+ require 'digest/sha1'
92
+ require 'base64'
93
+
94
+ require 'yaml'
95
+ require 'multi_json'
96
+
97
+ require 'thread' # Eventually depreciated
98
+ require 'celluloid'
99
+ require 'celluloid/autostart'
100
+
101
+ #---
102
+
103
+ # TODO: Make this dynamically settable
104
+
105
+ I18n.enforce_available_locales = false
106
+ I18n.load_path << File.expand_path(File.join('..', 'locales', 'en.yml'), lib_dir)
107
+
108
+ #---
109
+
110
+ if nucleon_locate('git')
111
+ require 'grit'
112
+ nucleon_require(util_dir, :git)
113
+ end
114
+
115
+ #---
116
+
117
+ # Make sure logger is at the top of our load order priorities
118
+ nucleon_require(util_dir, :logger)
119
+
120
+ #---
121
+
122
+ # Object modifications (100% pure monkey patches)
123
+ Dir.glob(File.join(mod_dir, '*.rb')).each do |file|
124
+ require file
125
+ end
126
+
127
+ #---
128
+
129
+ # Mixins for classes
130
+ Dir.glob(File.join(mixin_dir, '*.rb')).each do |file|
131
+ require file
132
+ end
133
+ Dir.glob(File.join(mixin_config_dir, '*.rb')).each do |file|
134
+ require file
135
+ end
136
+ Dir.glob(File.join(mixin_action_dir, '*.rb')).each do |file|
137
+ require file
138
+ end
139
+ Dir.glob(File.join(macro_dir, '*.rb')).each do |file|
140
+ require file
141
+ end
142
+
143
+ #---
144
+
145
+ # Include bootstrap classes
146
+ nucleon_require(core_dir, :errors)
147
+ nucleon_require(core_dir, :codes)
148
+ nucleon_require(util_dir, :data)
149
+ nucleon_require(core_dir, :config)
150
+ nucleon_require(util_dir, :console)
151
+ nucleon_require(core_dir, :core)
152
+
153
+ #---
154
+
155
+ # Include core utilities
156
+ [ :liquid,
157
+ :cli,
158
+ :disk,
159
+ :package,
160
+ :shell
161
+ ].each do |name|
162
+ nucleon_require(util_dir, name)
163
+ end
164
+
165
+ # Include plugin system
166
+ nucleon_require(core_dir, :facade)
167
+ nucleon_require(core_dir, :gems)
168
+ nucleon_require(core_dir, :manager)
169
+ nucleon_require(plugin_dir, :base)
170
+ nucleon_require(core_dir, :plugin)
171
+
172
+ #-------------------------------------------------------------------------------
173
+ # Core interface
174
+
175
+ module Nucleon
176
+
177
+ def self.VERSION
178
+ File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
179
+ end
180
+
181
+ #-----------------------------------------------------------------------------
182
+
183
+ extend Facade
184
+ end
@@ -1,14 +1,24 @@
1
1
  en:
2
2
  nucleon:
3
- errors:
4
- batch_error: |-
5
- An issue was encountered during batch processing
6
3
  core:
4
+ exec:
5
+ help:
6
+ usage: |-
7
+ Usage
8
+ header: |-
9
+ Available actions
10
+ footer: |-
11
+ For help on any individual action run `corl <action> -h`
12
+ errors:
13
+ missing_argument: |-
14
+ Argument <%{name}> must be specified
7
15
  util:
8
16
  cli:
9
17
  options:
10
- help: |-
11
- Display help information for this command
18
+ short_help: |-
19
+ Display brief help information for this command
20
+ extended_help: |-
21
+ Display a more extended breakdown of available options for this commands available actions
12
22
  log_level: |-
13
23
  Set the logging level for this execution run
14
24
  encoded: |-
@@ -16,42 +26,38 @@ en:
16
26
  parse:
17
27
  error: |-
18
28
  There was a problem with the command arguments given
19
- batch:
20
- unexpected_error: |
21
- There was a problem with batch %{process}: %{message}
22
- coral_error: |
23
- There was a problem with batch %{process}: %{message}
24
- mixins:
25
- project:
26
- options:
27
- provider: |-
28
- Nucleon plugin provider to use for this project (default %{default_value})
29
- reference: |-
30
- Project URL or reference string to set as primary remote (default %{default_value})
31
- revision: |-
32
- Revision or branch to load (default %{default_value})
33
- commit:
34
- options:
35
- commit: |-
36
- Commit any uncommitted changes (default %{default_value})
37
- empty: |-
38
- Allow commits with no changes (default %{default_value})
39
- message: |-
40
- Commit message (defaults to auto generated commit information)
41
- author: |-
42
- Author of the changes being committed if different from the committer
43
- propogate: |-
44
- Propogate commits throughout the project tree (default %{default_value})
45
- push:
46
- options:
47
- push: |-
48
- Push changes to remote server (default %{default_value})
49
- propogate: |-
50
- Propogate pushes to the remote throughout the project tree (default %{default_value})
51
- remote: |-
52
- Remote name to push to (default %{default_value})
53
- revision: |-
54
- Branch to push (default %{default_value})
29
+ mixin:
30
+ action:
31
+ project:
32
+ options:
33
+ project_provider: |-
34
+ Plugin provider to use for this project (default %{default_value})
35
+ project_reference: |-
36
+ Project URL or reference string to set as primary remote (default %{default_value})
37
+ revision: |-
38
+ Revision or branch to load (default %{default_value})
39
+ commit:
40
+ options:
41
+ commit: |-
42
+ Commit any uncommitted changes (default %{default_value})
43
+ allow_empty: |-
44
+ Allow commits with no changes (default %{default_value})
45
+ message: |-
46
+ Commit message (defaults to auto generated commit information)
47
+ author: |-
48
+ Author of the changes being committed if different from the committer
49
+ propogate_commit: |-
50
+ Propogate commits throughout the project tree (default %{default_value})
51
+ push:
52
+ options:
53
+ push: |-
54
+ Push changes to remote server (default %{default_value})
55
+ remote: |-
56
+ Remote name to push to (default %{default_value})
57
+ revision: |-
58
+ Branch to push (default %{default_value})
59
+ propogate_push: |-
60
+ Propogate pushes to the remote throughout the project tree (default %{default_value})
55
61
  actions:
56
62
  extract:
57
63
  options: