bcome 0.1.6 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a6174a45ea4309da7ce8053c8eef32a601725e4
4
- data.tar.gz: a9ee6b5a1181437c27b0e7ac4255e29c1a4d4d71
3
+ metadata.gz: 92514554431fdc1960b632453544f789e138ef72
4
+ data.tar.gz: 7b5a1c6dbbcacdd86c210233b1614b613f482f8c
5
5
  SHA512:
6
- metadata.gz: bec1eeb5d226b4fc6c75e6e3bd37c4ab2d16fb47b7a810898e347e4de009b8df8d74ab307bb67fe10515e6e107c7376155fe48fa7a1b2c249781dbbce511888d
7
- data.tar.gz: a7ba04ed80315c990352fadf8484cf5aff31b9bafa7e42214dfdc422dd92c2ff97ec1b3283485e941fcd93385b8efddbf8a37002fec61cb2542f16a2c710ccbd
6
+ metadata.gz: ec948cd860c212fdfc30e51376e5a3eb85d48073ed1cc06d5fb57cddd24a68d1dceb9d049813c584798763e7e9f14da08c8d0ebc6ea2c082681422751306f8be
7
+ data.tar.gz: 9a137c66c9afa2e40288eeab9a5955e307766455d35e29727896909b1865bde55946ec2c1afbcb4a2d8c5f14dd4ddf3233a56cac91acf2985da146c8eef9484c
data/lib/bcome.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'colorize'
1
+ require 'rainbow'
2
2
  require 'aws-sdk'
3
3
  require 'net/scp'
4
4
  require 'net/ssh/proxy/command'
data/lib/bcome/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bcome
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/become_object.rb CHANGED
@@ -75,7 +75,8 @@ module ::Bcome::BecomeObject
75
75
  if responds_to_list?
76
76
  ::RENDER.list_items(collection_key, resources)
77
77
  else
78
- puts "\nNo list function at this level".headsup
78
+ puts "\n" + "No list function at this level".warning + "\n\n"
79
+ puts "Enter 'menu' for all available options".menu_item_white + "\n\n"
79
80
  end
80
81
  end
81
82
  alias :ls :list
data/lib/command.rb CHANGED
@@ -50,11 +50,11 @@ class ::Bcome::Command
50
50
  end
51
51
 
52
52
  def stdout=(data)
53
- @stdout = data #data.output
53
+ @stdout = data
54
54
  end
55
55
 
56
56
  def stderr=(data)
57
- @stderr = data #data.output
57
+ @stderr = data
58
58
  end
59
59
 
60
60
  def exit_code=(data)
@@ -18,11 +18,11 @@ module Bcome::ContextFunctions
18
18
 
19
19
  def context_commands
20
20
  if context_cmd_functions && context_cmd_functions.any?
21
- context_cmd_functions.each do |context_function|
22
- puts
23
- puts context_function[:description].informational
24
- puts "Executed command: #{context_function[:executed_command]} bcome_context=\"#{context_breadcrumb}\""
25
- puts "Usage: > #{context_function[:command].command}"
21
+ puts "\n\n\s\s" + "Context Commands".menu_title_green + "\n\n"
22
+ context_cmd_functions.each_with_index do |context_function, index|
23
+ puts "\n\t#{index+1}. #{context_function[:description].menu_item_green}" + "\n"
24
+ puts "\tExecuted command:".menu_item_cyan + "\s#{context_function[:executed_command]} bcome_context=\"#{context_breadcrumb}\""
25
+ puts "\tUsage:".menu_item_cyan + "\s#{context_function[:command].command}"
26
26
  puts
27
27
  end
28
28
  else
data/lib/functions.rb CHANGED
@@ -4,14 +4,14 @@ module Bcome::Functions
4
4
 
5
5
  def functions
6
6
  unless cmd_functions
7
- puts "You don't yet have any custom functions defined. Have a read of the docs and define some. They're pretty useful.".informational
7
+ puts "\n\n" + "You don't yet have any custom functions defined. Have a read of the docs and define some. They're pretty useful.".warning + "\n\n"
8
8
  else
9
- puts
9
+ puts "\n\n\s\s" + "Functions".menu_title_green + "\n\n"
10
10
  cmd_functions.each_with_index do |cmd_function, i|
11
- puts "#{cmd_function[:ref].informational}"
12
- puts "Description: " + cmd_function[:description]
13
- puts "Command: > " + cmd_function[:command]
14
- puts "USAGE: > F \"#{cmd_function[:ref]}\""
11
+ puts "\tShortcut: ".menu_item_cyan + "\s#{cmd_function[:ref].informational}"
12
+ puts "\tDescription:".menu_item_cyan + "\s#{cmd_function[:description]}"
13
+ puts "\tCommand:".menu_item_cyan + "\s#{cmd_function[:command]}"
14
+ puts "\tUsage:".menu_item_cyan + "\sF \"#{cmd_function[:ref]}\""
15
15
  puts
16
16
  end
17
17
  end
@@ -20,7 +20,7 @@ module Bcome::Functions
20
20
 
21
21
  def F(reference)
22
22
  if self.is_a?(Bcome::Stack::Environment) && no_selections?
23
- puts "You are an an Environment level, and have not selected any nodes to workon.".failure
23
+ puts "\n\n" + "You are an an Environment level, and have not selected any nodes to workon.".warning + "\n\n"
24
24
  else
25
25
  command = cmd_for_ref(reference)
26
26
  if command
@@ -90,15 +90,17 @@ module ::Bcome::Selections
90
90
  def add_object(object)
91
91
  return if object_in_selections?(object)
92
92
  @objects = @objects ? (@objects << object) : [object]
93
+ puts "\n" + "#{object.identifier} added.".menu_item_cyan + "\sType 'selections' to see currently selections instances.'".menu_item_white
93
94
  return
94
95
  end
95
96
 
96
97
  def remove_object(object)
97
98
  return if no_selections?
98
99
  unless object_in_selections?(object)
99
- print "\n#{object.identifier} is not within selections\n".headsup
100
+ puts "\n#{object.identifier} is not within selections".headsup
100
101
  else
101
102
  @objects = @objects - [object]
103
+ puts "\n" + "#{object.identifier} removed.".menu_item_cyan + "\sType 'selections' to see currently selections instances.'".menu_item_white
102
104
  end
103
105
  return
104
106
  end
@@ -110,9 +112,10 @@ module ::Bcome::Selections
110
112
 
111
113
  def selections
112
114
  if no_selections?
113
- print "\nNo added nodes.\n".headsup
115
+ puts "\n" + "No added nodes.".headsup + "\n"
114
116
  else
115
- print "\nAdded nodes: #{@objects.collect(&:identifier).join(", ")}\n".headsup
117
+ puts "\n\s\s" + "Selected nodes:".menu_title_green + "\n\n"
118
+ puts @objects.collect {|o| o.do_describe }.join + "\n"
116
119
  end
117
120
  end
118
121
 
data/lib/nodes/estate.rb CHANGED
@@ -27,7 +27,7 @@ module ::Bcome::Node
27
27
  end
28
28
  end
29
29
 
30
- puts estate_machine_list.colorize(:green)
30
+ puts estate_machine_list
31
31
 
32
32
  return ""
33
33
  end
@@ -16,7 +16,7 @@ module ::Bcome::Orchestrator
16
16
  end
17
17
 
18
18
  def as_menu_items(stack_level_instance)
19
- stack_level_instance.recipes.collect {|recipe| { :command => recipe.recipe_identifier, :description => "(Command recipe): #{recipe.description}" } }
19
+ stack_level_instance.recipes.collect {|recipe| { :command => recipe.recipe_identifier, :description => recipe.description } }
20
20
  end
21
21
 
22
22
  end
@@ -1,47 +1,81 @@
1
1
  class String
2
2
 
3
- def informational
4
- self.colorize(:white).on_green
3
+ # with thanks to http://simianuprising.com/wp-content/uploads/2012/08/solarized-reference-horizontal.png
4
+ def colour_codes
5
+ {
6
+ :yellow => "#b58900",
7
+ :orange => "#cb4b16",
8
+ :red => "#dc322f",
9
+ :magenta => "#d33682",
10
+ :violet => "#6c71c4",
11
+ :blue => "#268bd2",
12
+ :cyan => "#2aa198",
13
+ :green => "#859900",
14
+ :white => "#ffffff"
15
+ }
5
16
  end
6
17
 
7
- def command
8
- self.colorize(:black).on_white
18
+ def highlight_colour_codes
19
+ {
20
+ :yellow => "#002b36",
21
+ :orange => "#073642",
22
+ :red => "#586e75",
23
+ :magenta => "#657b83",
24
+ :violet => "#839496",
25
+ :blue => "#93a1a1",
26
+ :cyan => "#eee8d5",
27
+ :green => "#fdf6e3"
28
+ }
9
29
  end
10
30
 
11
- def failure
12
- self.colorize(:red).on_white
31
+ def colours
32
+ {
33
+ :informational => { :colour => :yellow },
34
+ :failure => { :colour => :red },
35
+ :success => { :colour => :green },
36
+ :title => { :colour => :green },
37
+ :success => { :colour => :green },
38
+ :command => { :colour => :cyan, :highlight => true },
39
+ :danger => { :colour => :red },
40
+ :warning => { :colour => :orange },
41
+ :friendly => { :colour => :green },
42
+ :menu_item_green => { :colour => :green },
43
+ :menu_title_orange => { :colour => :orange, :highlight => true },
44
+ :menu_item_orange => { :colour => :orange },
45
+ :menu_title_green => { :colour => :green, :highlight => true },
46
+ :menu_item_white => { :colour => :white },
47
+ :menu_item_yellow => { :colour => :yellow },
48
+ :menu_item_cyan => { :colour => :cyan },
49
+ :selections => { :colour => :cyan },
50
+ :menu_title_cyan => { :colour => :cyan, :highlight => true },
51
+ :headsup => { :colour => :orange, :highlight => true },
52
+ :menu_item_magenta => { :colour => :magenta },
53
+ :cyan => { :colour => :cyan }
54
+ }
13
55
  end
14
56
 
15
- def success
16
- self.friendly
57
+ def has_colour?(colour_key)
58
+ colours.has_key?(colour_key)
17
59
  end
18
60
 
19
- def danger
20
- self.colorize(:white).on_red
21
- end
22
-
23
- def friendly
24
- self.colorize(:black).on_green
25
- end
26
-
27
- def warning
28
- self.colorize(:orange).on_black
29
- end
61
+ def method_missing(method_sym, *arguments, &black)
62
+ super unless has_colour?(method_sym)
63
+ colour_data = colours[method_sym]
30
64
 
31
- def menu
32
- self.colorize(:yellow).on_black
33
- end
34
-
35
- def headsup
36
- self.colorize(:yellow).on_black
37
- end
65
+ colour = colour_codes[colour_data[:colour]]
38
66
 
39
- def output
40
- self
67
+ unless colour_data[:highlight]
68
+ return Rainbow(self).color(colour)
69
+ else
70
+ highlight_colour = highlight_colour_codes[colour_data[:colour]]
71
+ return Rainbow(self).color(highlight_colour).bg(colour)
72
+ end
41
73
  end
42
74
 
43
- def bg_gray
44
- "\033[47m#{self}\033[0m"
75
+ def swatch
76
+ colours.each { |colour_key, colour_attributes|
77
+ puts "#{colour_key} : #{send(colour_key)}"
78
+ }
45
79
  end
46
80
 
47
81
  end
data/lib/render_irb.rb CHANGED
@@ -2,36 +2,50 @@ class ::Bcome::RenderIrb
2
2
 
3
3
  def list_items(parent_collection, items)
4
4
  if !items || !items.any?
5
- print "\nNo resources collections found. Maybe you forgot to add any?".headsup
5
+ print "\n\sNo resources collections found. Maybe you forgot to add any?".headsup
6
6
  else
7
- print "\n #{parent_collection}\n\n".colorize(:green) # are available:\n\n".colorize(:green)
7
+ print "\n\s"
8
+ puts "#{parent_collection.to_s.menu_title_green}\n\n".menu_title_green
8
9
  items.each do |item|
9
- colour = item.highlight? ? :yellow : :green
10
- print "* #{item.do_describe}\n".colorize(colour)
10
+ puts "\t*/added".danger + "\n" if item.highlight?
11
+ print item.do_describe
11
12
  end
13
+ print "\n\s\sUse cd [node identifier], e.g. cd \"#{items.first.identifier}\" to work on a given node.\n\n"
12
14
  end
13
- print "\n"
14
15
  end
15
16
 
16
17
  def menu(menu_items, stack_level_instance)
17
- recipe_menu_items = ::Bcome::Orchestrator::Recipe.as_menu_items(stack_level_instance)
18
- menu_items += recipe_menu_items if recipe_menu_items.any?
19
-
20
- menu_str = "\n** Commands **\n\n"
21
- menu_str = "\n\The following commands are available: \n\n"
22
- menu_items.each do |item|
23
- command = item[:command]
24
- description = item[:description]
25
- usage = item[:usage]
26
-
27
- menu_str += "> #{command}\n"
28
- menu_str += "- #{description}\n"
29
- menu_str += "e.g. #{usage}\n" if usage
18
+ menu_str = "\n\s#{"Standard Menu".menu_title_green}\n\n"
19
+ menu_items.each_with_index do |item, index|
20
+ menu_str += construct_menu_item_string(item, index, :menu_item_green)
21
+ end
30
22
 
31
- menu_str += "\n"
23
+ recipe_menu_items = ::Bcome::Orchestrator::Recipe.as_menu_items(stack_level_instance)
24
+ if recipe_menu_items.any?
25
+ menu_str += "\n\s#{"Orchestration Menu".menu_title_orange}\n\n"
26
+ recipe_menu_items.each_with_index do |item, index|
27
+ menu_str += construct_menu_item_string(item, index, :menu_item_orange)
28
+ end
32
29
  end
30
+
33
31
  menu_str += "\n\n"
34
- print menu_str.menu
32
+ print menu_str
33
+ return
34
+ end
35
+
36
+ def construct_menu_item_string(item, index, colour)
37
+ command = item[:command]
38
+ description = item[:description]
39
+ usage = item[:usage]
40
+ menu_str = "#{tab}#{index+1}. #{description}".send(colour) + "\n"
41
+ menu_str += "#{tab}" + "Command: ".menu_item_cyan + "#{command}\n".menu_item_white
42
+ menu_str += "#{tab}" + "Usage: ".menu_item_cyan + "#{usage}\n".menu_item_white if usage
43
+ menu_str += "\n"
44
+ return menu_str
45
+ end
46
+
47
+ def tab
48
+ "\s\s\s"
35
49
  end
36
50
 
37
51
  end
data/lib/ssh.rb CHANGED
@@ -14,7 +14,7 @@ class ::Bcome::Ssh
14
14
  proxy = command.proxy
15
15
 
16
16
  ::Net::SSH.start(instance.ip_address, ssh_user, :proxy => proxy, :keys => ssh_keys, :paranoid => false) do |ssh|
17
- puts "(#{instance.identifier})$ #{command.command}".command
17
+ puts "(#{instance.identifier})$".cyan + "\s#{command.command}"
18
18
  ssh_exec!(ssh, command)
19
19
  puts command.output
20
20
  print command.pretty_result
data/lib/stack/base.rb CHANGED
@@ -27,6 +27,7 @@ module ::Bcome::Stack
27
27
  puts "Executing Command Recipe #{recipe.recipe_identifier}".informational
28
28
  puts "Description: #{recipe.description}".command
29
29
  recipe.execute!(machines)
30
+ return
30
31
  else
31
32
  super
32
33
  end
@@ -70,9 +71,10 @@ module ::Bcome::Stack
70
71
  resource = resource_for_identifier(identifier)
71
72
 
72
73
  unless resource
73
- puts "No matching #{collection_key} for identifier '#{identifier}'. #{available_resources_options_string}".failure
74
+ puts "\nNo matching #{collection_key} for identifier '#{identifier}'.".failure + "\n\n#{available_resources_options_string}" + "\n\n"
74
75
  else
75
- puts "Working on #{identifier} from #{resource.reference_key}".informational
76
+ puts "\nFrom #{resource.reference_key}, working on '#{identifier}'.".informational + "\n\n"
77
+ puts "Hit 'menu' or 'ls' to see what you can do here.\n\n"
76
78
  become(resource)
77
79
  end
78
80
  end
@@ -87,7 +89,7 @@ module ::Bcome::Stack
87
89
  [
88
90
  { :command => "list / ls", :description => "List all available resources at the current context." },
89
91
  { :command => "describe", :description => "Describe the resource object at the current context." },
90
- { :command => "cd / workon / w", :description => "Select a resource object, and switch to its context.", :usage => "cd 'identifier'" },
92
+ { :command => "cd [Node Name]", :description => "Select a resource object, and switch to its context.", :usage => "cd 'YourServerName'" },
91
93
  { :command => "exit", :description => "Return to the previous context" },
92
94
  { :command => "exit!", :description => "Close all contexts, and exit Become."},
93
95
  { :command => "local", :description => "Execute a shell command on your local machine.", :usage => 'local "command"'},
@@ -101,14 +103,14 @@ module ::Bcome::Stack
101
103
  end
102
104
 
103
105
  def available_resources_options_string
104
- "Please select from one of '#{all_items.join(', ')}'"
106
+ "Please select from one of: #{all_items.join(', ')}'"
105
107
  end
106
108
 
107
109
  def describe
108
110
  if self.respond_to?(:do_describe)
109
- message = "\nCollection Key: #{reference_key}\n\nResource: #{self.do_describe}".colorize(:green)
111
+ message = "\n\tCollection Key:".menu_item_cyan + "\s#{reference_key}\n\n#{self.do_describe}"
110
112
  else
111
- message = "\nNothing to describe. Use 'list' to see namespace options".headsup unless self.respond_to?(:do_describe)
113
+ message = "\nNothing to describe. Use 'ls' or 'list' to see namespace options".headsup unless self.respond_to?(:do_describe)
112
114
  end
113
115
  puts message
114
116
  end
@@ -60,9 +60,10 @@ module ::Bcome::Stack
60
60
  end
61
61
 
62
62
  def do_describe
63
- desc = "#{node.identifier}"
64
- desc += "\t[ Net lookup: #{node.network_lookup_type}"
65
- desc += "\t * SSH Mode: #{node.ssh_mode_type} ]"
63
+ desc = "\tNode Id:".menu_item_cyan + "\s#{node.identifier}".menu_item_green + "\n"
64
+ desc += "\tNet Lookup:".menu_item_cyan + "\s#{node.network_lookup_type}".menu_item_white + "\n"
65
+ desc += "\tSSH Mode:".menu_item_cyan + "\s#{node.ssh_mode_type}".menu_item_white
66
+ return desc + "\n\n"
66
67
  end
67
68
 
68
69
  def collection_klass
@@ -99,11 +99,12 @@ module ::Bcome::Stack
99
99
  end
100
100
 
101
101
  def do_describe
102
- description = "#{node.identifier}#{ is_sudo? ? " MODE: sudo " : "" }"
103
- description += "\n\t* Internal IP #{@meta_data[:external_network_interface_address]}"
104
- description += "\n\t* External IP #{node.public_ip_address}" if node.public_ip_address
105
- description += "\n\t* #{node.role}" if node.role
106
- description += "\n"
102
+ description = "\tNode Id:".menu_item_cyan + "\s\s#{node.identifier.menu_item_yellow}"
103
+ description += "\n\tsudo: ".menu_item_cyan + (is_sudo? ? "on".danger : "off" )
104
+ description += "\n\t" + "Internal IP: ".menu_item_cyan + "#{@meta_data[:external_network_interface_address]}".menu_item_white
105
+ description += "\n\t" + "External IP: ".menu_item_cyan + "#{node.public_ip_address}".menu_item_white if node.public_ip_address
106
+ description += "\n\t" + "Role: ".menu_item_cyan + "#{node.role}".menu_item_white if node.role
107
+ description += "\n\n"
107
108
  return description
108
109
  end
109
110
 
@@ -111,6 +112,5 @@ module ::Bcome::Stack
111
112
  ::Bcome::Node::Instance
112
113
  end
113
114
 
114
-
115
115
  end
116
116
  end
@@ -27,7 +27,10 @@ module ::Bcome::Stack
27
27
  end
28
28
 
29
29
  def do_describe
30
- "#{identifier}\n - #{@meta_data[:description]}\n"
30
+ description = "\n"
31
+ description += "\t#{identifier.menu_item_green}\n"
32
+ description += "\t" + "Description: ".menu_item_cyan + @meta_data[:description].menu_item_white + "\n"
33
+ return description
31
34
  end
32
35
 
33
36
  def config_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Roderick (Webzakimbo)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: colorize
28
+ name: rainbow
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.7
33
+ version: 2.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.7
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-scp
43
43
  requirement: !ruby/object:Gem::Requirement