class Hookit::Resource::Warning
Public Class Methods
new(name)
click to toggle source
# File lib/hookit/resource/warning.rb, line 12 def initialize(name) source(name) unless source or content stream :stdout unless stream @default_header = "\u25BC\u25BC\u25BC\u25BC :: WARNING :: \u25BC\u25BC\u25BC\u25BC" @block_width = @default_header.length end
Public Instance Methods
run(action)
click to toggle source
# File lib/hookit/resource/warning.rb, line 20 def run(action) case action when :warn warn! end end
Protected Instance Methods
content!()
click to toggle source
# File lib/hookit/resource/warning.rb, line 41 def content! output_string ||= content or ::File.open("#{gem_root}/messages/#{source}").read return output_string end
gem()
click to toggle source
# File lib/hookit/resource/warning.rb, line 29 def gem dict[:template_gem] end
gem_root()
click to toggle source
# File lib/hookit/resource/warning.rb, line 37 def gem_root gem_spec.gem_dir end
gem_spec()
click to toggle source
# File lib/hookit/resource/warning.rb, line 33 def gem_spec Gem::Specification.find_by_name(gem) end
header!()
click to toggle source
# File lib/hookit/resource/warning.rb, line 46 def header! header = @default_header padding = "\u25BC" longest_line = content!.split.sort_by {|x| x.length}.last if longest_line.length > header.length difference = longest_line.length - header.length padding *= (difference.to_f / 2).ceil header = padding + header + padding end @block_width = header.length puts header end
warn!()
click to toggle source
# File lib/hookit/resource/warning.rb, line 71 def warn! header! case stream when :stdout puts content! when :stderr $stderr.puts content! end footer! end