ansible 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +1,9 @@
1
1
  module Ansible
2
2
  def escape_to_html(data)
3
- data = span("none", 0, true) + data
4
-
5
- { 30 => :black,
6
- 31 => :red,
7
- 32 => :green,
8
- 33 => :yellow,
9
- 34 => :blue,
10
- 35 => :magenta,
11
- 36 => :cyan,
12
- 37 => :white,
13
- 90 => :gray
14
- }.each do |key, value|
15
- data.gsub!(/\e\[(\d;)?#{key}m/) { |match|
16
- span(value, $1)
17
- }
18
- end
19
-
20
- data.gsub!(/\e\[0?m/, span("none"))
21
- data.gsub!(/\e\[(\d;)?(\d+)m/) { |match|
22
- span($2, $1)
3
+ data = span(true, "none") + data
4
+ data.gsub!(/\e\[0?m/, span(false, "none"))
5
+ data.gsub!(/\e\[([0-9;]+)m/) { |match|
6
+ span(false, *$1.split(';'))
23
7
  }
24
8
  data + "</span>"
25
9
  end
@@ -40,11 +24,15 @@ module Ansible
40
24
  end
41
25
 
42
26
  private
43
- def span(klass, level=0, first=false)
27
+ def span(first, *codes)
44
28
  s = first ? "" : "</span>"
45
29
 
46
- classes = ["ansible_#{klass}"]
47
- classes << "ansible_bold" if level.to_i == 1
30
+ if codes.include?("none")
31
+ classes = ["ansible_none"]
32
+ else
33
+ classes = codes.reject{|c| c.to_i == 0}.map{|c| "ansible_#{c.to_i}"}
34
+ end
35
+
48
36
  s += %Q{<span class="#{classes.join(" ")}">}
49
37
  s
50
38
  end
@@ -1,3 +1,3 @@
1
1
  module AnsibleVersion
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -6,8 +6,8 @@ end
6
6
 
7
7
  describe Ansible do
8
8
  ANSIBLE_NONE = %Q{<span class="ansible_none">}
9
- ANSIBLE_RED = %Q{<span class="ansible_red">}
10
- ANSIBLE_GREEN = %Q{<span class="ansible_green ansible_bold">}
9
+ ANSIBLE_RED = %Q{<span class="ansible_31">}
10
+ ANSIBLE_GREEN = %Q{<span class="ansible_1 ansible_32">}
11
11
  subject { Helper.new }
12
12
  describe "#ansi_escaped" do
13
13
  SAMPLE_TEXT = {
@@ -22,7 +22,9 @@ describe Ansible do
22
22
  "escaped text other" =>
23
23
  %Q{#{ANSIBLE_NONE}escaped </span>#{ANSIBLE_RED}text </span>#{ANSIBLE_GREEN}other</span>#{ANSIBLE_NONE}</span>#{ANSIBLE_NONE}</span>},
24
24
  "escaped text" =>
25
- %Q{#{ANSIBLE_NONE}escaped </span><span class="ansible_95 ansible_bold">text</span>#{ANSIBLE_NONE}</span>},
25
+ %Q{#{ANSIBLE_NONE}escaped </span><span class="ansible_1 ansible_95">text</span>#{ANSIBLE_NONE}</span>},
26
+ "escaped text" =>
27
+ %Q{#{ANSIBLE_NONE}escaped </span><span class="ansible_42 ansible_37 ansible_1">text</span>#{ANSIBLE_NONE}</span>},
26
28
  }
27
29
 
28
30
  it "should render the text as html" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ansible
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Solano Labs
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-04 00:00:00 -07:00
14
- default_executable:
13
+ date: 2011-10-07 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: bundler
@@ -70,7 +69,6 @@ files:
70
69
  - spec/ansible_spec.rb
71
70
  - spec/spec_helper.rb
72
71
  - stylesheets/ansible.css
73
- has_rdoc: true
74
72
  homepage: http://www.tddium.com/
75
73
  licenses: []
76
74
 
@@ -94,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
92
  requirements: []
95
93
 
96
94
  rubyforge_project: tddium
97
- rubygems_version: 1.6.2
95
+ rubygems_version: 1.8.10
98
96
  signing_key:
99
97
  specification_version: 3
100
98
  summary: Fast ANSI->HTML conversion