Class: DreamOps::HumanFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- DreamOps::HumanFormatter
- Defined in:
- lib/dream-ops/formatters/human.rb
Instance Method Summary collapse
-
#deprecation(message) ⇒ Object
Output a deprecation warning.
-
#error(message) ⇒ Object
Output an error message using ui.
- #fetch(dependency) ⇒ Object
-
#info(cookbook) ⇒ Object
Output the important information about a cookbook using ui.
-
#install(source, cookbook) ⇒ Object
Output a Cookbook installation message using ui.
-
#list(dependencies) ⇒ Object
Output a list of cookbooks using ui.
-
#msg(message) ⇒ Object
Output a generic message using ui.
-
#outdated(hash) ⇒ Object
Output a list of outdated cookbooks and the most recent version using ui.
-
#package(destination) ⇒ Object
Output a Cookbook package message using ui.
-
#search(results) ⇒ Object
Ouput Cookbook search results using ui.
-
#show(cookbook) ⇒ Object
Output Cookbook path using ui.
-
#skipping(cookbook, conn) ⇒ Object
Output a Cookbook skip message using ui.
-
#uploaded(cookbook, conn) ⇒ Object
Output a Cookbook upload message using ui.
-
#use(dependency) ⇒ Object
Output a Cookbook use message using ui.
-
#vendor(cookbook, destination) ⇒ Object
Output Cookbook vendor info message using ui.
-
#version ⇒ Object
Output the version of DreamOps.
-
#warn(message) ⇒ Object
Output a warning message using ui.
Methods inherited from BaseFormatter
#cleanup_hook, formatter_method
Instance Method Details
#deprecation(message) ⇒ Object
Output a deprecation warning
159 160 161 |
# File 'lib/dream-ops/formatters/human.rb', line 159 def deprecation() DreamOps.ui.info "DEPRECATED: #{}" end |
#error(message) ⇒ Object
Output an error message using DreamOps.ui
145 146 147 |
# File 'lib/dream-ops/formatters/human.rb', line 145 def error() DreamOps.ui.error end |
#fetch(dependency) ⇒ Object
9 10 11 |
# File 'lib/dream-ops/formatters/human.rb', line 9 def fetch(dependency) DreamOps.ui.info "Fetching '#{dependency.name}' from #{dependency.location}" end |
#info(cookbook) ⇒ Object
Output the important information about a cookbook using DreamOps.ui.
93 94 95 |
# File 'lib/dream-ops/formatters/human.rb', line 93 def info(cookbook) DreamOps.ui.info(cookbook.pretty_print) end |
#install(source, cookbook) ⇒ Object
Output a Cookbook installation message using DreamOps.ui
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dream-ops/formatters/human.rb', line 19 def install(source, cookbook) = "Installing #{cookbook.name} (#{cookbook.version})" if source.type == :chef_repo << " from #{cookbook.location_path}" elsif !source.default? << " from #{source}" << " ([#{cookbook.location_type}] #{cookbook.location_path})" end DreamOps.ui.info() end |
#list(dependencies) ⇒ Object
Output a list of cookbooks using DreamOps.ui
100 101 102 103 104 105 106 107 |
# File 'lib/dream-ops/formatters/human.rb', line 100 def list(dependencies) DreamOps.ui.info "Cookbooks installed by your Berksfile:" dependencies.each do |dependency| out = " * #{dependency}" out << " from #{dependency.location}" if dependency.location DreamOps.ui.info(out) end end |
#msg(message) ⇒ Object
Output a generic message using DreamOps.ui
138 139 140 |
# File 'lib/dream-ops/formatters/human.rb', line 138 def msg() DreamOps.ui.info end |
#outdated(hash) ⇒ Object
Output a list of outdated cookbooks and the most recent version using DreamOps.ui
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dream-ops/formatters/human.rb', line 63 def outdated(hash) if hash.empty? DreamOps.ui.info("All cookbooks up to date!") else DreamOps.ui.info("The following cookbooks have newer versions:") hash.each do |name, info| info["remote"].each do |remote_source, remote_version| out = " * #{name} (#{info['local']} => #{remote_version})" unless remote_source.default? out << " [#{remote_source.uri}]" end DreamOps.ui.info(out) end end end end |
#package(destination) ⇒ Object
Output a Cookbook package message using DreamOps.ui
86 87 88 |
# File 'lib/dream-ops/formatters/human.rb', line 86 def package(destination) DreamOps.ui.info "Cookbook(s) packaged to #{destination}" end |
#search(results) ⇒ Object
Ouput Cookbook search results using DreamOps.ui
112 113 114 115 116 |
# File 'lib/dream-ops/formatters/human.rb', line 112 def search(results) results.sort_by(&:name).each do |remote_cookbook| DreamOps.ui.info "#{remote_cookbook.name} (#{remote_cookbook.version})" end end |
#show(cookbook) ⇒ Object
Output Cookbook path using DreamOps.ui
121 122 123 124 |
# File 'lib/dream-ops/formatters/human.rb', line 121 def show(cookbook) path = File.(cookbook.path) DreamOps.ui.info(path) end |
#skipping(cookbook, conn) ⇒ Object
Output a Cookbook skip message using DreamOps.ui
53 54 55 |
# File 'lib/dream-ops/formatters/human.rb', line 53 def skipping(cookbook, conn) DreamOps.ui.info "Skipping #{cookbook.cookbook_name} (#{cookbook.version}) (frozen)" end |
#uploaded(cookbook, conn) ⇒ Object
Output a Cookbook upload message using DreamOps.ui
45 46 47 |
# File 'lib/dream-ops/formatters/human.rb', line 45 def uploaded(cookbook, conn) DreamOps.ui.info "Uploaded #{cookbook.cookbook_name} (#{cookbook.version}) to: '#{conn.server_url}'" end |
#use(dependency) ⇒ Object
Output a Cookbook use message using DreamOps.ui
35 36 37 38 39 |
# File 'lib/dream-ops/formatters/human.rb', line 35 def use(dependency) = "Using #{dependency.name} (#{dependency.locked_version})" << " from #{dependency.location}" if dependency.location DreamOps.ui.info() end |
#vendor(cookbook, destination) ⇒ Object
Output Cookbook vendor info message using DreamOps.ui
130 131 132 133 |
# File 'lib/dream-ops/formatters/human.rb', line 130 def vendor(cookbook, destination) cookbook_destination = File.join(destination, cookbook.cookbook_name) DreamOps.ui.info "Vendoring #{cookbook.cookbook_name} (#{cookbook.version}) to #{cookbook_destination}" end |
#version ⇒ Object
Output the version of DreamOps
4 5 6 |
# File 'lib/dream-ops/formatters/human.rb', line 4 def version DreamOps.ui.info "Dream Ops v#{DreamOps::VERSION}" end |
#warn(message) ⇒ Object
Output a warning message using DreamOps.ui
152 153 154 |
# File 'lib/dream-ops/formatters/human.rb', line 152 def warn() DreamOps.ui.warn end |