Sha256: d3d5b329bd1e64ab37720eddf5a7d56440121f684e6489ddb7a59f0df679e2dc

Contents?: true

Size: 1.02 KB

Versions: 32

Compression:

Stored size: 1.02 KB

Contents

module ArchitectureJS
  class Notification

    win_platform = !![
      /bccwin/i,
      /djgpp/i,
      /mingw/i,
      /mswin/i,
      /wince/i,
    ].find{ |r| RUBY_PLATFORM =~ r }
    
    @@indicators = {
      none: "",
      log: "\e[32m>>>\e[0m ",
      event: "\e[33m<<<\e[0m ",
      added: "\e[32m+++\e[0m ",
      error: "\e[0;31m!!!\e[0m "
    }

    @@indicators.merge!({
      none: "",
      log: ">>>",
      event: "<<<",
      added: "+++",
      error: "!!!"
    }) if win_platform

    def self.notify(type, message)
      raise "There is no #{type} indicator" unless @@indicators[type]
      "#{@@indicators[type]}#{message}"
    end
    
    def self.notice(message)
      self.notify :none, message 
    end
    
    def self.log(message)
      self.notify :log, message
    end
    
    def self.event(message)
      self.notify :event, message
    end
    
    def self.added(message)
      self.notify :added, message
    end
    
    def self.error(message)
      self.notify :error, message
    end
    
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
architecture-js-0.1.11 lib/architecture-js/notification.rb
architecture-js-0.1.10 lib/architecture-js/notification.rb
architecture-js-0.1.9 lib/architecture-js/notification.rb
architecture-js-0.1.8 lib/architecture-js/notification.rb
architecture-js-0.1.7 lib/architecture-js/notification.rb
architecture-js-0.1.6 lib/architecture-js/notification.rb
architecture-js-0.1.5 lib/architecture-js/notification.rb
architecture-js-0.1.4 lib/architecture-js/notification.rb
architecture-js-0.1.3 lib/architecture-js/notification.rb
architecture-js-0.1.2 lib/architecture-js/notification.rb
architecture-js-0.1.1 lib/architecture-js/notification.rb
architecture-js-0.1.0 lib/architecture-js/notification.rb