metacon 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ libdir = File.join(File.dirname(__FILE__), '..', 'lib')
4
+ if File.exists?(File.join(libdir,'metacon.rb'))
5
+ $LOAD_PATH.unshift(libdir)
6
+ end
7
+ require 'metacon'
8
+
9
+ MetaCon::Command.run
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ libdir = File.join(File.dirname(__FILE__), '..', 'lib')
5
+ if File.exists?(File.join(libdir,'metacon.rb'))
6
+ $LOAD_PATH.unshift(libdir)
7
+ end
8
+ require 'metacon'
9
+ require 'metacon/self_install'
10
+
11
+ ci = MetaCon::SelfInstall.new
12
+ ci.check_install
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,9 @@
1
+ module MetaCon
2
+ require 'metacon/cli_helpers'
3
+ require 'metacon/command'
4
+ VERSION = File.exist?(File.join(File.dirname(__FILE__),'VERSION')) ?
5
+ File.read(File.join(File.dirname(__FILE__),'VERSION')) : ""
6
+ class << self
7
+ def version() VERSION end
8
+ end
9
+ end
@@ -0,0 +1,110 @@
1
+ class String; def as_version; MetaCon::CLIHelpers::SymVer.new(self) end end
2
+
3
+ module MetaCon
4
+ module CLIHelpers
5
+
6
+ class SymVer
7
+ include Comparable
8
+ attr_accessor :varr
9
+ def initialize(vstring)
10
+ @varr = vstring.split('.').map{|p| p.to_i}
11
+ end
12
+
13
+ def <=>(other_v)
14
+ (0..[other_v.varr.size,@varr.size].max).each do |i|
15
+ s = @varr[i] || 0
16
+ o = other_v.varr[i] || 0
17
+ if s < o then return -1
18
+ elsif s > o then return 1 end
19
+ end
20
+ return 0
21
+ end
22
+ end
23
+
24
+ CONTEXT_OS = `uname -s`.strip.downcase.to_sym
25
+ def mac?() CONTEXT_OS == :darwin end
26
+ def darwin?() CONTEXT_OS == :darwin end
27
+ def linux?() CONTEXT_OS == :linux end
28
+
29
+ ESCS = {:normal =>"\e[0m", :black =>"\e[0;30m", :blue =>"\e[0;34m",
30
+ :green =>"\e[0;32m", :cyan =>"\e[0;36m", :red =>"\e[0;31m",
31
+ :purple =>"\e[0;35m", :brown =>"\e[0;33m", :gray =>"\e[0;37m",
32
+ :dark_gray =>"\e[1;30m", :light_blue=>"\e[1;34m", :light_green =>"\e[1;32m",
33
+ :light_cyan=>"\e[1;36m", :light_red =>"\e[1;31m", :light_purple =>"\e[1;35m",
34
+ :yellow =>"\e[1;33m", :white =>"\e[1;37m", :bg_black =>"\e[40m",
35
+ :bg_red =>"\e[41m", :bg_green =>"\e[42m", :bg_yellow =>"\e[43m",
36
+ :bg_blue =>"\e[44m", :bg_magenta=>"\e[45m", :bg_cyan =>"\e[46m",
37
+ :bg_white =>"\e[47m", :"=" =>"\e[44;1;37m", :"==" =>"\e[4;1;37m",
38
+ :"===" =>"\e[1;34m"}
39
+
40
+ def color_puts(str, emit=true)
41
+ begin
42
+ r = false
43
+ str.gsub!(/\|\{([^ \|]+ )([^\}\|]*)\}/){r=true; "#{ESCS[$1.strip.to_sym]}#{$2}#{ESCS[:normal]}"}
44
+ end while r
45
+ puts str if emit
46
+ return str
47
+ end
48
+
49
+ def cwarn(str) color_puts("---|{brown Warning:} #{str}") end
50
+ def cfail(str) color_puts("---|{red Fail:} #{str}") end
51
+
52
+ def status(str) color_puts("\n---|{== #{str}}") end
53
+ def result(str) color_puts(" |{green #{str}}\n") end
54
+
55
+ def fj(*args) File.expand_path(File.join(args)) end # Shortcut for File.join
56
+
57
+ def chd(*args)
58
+ dir = f(args)
59
+ color_puts "|{gray cd #{dir}}"
60
+ Dir.chdir(dir)
61
+ end
62
+
63
+ def command_exists?(cmd)
64
+ `( command -v #{cmd} )`.length > 0
65
+ end
66
+
67
+ def check_tool(name, vcmd, vpos=1, vexp='0', inst='', wmissing=false, wvers=true)
68
+ vs = `#{vcmd}`
69
+ if vs.length > 0
70
+ v = vs.strip.split(/\s+/)[vpos - 1]
71
+ require 'pp'
72
+ if v.as_version < vexp.as_version
73
+ if wvers
74
+ cwarn("#{name} expected to be >= version #{vexp} but only #{v} found. You may need to upgrade.")
75
+ return false
76
+ else
77
+ cfail("#{name} expected to be >= version #{vexp} but only #{v} found. Please upgrade.")
78
+ end
79
+ end
80
+ else
81
+ if wmissing
82
+ cwarn("#{name} not found. To install: #{inst}")
83
+ else
84
+ cfail("#{name} not found. To install: #{inst}")
85
+ return false
86
+ end
87
+ end
88
+ return true
89
+ end
90
+
91
+ def shellescape(str)
92
+ return "''" if str.empty?
93
+ str = str.dup
94
+ str.strip!
95
+ str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
96
+ str.gsub!(/\n/, "'\n'")
97
+ return str
98
+ end
99
+
100
+ def best_profile_file
101
+ prof = Dir[ENV['HOME']+'/.bashrc']
102
+ prof = Dir[ENV['HOME']+'/.zshrc'] if prof.size == 0
103
+ prof = Dir[ENV['HOME']+'/.bash_profile'] if prof.size == 0
104
+ prof = Dir[ENV['HOME']+'/.profile'] if prof.size == 0
105
+ return prof[0] unless prof.size == 0
106
+ return nil
107
+ end
108
+ end
109
+ end
110
+
@@ -0,0 +1,33 @@
1
+ module MetaCon
2
+ class Command
3
+ require 'optparse'
4
+ def self.run
5
+ banner = "metacon\n"+
6
+ "MetaController version #{MetaCon::VERSION}\n" +
7
+ "Usage: metacon [command] [options]"
8
+ options = {}
9
+ opts = OptionParser.new do |o|
10
+ o.version = MetaCon.version
11
+ o.banner = banner
12
+ o.separator ''
13
+ o.on('-v', '--[no-]verbose', 'Run command verbosely'){|v| options[:verbose]=v}
14
+
15
+ o.on('-h','--help', 'Show this message'){puts o; exit 0}
16
+ o.on('--version', 'Show version and exit'){puts MetaCon::VERSION; exit 0}
17
+
18
+ o.separator ''
19
+ o.separator 'commands '
20
+ o.separator '------------------'
21
+ o.separator commands.map{|c,p| "#{c.to_s.ljust(15)}#{p[:desc]}"}
22
+ end
23
+
24
+ files = opts.parse(ARGV)
25
+ end
26
+
27
+ def self.commands
28
+ [[:init, {:desc=>'Initialize ./ or specified directory as a metacon directory, creating it if necessary.',
29
+ :opt_arg=>'[DIRECTORY]'}]
30
+ ]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,52 @@
1
+ module MetaCon
2
+ class SelfInstall
3
+ include MetaCon::CLIHelpers
4
+
5
+ EXP_GIT_V = '1.7.4.1'
6
+ EXP_RVM_V = '1.8.2'
7
+ EXP_PYB_V = '1.1'
8
+
9
+ def check_install
10
+ exit 2 unless check_git
11
+ result 'Looks good'
12
+
13
+ exit 3 unless check_rvm
14
+ result 'Looks good'
15
+
16
+ exit 4 unless check_pythonbrew
17
+ result 'Looks good'
18
+
19
+ install_shelp
20
+ end
21
+
22
+ def check_git
23
+ status('Checking git')
24
+ return check_tool('Git', 'git --version', 3, EXP_GIT_V,
25
+ 'http://book.git-scm.com/2_installing_git.html')
26
+ end
27
+
28
+ def check_rvm
29
+ status('Checking rvm')
30
+ return check_tool('RVM', 'rvm --version', 2, EXP_RVM_V,
31
+ 'http://beginrescueend.com/rvm/install/')
32
+ end
33
+
34
+ def check_pythonbrew
35
+ status ('Checking pythonbrew')
36
+ return check_tool('Python-brew','pythonbrew --version', 1, EXP_PYB_V,
37
+ 'https://github.com/utahta/pythonbrew/blob/master/README.rst')
38
+ end
39
+
40
+ def install_shelp
41
+ status "Checking shell helper functionality"
42
+
43
+ shelp = File.join(File.dirname(__FILE__), '..','..', 'shelp','metacon.bashrc')
44
+ if File.exists?(shelp)
45
+ result "Not yet implemented- you're good to go"
46
+ else
47
+ cfail "Couldn't find shell helper files (metacon.bashrc) - installation broken somehow..."
48
+ exit 5
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,95 @@
1
+ # Meta-dependencies (depended on by metacon)
2
+ - git
3
+ - ruby
4
+ - rvm
5
+ - god
6
+ - supervisord(?)
7
+ (and if there are any python / pip dependencies or subs that need them):
8
+ - python
9
+ - pythonbrew
10
+
11
+ (Perhaps only installed lazily as needed by the conf options?)
12
+ (also something inserted into .bashrc etc. for autocompletion and ps1
13
+ alterations)
14
+
15
+
16
+ # Installation type
17
+ ## 1. general
18
+ - Discouraged if possible because then different environments are no longer
19
+ isolated.
20
+ - Not allowed if different roles require different versions (in which case
21
+ one would be encouraged to turn it into a submodule and run prebuilt local
22
+ versions instead).
23
+ - Can block switching to a different environment if the machine doesn't have
24
+ the correct version required for that other environment.
25
+ Defined by:
26
+ * Command to check if tool exists
27
+ * Command for figuring out what version the tool is at currently
28
+ * Command for testing the tool, if desired- in a global context or local to
29
+ the project.
30
+ * Command for seeing which versions are available for installation
31
+ * Installation hints or commands (if any divergences from the standard installchain)
32
+
33
+ Examples:
34
+ * git-core, imagemagick...
35
+
36
+
37
+ ### Installchain
38
+ #### Preferred tool heirarchy per OS & dependency-type.
39
+ * Test to see if dependency tool is available and working correctly (has
40
+ correct permissions etc.)
41
+ * Looks for individual preference overrides (e.g., yes, I have brew, but I
42
+ prefer you try w/ macports first... etc.)
43
+ * Ability to do a rehearsal - shows what seems to be missing and what would
44
+ probably be used to install it.
45
+
46
+ ## 2. language
47
+ - Initially support isolated versions for:
48
+ * ruby - via rvm
49
+ * python - via python-brew
50
+ - At some point should be pretty easy to add to that list:
51
+ * perl (via perlbrew)
52
+ * gcc (via ???)
53
+ * anything that's usually switchable via ubuntu's update-alternatives (? -
54
+ assuming we can do it in isolated environments at the same time)
55
+ - These would need to get checked against their respective tools (rvm etc.)
56
+ to see which versions are available etc. and warnings issued if something
57
+ else was chosen
58
+ Defined by:
59
+ * Command for seeing which versions are available for installation
60
+
61
+ ## 3. sub (git submodule)
62
+ - When switching roles or environment symlink for submodule directory changes,
63
+ which means the .metacon/bin/ added to the users search path (??) is also
64
+ now looking at the one for the other role/env/etc.
65
+
66
+ Defined by:
67
+ * (Will look for actual location via git locally and create one if
68
+ necessary(?)...)
69
+ * Branch
70
+ * Commit (if not head)
71
+ * mini-installation commands
72
+ - build
73
+ - rebuild
74
+ - test
75
+ - (start/stop/restart/sync/deploy ?)
76
+ -
77
+
78
+ ## 4. git (?)
79
+ - Don't know if this is really going to be useful as something separate from
80
+ "general" yet.
81
+ - Could populate list of available versions etc. etc. straight from github
82
+ (including private via private keys etc.)
83
+
84
+ ## 5. gem (ruby module)
85
+ - Together they take the place of, for example, Gemfile + Gemfile.lock files
86
+
87
+ ## 6. pip (python module)
88
+ - Together they take the place of pip dependency list files
89
+
90
+
91
+ ##
92
+
93
+ Type: submodule
94
+
95
+
@@ -0,0 +1,5 @@
1
+
2
+
3
+
4
+
5
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+
3
+
4
+ echo 'hello'
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'minitest/unit'
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ require 'metacon'
15
+
16
+ class MiniTest::Unit::TestCase
17
+ end
18
+
19
+ MiniTest::Unit.autorun
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestMetacon < MiniTest::Unit::TestCase
4
+ def test_something_for_real
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metacon
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Joseph Wecker
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-12 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 51
29
+ segments:
30
+ - 0
31
+ - 11
32
+ - 0
33
+ version: 0.11.0
34
+ name: god
35
+ version_requirements: *id001
36
+ prerelease: false
37
+ - !ruby/object:Gem::Dependency
38
+ type: :development
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ name: minitest
49
+ version_requirements: *id002
50
+ prerelease: false
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 7
59
+ segments:
60
+ - 0
61
+ - 6
62
+ - 0
63
+ version: 0.6.0
64
+ name: yard
65
+ version_requirements: *id003
66
+ prerelease: false
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 23
75
+ segments:
76
+ - 1
77
+ - 0
78
+ - 0
79
+ version: 1.0.0
80
+ name: bundler
81
+ version_requirements: *id004
82
+ prerelease: false
83
+ - !ruby/object:Gem::Dependency
84
+ type: :development
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 7
91
+ segments:
92
+ - 1
93
+ - 6
94
+ - 4
95
+ version: 1.6.4
96
+ name: jeweler
97
+ version_requirements: *id005
98
+ prerelease: false
99
+ - !ruby/object:Gem::Dependency
100
+ type: :development
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ name: rcov
111
+ version_requirements: *id006
112
+ prerelease: false
113
+ 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
+ email: jwecker@justin.tv
115
+ executables:
116
+ - metacon-install
117
+ - metacon
118
+ extensions: []
119
+
120
+ extra_rdoc_files:
121
+ - LICENSE.txt
122
+ - README.rdoc
123
+ files:
124
+ - .attic/old/.cmd_common
125
+ - .attic/old/Gemfile
126
+ - .attic/old/Gemfile.lock
127
+ - .attic/old/README
128
+ - .attic/old/Rakefile
129
+ - .attic/old/build
130
+ - .attic/old/initialize
131
+ - .attic/old/rake_help.rb
132
+ - .attic/old/rebuild
133
+ - .attic/old/restart
134
+ - .attic/old/sync
135
+ - .attic/old/test
136
+ - .attic/old/update_submodules
137
+ - .attic/old/workers_help.sh
138
+ - .document
139
+ - Gemfile
140
+ - Gemfile.lock
141
+ - LICENSE.txt
142
+ - README.rdoc
143
+ - Rakefile
144
+ - TODO.md
145
+ - VERSION
146
+ - bin/metacon
147
+ - bin/metacon-install
148
+ - lib/VERSION
149
+ - lib/metacon.rb
150
+ - lib/metacon/cli_helpers.rb
151
+ - lib/metacon/command.rb
152
+ - lib/metacon/self_install.rb
153
+ - notes-dependency-tool.md
154
+ - notes.rdoc
155
+ - shelp/metacon.bashrc
156
+ - test/helper.rb
157
+ - test/test_metacon.rb
158
+ has_rdoc: true
159
+ homepage: http://github.com/josephwecker/metacon
160
+ licenses:
161
+ - MIT
162
+ post_install_message: "\n\n\
163
+ \e[1;32m\e[40m--- Please run \e[1;37mmetacon-install\e[1;32m to check dependencies & finish the installation --- \e[0m\n\n"
164
+ rdoc_options: []
165
+
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ hash: 3
174
+ segments:
175
+ - 0
176
+ version: "0"
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ hash: 3
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ requirements:
187
+ - git, v1.7.4.1 or greater
188
+ - rvm, v1.8.2 or greater
189
+ - pythonbrew, v1.1 or greater
190
+ rubyforge_project:
191
+ rubygems_version: 1.6.2
192
+ signing_key:
193
+ specification_version: 3
194
+ summary: Metacontroller for organizing aggregate projects
195
+ test_files: []
196
+