Class: Object
Instance Method Summary collapse
- #available_resources_options_string ⇒ Object
- #become(object) ⇒ Object
- #become_identifier ⇒ Object
- #describe ⇒ Object
- #highlight? ⇒ Boolean
- #list ⇒ Object (also: #ls)
- #menu ⇒ Object
- #menu_items ⇒ Object
- #set_irb_prompt(conf) ⇒ Object
- #workon(identifier) ⇒ Object (also: #w)
Methods included from Bcome::CommandHelper
Instance Method Details
#available_resources_options_string ⇒ Object
49 50 51 |
# File 'lib/object.rb', line 49 def "Please select from one of '#{all_items.join(', ')}'" end |
#become(object) ⇒ Object
14 15 16 |
# File 'lib/object.rb', line 14 def become(object) BECOME.set(object, self) end |
#become_identifier ⇒ Object
10 11 12 |
# File 'lib/object.rb', line 10 def become_identifier ::START_PROMPT end |
#describe ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/object.rb', line 53 def describe if self.respond_to?(:do_describe) = "\nCollection Key: #{reference_key}\n\nResource: #{self.do_describe}".colorize(:green) else = "\nNothing to describe. Use 'list' to see namespace options".headsup unless self.respond_to?(:do_describe) end puts end |
#highlight? ⇒ Boolean
45 46 47 |
# File 'lib/object.rb', line 45 def highlight? false ## override in stack objects that should be highlighted within a list, e.g. instance objects at the environment level that have been selected to workon on end |
#list ⇒ Object Also known as: ls
5 6 7 |
# File 'lib/object.rb', line 5 def list BOOT.send(:list) ### Our starting point in the hierarchy... maybe this is all ultimately configurable? end |
#menu ⇒ Object
41 42 43 |
# File 'lib/object.rb', line 41 def ::RENDER.() end |
#menu_items ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/object.rb', line 30 def [ { :command => "list / ls", :description => "List all available resources at the current context." }, { :command => "describe", :description => "Describe the resource object at the current context." }, { :command => "workon' / w", :description => "Select a resource object, and switch to its context.", :usage => "workon 'identifier'" }, { :command => "exit", :description => "Close the current context" }, { :command => "exit!", :description => "Close all contexts, and exit Become."}, { :command => "local", :description => "Execute a shell command on your local machine.", :usage => 'local "command"'} ] end |
#set_irb_prompt(conf) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/object.rb', line 62 def set_irb_prompt(conf) conf[:PROMPT][:CUSTOM] = { :PROMPT_N => "\e[1m:\e[m ", :PROMPT_I => "\e[1m#{BECOME.irb_prompt} >\e[m ", :PROMPT_C => "\e[1m#{BECOME.irb_prompt} >\e[m ", :RETURN => ::VERBOSE ? "%s \n" : "\n" } conf[:PROMPT_MODE] = :CUSTOM end |
#workon(identifier) ⇒ Object Also known as: w
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/object.rb', line 18 def workon(identifier) resource = resource_for_identifier(identifier) unless resource puts "No matching #{collection_key} for identifier '#{identifier}'. #{}".failure else puts "\\ \nFrom #{resource.reference_key}, working on #{identifier}\n".command become(resource) end end |