bcat 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'bcat'
3
- s.version = '0.5.1'
4
- s.date = '2010-07-11'
3
+ s.version = '0.5.2'
4
+ s.date = '2010-08-23'
5
5
 
6
6
  s.description = "pipe to browser utility"
7
7
  s.summary =
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  bin/a2h
23
23
  bin/bcat
24
24
  bin/btee
25
+ contrib/bman
25
26
  lib/bcat.rb
26
27
  lib/bcat/ansi.rb
27
28
  lib/bcat/browser.rb
@@ -44,7 +45,7 @@ Gem::Specification.new do |s|
44
45
  # = MANIFEST =
45
46
 
46
47
  s.default_executable = 'bcat'
47
- s.executables = ['bcat']
48
+ s.executables = ['a2h', 'bcat', 'btee']
48
49
 
49
50
  s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/}
50
51
  s.add_dependency 'rack', '< 1.2'
data/bin/bcat CHANGED
@@ -22,7 +22,7 @@ options = {
22
22
  :Host => '127.0.0.1',
23
23
  :Port => 0,
24
24
  :format => nil,
25
- :title => Dir.pwd,
25
+ :title => nil,
26
26
  :browser => (ENV['BCAT_BROWSER'].to_s.size > 0 ? ENV['BCAT_BROWSER'] : 'default'),
27
27
  :ansi => false,
28
28
  :debug => false,
@@ -0,0 +1,26 @@
1
+ #!/bin/sh
2
+ # Usage: bman <man-args>
3
+ # Open manual page in browser with bcat.
4
+ #
5
+ # Original zsh version by Nick Stenning <http://github.com/nickstenning>
6
+ # http://github.com/rtomayko/bcat/issues#issue/8
7
+ #
8
+ # Ported to POSIX shell by Ryan Tomayko <http://github.com/rtomayko>
9
+ set -e
10
+
11
+ # we use normal bold and underline
12
+ BOLD="\033[1m"
13
+ EM="\033[3m"
14
+ RESET="\033[0m"
15
+
16
+ # pass argv directly over to man
17
+ man "$@" |
18
+
19
+ # replace ^H based bold and underline with ansi equivelants
20
+ sed "
21
+ s/_\(.\)/"$(echo "$EM")"\1"$(echo "$RESET")"/g
22
+ s/\(.\)\1/"$(echo "$BOLD")"\1"$(echo "$RESET")"/g
23
+ " |
24
+
25
+ # pipe it into bcat
26
+ bcat
@@ -6,7 +6,7 @@ require 'bcat/server'
6
6
  require 'bcat/browser'
7
7
 
8
8
  class Bcat
9
- VERSION = '0.5.1'
9
+ VERSION = '0.5.2'
10
10
  include Rack::Utils
11
11
 
12
12
  attr_reader :format
@@ -57,6 +57,7 @@ class Bcat
57
57
  yield buf
58
58
  elsif head_parser.feed(buf)
59
59
  yield content_for_head(inject=head_parser.head)
60
+ yield "\n"
60
61
  yield head_parser.body
61
62
  head_parser = nil
62
63
  end
@@ -64,6 +65,7 @@ class Bcat
64
65
 
65
66
  if head_parser
66
67
  yield content_for_head(inject=head_parser.head) +
68
+ "\n" +
67
69
  head_parser.body
68
70
  end
69
71
 
@@ -83,14 +85,15 @@ class Bcat
83
85
  "<html>",
84
86
  "<head>",
85
87
  "<!-- bcat was here -->",
86
- "<title>#{self[:title] || 'bcat'}</title>",
87
88
  inject.to_s,
89
+ "<link href=\"data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=\" rel=\"icon\" type=\"image/x-icon\" />",
90
+ "<title>#{self[:title] || 'bcat'}</title>",
88
91
  "</head>"
89
92
  ].join("\n")
90
93
  end
91
94
 
92
95
  def foot
93
- "</body></html>"
96
+ "</body>\n</html>\n"
94
97
  end
95
98
 
96
99
  def escape_js(string)
@@ -102,8 +102,8 @@ class Bcat
102
102
  when 0 ; yield reset_styles if @stack.any?
103
103
  when 1 ; yield push_tag("b") # bright
104
104
  when 2 ; #dim
105
- when 3 ; yield push_tag("u")
106
- when 5 ; yield push_tag("blink")
105
+ when 3, 4 ; yield push_tag("u")
106
+ when 5, 6 ; yield push_tag("blink")
107
107
  when 7 ; #reverse
108
108
  when 8 ; yield push_style("display:none")
109
109
  when 9 ; yield push_tag("strike")
@@ -45,7 +45,7 @@ class Bcat
45
45
  def open(url)
46
46
  command = browser_command
47
47
  fork do
48
- [$stdin, $stdout].each { |fd| fd.close }
48
+ $stdin.close
49
49
  exec "#{command} '#{shell_quote(url)}'"
50
50
  end
51
51
  end
@@ -28,7 +28,7 @@ class Bcat
28
28
  !@body.nil?
29
29
  end
30
30
 
31
- # Determine if the input is HTML. This nil before the first non-whitespace
31
+ # Determine if the input is HTML. This is nil before the first non-whitespace
32
32
  # character is received, true if the first non-whitespace character is a
33
33
  # '<', and false if the first non-whitespace character is something other
34
34
  # than '<'.
@@ -37,7 +37,7 @@ class Bcat
37
37
  end
38
38
 
39
39
  # The head contents without any DOCTYPE, <html>, or <head> tags. This should
40
- # consist of only <style>, <script>, <link>, <meta>, and <title> tags.
40
+ # consist of only <style>, <script>, <link>, <meta>, <base>, and <title> tags.
41
41
  def head
42
42
  @head.join.gsub(/<\/?(?:html|head|!DOCTYPE).*?>/mi, '')
43
43
  end
@@ -59,14 +59,14 @@ class Bcat
59
59
  /\A(<title.*?>.*?<\/title>)/mi,
60
60
  /\A(<script.*?>.*?<\/script>)/mi,
61
61
  /\A(<style.*?>.*?<\/style>)/mi,
62
- /\A(<(?:html|head|meta|link).*?>)/mi,
63
- /\A(<\/(?:html|head|meta|link|script|style|title)>)/mi,
62
+ /\A(<(?:html|head|meta|link|base).*?>)/mi,
63
+ /\A(<\/(?:html|head|meta|link|base|script|style|title)>)/mi,
64
64
  /\A(<!--(.*?)-->)/m
65
65
  ]
66
66
 
67
67
  BODY_TOKS = [
68
68
  /\A[^<]/,
69
- /\A<(?!html|head|meta|link|script|style|title).*?>/
69
+ /\A<(?!html|head|meta|link|base|script|style|title).*?>/
70
70
  ]
71
71
 
72
72
  # Parses buf into head and body parts. Basic approach is to eat anything
@@ -136,6 +136,9 @@ Use with `makeprg`:
136
136
  set makeprg=markdown\ %\ \\\|bcat
137
137
  set makeprg=testrb\ %\ \\\|bcat
138
138
 
139
+ (Note that you may need to escape the `%` character with quotes if there's
140
+ spaces in the pathname. For example: `!markdown '%' |bcat`.)
141
+
139
142
  ## SEE ALSO
140
143
 
141
144
  cat(1), tee(1), open(1)
@@ -136,6 +136,9 @@ Use with `makeprg`:
136
136
  set makeprg=markdown\ %\ \\\|bcat
137
137
  set makeprg=testrb\ %\ \\\|bcat
138
138
 
139
+ (Note that you may need to escape the `%` character with quotes if there's
140
+ spaces in the pathname. For example: `!markdown '%' |bcat`.)
141
+
139
142
  ## SEE ALSO
140
143
 
141
144
  cat(1), tee(1), open(1)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Tomayko
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-11 00:00:00 -07:00
18
+ date: 2010-08-23 00:00:00 -07:00
19
19
  default_executable: bcat
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -36,7 +36,9 @@ dependencies:
36
36
  description: pipe to browser utility
37
37
  email: rtomayko@gmail.com
38
38
  executables:
39
+ - a2h
39
40
  - bcat
41
+ - btee
40
42
  extensions: []
41
43
 
42
44
  extra_rdoc_files:
@@ -51,6 +53,7 @@ files:
51
53
  - bin/a2h
52
54
  - bin/bcat
53
55
  - bin/btee
56
+ - contrib/bman
54
57
  - lib/bcat.rb
55
58
  - lib/bcat/ansi.rb
56
59
  - lib/bcat/browser.rb