colorer 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/colorer.rb +5 -12
  3. data/test/sgr.irt +3 -3
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/lib/colorer.rb CHANGED
@@ -55,20 +55,13 @@ module Colorer
55
55
  end
56
56
 
57
57
  def define_styles(styles, force=false)
58
+ styles = Colorer::BASIC_SGR.merge(styles) if styles.delete(:basic)
58
59
  styles.each_pair do |meth, style|
60
+ style = [style] unless style.is_a?(Array)
59
61
  String.class_eval do
60
- if meth == :basic && style
61
- Colorer::BASIC_SGR.each_pair do |m, sgr|
62
- raise AlreadyDefinedMethod.new(m, self) if !force && method_defined?(m)
63
- define_method(m) do
64
- Colorer.add_sgr(self, sgr)
65
- end
66
- end
67
- else
68
- raise AlreadyDefinedMethod.new(meth, self) if !force && method_defined?(meth)
69
- define_method(meth) do
70
- style.inject(self) { |str, sgr| Colorer.add_sgr(str, sgr) }
71
- end
62
+ raise AlreadyDefinedMethod.new(meth, self) if !force && method_defined?(meth)
63
+ define_method(meth) do
64
+ style.inject(self) { |str, sgr| Colorer.add_sgr(str, sgr) }
72
65
  end
73
66
  end
74
67
  end
data/test/sgr.irt CHANGED
@@ -9,9 +9,9 @@ puts _
9
9
  test_value_eql? "\e[0;1;7mMixed SGR parameters\e[0m"
10
10
 
11
11
  desc "Basic and custom definition"
12
- Colorer.define_styles({:basic => true, :goo => [7]}, 1)
13
- "Basic and custom definition".green.goo
12
+ Colorer.define_styles({:basic => true, :goo => [7], :guu => 4}, 1)
13
+ "Basic and custom definition".green.goo.guu
14
14
  puts _
15
- test_value_eql? "\e[0;32;7mBasic and custom definition\e[0m"
15
+ test_value_eql? "\e[0;32;7;4mBasic and custom definition\e[0m"
16
16
 
17
17
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Domizio Demichelis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-17 00:00:00 -04:00
18
+ date: 2010-10-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency