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 +4 -4
- data/bin/boot.rb +1 -1
- data/bin/boot_no_shell.rb +4 -0
- data/lib/bcome/version.rb +1 -1
- data/lib/become_object.rb +6 -0
- data/lib/boot.rb +4 -0
- data/lib/context_functions.rb +54 -0
- data/lib/stack/base.rb +13 -1
- data/lib/stack/estate.rb +0 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bc3b83a397c5195c615dc733ac8a73ddf83b5b9
|
4
|
+
data.tar.gz: bffd288b51aac1466ede8d57fb753022b5f6ef81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3d3259982bb41800c7b459b67d506d9c729f612300d2611b6c199fbc4175a67231750c2ea26688c500afcedae33102ec76a8bbf2ce44cc23eb17cb0afbbc508
|
7
|
+
data.tar.gz: cae0dc41508b1c793fb75fd335acf51dd69716376b7c27aa671efb248d1571f2c4c379e4ba904658f0454747966364fe70a3fd957a2b94ae917c2b243a9470ec
|
data/bin/boot.rb
CHANGED
@@ -39,7 +39,7 @@ RENDER = ::Bcome::RenderIrb.new
|
|
39
39
|
## MANAGE QUICK CONTEXTS #
|
40
40
|
###########################
|
41
41
|
|
42
|
-
quick_context =
|
42
|
+
quick_context = ENV['bcome_context'] ? ENV['bcome_context'] : ARGV[0]
|
43
43
|
|
44
44
|
if quick_context
|
45
45
|
quick_context =~ /(.+):(.+)/
|
data/lib/bcome/version.rb
CHANGED
data/lib/become_object.rb
CHANGED
@@ -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
|
data/lib/boot.rb
CHANGED
@@ -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
|
data/lib/stack/base.rb
CHANGED
@@ -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
|
|
data/lib/stack/estate.rb
CHANGED
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
|
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
|