bcome 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65790bceb47d5870e33e4879362c00a154a06326
4
- data.tar.gz: 2f940a8ee313e71752f66ed852048b3d48c6ad46
3
+ metadata.gz: 0bc3b83a397c5195c615dc733ac8a73ddf83b5b9
4
+ data.tar.gz: bffd288b51aac1466ede8d57fb753022b5f6ef81
5
5
  SHA512:
6
- metadata.gz: eb5e1c75221c5145890bae1c75112e82d8ff6ccdfa2b078bf7a7eb15f01230aeafdb9f8c4fe33458b36fb0f25669a49e2e4a807c84a8db476ea0b0b6783f36ba
7
- data.tar.gz: 2c96b8e049ad3b1c18562670a9ed5fb419ce362572a442cc8ec96b4be9ffcaeded6cc9ed0e630afa22dd9e0c4beac041b05d72db8b5d3e44162d2b81f15b66a6
6
+ metadata.gz: e3d3259982bb41800c7b459b67d506d9c729f612300d2611b6c199fbc4175a67231750c2ea26688c500afcedae33102ec76a8bbf2ce44cc23eb17cb0afbbc508
7
+ data.tar.gz: cae0dc41508b1c793fb75fd335acf51dd69716376b7c27aa671efb248d1571f2c4c379e4ba904658f0454747966364fe70a3fd957a2b94ae917c2b243a9470ec
@@ -39,7 +39,7 @@ RENDER = ::Bcome::RenderIrb.new
39
39
  ## MANAGE QUICK CONTEXTS #
40
40
  ###########################
41
41
 
42
- quick_context = @bcome_context ? @bcome_context : ARGV[0]
42
+ quick_context = ENV['bcome_context'] ? ENV['bcome_context'] : ARGV[0]
43
43
 
44
44
  if quick_context
45
45
  quick_context =~ /(.+):(.+)/
@@ -0,0 +1,4 @@
1
+
2
+ raise "No context for bcome provided" unless ENV['bcome_context']
3
+ @no_shell = true
4
+ load Bcome::Boot.boot_path
@@ -1,3 +1,3 @@
1
1
  module Bcome
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -20,6 +20,12 @@ module ::Bcome::BecomeObject
20
20
  "#{previous_workspace_object.send(:namespace)}/#{identifier}"
21
21
  end
22
22
 
23
+ def context_breadcrumb
24
+ breadcrumb = namespace.gsub("/", ":")
25
+ breadcrumb.slice!(0)
26
+ return breadcrumb
27
+ end
28
+
23
29
  def previous_workspace_object=(object)
24
30
  @previous_workspace_object = object
25
31
  end
@@ -1,6 +1,10 @@
1
1
  module Bcome
2
2
  class Boot
3
3
 
4
+ def self.no_shell_boot_path
5
+ return "#{File.dirname(__FILE__)}/../bin/boot_no_shell.rb"
6
+ end
7
+
4
8
  def self.boot_path
5
9
  return "#{File.dirname(__FILE__)}/../bin/boot.rb"
6
10
  end
@@ -0,0 +1,54 @@
1
+ module Bcome::ContextFunctions
2
+
3
+ CONFIGS_PATH = "bcome/config"
4
+
5
+ def execute_command_for_context(context_command)
6
+ full_command = context_command[:executed_command] + " bcome_context=\"#{context_breadcrumb}\""
7
+ run_local(full_command)
8
+ end
9
+
10
+ def command_for_context(command)
11
+ return false unless context_cmd_functions || !context_cmd_functions.any?
12
+ ccfs = context_cmd_functions.select{|ccf| ccf[:command].to_s == command.to_s }
13
+ raise "Multiple context commands found at context level #{context_breadcrumb} for command key #{command}" if ccfs.size > 1
14
+ return ccfs.first
15
+ end
16
+
17
+ def context_commands
18
+ if context_cmd_functions && context_cmd_functions.any?
19
+ context_cmd_functions.each do |context_function|
20
+ puts
21
+ puts context_function[:description].informational
22
+ puts "Executed command: #{context_function[:executed_command]} bcome_context=\"#{context_breadcrumb}\""
23
+ puts "Usage: > #{context_function[:command].command}"
24
+ puts
25
+ end
26
+ else
27
+ puts "You don't have any context specific functions defined yet."
28
+ end
29
+ return
30
+ end
31
+
32
+ def context_cmd_functions
33
+ return [] unless has_context_functions_config?
34
+ @context_cmd_functions ||= load_context_cmd_functions
35
+ end
36
+
37
+ def has_context_cmd_functions?
38
+ !context_cmd_functions.nil?
39
+ end
40
+
41
+ def load_context_cmd_functions
42
+ configs = YAML.load_file(context_cmd_config_path)
43
+ return configs[context_breadcrumb]
44
+ end
45
+
46
+ def context_cmd_config_path
47
+ "#{CONFIGS_PATH}/context_functions.yml"
48
+ end
49
+
50
+ def has_context_functions_config?
51
+ File.exist?(context_cmd_config_path)
52
+ end
53
+
54
+ end
@@ -1,6 +1,9 @@
1
1
  module ::Bcome::Stack
2
2
  class Base
3
3
 
4
+ include ::Bcome::ContextFunctions
5
+ include ::Bcome::CommandHelper
6
+
4
7
  def machines
5
8
  node.machines
6
9
  end
@@ -13,6 +16,14 @@ module ::Bcome::Stack
13
16
  @node ||= construct_node
14
17
  end
15
18
 
19
+ def method_missing(method_sym, *arguments, &block)
20
+ if command_for_context = command_for_context(method_sym)
21
+ execute_command_for_context(command_for_context)
22
+ else
23
+ super
24
+ end
25
+ end
26
+
16
27
  def construct_node
17
28
  node_attributes = meta_data
18
29
 
@@ -72,7 +83,8 @@ module ::Bcome::Stack
72
83
  { :command => "exit", :description => "Return to the previous context" },
73
84
  { :command => "exit!", :description => "Close all contexts, and exit Become."},
74
85
  { :command => "local", :description => "Execute a shell command on your local machine.", :usage => 'local "command"'},
75
- { :command => "machines", :description => "Return all servers below the current level to the console. These objects can be manipulated directly" }
86
+ { :command => "machines", :description => "Return all servers below the current level to the console. These objects can be manipulated directly" },
87
+ { :command => "context_commands", :description => "List all shell commands for invoking non-shell processes, in the current bcome context" },
76
88
  ]
77
89
  end
78
90
 
@@ -2,7 +2,6 @@ module ::Bcome::Stack
2
2
  class Estate < ::Bcome::Stack::Base
3
3
 
4
4
  include ::Bcome::BecomeObject
5
- include ::Bcome::CommandHelper
6
5
 
7
6
  def config_path
8
7
  "#{CONFIGS_PATH}/platform.yml"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Roderick (Webzakimbo)
@@ -115,6 +115,7 @@ files:
115
115
  - bin/bcome
116
116
  - bin/bcome-setup
117
117
  - bin/boot.rb
118
+ - bin/boot_no_shell.rb
118
119
  - documentation/configuration.md
119
120
  - documentation/examples/functions.yml-example
120
121
  - documentation/examples/network.yml-example
@@ -128,6 +129,7 @@ files:
128
129
  - lib/become_object.rb
129
130
  - lib/boot.rb
130
131
  - lib/command.rb
132
+ - lib/context_functions.rb
131
133
  - lib/filters/base.rb
132
134
  - lib/filters/ec2_filter.rb
133
135
  - lib/functions.rb