Class: KnifeInfo::Info
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- KnifeInfo::Info
- Defined in:
- lib/chef/knife/info.rb
Instance Attribute Summary collapse
-
#config_file_location ⇒ Object
readonly
Returns the value of attribute config_file_location.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #long_print ⇒ Object
- #medium_print ⇒ Object
- #read_config_data ⇒ Object
- #run ⇒ Object
- #tiny_print ⇒ Object
- #user_string ⇒ Object
Instance Attribute Details
#config_file_location ⇒ Object (readonly)
Returns the value of attribute config_file_location.
70 71 72 |
# File 'lib/chef/knife/info.rb', line 70 def config_file_location @config_file_location end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
70 71 72 |
# File 'lib/chef/knife/info.rb', line 70 def host @host end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
70 71 72 |
# File 'lib/chef/knife/info.rb', line 70 def organization @organization end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
70 71 72 |
# File 'lib/chef/knife/info.rb', line 70 def user @user end |
Instance Method Details
#long_print ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/chef/knife/info.rb', line 61 def long_print <<-VERBOSE.gsub(/^\s+/, '') Host: #{@host} Username: #{username} Organization: #{@organization} Config File: #{@config_file} VERBOSE end |
#medium_print ⇒ Object
57 58 59 |
# File 'lib/chef/knife/info.rb', line 57 def medium_print "#{user_string}#{@host}/#{organization}" end |
#read_config_data ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/chef/knife/info.rb', line 38 def read_config_data @config_file = Chef::Knife.locate_config_file uri = URI(server_url) @host = uri.host %r(.*/organizations/(?<org>.*)$) =~ uri.path @organization = org || '' end |
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/chef/knife/info.rb', line 26 def run read_config_data unless @config_file.nil? case when config[:long] then ui.msg(long_print) when config[:medium] then ui.msg(medium_print) else ui.msg(tiny_print) end end end |
#tiny_print ⇒ Object
52 53 54 55 |
# File 'lib/chef/knife/info.rb', line 52 def tiny_print %r(^(?<host>[a-zA-Z0-9-]+)\..*$) =~ @host "#{user_string}#{host}/#{@organization}" end |
#user_string ⇒ Object
48 49 50 |
# File 'lib/chef/knife/info.rb', line 48 def user_string (username != ENV['USER']) ? "#{username}@" : '' end |