ansible 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ansible.rb +11 -23
- data/lib/ansible/version.rb +1 -1
- data/spec/ansible_spec.rb +5 -3
- metadata +3 -5
data/lib/ansible.rb
CHANGED
@@ -1,25 +1,9 @@
|
|
1
1
|
module Ansible
|
2
2
|
def escape_to_html(data)
|
3
|
-
data = span("none"
|
4
|
-
|
5
|
-
{
|
6
|
-
|
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(
|
27
|
+
def span(first, *codes)
|
44
28
|
s = first ? "" : "</span>"
|
45
29
|
|
46
|
-
|
47
|
-
|
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
|
data/lib/ansible/version.rb
CHANGED
data/spec/ansible_spec.rb
CHANGED
@@ -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="
|
10
|
-
ANSIBLE_GREEN = %Q{<span class="
|
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 [0;31mtext [1;32mother[0m[m" =>
|
23
23
|
%Q{#{ANSIBLE_NONE}escaped </span>#{ANSIBLE_RED}text </span>#{ANSIBLE_GREEN}other</span>#{ANSIBLE_NONE}</span>#{ANSIBLE_NONE}</span>},
|
24
24
|
"escaped [1;95mtext[0m" =>
|
25
|
-
%Q{#{ANSIBLE_NONE}escaped </span><span class="ansible_95
|
25
|
+
%Q{#{ANSIBLE_NONE}escaped </span><span class="ansible_1 ansible_95">text</span>#{ANSIBLE_NONE}</span>},
|
26
|
+
"escaped [42;37;1mtext[0m" =>
|
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.
|
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-
|
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.
|
95
|
+
rubygems_version: 1.8.10
|
98
96
|
signing_key:
|
99
97
|
specification_version: 3
|
100
98
|
summary: Fast ANSI->HTML conversion
|