jugyo-termcolor 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -8,20 +8,28 @@ Termcolor is a library for ANSII color formatting like HTML for output in termin
8
8
 
9
9
  == FEATURES/PROBLEMS:
10
10
 
11
-
12
11
  == SYNOPSIS:
13
12
 
13
+ TermColor.parse('<blue>Hello</blue> <red>World!</red>')
14
+ #=> "\e[34mHello\e[0m \e[31mWorld!\e[0m"
15
+
14
16
  == REQUIREMENTS:
15
17
 
16
18
  * highline
17
19
 
18
20
  == INSTALL:
19
21
 
22
+ sudo gem install termcolor
23
+
24
+ or
25
+
20
26
  gem source -a http://gems.github.com
21
27
  sudo gem install jugyo-termcolor
22
28
 
23
29
  == TODO:
24
30
 
31
+ for windows...
32
+
25
33
  == LICENSE:
26
34
 
27
35
  (The MIT License)
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  $:.unshift File.dirname(__FILE__) + '/lib/'
2
3
  require 'termcolor'
3
4
  require 'spec/rake/spectask'
@@ -12,6 +13,7 @@ desc 'Generate gemspec'
12
13
  task :gemspec do |t|
13
14
  open('termcolor.gemspec', "wb" ) do |file|
14
15
  file << <<-EOS
16
+ # -*- coding: utf-8 -*-
15
17
  Gem::Specification.new do |s|
16
18
  s.name = 'termcolor'
17
19
  s.version = '#{TermColor::VERSION}'
data/lib/termcolor.rb CHANGED
@@ -1,19 +1,19 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'highline'
2
3
  require 'cgi'
3
4
  require 'rexml/parsers/streamparser'
4
5
  require 'rexml/parsers/baseparser'
5
6
  require 'rexml/streamlistener'
6
7
 
7
- class TermColor
8
- VERSION = '0.1.0'
8
+ module TermColor
9
+ VERSION = '0.2.1'
9
10
  include REXML
10
11
 
11
12
  class ParseError < StandardError; end
12
13
 
13
14
  class << self
14
- @highline = HighLine.new
15
- def print(text)
16
- print parse(text)
15
+ def escape(text)
16
+ CGI.escapeHTML(text)
17
17
  end
18
18
 
19
19
  def parse(text)
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
1
  # -*- coding: utf-8 -*-
2
-
3
2
  $:.unshift(File.dirname(__FILE__) + '/../lib')
4
3
  require 'termcolor'
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
-
3
2
  require File.dirname(__FILE__) + '/spec_helper'
4
3
 
5
- class TermColor
4
+ module TermColor
6
5
  describe TermColor do
7
6
  before do
8
7
  end
@@ -29,5 +28,10 @@ class TermColor
29
28
  lambda{ TermColor.parse('aaaaa<red>aaaaa</blue>aaaaa') }.should raise_error(TermColor::ParseError)
30
29
  lambda{ TermColor.parse('aaaaa<red>aaaaaaaaaa') }.should_not raise_error(TermColor::ParseError)
31
30
  end
31
+
32
+ it 'should escape text' do
33
+ text = 'a<foo>&</foo>a'
34
+ TermColor.escape(text).should == "a&lt;foo&gt;&amp;&lt;/foo&gt;a"
35
+ end
32
36
  end
33
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jugyo-termcolor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo