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
- #run ⇒ Object
- #tiny_print ⇒ Object
- #user_string ⇒ Object
Instance Attribute Details
#config_file_location ⇒ Object (readonly)
Returns the value of attribute config_file_location.
66 67 68 |
# File 'lib/chef/knife/info.rb', line 66 def config_file_location @config_file_location end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
66 67 68 |
# File 'lib/chef/knife/info.rb', line 66 def host @host end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
66 67 68 |
# File 'lib/chef/knife/info.rb', line 66 def organization @organization end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
66 67 68 |
# File 'lib/chef/knife/info.rb', line 66 def user @user end |
Instance Method Details
#long_print ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/chef/knife/info.rb', line 57 def long_print <<-VERBOSE.gsub(/^\s+/, '') Host: #{@host} Username: #{username} Organization: #{@organization} Config File: #{@config_file_location} VERBOSE end |
#medium_print ⇒ Object
53 54 55 |
# File 'lib/chef/knife/info.rb', line 53 def medium_print "#{user_string}#{@host}/#{organization}" end |
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chef/knife/info.rb', line 26 def run @config_file_location = Chef::Knife.locate_config_file uri = URI(server_url) @host = uri.host %r(.*/(?<org>.*)$) =~ uri.path @organization = org || '' if config[:long] ui.msg(long_print) elsif config[:medium] ui.msg(medium_print) else config[:tiny] ui.msg(tiny_print) end end |
#tiny_print ⇒ Object
48 49 50 51 |
# File 'lib/chef/knife/info.rb', line 48 def tiny_print %r(^(?<host>[a-zA-Z0-9-]+)\..*$) =~ @host "#{user_string}#{host}/#{@organization}" end |
#user_string ⇒ Object
44 45 46 |
# File 'lib/chef/knife/info.rb', line 44 def user_string (username != ENV['USER']) ? "#{username}@" : '' end |