Sha256: 24793e4dcf0ac2f5a1448eaaded923824c500efe34d2af91e1e7e841186945a3

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 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 ",
      prompt: ">>> "
    }

    @@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

    def self.prompt
      self.notify :prompt, ''
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
architecture-js-0.6.3 lib/architecture-js/notification.rb
architecture-js-0.6.2 lib/architecture-js/notification.rb
architecture-js-0.6.1 lib/architecture-js/notification.rb
architecture-js-0.6.0 lib/architecture-js/notification.rb
architecture-js-0.5.8 lib/architecture-js/notification.rb
architecture-js-0.5.7 lib/architecture-js/notification.rb
architecture-js-0.5.6 lib/architecture-js/notification.rb
architecture-js-0.5.5 lib/architecture-js/notification.rb
architecture-js-0.5.4 lib/architecture-js/notification.rb
architecture-js-0.5.3 lib/architecture-js/notification.rb
architecture-js-0.5.2 lib/architecture-js/notification.rb
architecture-js-0.5.1 lib/architecture-js/notification.rb
architecture-js-0.5.0 lib/architecture-js/notification.rb