metacon 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.rdoc +14 -0
- data/TODO.md +9 -15
- data/VERSION +1 -1
- data/lib/VERSION +1 -1
- data/lib/metacon.rb +1 -0
- data/lib/metacon/cli_helpers.rb +7 -4
- data/lib/metacon/command.rb +95 -7
- data/lib/metacon/config.rb +62 -0
- data/lib/metacon/init.rb +39 -0
- data/lib/metacon/project.rb +164 -0
- data/lib/metacon/stat.rb +29 -0
- data/lib/metacon/switch.rb +28 -0
- data/metacon.gemspec +104 -0
- data/notes-dependency-tool.md +13 -14
- data/shelp/metacon.bashrc +2 -1
- metadata +36 -14
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,6 +3,7 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
git (1.2.5)
|
5
5
|
god (0.11.0)
|
6
|
+
highline (1.6.2)
|
6
7
|
jeweler (1.6.4)
|
7
8
|
bundler (~> 1.0)
|
8
9
|
git (>= 1.2.5)
|
@@ -18,6 +19,7 @@ PLATFORMS
|
|
18
19
|
DEPENDENCIES
|
19
20
|
bundler (~> 1.0.0)
|
20
21
|
god (~> 0.11.0)
|
22
|
+
highline (~> 1.6.2)
|
21
23
|
jeweler (~> 1.6.4)
|
22
24
|
minitest
|
23
25
|
rcov
|
data/README.rdoc
CHANGED
@@ -5,6 +5,20 @@ development work but might be more generalizable later. For controlling a
|
|
5
5
|
complex project repository. (Where controlling = developing, deploying,
|
6
6
|
running/supervising, branching, aggregating, etc.)
|
7
7
|
|
8
|
+
== Commands
|
9
|
+
|
10
|
+
== Configs
|
11
|
+
=== Standard families / families w/ special functionality
|
12
|
+
==== dependencies
|
13
|
+
Define the overall dependencies for meta-environments
|
14
|
+
==== osenv
|
15
|
+
Sets up misc. os (bash) environment variables for meta-environments (probably
|
16
|
+
won't be able to guarantee they're set except in specific run contexts)
|
17
|
+
|
18
|
+
==== deployment
|
19
|
+
|
20
|
+
==== runtime
|
21
|
+
|
8
22
|
== Description
|
9
23
|
=== Context: A random walk through changing your project environment
|
10
24
|
(while iterating/working on a single project, using mostly ruby and python as
|
data/TODO.md
CHANGED
@@ -1,20 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Installation
|
4
|
-
(gem -> basic libraries used by commands)
|
5
|
-
(installer ->
|
6
|
-
- Basic install-script (similar to rvm installation procedure)
|
7
|
-
- Install/ensure dependencies
|
8
|
-
- git
|
9
|
-
- rvm
|
10
|
-
- god
|
11
|
-
- pythonbrew
|
12
|
-
- Install shell shim
|
13
|
-
|
14
1
|
# Components
|
15
2
|
## General Commandline
|
16
|
-
|
3
|
+
|
17
4
|
## Commands
|
5
|
+
- init
|
6
|
+
|
18
7
|
- st / stat -> environment + versions of dependencies, state of submodules,
|
19
8
|
current git state, running state, etc.
|
20
9
|
- env [-l[ist] || new\_env]
|
@@ -35,10 +24,15 @@
|
|
35
24
|
- Allow a ~/.metacon-config for filling in general things not specified in
|
36
25
|
project directory.
|
37
26
|
- project.config > home.config > default.config
|
38
|
-
- Make sure there is general (sane) config stuff for
|
27
|
+
- Make sure there is general (sane) config stuff for basic ruby-god stuff
|
39
28
|
|
40
29
|
## Shell Prompt (PS1) for Bash/ZSH
|
41
30
|
|
42
31
|
## Autocomplete
|
43
32
|
|
44
33
|
|
34
|
+
|
35
|
+
## Context Changes
|
36
|
+
*
|
37
|
+
|
38
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/metacon.rb
CHANGED
data/lib/metacon/cli_helpers.rb
CHANGED
@@ -2,6 +2,7 @@ class String; def as_version; MetaCon::CLIHelpers::SymVer.new(self) end end
|
|
2
2
|
|
3
3
|
module MetaCon
|
4
4
|
module CLIHelpers
|
5
|
+
def included(by); by.extend(self) end
|
5
6
|
|
6
7
|
class SymVer
|
7
8
|
include Comparable
|
@@ -45,12 +46,13 @@ module MetaCon
|
|
45
46
|
puts str if emit
|
46
47
|
return str
|
47
48
|
end
|
49
|
+
alias :cputs :color_puts
|
48
50
|
|
49
|
-
def cwarn(str) color_puts("
|
50
|
-
def cfail(str) color_puts("
|
51
|
+
def cwarn(str) color_puts("|{brown Warning:} #{str}") end
|
52
|
+
def cfail(str) color_puts("|{red Fail:} #{str}") end
|
51
53
|
|
52
|
-
def status(str) color_puts("\n
|
53
|
-
def result(str) color_puts("
|
54
|
+
def status(str) color_puts("\n|{== #{str}}") end
|
55
|
+
def result(str) color_puts(" |{green #{str}}\n") end
|
54
56
|
|
55
57
|
def fj(*args) File.expand_path(File.join(args)) end # Shortcut for File.join
|
56
58
|
|
@@ -105,6 +107,7 @@ module MetaCon
|
|
105
107
|
return prof[0] unless prof.size == 0
|
106
108
|
return nil
|
107
109
|
end
|
110
|
+
extend self
|
108
111
|
end
|
109
112
|
end
|
110
113
|
|
data/lib/metacon/command.rb
CHANGED
@@ -1,10 +1,72 @@
|
|
1
1
|
module MetaCon
|
2
2
|
class Command
|
3
3
|
require 'optparse'
|
4
|
+
require 'metacon/cli_helpers'
|
5
|
+
require 'highline'
|
6
|
+
require 'metacon/init'
|
7
|
+
require 'metacon/stat'
|
8
|
+
require 'metacon/switch'
|
9
|
+
include MetaCon::CLIHelpers
|
10
|
+
CMD_ALIASES = {
|
11
|
+
:init => :init,
|
12
|
+
:initialize => :init,
|
13
|
+
|
14
|
+
:st => :stat,
|
15
|
+
:stat => :stat,
|
16
|
+
:status => :stat,
|
17
|
+
:statistics => :stat,
|
18
|
+
|
19
|
+
:c => :curr,
|
20
|
+
:curr => :curr,
|
21
|
+
:current => :curr,
|
22
|
+
|
23
|
+
:role => :role,
|
24
|
+
|
25
|
+
:rtc => :rtc,
|
26
|
+
:rctx => :rtc,
|
27
|
+
:runtime => :rtc,
|
28
|
+
:runtimecontext => :rtc,
|
29
|
+
|
30
|
+
:os => :os,
|
31
|
+
:operatingsystem => :os,
|
32
|
+
|
33
|
+
:host => :host,
|
34
|
+
:machine => :host,
|
35
|
+
:computer => :host,
|
36
|
+
:server => :host,
|
37
|
+
|
38
|
+
:conf => :conf,
|
39
|
+
:config => :conf,
|
40
|
+
:configuration=> :conf
|
41
|
+
}
|
42
|
+
COMMANDS = [[:init, {:args => ['[DIRECTORY]'],
|
43
|
+
:desc => 'Init metacon project dir, default ./, create if necessary',
|
44
|
+
:handler => MetaCon::Init}],
|
45
|
+
[:stat, {:args => ['[STAT-NAME]'],
|
46
|
+
:desc => 'Status of / information about the current context',
|
47
|
+
:handler => MetaCon::Stat}],
|
48
|
+
[:curr, {:args => ['[KIND]'],
|
49
|
+
:desc => 'Display current metacontext (or specified part)',
|
50
|
+
:handler => MetaCon::Stat}],
|
51
|
+
[:role, {:args => ['[SWITCH-TO]'],
|
52
|
+
:desc => 'Show current role in list, or switch to new.',
|
53
|
+
:handler => MetaCon::Switch}],
|
54
|
+
[:rtc, {:args => ['[SWITCH-TO]'],
|
55
|
+
:desc => 'Show current runtime-context in list, or switch to new.',
|
56
|
+
:handler => MetaCon::Switch}],
|
57
|
+
[:os, {:args => ['[SWITCH-TO]'],
|
58
|
+
:desc => 'Show current OS in list, or try to switch to new.',
|
59
|
+
:handler => MetaCon::Switch}],
|
60
|
+
[:host, {:args => ['[SWITCH-TO]'],
|
61
|
+
:desc => 'Show current host/machine in list, or try to switch to new.',
|
62
|
+
:handler => MetaCon::Switch}],
|
63
|
+
[:conf, {:args => ['[FAMILY]'],
|
64
|
+
:desc => 'Output the currently applicable configuration',
|
65
|
+
:handler => MetaCon::Command}] ]
|
4
66
|
def self.run
|
5
67
|
banner = "metacon\n"+
|
6
68
|
"MetaController version #{MetaCon::VERSION}\n" +
|
7
|
-
"Usage: metacon [
|
69
|
+
"Usage: metacon [COMMAND] [OPTIONS]"
|
8
70
|
options = {}
|
9
71
|
opts = OptionParser.new do |o|
|
10
72
|
o.version = MetaCon.version
|
@@ -18,16 +80,42 @@ module MetaCon
|
|
18
80
|
o.separator ''
|
19
81
|
o.separator 'commands '
|
20
82
|
o.separator '------------------'
|
21
|
-
|
83
|
+
cmds = COMMANDS.map do |c,p|
|
84
|
+
args = p[:args].join(' ')
|
85
|
+
"#{(c.to_s + ' ' + args).ljust(36)} #{p[:desc]}"
|
86
|
+
end
|
87
|
+
o.separator cmds
|
22
88
|
end
|
89
|
+
rest = opts.parse(ARGV)
|
23
90
|
|
24
|
-
|
91
|
+
if rest.size == 0
|
92
|
+
puts opts
|
93
|
+
exit
|
94
|
+
end
|
95
|
+
command_key = rest.shift.strip.downcase
|
96
|
+
command = CMD_ALIASES[command_key.to_sym]
|
97
|
+
|
98
|
+
if command.nil?
|
99
|
+
cfail "Command #{command_key} not found. Use -h to see the list of commands."
|
100
|
+
exit 2
|
101
|
+
end
|
102
|
+
$cli = HighLine.new
|
103
|
+
$cli.extend(MetaCon::CLIHelpers)
|
104
|
+
unless command == :init
|
105
|
+
$proj = MetaCon::Project.new
|
106
|
+
$cli.cfail 'Not a metacon project. Use `metacon init`' and exit(5) unless $proj.valid
|
107
|
+
end
|
108
|
+
|
109
|
+
command_info = COMMANDS.select{|k,v| k == command}[0][1]
|
110
|
+
command_info[:handler].send :handle, command, rest
|
25
111
|
end
|
26
112
|
|
27
|
-
def self.
|
28
|
-
|
29
|
-
|
30
|
-
|
113
|
+
def self.handle(cmd,opts)
|
114
|
+
if cmd == :conf
|
115
|
+
conf = $proj.conf
|
116
|
+
conf = Hash[opts.map{|fam| [fam, conf[fam]]}] if opts.size > 0
|
117
|
+
puts conf.to_yaml
|
118
|
+
end
|
31
119
|
end
|
32
120
|
end
|
33
121
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module MetaCon
|
2
|
+
class Config
|
3
|
+
attr_accessor :data, :declared
|
4
|
+
def initialize(root)
|
5
|
+
# TODO: Ability to explicitly set mconf files in .metacon settings
|
6
|
+
require 'yaml'
|
7
|
+
conf_files = Dir[root + '/**/*.mconf']
|
8
|
+
@data = []
|
9
|
+
@declared = {:rtc=>{}, :role=>{}, :os=>{}, :host=>{}}
|
10
|
+
conf_files.each{|cf| update_with(cf) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](context)
|
14
|
+
rtc,role,os,host = [:rtc,:role,:os,:host].map{|k| context.delete(k) || '*'}
|
15
|
+
relevant = @data.select do |keys,fc|
|
16
|
+
(rtc == '*' || keys[0] == '*' || rtc == keys[0]) &&
|
17
|
+
(role== '*' || keys[1] == '*' || role== keys[1]) &&
|
18
|
+
(os == '*' || keys[2] == '*' || os == keys[2]) &&
|
19
|
+
(host== '*' || keys[3] == '*' || host== keys[3])
|
20
|
+
end
|
21
|
+
res = {}
|
22
|
+
relevant.each do |k, fc|
|
23
|
+
fam, content = fc
|
24
|
+
if res.has_key?(fam)
|
25
|
+
currv = res[fam]
|
26
|
+
if content.is_a?(Array) && currv.is_a?(Array)
|
27
|
+
res[fam] = currv | content
|
28
|
+
elsif content.is_a?(Hash) && currv.is_a?(Hash)
|
29
|
+
res[fam] = currv.merge(content)
|
30
|
+
else
|
31
|
+
# TODO: Think through more merge scenarios
|
32
|
+
raise "Could not combine conf parameters for #{fam}"
|
33
|
+
end
|
34
|
+
else res[fam] = content end
|
35
|
+
end
|
36
|
+
return res
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def update_with(fname)
|
42
|
+
default_family = File.basename(fname,'.mconf')
|
43
|
+
content = YAML.load_file(fname)
|
44
|
+
return unless content
|
45
|
+
content.each{|k,v| update_group(default_family, k, v)}
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_group(default_family, key, content)
|
49
|
+
if key.start_with? '/'
|
50
|
+
# TODO: Actually parse these- negative namespaces, regex, etc.
|
51
|
+
rtc, role, os, host = key.split('/').map{|v| v.strip}[1..-1]
|
52
|
+
@declared[:rtc][rtc] = true unless rtc == '*'
|
53
|
+
@declared[:role][role] = true unless role == '*'
|
54
|
+
@declared[:os][os] = true unless os == '*'
|
55
|
+
@declared[:host][host] = true unless host == '*'
|
56
|
+
@data << [[rtc,role,os,host],[default_family, content]]
|
57
|
+
elsif content.is_a?(Hash)
|
58
|
+
content.each{|k,v| update_group(key,k,v) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/metacon/init.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module MetaCon
|
2
|
+
class Init
|
3
|
+
require 'fileutils'
|
4
|
+
def self.handle(_cmd, opts)
|
5
|
+
dir = opts.shift
|
6
|
+
dir ||= './'
|
7
|
+
# Find out if different roles are specified. If none- default to primary.
|
8
|
+
# Default to dev
|
9
|
+
# Run context-shift/verify
|
10
|
+
|
11
|
+
if MetaCon::Project.initialized?(dir)
|
12
|
+
exit(3) unless $cli.agree('This is already part of a metacon project. Continue? (y/n)', true)
|
13
|
+
end
|
14
|
+
|
15
|
+
already_there = false
|
16
|
+
mcd = File.join(dir,'.metacon')
|
17
|
+
if File.directory?(dir)
|
18
|
+
already_there = File.directory?(mcd)
|
19
|
+
else FileUtils.mkdir_p(dir) end
|
20
|
+
if already_there
|
21
|
+
exit(3) unless $cli.agree('Refresh existing .metacon directory? (y/n) ', true)
|
22
|
+
`rm -rf "#{mcd}"`
|
23
|
+
end
|
24
|
+
FileUtils.mkdir(mcd)
|
25
|
+
|
26
|
+
$cli.status "Initializing..."
|
27
|
+
mcp = MetaCon::Project.new(mcd)
|
28
|
+
|
29
|
+
init_role = mcp.list(:role)[0] || 'main'
|
30
|
+
init_rtc = mcp.list(:rtc)[0] || 'dev'
|
31
|
+
switch_res = mcp.switch(:role => init_role, :rtc => init_rtc)
|
32
|
+
if switch_res == :impossible
|
33
|
+
$cli.cfail 'Cannot initialize the metacontext- submodules need to have files committed.'
|
34
|
+
exit 4
|
35
|
+
end
|
36
|
+
$cli.result "\"#{dir}\" is now a metacon project"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
module MetaCon
|
2
|
+
class Project
|
3
|
+
require 'metacon/config'
|
4
|
+
attr_accessor :mc_dir, :rel_dir, :root_dir, :valid
|
5
|
+
def self.initialized?(relative_to='./')
|
6
|
+
! find_mc_dir(relative_to).nil?
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(relative_to='./')
|
10
|
+
@rel_dir = File.expand_path(relative_to)
|
11
|
+
@mc_dir = Project.find_mc_dir(@rel_dir)
|
12
|
+
if @mc_dir.nil?
|
13
|
+
@root_dir = nil
|
14
|
+
@valid = false
|
15
|
+
@state = nil
|
16
|
+
else
|
17
|
+
@root_dir = File.expand_path(File.join(@mc_dir, '..'))
|
18
|
+
@valid = true
|
19
|
+
@state = SavedState.new(@mc_dir)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def conf_obj
|
24
|
+
refresh_conf if @config.nil?
|
25
|
+
@config
|
26
|
+
end
|
27
|
+
|
28
|
+
def conf
|
29
|
+
refresh_conf if @config.nil?
|
30
|
+
@config[current_state]
|
31
|
+
end
|
32
|
+
|
33
|
+
def this_os; `uname -s`.strip.downcase end
|
34
|
+
def this_host; `uname -n`.strip end
|
35
|
+
|
36
|
+
def different_os?
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def atomic(&block)
|
41
|
+
@state.atomic do |s|
|
42
|
+
yield self, s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def switch(changes={})
|
47
|
+
return :nochange if changes=={}
|
48
|
+
return :impossible unless can_switch?
|
49
|
+
changed = false
|
50
|
+
@state.atomic do |s|
|
51
|
+
changes.each do |key, val|
|
52
|
+
s[key] = val unless s[key] == val
|
53
|
+
end
|
54
|
+
changed = s.dirty
|
55
|
+
end
|
56
|
+
if changed
|
57
|
+
return setup_context
|
58
|
+
else
|
59
|
+
return :nochange
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def can_switch?
|
64
|
+
# TODO: make sure submodules don't have stuff to stash etc.
|
65
|
+
return true
|
66
|
+
end
|
67
|
+
|
68
|
+
def current_state
|
69
|
+
st = @state.readonly
|
70
|
+
st[:os] = this_os if (st[:os] == '(this)' || st[:os] == '.')
|
71
|
+
st[:host] = this_host if (st[:host] == '(this)' || st[:host] == '.')
|
72
|
+
return st
|
73
|
+
end
|
74
|
+
|
75
|
+
def list(to_list)
|
76
|
+
return nil unless @valid
|
77
|
+
refresh_conf
|
78
|
+
cs = current_state
|
79
|
+
@config.declared[to_list].keys | [cs[to_list]]
|
80
|
+
end
|
81
|
+
|
82
|
+
protected
|
83
|
+
|
84
|
+
def self.find_mc_dir(relative_to='./')
|
85
|
+
d = relative_to.dup
|
86
|
+
while ! File.directory?(File.join(d,'.metacon'))
|
87
|
+
d = File.expand_path(File.join(d,'..'))
|
88
|
+
return nil if d == '/'
|
89
|
+
end
|
90
|
+
return File.join(d,'.metacon')
|
91
|
+
end
|
92
|
+
|
93
|
+
def refresh_conf; @config = Config.new(@root_dir) end
|
94
|
+
|
95
|
+
def setup_context
|
96
|
+
# Dependencies loaded in for:
|
97
|
+
# - ruby
|
98
|
+
# - gems
|
99
|
+
# - bundler Gemfiles
|
100
|
+
# - python
|
101
|
+
# - pips
|
102
|
+
# - submodules
|
103
|
+
# - (general tools)
|
104
|
+
# Use different classes for each to encourage adding more
|
105
|
+
|
106
|
+
return :switched
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class SavedState
|
111
|
+
require 'yaml'
|
112
|
+
attr_accessor :dirty
|
113
|
+
def initialize(mcdir)
|
114
|
+
raise "#{mcdir} not found" unless File.directory?(mcdir)
|
115
|
+
@fstate = File.join(mcdir,'current_state')
|
116
|
+
@in_atomic = @dirty = false
|
117
|
+
end
|
118
|
+
|
119
|
+
def blank_initial_state
|
120
|
+
@dirty = true
|
121
|
+
{:role => 'main',
|
122
|
+
:rtc => 'dev',
|
123
|
+
:os => '(this)',
|
124
|
+
:host => '(this)'}
|
125
|
+
end
|
126
|
+
|
127
|
+
def atomic(&block)
|
128
|
+
@in_atomic = true
|
129
|
+
`touch #{@fstate}` # Guarantee exists and change timestamps
|
130
|
+
File.open(@fstate,'r+') do |f|
|
131
|
+
f.flock File::LOCK_EX
|
132
|
+
@state = YAML::load(f.read)
|
133
|
+
@state ||= blank_initial_state
|
134
|
+
yield self
|
135
|
+
if @dirty
|
136
|
+
f.pos = 0
|
137
|
+
f.print @state.to_yaml
|
138
|
+
f.truncate(f.pos)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
@dirty = false
|
142
|
+
@in_atomic = false
|
143
|
+
end
|
144
|
+
|
145
|
+
def readonly
|
146
|
+
res = YAML::load_file(@fstate)
|
147
|
+
res ||= blank_initial_state
|
148
|
+
return res
|
149
|
+
end
|
150
|
+
|
151
|
+
def [](key)
|
152
|
+
if @in_atomic
|
153
|
+
@state[key]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def []=(key,val)
|
158
|
+
if @in_atomic
|
159
|
+
@state[key] = val
|
160
|
+
@dirty = true
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
data/lib/metacon/stat.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module MetaCon
|
2
|
+
class Stat
|
3
|
+
def self.handle(cmd, opts)
|
4
|
+
case cmd
|
5
|
+
when :stat; stat(opts)
|
6
|
+
when :curr; curr(opts)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.stat(opts)
|
11
|
+
puts '(not yet implemented)'
|
12
|
+
puts curr(opts)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.curr(opts=[], proj=nil)
|
16
|
+
proj ||= $proj
|
17
|
+
$cli.cfail 'Not a metacon project. Use `metacon init`' and exit(5) unless proj.valid
|
18
|
+
state = proj.current_state
|
19
|
+
os = state[:os] == proj.this_os ? '.' : state[:os]
|
20
|
+
host = state[:host] == proj.this_host ? '.' : state[:host]
|
21
|
+
if opts.size == 0
|
22
|
+
puts "/#{state[:rtc]}/#{state[:role]}/#{os}/#{host}/"
|
23
|
+
else
|
24
|
+
# TODO: check for valid types
|
25
|
+
opts.each{|o| puts state[o.to_sym]}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module MetaCon
|
2
|
+
class Switch
|
3
|
+
def self.handle(cmd, opts)
|
4
|
+
if opts.nil? or opts.size == 0
|
5
|
+
all = $proj.list(cmd)
|
6
|
+
current = $proj.current_state[cmd]
|
7
|
+
all.sort.each do |avail|
|
8
|
+
if avail == current
|
9
|
+
$cli.cputs "* |{green #{avail}}"
|
10
|
+
else
|
11
|
+
puts " #{avail}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
else
|
15
|
+
res = $proj.switch({cmd=>opts[0]})
|
16
|
+
case res
|
17
|
+
when :nochange
|
18
|
+
$cli.cwarn 'Nothing changed'
|
19
|
+
when :switched
|
20
|
+
$cli.result "Switched #{cmd} to '#{opts[0]}'"
|
21
|
+
when :impossible
|
22
|
+
$cli.cfail 'Cannot switch. Probably because submodules need committing.'
|
23
|
+
end
|
24
|
+
MetaCon::Stat.curr
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/metacon.gemspec
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{metacon}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Joseph Wecker"]
|
12
|
+
s.date = %q{2011-10-18}
|
13
|
+
s.description = %q{Tool with some similarities to puppet but specializing in fast development iteration and continuous deployment. Specifically initially for use with justin.tv / twitch.tv project clusters.}
|
14
|
+
s.email = %q{jwecker@justin.tv}
|
15
|
+
s.executables = ["metacon-install", "metacon"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".attic/old/.cmd_common",
|
22
|
+
".attic/old/Gemfile",
|
23
|
+
".attic/old/Gemfile.lock",
|
24
|
+
".attic/old/README",
|
25
|
+
".attic/old/Rakefile",
|
26
|
+
".attic/old/build",
|
27
|
+
".attic/old/initialize",
|
28
|
+
".attic/old/rake_help.rb",
|
29
|
+
".attic/old/rebuild",
|
30
|
+
".attic/old/restart",
|
31
|
+
".attic/old/sync",
|
32
|
+
".attic/old/test",
|
33
|
+
".attic/old/update_submodules",
|
34
|
+
".attic/old/workers_help.sh",
|
35
|
+
".document",
|
36
|
+
"Gemfile",
|
37
|
+
"Gemfile.lock",
|
38
|
+
"LICENSE.txt",
|
39
|
+
"README.rdoc",
|
40
|
+
"Rakefile",
|
41
|
+
"TODO.md",
|
42
|
+
"VERSION",
|
43
|
+
"bin/metacon",
|
44
|
+
"bin/metacon-install",
|
45
|
+
"lib/VERSION",
|
46
|
+
"lib/metacon.rb",
|
47
|
+
"lib/metacon/cli_helpers.rb",
|
48
|
+
"lib/metacon/command.rb",
|
49
|
+
"lib/metacon/config.rb",
|
50
|
+
"lib/metacon/init.rb",
|
51
|
+
"lib/metacon/project.rb",
|
52
|
+
"lib/metacon/self_install.rb",
|
53
|
+
"lib/metacon/stat.rb",
|
54
|
+
"lib/metacon/switch.rb",
|
55
|
+
"metacon.gemspec",
|
56
|
+
"notes-dependency-tool.md",
|
57
|
+
"notes.rdoc",
|
58
|
+
"shelp/metacon.bashrc",
|
59
|
+
"test/helper.rb",
|
60
|
+
"test/test_metacon.rb"
|
61
|
+
]
|
62
|
+
s.homepage = %q{http://github.com/josephwecker/metacon}
|
63
|
+
s.licenses = ["MIT"]
|
64
|
+
s.post_install_message = %q{
|
65
|
+
|
66
|
+
[1;32m[40m--- Please run [1;37mmetacon-install[1;32m to check dependencies & finish the installation --- [0m
|
67
|
+
|
68
|
+
}
|
69
|
+
s.require_paths = ["lib"]
|
70
|
+
s.requirements = ["git, v1.7.4.1 or greater", "rvm, v1.8.2 or greater", "pythonbrew, v1.1 or greater"]
|
71
|
+
s.rubygems_version = %q{1.6.2}
|
72
|
+
s.summary = %q{Metacontroller for organizing aggregate projects}
|
73
|
+
|
74
|
+
if s.respond_to? :specification_version then
|
75
|
+
s.specification_version = 3
|
76
|
+
|
77
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
78
|
+
s.add_runtime_dependency(%q<god>, ["~> 0.11.0"])
|
79
|
+
s.add_runtime_dependency(%q<highline>, ["~> 1.6.2"])
|
80
|
+
s.add_development_dependency(%q<minitest>, [">= 0"])
|
81
|
+
s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
|
82
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
83
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
84
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
85
|
+
else
|
86
|
+
s.add_dependency(%q<god>, ["~> 0.11.0"])
|
87
|
+
s.add_dependency(%q<highline>, ["~> 1.6.2"])
|
88
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
89
|
+
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
90
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
91
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
92
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
93
|
+
end
|
94
|
+
else
|
95
|
+
s.add_dependency(%q<god>, ["~> 0.11.0"])
|
96
|
+
s.add_dependency(%q<highline>, ["~> 1.6.2"])
|
97
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
98
|
+
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
99
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
100
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
101
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
data/notes-dependency-tool.md
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
# Tool stack
|
2
|
+
|
3
|
+
* sanity-test
|
4
|
+
* pre-deploy-build
|
5
|
+
* pre-deploy-rebuild
|
6
|
+
* sync
|
7
|
+
* build
|
8
|
+
* rebuild
|
9
|
+
* test
|
10
|
+
* start
|
11
|
+
* restart
|
12
|
+
* hard-restart
|
13
|
+
* stop
|
15
14
|
|
16
15
|
# Installation type
|
17
16
|
## 1. general
|
data/shelp/metacon.bashrc
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metacon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joseph Wecker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-18 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,8 +35,24 @@ dependencies:
|
|
35
35
|
version_requirements: *id001
|
36
36
|
prerelease: false
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
type: :
|
38
|
+
type: :runtime
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 11
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 6
|
48
|
+
- 2
|
49
|
+
version: 1.6.2
|
50
|
+
name: highline
|
51
|
+
version_requirements: *id002
|
52
|
+
prerelease: false
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
type: :development
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
56
|
none: false
|
41
57
|
requirements:
|
42
58
|
- - ">="
|
@@ -46,11 +62,11 @@ dependencies:
|
|
46
62
|
- 0
|
47
63
|
version: "0"
|
48
64
|
name: minitest
|
49
|
-
version_requirements: *
|
65
|
+
version_requirements: *id003
|
50
66
|
prerelease: false
|
51
67
|
- !ruby/object:Gem::Dependency
|
52
68
|
type: :development
|
53
|
-
requirement: &
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
70
|
none: false
|
55
71
|
requirements:
|
56
72
|
- - ~>
|
@@ -62,11 +78,11 @@ dependencies:
|
|
62
78
|
- 0
|
63
79
|
version: 0.6.0
|
64
80
|
name: yard
|
65
|
-
version_requirements: *
|
81
|
+
version_requirements: *id004
|
66
82
|
prerelease: false
|
67
83
|
- !ruby/object:Gem::Dependency
|
68
84
|
type: :development
|
69
|
-
requirement: &
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
70
86
|
none: false
|
71
87
|
requirements:
|
72
88
|
- - ~>
|
@@ -78,11 +94,11 @@ dependencies:
|
|
78
94
|
- 0
|
79
95
|
version: 1.0.0
|
80
96
|
name: bundler
|
81
|
-
version_requirements: *
|
97
|
+
version_requirements: *id005
|
82
98
|
prerelease: false
|
83
99
|
- !ruby/object:Gem::Dependency
|
84
100
|
type: :development
|
85
|
-
requirement: &
|
101
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
86
102
|
none: false
|
87
103
|
requirements:
|
88
104
|
- - ~>
|
@@ -94,11 +110,11 @@ dependencies:
|
|
94
110
|
- 4
|
95
111
|
version: 1.6.4
|
96
112
|
name: jeweler
|
97
|
-
version_requirements: *
|
113
|
+
version_requirements: *id006
|
98
114
|
prerelease: false
|
99
115
|
- !ruby/object:Gem::Dependency
|
100
116
|
type: :development
|
101
|
-
requirement: &
|
117
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
102
118
|
none: false
|
103
119
|
requirements:
|
104
120
|
- - ">="
|
@@ -108,7 +124,7 @@ dependencies:
|
|
108
124
|
- 0
|
109
125
|
version: "0"
|
110
126
|
name: rcov
|
111
|
-
version_requirements: *
|
127
|
+
version_requirements: *id007
|
112
128
|
prerelease: false
|
113
129
|
description: Tool with some similarities to puppet but specializing in fast development iteration and continuous deployment. Specifically initially for use with justin.tv / twitch.tv project clusters.
|
114
130
|
email: jwecker@justin.tv
|
@@ -149,7 +165,13 @@ files:
|
|
149
165
|
- lib/metacon.rb
|
150
166
|
- lib/metacon/cli_helpers.rb
|
151
167
|
- lib/metacon/command.rb
|
168
|
+
- lib/metacon/config.rb
|
169
|
+
- lib/metacon/init.rb
|
170
|
+
- lib/metacon/project.rb
|
152
171
|
- lib/metacon/self_install.rb
|
172
|
+
- lib/metacon/stat.rb
|
173
|
+
- lib/metacon/switch.rb
|
174
|
+
- metacon.gemspec
|
153
175
|
- notes-dependency-tool.md
|
154
176
|
- notes.rdoc
|
155
177
|
- shelp/metacon.bashrc
|