col 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,8 @@
1
- === 1.0.1 / 2012-01-01
1
+ === 1.0.2 / 2012-01-02
2
+
3
+ * Code is now compatible with Ruby 1.8.6.
4
+
5
+ === 1.0.1 / 2012-01-02
2
6
 
3
7
  * 1 minor enhancement:
4
8
 
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_runtime_dependency "term-ansicolor", ">= 1.0"
27
27
 
28
- #s.add_development_dependency "T"
29
28
  s.add_development_dependency "bundler"
29
+ s.add_development_dependency "whitestone"
30
30
 
31
- s.required_ruby_version = '>= 1.8.6' # Not sure about this.
31
+ s.required_ruby_version = '>= 1.8.6' # Tested.
32
32
  end
@@ -324,8 +324,11 @@ environment has been tested!
324
324
 
325
325
  ### History
326
326
 
327
- January 1 2012: Version 1.0.1 released (minor bug fix for 1.9.3)
328
- July 25 2010: Version 1.0 released.
327
+ * 2 JAN 2012: Version 1.0.2 released (1.8.6 compatibility)
328
+ * 2 JAN 2012: Version 1.0.1 released (minor bug fix for 1.9.3)
329
+ * 25 JUL 25 2010: Version 1.0 released.
330
+
331
+ See History.txt for more details.
329
332
 
330
333
  ### Credits
331
334
 
data/lib/col.rb CHANGED
@@ -5,7 +5,6 @@ require 'col/version'
5
5
 
6
6
  class Col
7
7
 
8
-
9
8
  # args: array of strings (to_s is called on each)
10
9
  def initialize(*args)
11
10
  @strings = args.map { |a| a.to_s }
@@ -34,14 +33,14 @@ class Col
34
33
  end
35
34
 
36
35
  def Col.inline(*args)
37
- unless args.size.even?
36
+ unless args.size % 2 == 0 # even? breaks 1.8.6
38
37
  raise Col::Error, "Col.inline requires an even number of arguments"
39
38
  end
40
- String.new.tap { |result|
41
- args.each_slice(2) do |string, format|
42
- result << Col(string.to_s).fmt(format)
43
- end
44
- }
39
+ result = String.new
40
+ Col::Utils.each_pair(args) do |string, format|
41
+ result << Col(string.to_s).fmt(format)
42
+ end
43
+ result
45
44
  end
46
45
 
47
46
  # e.g.
@@ -98,12 +97,12 @@ class Col::Formatter
98
97
  unless @strings.size == @format_spec.size
99
98
  raise Col::Error, "mismatching strings and specs"
100
99
  end
101
- String.new.tap { |str|
102
- @strings.zip(@format_spec).each do |string, spec|
103
- d = decorated_string(string, spec)
104
- str << d
105
- end
106
- }
100
+ result = String.new
101
+ @strings.zip(@format_spec).each do |string, spec|
102
+ d = decorated_string(string, spec)
103
+ result << d
104
+ end
105
+ result
107
106
  end
108
107
 
109
108
  # e.g.
@@ -347,3 +346,23 @@ class Col::DB
347
346
  end
348
347
 
349
348
  end # Col::DB
349
+
350
+ # --------------------------------------------------------------------------- #
351
+
352
+ # Utility methods to enable Col to work on 1.8.6.
353
+ class Col::Utils
354
+ if RUBY_VERSION < "1.8.7"
355
+ def self.each_pair(array)
356
+ a = array.dup
357
+ loop do
358
+ pair = a.slice!(0,2)
359
+ break if pair.empty?
360
+ yield pair
361
+ end
362
+ end
363
+ else
364
+ def self.each_pair(array, &block)
365
+ array.each_slice(2, &block)
366
+ end
367
+ end
368
+ end
@@ -1,3 +1,3 @@
1
1
  class Col
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -62,7 +62,6 @@ D "General formatting (multiple strings)" do
62
62
  end
63
63
 
64
64
  D "Method names, like Col('foo').red.bold" do
65
- Eq Col::VERSION, "1.0.1a"
66
65
  Ko Col('foo').red, Col
67
66
  Ko Col('foo').red.bold, Col
68
67
  Eq Col('foo').red.bold.to_str, "foo".red.bold
@@ -171,7 +170,7 @@ D "Col.inline" do
171
170
  E(Col::Error) do
172
171
  Col.inline( "foo", :blue, "bar", :red, "quux" )
173
172
  end
174
- Mt Attest.exception.message, /even/i
173
+ Mt Whitestone.exception.message, /even/i
175
174
  end
176
175
  end
177
176
 
@@ -226,16 +225,16 @@ end
226
225
  D "Erroneous specifications" do
227
226
  D "incorrect number of arguments" do
228
227
  E(Col::Error) { Col["one","two"].fmt :b }
229
- Mt Attest.exception.message, /incorrect number of arguments/i
228
+ Mt Whitestone.exception.message, /incorrect number of arguments/i
230
229
  E(Col::Error) { Col["one","two"].fmt(:b, :r, :g) }
231
- Mt Attest.exception.message, /incorrect number of arguments/i
230
+ Mt Whitestone.exception.message, /incorrect number of arguments/i
232
231
  E(Col::Error) { Col["one","two"].fmt(:b, :r, :g, :cbow) }
233
- Mt Attest.exception.message, /incorrect number of arguments/i
232
+ Mt Whitestone.exception.message, /incorrect number of arguments/i
234
233
  end
235
234
 
236
235
  D "invalid code" do
237
236
  E(Col::Error) { Col["one","two"].fmt(:T, :r) }
238
237
  E(Col::Error) { Col["one","two"].fmt "T,r" }
239
- Mt Attest.exception.message, /invalid color code/i
238
+ Mt Whitestone.exception.message, /invalid color code/i
240
239
  end
241
240
  end
@@ -1,14 +1,14 @@
1
1
  D "Col::DB" do
2
2
  D "method?" do
3
3
  D "given symbol" do
4
- T Col::DB.method? :yellow
5
- T Col::DB.method? :blink
6
- T Col::DB.method? :on_cyan
4
+ T Col::DB.method?(:yellow)
5
+ T Col::DB.method?(:blink)
6
+ T Col::DB.method?(:on_cyan)
7
7
  end
8
8
  D "given string" do
9
- T Col::DB.method? "yellow"
10
- T Col::DB.method? "blink"
11
- T Col::DB.method? "on_cyan"
9
+ T Col::DB.method?("yellow")
10
+ T Col::DB.method?("blink")
11
+ T Col::DB.method?("on_cyan")
12
12
  end
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: col
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-01 00:00:00.000000000 Z
12
+ date: 2012-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &2155928480 !ruby/object:Gem::Requirement
16
+ requirement: &2157711260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2155928480
24
+ version_requirements: *2157711260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2155927760 !ruby/object:Gem::Requirement
27
+ requirement: &2157710800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,18 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2155927760
35
+ version_requirements: *2157710800
36
+ - !ruby/object:Gem::Dependency
37
+ name: whitestone
38
+ requirement: &2157710240 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2157710240
36
47
  description: ! " Console color formatting library with abbreviations (e.g. 'rb'
37
48
  for\n red and bold), and the ability to format several strings easily.\n No
38
49
  methods are added to core classes.\n"
@@ -78,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
89
  version: '0'
79
90
  requirements: []
80
91
  rubyforge_project: ''
81
- rubygems_version: 1.8.13
92
+ rubygems_version: 1.8.10
82
93
  signing_key:
83
94
  specification_version: 3
84
95
  summary: High-level console color formatting