BlueAdmiral 0.0.1 → 0.0.2

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/BlueAdmiral.gemspec CHANGED
@@ -5,15 +5,15 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{BlueAdmiral}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Love"]
12
12
  s.date = %q{2011-05-03}
13
- s.default_executable = %q{bootstrap}
13
+ s.default_executable = %q{mercury}
14
14
  s.description = %q{Prepares hosts/networks/etc to become part of a stated Mercury environment}
15
15
  s.email = %q{david@homeunix.org.uk}
16
- s.executables = ["bootstrap"]
16
+ s.executables = ["mercury"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
19
  "README.rdoc"
@@ -29,12 +29,13 @@ Gem::Specification.new do |s|
29
29
  "README.rdoc",
30
30
  "Rakefile",
31
31
  "VERSION",
32
- "bin/bootstrap",
32
+ "bin/mercury",
33
33
  "lib/LICENSE",
34
34
  "lib/mercury.rb",
35
35
  "lib/mercury/cli.rb",
36
36
  "lib/mercury/cli/base.rb",
37
37
  "lib/mercury/cli/commands.rb",
38
+ "lib/mercury/cli/commands/bootstrap.rb",
38
39
  "lib/mercury/cli/commands/help.rb",
39
40
  "lib/mercury/cli/commands/show.rb",
40
41
  "lib/mercury/cli/logger.rb",
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
File without changes
@@ -1,22 +1,48 @@
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
- ###
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
15
 
16
+ # @author Denis Defreyne
17
+ # @author David Love
18
+ #
19
+ # The +CLI+ module acts as the gathering place for all the gloabl options
20
+ # and the sub-commands which the +mercury+ command can deal with.
21
+ # Sub-commands are themselves defined in the {Mercury::CLI::Commands}
22
+ # module
16
23
  module Mercury::CLI
17
24
 
25
+ # @author Denis Defreyne
26
+ # @author David Love
27
+ #
28
+ # Details the global options applicable to all commands, and the code necessary
29
+ # to process those options. Each sub-command also needs to be registered with
30
+ # this class for it to work: strange things will happen if the sub-command is
31
+ # not set-up here!
32
+ #
33
+ # When creating a new sub-command, the constructor for that sub-command needs
34
+ # to be added to the {Base#initialize} function of *this* class as well. Be sure to
35
+ # also add the path to the file where the sub-command is defined to the file
36
+ # +lib/mercury/cli/commands.rb+, otherwise you will get warnings of unknown
37
+ # classes.
18
38
  class Base < Cri::Base
19
39
 
40
+ # Instantiates the sub-commands by creating a single reference to each
41
+ # known sub-command.
42
+ #
43
+ # @note This means that if your sub-command is not in this constructor
44
+ # it *will not* be found, and *will not* appear as a valid sub-command.
45
+ # If something is missing from the 'help' command, check this method!
20
46
  def initialize
21
47
  super('mercury')
22
48
 
@@ -25,6 +51,7 @@ module Mercury::CLI
25
51
  add_command(self.help_command)
26
52
 
27
53
  # Add other commands
54
+ add_command(Mercury::CLI::Commands::Bootstrap.new)
28
55
  add_command(Mercury::CLI::Commands::Show.new)
29
56
  end
30
57
 
@@ -50,6 +77,7 @@ module Mercury::CLI
50
77
  ]
51
78
  end
52
79
 
80
+ # Process the global options, and set/change the application state from them
53
81
  def handle_option(option)
54
82
  # Handle version option
55
83
  if option == :version
@@ -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
+ module Mercury::CLI::Commands
17
+
18
+ # @author David Love
19
+ #
20
+ # The +bootstrap+ command prepared the basic Mercury realms (if
21
+ # needed), and then links the current host to those realms. The basic
22
+ # realms consists of
23
+ #
24
+ # +Realm 0+: *Namespace*. All the named realms stored in this domain.
25
+ #
26
+ # +Realm 1+: *Realm Handlers*. The basic gateways needed to create/store/update
27
+ # other realms.
28
+ #
29
+ # +Realm 5+: *Realm Code*. Libraries and other code which the realm handlers
30
+ # should use by preference when conducting operations on the realms.
31
+ #
32
+ # If the IP address of a server (or a server name) is given to as an argument
33
+ # to this command, then we will use that IP address (name) for as the Mercury
34
+ # realm server to contact. Otherwise we will look for the same data from the file
35
+ # +/etc/mercury.conf+: aborting if the file cannot be found.
36
+ #
37
+ # Once we have made contact with the server, we look at the basic realms listed
38
+ # above, and attempt to ensure they can be found. If not, an attempt is made to
39
+ # create the basic realms: aborting if this attempt fails.
40
+ #
41
+ # Finally, once everything has been set-up, we upload the core realm code (or
42
+ # update the existing code)
43
+ class Bootstrap < Cri::Command
44
+
45
+ # The name of the sub-command (as it appears in the command line app)
46
+ def name
47
+ 'bootstrap'
48
+ end
49
+
50
+ # The aliases this sub-command is known by
51
+ def aliases
52
+ []
53
+ end
54
+
55
+ # A short help text describing the purpose of this command
56
+ def short_desc
57
+ 'Create a link between this host and the mercury servers.'
58
+ end
59
+
60
+ # A longer description, detailing both the purpose and the
61
+ # use of this command
62
+ def long_desc
63
+ 'Look for the specified server, adding the data required to link the ' +
64
+ 'current host to that server. If the found server has not been set-up ' +
65
+ 'then this command also performs the setup of the base realms as well. '
66
+ end
67
+
68
+ # Show the user the basic syntax of this command
69
+ def usage
70
+ "mercury bootstrap [-s server]"
71
+ end
72
+
73
+ # Define the options for this command
74
+ def option_definitions
75
+ [
76
+ { :short => 's', :long => 'server', :argument => :optional }
77
+ ]
78
+ end
79
+
80
+ # Execute the command
81
+ def run(options, arguments)
82
+ return
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -15,32 +15,54 @@
15
15
 
16
16
  module Mercury::CLI::Commands
17
17
 
18
+ # @author Denis Defreyne
19
+ # @author David Love
20
+ #
21
+ # The +help+ command show the user a brief summary of the available
22
+ # sub-commands, and the short description of each of those commands.
23
+ #
24
+ # Further help is available to the user, if one of the sub-commands
25
+ # is named as an argument to this command. In that case, the longer
26
+ # help for the command is displayed.
27
+ #
28
+ # @note This class is merely a helper class: the actual text, options
29
+ # and other details are drawn directly from the source code of those
30
+ # commands. In the execution of this command, we rely on the +cri+
31
+ # and +cli+ libraries to do the hard work of actually processing the
32
+ # sub-commands.
18
33
  class Help < Cri::Command
19
34
 
35
+ # The name of the sub-command (as it appears in the command line app)
20
36
  def name
21
37
  'help'
22
38
  end
23
39
 
40
+ # The aliases this sub-command is known by
24
41
  def aliases
25
42
  []
26
43
  end
27
44
 
45
+ # A short help text describing the purpose of this command
28
46
  def short_desc
29
47
  'Show help for a command'
30
48
  end
31
49
 
50
+ # A longer description, detailing both the purpose and the
51
+ # use of this command
32
52
  def long_desc
33
53
  'Show help for the given command, or show general help. When no ' +
34
54
  'command is given, a list of available commands is displayed, as ' +
35
- 'well as a list of global commandline options. When a command is ' +
55
+ 'well as a list of global command-line options. When a command is ' +
36
56
  'given, a command description as well as command-specific ' +
37
- 'commandline options are shown.'
57
+ 'command-line options are shown.'
38
58
  end
39
59
 
60
+ # Show the user the basic syntax of this command
40
61
  def usage
41
62
  "mercury help [command]"
42
63
  end
43
64
 
65
+ # Execute the command
44
66
  def run(options, arguments)
45
67
  # Check arguments
46
68
  if arguments.size > 1
@@ -53,7 +75,7 @@ module Mercury::CLI::Commands
53
75
  text = ''
54
76
 
55
77
  # Add title
56
- text << "A Mercury Server client written in Ruby.\n"
78
+ text << "A command-line tool for managing Mercury realms.\n"
57
79
 
58
80
  # Add available commands
59
81
  text << "\n"
@@ -1,48 +1,63 @@
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
- ###
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
+ # @author David Love
17
+ #
15
18
 
16
19
  module Mercury::CLI::Commands
17
20
 
21
+ # @author David Love
22
+ #
23
+ # Displays a summary of the realm data found in the configured Mercury
24
+ # server.
18
25
  class Show < Cri::Command
19
-
26
+
27
+ # The name of the sub-command (as it appears in the command line app)
20
28
  def name
21
29
  'show-status'
22
30
  end
23
31
 
32
+ # The aliases this sub-command is known by
24
33
  def aliases
25
34
  []
26
35
  end
27
36
 
37
+ # A short help text describing the purpose of this command
28
38
  def short_desc
29
39
  'Create or update information from the network'
30
40
  end
31
41
 
42
+ # A longer description, detailing both the purpose and the
43
+ # use of this command
32
44
  def long_desc
33
45
  "Displays the current state of the evironemnt " +
34
46
  "to update the host files (held in the 'hosts' directory). Existing " +
35
47
  "information will be updated, and missing information inserted.\n"
36
48
  end
37
-
49
+
50
+ # Show the user the basic syntax of this command
38
51
  def usage
39
52
  "bootstrap show-status"
40
53
  end
41
54
 
55
+ # Define the options for this command
42
56
  def option_definitions
43
57
  []
44
58
  end
45
59
 
60
+ # Execute the command
46
61
  def run(options, arguments)
47
62
 
48
63
  # Load the list of groups
@@ -1,21 +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
- ###
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.
15
14
 
15
+ # @author David Love
16
+ #
17
+ # The +Commands+ module acts as the gathering place for all the sub-commands
18
+ # which the +mercury+ command can deal with. Each sub-command defines both
19
+ # the command action, options, and associated help text.
20
+ #
21
+ # All commands should live under +lib/mercury/cli/commands+, with the
22
+ # file-name named after the sub-command defined within it.
16
23
  module Mercury::CLI::Commands
17
24
  end
18
25
 
19
26
  require 'mercury/cli/commands/help'
20
27
 
28
+ require 'mercury/cli/commands/bootstrap'
21
29
  require 'mercury/cli/commands/show'
@@ -21,6 +21,8 @@ module Mercury::CLI
21
21
  # feedback in the terminal.
22
22
  class Logger
23
23
 
24
+ # ANSI console codes (escape sequences) for highlighting particular
25
+ # log outputs.
24
26
  ACTION_COLORS = {
25
27
  :create => "\e[1m" + "\e[32m", # bold + green
26
28
  :update => "\e[1m" + "\e[33m", # bold + yellow
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: BlueAdmiral
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Love
@@ -11,7 +11,7 @@ bindir: bin
11
11
  cert_chain: []
12
12
 
13
13
  date: 2011-05-03 00:00:00 +01:00
14
- default_executable: bootstrap
14
+ default_executable: mercury
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: hiredis
@@ -137,7 +137,7 @@ dependencies:
137
137
  description: Prepares hosts/networks/etc to become part of a stated Mercury environment
138
138
  email: david@homeunix.org.uk
139
139
  executables:
140
- - bootstrap
140
+ - mercury
141
141
  extensions: []
142
142
 
143
143
  extra_rdoc_files:
@@ -154,12 +154,13 @@ files:
154
154
  - README.rdoc
155
155
  - Rakefile
156
156
  - VERSION
157
- - bin/bootstrap
157
+ - bin/mercury
158
158
  - lib/LICENSE
159
159
  - lib/mercury.rb
160
160
  - lib/mercury/cli.rb
161
161
  - lib/mercury/cli/base.rb
162
162
  - lib/mercury/cli/commands.rb
163
+ - lib/mercury/cli/commands/bootstrap.rb
163
164
  - lib/mercury/cli/commands/help.rb
164
165
  - lib/mercury/cli/commands/show.rb
165
166
  - lib/mercury/cli/logger.rb
@@ -179,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
180
  requirements:
180
181
  - - ">="
181
182
  - !ruby/object:Gem::Version
182
- hash: -4315529852713499843
183
+ hash: -976333998919963703
183
184
  segments:
184
185
  - 0
185
186
  version: "0"