bcat 0.6.1 → 0.6.2

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.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'bcat'
3
- s.version = '0.6.1'
4
- s.date = '2011-05-22'
3
+ s.version = '0.6.2'
4
+ s.date = '2011-09-10'
5
5
 
6
6
  s.description = "pipe to browser utility"
7
7
  s.summary =
@@ -6,7 +6,7 @@ require 'bcat/server'
6
6
  require 'bcat/browser'
7
7
 
8
8
  class Bcat
9
- VERSION = '0.6.1'
9
+ VERSION = '0.6.2'
10
10
  include Rack::Utils
11
11
 
12
12
  attr_reader :format
@@ -112,6 +112,9 @@ class Bcat
112
112
  when 90..97 ; yield push_style("ef#{8 + code - 90}")
113
113
  when 100..107 ; yield push_style("eb#{8 + code - 100}")
114
114
  end
115
+ when :xterm256
116
+ code = data
117
+ yield push_style("ef#{code}")
115
118
  end
116
119
  end
117
120
  end
@@ -143,6 +146,8 @@ class Bcat
143
146
  # characters to remove completely
144
147
  [/\A\x08+/, lambda { |m| '' }],
145
148
 
149
+ [/\A\x1b\[38;5;(\d+)m/, lambda { |m| yield :xterm256, $1.to_i; '' } ],
150
+
146
151
  # ansi escape sequences that mess with the display
147
152
  [/\A\x1b\[((?:\d{1,3};?)+|)m/, lambda { |m|
148
153
  m = '0' if m.strip.empty?
@@ -159,8 +164,7 @@ class Bcat
159
164
 
160
165
  while (size = text.size) > 0
161
166
  tokens.each do |pattern, sub|
162
- while text.sub!(pattern) { sub.call($1) }
163
- end
167
+ break if text.sub!(pattern) { sub.call($1) }
164
168
  end
165
169
  break if text.size == size
166
170
  end
@@ -118,4 +118,10 @@ class ANSITest < Test::Unit::TestCase
118
118
  expect = "oops forgot the 'm'"
119
119
  assert_equal expect, Bcat::ANSI.new(text).to_html
120
120
  end
121
+
122
+ test "xterm-256" do
123
+ text = "\x1b[38;5;196mhello"
124
+ expect = "<span style='color:#ff0000'>hello</span>"
125
+ assert_equal expect, Bcat::ANSI.new(text).to_html
126
+ end
121
127
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 6
9
- - 1
10
- version: 0.6.1
8
+ - 2
9
+ version: 0.6.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Ryan Tomayko
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-05-22 00:00:00 -07:00
17
+ date: 2011-09-10 00:00:00 -07:00
19
18
  default_executable: bcat
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rack
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ~>
28
26
  - !ruby/object:Gem::Version
29
- hash: 15
30
27
  segments:
31
28
  - 1
32
29
  - 0
@@ -84,27 +81,23 @@ rdoc_options:
84
81
  require_paths:
85
82
  - lib
86
83
  required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
84
  requirements:
89
85
  - - ">="
90
86
  - !ruby/object:Gem::Version
91
- hash: 3
92
87
  segments:
93
88
  - 0
94
89
  version: "0"
95
90
  required_rubygems_version: !ruby/object:Gem::Requirement
96
- none: false
97
91
  requirements:
98
92
  - - ">="
99
93
  - !ruby/object:Gem::Version
100
- hash: 3
101
94
  segments:
102
95
  - 0
103
96
  version: "0"
104
97
  requirements: []
105
98
 
106
99
  rubyforge_project:
107
- rubygems_version: 1.3.7
100
+ rubygems_version: 1.3.6
108
101
  signing_key:
109
102
  specification_version: 3
110
103
  summary: Concatenate input from standard input, or one or more files, and write progressive output to a browser.