Module: Pow

Defined in:
lib/pow.rb,
lib/pow/profile.rb

Defined Under Namespace

Classes: Profile, Puts

Constant Summary collapse

CODES =
{
:clear           => 0,
:reset           => 0, #clear
:bold            => 1,
:dark            => 2,
:italic          => 3,
:underline       => 4,
:underscore      => 4,
:blink           => 5,
:rapid_blink     => 6,
:negative        => 7,
:concealed       => 8,
:strikethrough   => 9,
:black           => 30,
:red             => 31,
:green           => 32,
:yellow          => 33,
:blue            => 34,
:magenta         => 35,
:purple          => 35,
:cyan            => 36,
:white           => 37,
:on_black        => 40,
:on_red          => 41,
:on_green        => 42,
:on_yellow       => 43,
:on_blue         => 44,
:on_magenta      => 45, 
:on_purple       => 45, 
:on_cyan         => 46,
:on_white        => 47,
:brown           => [:yellow, :dark],
:navy            => [:blue, :dark],
:dark_red        => [:red, :dark],
:dark_blue       => [:blue, :dark],
:dark_cyan       => [:cyan, :dark],
:dark_green      => [:green, :dark],
:dark_magenta    => [:magenta, :dark],
:dark_purple     => [:purple, :dark],
:gray            => [:white, :dark],
:grey            => [:white, :dark]
}.freeze

Class Method Summary collapse

Class Method Details

.defaultsObject



34
35
36
# File 'lib/pow.rb', line 34

def defaults
  @@defaults
end

.defaults=(val) ⇒ Object



38
39
40
# File 'lib/pow.rb', line 38

def defaults=(val)
  @@defaults = val || {}
end

.disableObject



22
23
24
# File 'lib/pow.rb', line 22

def disable
  @@enabled = false
end

.disabled?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/pow.rb', line 30

def disabled?
  @@enabled == false
end

.enableObject



18
19
20
# File 'lib/pow.rb', line 18

def enable
  @@enabled = true
end

.enabled?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/pow.rb', line 26

def enabled?
  @@enabled == true
end

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/pow.rb', line 4

def included(base)
  @@defaults = {}
  @@enabled  = true
  @@profile  = nil
  Pow.load_profile
  base.send(:define_method, :puts){ |*args| Puts.new(*args) }
  base.send(:define_method, :puts!){ |*args| opts=(args.detect{|a| a.is_a?(Hash)} || {}).merge(:misc => {:bold => true}); args.reject!{|a| a.is_a?(Hash)}; args = [args.push(opts)].flatten; Puts.new(*args) } # Now that's just self-explanatory ..
  base.send(:define_method, :puts_){ |*args| opts=(args.detect{|a| a.is_a?(Hash)} || {}).merge(:misc => {:underline => true}); args.reject!{|a| a.is_a?(Hash)}; args = [args.push(opts)].flatten; Puts.new(*args) } # Now that's just self-explanatory ..

  base.send(:alias_method, :p, :puts)
  base.send(:alias_method, :p!, :puts!)
  base.send(:alias_method, :p_, :puts_)
end

.load_profile(profile_path = :default) ⇒ Object



46
47
48
49
# File 'lib/pow.rb', line 46

def load_profile( profile_path=:default )
  @@profile    = Pow::Profile.new( profile_path )
  Pow.defaults = @@profile.read[:settings] rescue {}
end

.profileObject



42
43
44
# File 'lib/pow.rb', line 42

def profile
  @@profile
end

.unload_profileObject



51
52
53
# File 'lib/pow.rb', line 51

def unload_profile
  Pow.defaults = {}
end