Module: Docks::Messenger
- Defined in:
- lib/docks/messenger.rb
Constant Summary collapse
- @@quiet =
false
- @@header =
nil
Class Method Summary collapse
- .colorize(color, str) ⇒ Object
- .created(*files) ⇒ Object
- .created_files(*files) ⇒ Object
- .error(message) ⇒ Object
- .file(file, action = :updated) ⇒ Object
- .file_header(header) ⇒ Object
- .green(str) ⇒ Object
- .puts(str) ⇒ Object
- .quiet ⇒ Object
- .red(str) ⇒ Object
- .show ⇒ Object
- .succeed(message) ⇒ Object
- .warn(message) ⇒ Object
- .yellow(str) ⇒ Object
Class Method Details
.colorize(color, str) ⇒ Object
60 61 62 |
# File 'lib/docks/messenger.rb', line 60 def self.colorize(color, str) "\e[#{color}m#{str}\e[0m" end |
.created(*files) ⇒ Object
21 22 23 24 |
# File 'lib/docks/messenger.rb', line 21 def self.created(*files) puts 'Created the following files and directories:' created_files files end |
.created_files(*files) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/docks/messenger.rb', line 26 def self.created_files(*files) files.flatten.each do |file| puts " #{file}" if File.directory? file created_files Dir["#{file}/*"] end end end |
.error(message) ⇒ Object
18 |
# File 'lib/docks/messenger.rb', line 18 def self.error(); puts red("Error: #{}") end |
.file(file, action = :updated) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/docks/messenger.rb', line 35 def self.file(file, action = :updated) unless @@header.nil? puts "\n#{@@header}" puts "-" * @@header.length @@header = nil end file = file.to_s.sub((Docks.config.root || Pathname.pwd).to_s, "").sub(/^\//, "") case action when :updated then puts "Updated #{file}" when :created then puts green("Created #{file}") when :deleted then puts red("Deleted #{file}") end end |
.file_header(header) ⇒ Object
51 52 53 |
# File 'lib/docks/messenger.rb', line 51 def self.file_header(header) @@header = header end |
.green(str) ⇒ Object
66 |
# File 'lib/docks/messenger.rb', line 66 def self.green(str); colorize(32, str) end |
.puts(str) ⇒ Object
16 |
# File 'lib/docks/messenger.rb', line 16 def self.puts(); puts end |
.quiet ⇒ Object
6 7 8 9 |
# File 'lib/docks/messenger.rb', line 6 def self.quiet @@quiet = true self end |
.red(str) ⇒ Object
65 |
# File 'lib/docks/messenger.rb', line 65 def self.red(str); colorize(31, str) end |
.show ⇒ Object
11 12 13 14 |
# File 'lib/docks/messenger.rb', line 11 def self.show @@quiet = false self end |
.succeed(message) ⇒ Object
19 |
# File 'lib/docks/messenger.rb', line 19 def self.succeed(); puts green() end |
.warn(message) ⇒ Object
17 |
# File 'lib/docks/messenger.rb', line 17 def self.warn(); puts yellow("Warning: #{}") end |
.yellow(str) ⇒ Object
64 |
# File 'lib/docks/messenger.rb', line 64 def self.yellow(str); colorize(33, str) end |