BlueAdmiral 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,27 @@
1
+ ruby_string="ruby-1.9.2-p180"
2
+ gemset_name="blueadmiral"
3
+
4
+ if rvm list strings | grep -q "${ruby_string}" ; then
5
+
6
+ # Load or create the specified environment
7
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
8
+ && -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
9
+ \. "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}"
10
+ else
11
+ rvm --create "${ruby_string}@${gemset_name}"
12
+ fi
13
+
14
+ # Ensure that Bundler is installed, install it if it is not.
15
+ if ! command -v bundle ; then
16
+ gem install bundler
17
+ fi
18
+
19
+ # Bundle while reducing excess noise.
20
+ bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
21
+
22
+ else
23
+
24
+ # Notify the user to install the desired interpreter before proceeding.
25
+ echo "${ruby_string} was not found, please run 'rvm install ${ruby_string}' and then cd back into the project directory."
26
+
27
+ fi
@@ -0,0 +1,92 @@
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{BlueAdmiral}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David Love"]
12
+ s.date = %q{2011-05-03}
13
+ s.default_executable = %q{bootstrap}
14
+ s.description = %q{Prepares hosts/networks/etc to become part of a stated Mercury environment}
15
+ s.email = %q{david@homeunix.org.uk}
16
+ s.executables = ["bootstrap"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ ".rvmrc",
25
+ "BlueAdmiral.gemspec",
26
+ "Gemfile",
27
+ "Gemfile.lock",
28
+ "LICENSE",
29
+ "README.rdoc",
30
+ "Rakefile",
31
+ "VERSION",
32
+ "bin/bootstrap",
33
+ "lib/LICENSE",
34
+ "lib/mercury.rb",
35
+ "lib/mercury/cli.rb",
36
+ "lib/mercury/cli/base.rb",
37
+ "lib/mercury/cli/commands.rb",
38
+ "lib/mercury/cli/commands/help.rb",
39
+ "lib/mercury/cli/commands/show.rb",
40
+ "lib/mercury/cli/logger.rb",
41
+ "spec/BlueAdmiral_spec.rb",
42
+ "spec/spec_helper.rb"
43
+ ]
44
+ s.homepage = %q{http://github.com/dlove24/BlueAdmiral}
45
+ s.licenses = ["ISC"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = %q{1.6.2}
48
+ s.summary = %q{%Bootstrapping and maintenance commands for the Mercury environment}
49
+
50
+ if s.respond_to? :specification_version then
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<hiredis>, ["~> 0.3.1"])
55
+ s.add_runtime_dependency(%q<em-synchrony>, [">= 0"])
56
+ s.add_runtime_dependency(%q<redis>, ["~> 2.2.0"])
57
+ s.add_runtime_dependency(%q<json>, [">= 0"])
58
+ s.add_runtime_dependency(%q<cli>, [">= 0"])
59
+ s.add_runtime_dependency(%q<cri>, [">= 0"])
60
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
61
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
62
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
63
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
64
+ s.add_development_dependency(%q<rcov>, [">= 0"])
65
+ else
66
+ s.add_dependency(%q<hiredis>, ["~> 0.3.1"])
67
+ s.add_dependency(%q<em-synchrony>, [">= 0"])
68
+ s.add_dependency(%q<redis>, ["~> 2.2.0"])
69
+ s.add_dependency(%q<json>, [">= 0"])
70
+ s.add_dependency(%q<cli>, [">= 0"])
71
+ s.add_dependency(%q<cri>, [">= 0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
74
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
75
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
76
+ s.add_dependency(%q<rcov>, [">= 0"])
77
+ end
78
+ else
79
+ s.add_dependency(%q<hiredis>, ["~> 0.3.1"])
80
+ s.add_dependency(%q<em-synchrony>, [">= 0"])
81
+ s.add_dependency(%q<redis>, ["~> 2.2.0"])
82
+ s.add_dependency(%q<json>, [">= 0"])
83
+ s.add_dependency(%q<cli>, [">= 0"])
84
+ s.add_dependency(%q<cri>, [">= 0"])
85
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
86
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
87
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
88
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
89
+ s.add_dependency(%q<rcov>, [">= 0"])
90
+ end
91
+ end
92
+
data/Gemfile ADDED
@@ -0,0 +1,42 @@
1
+ ###
2
+ ### Sources
3
+ ###
4
+
5
+ # Main Ruby Gems site
6
+ source "http://rubygems.org"
7
+
8
+ ###
9
+ ### Core Gems. These are required in _all_ environments (additional environments
10
+ ### follow).
11
+ ###
12
+
13
+ # Gem required for linking to the Redis server
14
+ gem "hiredis", "~> 0.3.1"
15
+ gem "em-synchrony"
16
+ gem "redis", "~> 2.2.0", :require => ["redis/connection/synchrony", "redis"]
17
+
18
+ # JSON Parser
19
+ gem "json"
20
+
21
+ # Command line parser
22
+ gem "cli"
23
+ gem "cri"
24
+
25
+ ###
26
+ ### Development Gems. All _additional_ gems required by development (as apposed to
27
+ ### production environments). If it is required at run-time, it
28
+ ### belongs above.
29
+ group :development do
30
+
31
+ # Gem management tools
32
+ gem "bundler", "~> 1.0.0"
33
+ gem "jeweler", "~> 1.6.0"
34
+
35
+ # Documentation Tools
36
+ gem "yard", "~> 0.6.0"
37
+
38
+ # Testing Tools
39
+ gem "rspec", "~> 2.3.0"
40
+ gem "rcov", ">= 0"
41
+
42
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ cli (0.0.1.2)
5
+ cri (1.0.1)
6
+ diff-lcs (1.1.2)
7
+ em-synchrony (0.2.0)
8
+ eventmachine (>= 0.12.9)
9
+ eventmachine (0.12.10)
10
+ git (1.2.5)
11
+ hiredis (0.3.1)
12
+ jeweler (1.6.0)
13
+ bundler (~> 1.0.0)
14
+ git (>= 1.2.5)
15
+ rake
16
+ json (1.5.1)
17
+ rake (0.8.7)
18
+ rcov (0.9.9)
19
+ redis (2.2.0)
20
+ rspec (2.3.0)
21
+ rspec-core (~> 2.3.0)
22
+ rspec-expectations (~> 2.3.0)
23
+ rspec-mocks (~> 2.3.0)
24
+ rspec-core (2.3.1)
25
+ rspec-expectations (2.3.0)
26
+ diff-lcs (~> 1.1.2)
27
+ rspec-mocks (2.3.0)
28
+ yard (0.6.8)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.0.0)
35
+ cli
36
+ cri
37
+ em-synchrony
38
+ hiredis (~> 0.3.1)
39
+ jeweler (~> 1.6.0)
40
+ json
41
+ rcov
42
+ redis (~> 2.2.0)
43
+ rspec (~> 2.3.0)
44
+ yard (~> 0.6.0)
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2011 David Love <david@homeunix.org.uk>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = BlueAdmiral
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to BlueAdmiral
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 David Love. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "BlueAdmiral"
18
+ gem.homepage = "http://github.com/dlove24/BlueAdmiral"
19
+ gem.license = "ISC"
20
+ gem.summary = "%Bootstrapping and maintenance commands for the Mercury environment"
21
+ gem.description = "Prepares hosts/networks/etc to become part of a stated Mercury environment"
22
+ gem.email = "david@homeunix.org.uk"
23
+ gem.authors = ["David Love"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'yard'
42
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/bootstrap ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ### Copyright (c) 2011 David Love <david@homeunix.org.uk>
4
+ ###
5
+ ### Permission to use, copy, modify, and/or distribute this software for
6
+ ### any purpose with or without fee is hereby granted, provided that the
7
+ ### above copyright notice and this permission notice appear in all copies.
8
+ ###
9
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ ###
17
+
18
+ ### @author David Love
19
+ ###
20
+ ### Bootstraping Command. Used to initalize various aspects of the Mercury
21
+ ### environment.
22
+ ###
23
+ ### @note The sub-commands provided by the bootstrap command assume (at-least)
24
+ ### a minimally working Ruby environment, with the required gems installed. Various
25
+ ### 'First Boot' scripts are available in the `scripts` directory for different
26
+ ### platforms which will achive at least this minimal state
27
+ ###
28
+
29
+ # Add lib to load path
30
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
31
+
32
+ # Load the rubygems library
33
+ require 'rubygems'
34
+
35
+ # Load core application library
36
+ require 'mercury'
37
+
38
+ # Load command line handler
39
+ require 'mercury/cli'
40
+
41
+ # Load the commands from the cmds dir
42
+ plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../cmds')
43
+
44
+ Dir[plugin_dir + '/*.rb'].sort.each{|file|
45
+ require file
46
+ }
47
+
48
+ # Run base
49
+ Mercury::CLI::Base.new.run(ARGV)
data/lib/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Denis Defreyne and contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
20
+
@@ -0,0 +1,74 @@
1
+ ### Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
2
+ ###
3
+ ### Permission to use, copy, modify, and/or distribute this software for
4
+ ### any purpose with or without fee is hereby granted, provided that the
5
+ ### above copyright notice and this permission notice appear in all copies.
6
+ ###
7
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+ ###
15
+
16
+ module Mercury::CLI
17
+
18
+ class Base < Cri::Base
19
+
20
+ def initialize
21
+ super('mercury')
22
+
23
+ # Add help command
24
+ self.help_command = Mercury::CLI::Commands::Help.new
25
+ add_command(self.help_command)
26
+
27
+ # Add other commands
28
+ add_command(Mercury::CLI::Commands::Show.new)
29
+ end
30
+
31
+ # Returns the list of global option definitionss.
32
+ def global_option_definitions
33
+ [
34
+ {
35
+ :long => 'help', :short => 'h', :argument => :forbidden,
36
+ :desc => 'show this help message and quit'
37
+ },
38
+ {
39
+ :long => 'no-color', :short => 'C', :argument => :forbidden,
40
+ :desc => 'disable color'
41
+ },
42
+ {
43
+ :long => 'version', :short => 'v', :argument => :forbidden,
44
+ :desc => 'show version information and quit'
45
+ },
46
+ {
47
+ :long => 'verbose', :short => 'V', :argument => :forbidden,
48
+ :desc => 'make mercury output more detailed'
49
+ }
50
+ ]
51
+ end
52
+
53
+ def handle_option(option)
54
+ # Handle version option
55
+ if option == :version
56
+ puts "Mercury Bootstrap Client #{Mercury::VERSION} (c) 2011 David Love."
57
+ puts "Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) running on #{RUBY_PLATFORM}"
58
+ exit 0
59
+ # Handle verbose option
60
+ elsif option == :verbose
61
+ Mercury::CLI::Logger.instance.level = :low
62
+ # Handle no-color option
63
+ elsif option == :'no-color'
64
+ Mercury::CLI::Logger.instance.color = false
65
+ # Handle help option
66
+ elsif option == :help
67
+ show_help
68
+ exit 0
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ end
@@ -0,0 +1,84 @@
1
+ ### Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
2
+ ###
3
+ ### Permission to use, copy, modify, and/or distribute this software for
4
+ ### any purpose with or without fee is hereby granted, provided that the
5
+ ### above copyright notice and this permission notice appear in all copies.
6
+ ###
7
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+ ###
15
+
16
+ module Mercury::CLI::Commands
17
+
18
+ class Help < Cri::Command
19
+
20
+ def name
21
+ 'help'
22
+ end
23
+
24
+ def aliases
25
+ []
26
+ end
27
+
28
+ def short_desc
29
+ 'Show help for a command'
30
+ end
31
+
32
+ def long_desc
33
+ 'Show help for the given command, or show general help. When no ' +
34
+ 'command is given, a list of available commands is displayed, as ' +
35
+ 'well as a list of global commandline options. When a command is ' +
36
+ 'given, a command description as well as command-specific ' +
37
+ 'commandline options are shown.'
38
+ end
39
+
40
+ def usage
41
+ "mercury help [command]"
42
+ end
43
+
44
+ def run(options, arguments)
45
+ # Check arguments
46
+ if arguments.size > 1
47
+ $stderr.puts "usage: #{usage}"
48
+ exit 1
49
+ end
50
+
51
+ if arguments.length == 0
52
+ # Build help text
53
+ text = ''
54
+
55
+ # Add title
56
+ text << "A Mercury Server client written in Ruby.\n"
57
+
58
+ # Add available commands
59
+ text << "\n"
60
+ text << "Available commands:\n"
61
+ text << "\n"
62
+ @base.commands.sort.each do |command|
63
+ text << sprintf(" %-20s %s\n", command.name, command.short_desc)
64
+ end
65
+
66
+ # Add global options
67
+ text << "\n"
68
+ text << "Global options:\n"
69
+ text << "\n"
70
+ @base.global_option_definitions.sort { |x,y| x[:long] <=> y[:long] }.each do |opt_def|
71
+ text << sprintf(" -%1s --%-15s %s\n", opt_def[:short], opt_def[:long], opt_def[:desc])
72
+ end
73
+
74
+ # Display text
75
+ puts text
76
+ elsif arguments.length == 1
77
+ command = @base.command_named(arguments[0])
78
+ puts command.help
79
+ end
80
+ end
81
+
82
+ end
83
+
84
+ end
@@ -0,0 +1,72 @@
1
+ ### Copyright (c) 2011 David Love
2
+ ###
3
+ ### Permission to use, copy, modify, and/or distribute this software for
4
+ ### any purpose with or without fee is hereby granted, provided that the
5
+ ### above copyright notice and this permission notice appear in all copies.
6
+ ###
7
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+ ###
15
+
16
+ module Mercury::CLI::Commands
17
+
18
+ class Show < Cri::Command
19
+
20
+ def name
21
+ 'show-status'
22
+ end
23
+
24
+ def aliases
25
+ []
26
+ end
27
+
28
+ def short_desc
29
+ 'Create or update information from the network'
30
+ end
31
+
32
+ def long_desc
33
+ "Displays the current state of the evironemnt " +
34
+ "to update the host files (held in the 'hosts' directory). Existing " +
35
+ "information will be updated, and missing information inserted.\n"
36
+ end
37
+
38
+ def usage
39
+ "bootstrap show-status"
40
+ end
41
+
42
+ def option_definitions
43
+ []
44
+ end
45
+
46
+ def run(options, arguments)
47
+
48
+ # Load the list of groups
49
+ group_list = YAML::load( File.open("config/groups.yaml"))
50
+
51
+ # Load the list of networks
52
+ network_list = YAML::load( File.open("config/networks.yaml"))
53
+
54
+ # Update the information in each group-network directory
55
+ gn_name_list = Array.new
56
+
57
+ network_list.each{|network|
58
+ puts network[1]
59
+
60
+ net_block = network[1]['ip4-address-block'].to_s
61
+
62
+ # Scan this network
63
+ # parser = Nmap::Parser.parsescan("nmap", "-sVC " + net_block)
64
+
65
+ puts parser
66
+ }
67
+
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,21 @@
1
+ ### Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
2
+ ###
3
+ ### Permission to use, copy, modify, and/or distribute this software for
4
+ ### any purpose with or without fee is hereby granted, provided that the
5
+ ### above copyright notice and this permission notice appear in all copies.
6
+ ###
7
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+ ###
15
+
16
+ module Mercury::CLI::Commands
17
+ end
18
+
19
+ require 'mercury/cli/commands/help'
20
+
21
+ require 'mercury/cli/commands/show'
@@ -0,0 +1,87 @@
1
+ ### Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
2
+ ###
3
+ ### Permission to use, copy, modify, and/or distribute this software for
4
+ ### any purpose with or without fee is hereby granted, provided that the
5
+ ### above copyright notice and this permission notice appear in all copies.
6
+ ###
7
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+ ###
15
+
16
+ require 'singleton'
17
+
18
+ module Mercury::CLI
19
+
20
+ # Mercury::CLI::Logger is a singleton class responsible for generating
21
+ # feedback in the terminal.
22
+ class Logger
23
+
24
+ ACTION_COLORS = {
25
+ :create => "\e[1m" + "\e[32m", # bold + green
26
+ :update => "\e[1m" + "\e[33m", # bold + yellow
27
+ :identical => "\e[1m", # bold
28
+ :skip => "\e[1m", # bold
29
+ :'not written' => "\e[1m" # bold
30
+ }
31
+
32
+ include Singleton
33
+
34
+ # The log level, which can be :high, :low or :off (which will log all
35
+ # messages, only high-priority messages, or no messages at all,
36
+ # respectively).
37
+ attr_accessor :level
38
+
39
+ # Whether to use color in log messages or not
40
+ attr_accessor :color
41
+ alias_method :color?, :color
42
+
43
+ def initialize
44
+ @level = :high
45
+ @color = true
46
+ end
47
+
48
+ # Logs a file-related action.
49
+ #
50
+ # +level+:: The importance of this action. Can be :high or :low.
51
+ #
52
+ # +action+:: The kind of file action. Can be :create, :update or
53
+ # :identical.
54
+ #
55
+ # +identifier+:: The identifier of the item the action was performed on.
56
+ def file(level, action, identifier, duration=nil)
57
+ log(
58
+ level,
59
+ '%s%12s%s %s%s' % [
60
+ color? ? ACTION_COLORS[action.to_sym] : '',
61
+ action,
62
+ color? ? "\e[0m" : '',
63
+ duration.nil? ? '' : "[%2.2fs] " % [ duration ],
64
+ identifier
65
+ ]
66
+ )
67
+ end
68
+
69
+ # Logs a message.
70
+ #
71
+ # +level+:: The importance of this message. Can be :high or :low.
72
+ #
73
+ # +s+:: The message to be logged.
74
+ #
75
+ # +io+:: The IO instance to which the message will be written. Defaults to
76
+ # standard output.
77
+ def log(level, s, io=$stdout)
78
+ # Don't log when logging is disabled
79
+ return if @level == :off
80
+
81
+ # Log when level permits it
82
+ io.puts(s) if (@level == :low or @level == level)
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -0,0 +1,29 @@
1
+ ### Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
2
+ ###
3
+ ### Permission to use, copy, modify, and/or distribute this software for
4
+ ### any purpose with or without fee is hereby granted, provided that the
5
+ ### above copyright notice and this permission notice appear in all copies.
6
+ ###
7
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+ ###
15
+
16
+ require 'rubygems'
17
+
18
+ # Load command line handling library
19
+ require 'cri'
20
+
21
+ # Install module for command line
22
+ # interface
23
+ module Mercury:CLI
24
+ end
25
+
26
+ # Load the command line handling modules
27
+ require 'mercury/cli/logger'
28
+ require 'mercury/cli/commands'
29
+ require 'mercury/cli/base'
data/lib/mercury.rb ADDED
@@ -0,0 +1,24 @@
1
+ ### Copyright (c) 2010, David Love
2
+ ###
3
+ ### Permission to use, copy, modify, and/or distribute this software for
4
+ ### any purpose with or without fee is hereby granted, provided that the
5
+ ### above copyright notice and this permission notice appear in all copies.
6
+ ###
7
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+ ###
15
+
16
+ module Mercury
17
+
18
+ ## Define Application Global constants
19
+
20
+ # The current Mercury Server client version.
21
+ VERSION = '0.1'
22
+
23
+ end
24
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Blueadmiral" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'BlueAdmiral'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: BlueAdmiral
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - David Love
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-03 00:00:00 +01:00
14
+ default_executable: bootstrap
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: hiredis
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.3.1
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: em-synchrony
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: redis
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.2.0
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: json
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: cli
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: cri
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: bundler
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: jeweler
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ version: 1.6.0
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: yard
106
+ requirement: &id009 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: 0.6.0
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: rspec
117
+ requirement: &id010 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ version: 2.3.0
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: rcov
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: *id011
137
+ description: Prepares hosts/networks/etc to become part of a stated Mercury environment
138
+ email: david@homeunix.org.uk
139
+ executables:
140
+ - bootstrap
141
+ extensions: []
142
+
143
+ extra_rdoc_files:
144
+ - LICENSE
145
+ - README.rdoc
146
+ files:
147
+ - .document
148
+ - .rspec
149
+ - .rvmrc
150
+ - BlueAdmiral.gemspec
151
+ - Gemfile
152
+ - Gemfile.lock
153
+ - LICENSE
154
+ - README.rdoc
155
+ - Rakefile
156
+ - VERSION
157
+ - bin/bootstrap
158
+ - lib/LICENSE
159
+ - lib/mercury.rb
160
+ - lib/mercury/cli.rb
161
+ - lib/mercury/cli/base.rb
162
+ - lib/mercury/cli/commands.rb
163
+ - lib/mercury/cli/commands/help.rb
164
+ - lib/mercury/cli/commands/show.rb
165
+ - lib/mercury/cli/logger.rb
166
+ - spec/BlueAdmiral_spec.rb
167
+ - spec/spec_helper.rb
168
+ has_rdoc: true
169
+ homepage: http://github.com/dlove24/BlueAdmiral
170
+ licenses:
171
+ - ISC
172
+ post_install_message:
173
+ rdoc_options: []
174
+
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ hash: -4315529852713499843
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: "0"
192
+ requirements: []
193
+
194
+ rubyforge_project:
195
+ rubygems_version: 1.6.2
196
+ signing_key:
197
+ specification_version: 3
198
+ summary: "%Bootstrapping and maintenance commands for the Mercury environment"
199
+ test_files: []
200
+