heel 3.2.1 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +11 -0
  3. data/Manifest.txt +11 -19
  4. data/README.md +32 -25
  5. data/Rakefile +21 -9
  6. data/data/css/pico.min.css +5 -0
  7. data/data/css/syntax-highlighting.css +61 -0
  8. data/data/error.rhtml +18 -16
  9. data/data/lineicons/code-browser.svg +16 -0
  10. data/data/lineicons/file.svg +12 -0
  11. data/data/lineicons/folder-alt.svg +9 -0
  12. data/data/lineicons/html5.svg +21 -0
  13. data/data/lineicons/image.svg +17 -0
  14. data/data/lineicons/pdf.svg +18 -0
  15. data/data/lineicons/presentation.svg +10 -0
  16. data/data/lineicons/word.svg +23 -0
  17. data/data/lineicons/zip.svg +14 -0
  18. data/data/listing.rhtml +40 -30
  19. data/lib/heel/directory_indexer.rb +1 -1
  20. data/lib/heel/mime_map.rb +13 -16
  21. data/lib/heel/rackapp.rb +47 -28
  22. data/lib/heel/server.rb +7 -6
  23. data/lib/heel/template_vars.rb +4 -0
  24. data/lib/heel.rb +1 -1
  25. data/spec/configuration_spec.rb +10 -6
  26. data/spec/directory_indexer_spec.rb +14 -11
  27. data/spec/rackapp_spec.rb +13 -13
  28. data/spec/server_spec.rb +24 -24
  29. data/spec/template_vars_spec.rb +2 -2
  30. data/tasks/default.rake +24 -16
  31. data/tasks/this.rb +6 -3
  32. metadata +80 -57
  33. data/data/css/coderay-alpha.css +0 -120
  34. data/data/css/coderay-cycnus.css +0 -104
  35. data/data/css/coderay-murphy.css +0 -98
  36. data/data/css/index.css +0 -77
  37. data/data/famfamfam/icons/application.png +0 -0
  38. data/data/famfamfam/icons/compress.png +0 -0
  39. data/data/famfamfam/icons/error.png +0 -0
  40. data/data/famfamfam/icons/folder.png +0 -0
  41. data/data/famfamfam/icons/html.png +0 -0
  42. data/data/famfamfam/icons/page_excel.png +0 -0
  43. data/data/famfamfam/icons/page_white.png +0 -0
  44. data/data/famfamfam/icons/page_white_acrobat.png +0 -0
  45. data/data/famfamfam/icons/page_white_code.png +0 -0
  46. data/data/famfamfam/icons/page_white_powerpoint.png +0 -0
  47. data/data/famfamfam/icons/page_white_text.png +0 -0
  48. data/data/famfamfam/icons/picture.png +0 -0
  49. data/data/famfamfam/icons/xhtml.png +0 -0
  50. data/data/famfamfam/readme.html +0 -1495
  51. data/data/famfamfam/readme.txt +0 -22
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="lni_lni-presentation" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
4
+ x="0px" y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve">
5
+ <path d="M57,5.5H7c-2.9,0-5.3,2.4-5.3,5.3v6.4c0,1.2,1,2.3,2.3,2.3h0.2v20.3c0,2.9,2.4,5.3,5.3,5.3h20.3v5.5L25,54.5
6
+ c-1,0.8-1.1,2.2-0.3,3.2c0.4,0.5,1.1,0.8,1.7,0.8c0.5,0,1-0.2,1.4-0.5l4.1-3.4l4.1,3.4c1,0.8,2.4,0.7,3.2-0.3c0.8-1,0.7-2.4-0.3-3.2
7
+ l-4.7-3.9V45h20.3c2.9,0,5.3-2.4,5.3-5.3V19.5H60c1.2,0,2.3-1,2.3-2.3v-6.4C62.3,7.9,59.9,5.5,57,5.5z M6.3,10.8
8
+ C6.3,10.4,6.6,10,7,10h50c0.4,0,0.8,0.3,0.8,0.8V15h-0.1c0,0-0.1,0-0.1,0H6.4c0,0-0.1,0-0.1,0H6.3V10.8z M55.3,39.8
9
+ c0,0.4-0.3,0.8-0.8,0.8H9.4c-0.4,0-0.8-0.3-0.8-0.8V19.5h46.6V39.8z"/>
10
+ </svg>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 65 64" style="enable-background:new 0 0 65 64;" xml:space="preserve">
5
+ <g>
6
+ <path d="M10.6,29.8c1.2,0,2.3-1,2.3-2.3V8c0-1,0.8-1.8,1.8-1.8h22.6V19c0,1.2,1,2.3,2.3,2.3h12.7V27c0,1.2,1,2.3,2.3,2.3
7
+ s2.3-1,2.3-2.3v-7.4c0-1.1-0.5-2.2-1.3-3L41.6,3c-0.8-0.8-1.9-1.2-3-1.2h-24c-3.4,0-6.3,2.8-6.3,6.3v19.5
8
+ C8.4,28.7,9.4,29.8,10.6,29.8z M41.7,9.4l7.5,7.4h-7.5V9.4z"/>
9
+ <path d="M54.4,51.8c-1.2,0-2.3,1-2.3,2.3v2c0,1-0.8,1.8-1.8,1.8H14.6c-1,0-1.8-0.8-1.8-1.8v-1.4c0-1.2-1-2.3-2.3-2.3
10
+ s-2.3,1-2.3,2.3V56c0,3.4,2.8,6.3,6.3,6.3h35.7c3.4,0,6.3-2.8,6.3-6.3v-2C56.6,52.8,55.6,51.8,54.4,51.8z"/>
11
+ <path d="M56.7,30.3h-4.6c-1.2,0-2.3,1-2.3,2.3v15.1c0,1.2,1,2.3,2.3,2.3h4.6c3.5,0,6.4-2.9,6.4-6.5v-6.6
12
+ C63.1,33.2,60.2,30.3,56.7,30.3z M58.6,43.4c0,1.1-0.9,2-1.9,2h-2.3V34.8h2.3c1,0,1.9,0.9,1.9,2V43.4z"/>
13
+ <path d="M47.1,39.4v-6.6c0-1.2-1-2.3-2.3-2.3h-7.1c-1.2,0-2.3,1-2.3,2.3v14.9c0,1.2,1,2.3,2.3,2.3s2.3-1,2.3-2.3v-5.3l4,6.5
14
+ c0.4,0.7,1.2,1.1,1.9,1.1c0.4,0,0.8-0.1,1.2-0.3c1.1-0.7,1.4-2,0.7-3.1l-3-4.8h0C46.1,41.7,47.1,40.7,47.1,39.4z M40,35h2.6v2.1H40
15
+ V35z"/>
16
+ <path d="M20.5,36.8v6.9c0,3.5,2.8,6.3,6.3,6.3s6.3-2.8,6.3-6.3v-6.9c0-3.5-2.8-6.3-6.3-6.3S20.5,33.4,20.5,36.8z M28.6,36.8v6.9
17
+ c0,1-0.8,1.8-1.8,1.8S25,44.7,25,43.7v-6.9c0-1,0.8-1.8,1.8-1.8S28.6,35.8,28.6,36.8z"/>
18
+ <path d="M10.5,48.2l0.3-1.4l0.3,1.4c0.2,1,1.1,1.7,2.1,1.8c1,0,2-0.6,2.2-1.6l4-14.1c0.3-1.2-0.4-2.4-1.6-2.8
19
+ c-1.2-0.3-2.4,0.4-2.8,1.6l-1.5,5.4l-0.7-3.1c-0.2-1-1.1-1.8-2.2-1.8c0,0,0,0,0,0c-1.1,0-2,0.8-2.2,1.8l-0.6,3.1L6.3,33
20
+ c-0.3-1.2-1.6-1.9-2.8-1.5C2.4,31.8,1.7,33,2,34.2l4.1,14.1c0.3,1,1.2,1.6,2.2,1.6c0,0,0.1,0,0.1,0C9.4,49.9,10.3,49.2,10.5,48.2z"
21
+ />
22
+ </g>
23
+ </svg>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="lni_lni-zip" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
4
+ y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve">
5
+ <path d="M56.3,11.6h-3.4V9.4c0-4.2-3.4-7.6-7.6-7.6H10.8c-4.2,0-7.6,3.4-7.6,7.6v30.7c0,1.4,0.6,2.7,1.6,3.6L23,60.9
6
+ c0.9,0.9,2.1,1.3,3.4,1.3h18.8c4.2,0,7.6-3.4,7.6-7.6V34.5h3.4c1.4,0,2.5-1.1,2.5-2.5V14.2C58.8,12.8,57.7,11.6,56.3,11.6z
7
+ M10.3,42.8H23c0.2,0,0.4,0.2,0.4,0.4v11.9L10.3,42.8z M48.4,54.6c0,1.7-1.4,3.1-3.1,3.1H28V43.2c0-2.7-2.2-4.9-4.9-4.9H7.6V9.4
8
+ c0-1.7,1.4-3.1,3.1-3.1h34.5c1.7,0,3.1,1.4,3.1,3.1v2.3H18.1c-1.4,0-2.5,1.1-2.5,2.5V32c0,1.4,1.1,2.5,2.5,2.5h30.3V54.6z
9
+ M38.4,19.3v7.6c0,1.4-1.1,2.5-2.5,2.5s-2.5-1.1-2.5-2.5v-7.6c0-1.4,1.1-2.5,2.5-2.5S38.4,17.9,38.4,19.3z M30.8,26.9
10
+ c0,1.4-1.1,2.5-2.5,2.5H24c-0.9,0-1.8-0.5-2.2-1.3c-0.4-0.8-0.4-1.8,0.1-2.6l2.3-3.8h-0.9c-1.4,0-2.5-1.1-2.5-2.5
11
+ c0-1.4,1.1-2.5,2.5-2.5h5.5c0.9,0,1.8,0.5,2.2,1.3c0.4,0.8,0.4,1.8-0.1,2.6l-2.3,3.8C29.8,24.5,30.8,25.6,30.8,26.9z M48.6,26.9
12
+ h-2.5c0,1.4-1.1,2.5-2.5,2.5S41,28.3,41,26.9v-2.5v-5.1c0-1.4,1.1-2.5,2.5-2.5h5.1c2.8,0,5.1,2.3,5.1,5.1
13
+ C53.7,24.6,51.4,26.9,48.6,26.9z"/>
14
+ </svg>
data/data/listing.rhtml CHANGED
@@ -1,20 +1,18 @@
1
1
  <!DOCTYPE html>
2
- <html lang='en'>
2
+ <html lang='en' data-theme="light">
3
3
  <head>
4
4
  <title>Index of <%= base_uri %></title>
5
+
5
6
  <meta charset='utf-8'>
6
- <link href='/heel_css/index.css' rel='stylesheet' type='text/css'>
7
- <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
8
- <!--[if IE]>
9
- <script src='//html5shiv.googlecode.com/svn/trunk/html5.js'></script>
10
- <![endif]-->
7
+ <meta name="viewport" content="width=device-width, initial-scale=1" >
8
+
9
+ <link href='/heel_css/pico.min.css' rel='stylesheet' type='text/css'>
11
10
  </head>
12
11
  <body>
13
- <div role='wrapper'>
14
- <header>
15
- <h1>Index of <%= base_uri %></h1>
16
- </header>
17
- <div role='content'>
12
+ <main class="container">
13
+ <h1>Index of: <%= base_uri %></h1>
14
+
15
+ <figure>
18
16
  <table>
19
17
  <thead>
20
18
  <tr>
@@ -24,33 +22,45 @@
24
22
  <th>Type</th>
25
23
  </tr>
26
24
  </thead>
25
+
27
26
  <tbody>
28
27
  <% entries.each do |entry| %>
29
- <tr>
30
- <td>
31
- <a href="<%= "#{base_uri.chomp('/')}/#{entry.link}" %>">
32
- <% if entry.icon_url then %>
33
- <img src="<%= entry.icon_url %>" width="16" height="16" alt="icon for type <%= entry.content_type %>" />
28
+ <tr>
29
+ <td>
30
+ <a href="<%= "#{base_uri.chomp('/')}/#{entry.link}" %>">
31
+ <% if entry.icon_url then %>
32
+ <img src="<%= entry.icon_url %>" width="32" height="32" alt="icon for type <%= entry.content_type %>">
33
+ <% end %>
34
+ <%= entry.name %>
35
+ </a>
36
+ <% if highlighting? && (entry.content_type != 'Directory') then %>
37
+ (<a download="<%= entry.name %>" href="<%= "#{base_uri.chomp('/')}/#{entry.link}?highlighting=false" %>">download</a>)
34
38
  <% end %>
35
- <%= entry.name %>
36
- </a>
37
- <% if highlighting? and entry.content_type != 'Directory' then %>
38
- (<a href="<%= "#{base_uri.chomp('/')}/#{entry.link}?highlighting=false" %>">download</a>)
39
- <% end %>
40
- </td>
41
- <td><%= entry.last_modified %></td>
42
- <td class="<%= entry.content_type == "Directory" ? 'c' : 'n' %>" ><%= entry.size %></td>
43
- <td><%= entry.content_type %></td>
44
- </tr>
39
+ </td>
40
+ <td><%= entry.last_modified %></td>
41
+ <td class="<%= entry.content_type == "Directory" ? 'c' : 'n' %>" ><%= entry.size %></td>
42
+ <td><%= entry.content_type %></td>
43
+ </tr>
45
44
  <% end %>
46
45
  </tbody>
46
+
47
+ <tfoot>
48
+ <tr>
49
+ <th>Name</th>
50
+ <th>Last Modified</th>
51
+ <th>Size</th>
52
+ <th>Type</th>
53
+ </tr>
54
+ </tfoot>
47
55
  </table>
48
- </div>
49
- <footer>
56
+ </figure>
57
+
58
+ <footer class="container">
59
+ <hr>
50
60
  <p>
51
- <a href="<%= homepage %>">heel</a> v<%= Heel::VERSION %>
61
+ <small><a href="<%= homepage %>" target="_blank">heel</a> v<%= Heel::VERSION %></small>
52
62
  </p>
53
63
  </footer>
54
- </div>
64
+ </main>
55
65
  </body>
56
66
  </html>
@@ -87,7 +87,7 @@ module Heel
87
87
  entries << entry_data
88
88
  end
89
89
 
90
- template_vars = TemplateVars.new( :base_uri => req.path_info )
90
+ template_vars = TemplateVars.new( :base_uri => req.path_info, :highlighting => highlighting? )
91
91
  template_vars.entries = entries.sort_by { |e| e.link }
92
92
  template_vars.homepage = Heel::Configuration::HOMEPAGE
93
93
 
data/lib/heel/mime_map.rb CHANGED
@@ -15,22 +15,19 @@ module Heel
15
15
  class << self
16
16
  def icons_by_mime_type
17
17
  @icons_by_mime_type ||= {
18
- "text/plain" => "page_white_text.png",
19
- "image" => "picture.png",
20
- "pdf" => "page_white_acrobat.png",
21
- "xml" => "page_white_code.png",
22
- "compress" => "compress.png",
23
- "gzip" => "compress.png",
24
- "zip" => "compress.png",
25
- "application/xhtml+xml" => "xhtml.png",
26
- "application/word" => "page_word.png",
27
- "application/excel" => "page_excel.png",
28
- "application/powerpoint" => "page_white_powerpoint.png",
29
- "text/html" => "html.png",
30
- "application" => "application.png",
31
- "text" => "page_white_text.png",
32
- :directory => "folder.png",
33
- :default => "page_white.png",
18
+ "text/plain" => "file.svg",
19
+ "image" => "image.svg",
20
+ "pdf" => "pdf.svg",
21
+ "x-zip-compressed" => "zip.svg",
22
+ "x-gtar" => "zip.svg",
23
+ "x-gzip" => "zip.svg",
24
+ "application/x-word" => "word.svg",
25
+ "application/powerpoint" => "presentation.svg",
26
+ "text/html" => "html5.svg",
27
+ "application" => "file.svg",
28
+ "text" => "file.svg",
29
+ :directory => "folder-alt.svg",
30
+ :default => "file.svg",
34
31
  }
35
32
  end
36
33
 
data/lib/heel/rackapp.rb CHANGED
@@ -5,8 +5,7 @@
5
5
 
6
6
  require 'rack'
7
7
  require 'rack/utils'
8
- require 'coderay'
9
- require 'coderay/helpers/file_type'
8
+ require 'rouge'
10
9
  require 'time'
11
10
 
12
11
  module Heel
@@ -63,7 +62,7 @@ module Heel
63
62
  def directory_index_response(req)
64
63
  response = ::Rack::Response.new
65
64
  dir_index = File.join(req.request_path, directory_index_html)
66
- if File.file?(dir_index) and File.readable?(dir_index) then
65
+ if File.file?(dir_index) && File.readable?(dir_index) then
67
66
  response['Content-Type'] = mime_map.mime_type_of(dir_index).to_s
68
67
  response.write( File.read( dir_index ) )
69
68
  elsif directory_listing_allowed? then
@@ -76,44 +75,64 @@ module Heel
76
75
  return response.finish
77
76
  end
78
77
 
78
+ def slurp_path(path)
79
+ source = nil
80
+ File.open(path, 'rt:bom|utf-8') do |f|
81
+ source = f.read
82
+ end
83
+ return source
84
+ end
85
+
86
+ def highlight_contents(req, file_type)
87
+ source = slurp_path(req.request_path)
88
+ # only do a rouge type check if we are going to use rouge in the
89
+ # response
90
+ lexer = ::Rouge::Lexer.guess(
91
+ filename: req.request_path,
92
+ source: source,
93
+ mime_type: file_type
94
+ )
95
+
96
+ formatter = ::Rouge::Formatters::HTMLPygments.new(::Rouge::Formatters::HTML.new)
97
+ content = formatter.format(lexer.lex(source))
98
+
99
+ body = <<-EOM
100
+ <html>
101
+ <head>
102
+ <title>#{req.path_info}</title>
103
+ <link href='/heel_css/syntax-highlighting.css' rel='stylesheet' type='text/css'>
104
+ </head>
105
+ <body>
106
+ #{content}
107
+ </body>
108
+ </html>
109
+ EOM
110
+
111
+ return body
112
+ end
79
113
 
80
- # formulate a file content response. Possibly a coderay highlighted file if
81
- # it is a type that code ray can deal with and the file is not already an
114
+
115
+ # formulate a file content response. Possibly a rouge highlighted file if
116
+ # it is a type that rouge can deal with and the file is not already an
82
117
  # html file.
83
118
  #
84
119
  def file_response(req)
85
120
  response = ::Rack::Response.new
86
-
87
121
  response['Last-Modified'] = req.stat.mtime.rfc822
122
+ file_type = mime_map.mime_type_of(req.request_path)
88
123
 
89
- if highlighting? and req.highlighting? then
90
- # only do a coderay type check if we are going to use coderay in the
91
- # response
92
- code_ray_type = CodeRay::FileType[req.request_path, true]
93
- if code_ray_type and (code_ray_type != :html) then
94
- body = <<-EOM
95
- <html>
96
- <head>
97
- <title>#{req.path_info}</title>
98
- <!-- CodeRay syntax highlighting CSS -->
99
- <link rel="stylesheet" href="/heel_css/coderay-alpha.css" type="text/css" />
100
- </head>
101
- <body>
102
- #{CodeRay.scan_file(req.request_path,:auto).html({ :wrap => :div, :line_numbers => :inline })}
103
- </body>
104
- </html>
105
- EOM
106
- response['Content-Type'] = 'text/html'
107
- response['Content-Length'] = body.length.to_s
124
+ if highlighting? and req.highlighting? then
125
+ if file_type && (file_type != 'text/html') then
126
+ body = highlight_contents(req, file_type)
127
+ response['Content-Type'] = 'text/html'
128
+ response['Content-Length'] = body.length.to_s
108
129
  response.write( body )
109
130
  return response.finish
110
131
  end
111
132
  end
112
133
 
113
134
  # fall through to a default file return
114
-
115
- file_type = mime_map.mime_type_of(req.request_path)
116
- response['Content-Type'] = file_type.to_s
135
+ response['Content-Type'] = file_type.to_s
117
136
  File.open( req.request_path ) do |f|
118
137
  while p = f.read( 8192 ) do
119
138
  response.write( p )
data/lib/heel/server.rb CHANGED
@@ -7,6 +7,7 @@ require 'ostruct'
7
7
  require 'launchy'
8
8
  require 'fileutils'
9
9
  require 'heel/rackapp'
10
+ require 'rackup'
10
11
  require 'puma'
11
12
 
12
13
  module Heel
@@ -56,7 +57,7 @@ module Heel
56
57
  defaults.port = 4331
57
58
  defaults.document_root = Dir.pwd
58
59
  defaults.daemonize = false
59
- defaults.highlighting = false
60
+ defaults.highlighting = true
60
61
  defaults.kill = false
61
62
  defaults.launch_browser = true
62
63
  return defaults
@@ -228,17 +229,17 @@ module Heel
228
229
  run app
229
230
  end
230
231
  map "/heel_css" do
231
- run Rack::File.new(Heel::Configuration.data_path( "css" ))
232
+ run Rack::Files.new(Heel::Configuration.data_path( "css" ))
232
233
  end
233
234
  map "/heel_icons" do
234
- run Rack::File.new(Heel::Configuration.data_path("famfamfam", "icons"))
235
+ run Rack::Files.new(Heel::Configuration.data_path("lineicons"))
235
236
  end
236
237
  }
237
238
  return stack.to_app
238
239
  end
239
240
 
240
241
  # If we are daemonizing the fork and wait for the child to launch the server
241
- # If we are not daemonizing, throw the Rack::Server in a background thread
242
+ # If we are not daemonizing, throw the ::Rackup::Server in a background thread
242
243
  def start_server
243
244
  if options.daemonize then
244
245
  start_background_server
@@ -252,14 +253,14 @@ module Heel
252
253
  if cpid = fork then
253
254
  Process.waitpid( cpid )
254
255
  else
255
- server = Rack::Server.new( server_options )
256
+ server = ::Rackup::Server.new( server_options )
256
257
  server.start
257
258
  end
258
259
  end
259
260
 
260
261
  def start_foreground_server
261
262
  Thread.new {
262
- server = Rack::Server.new( server_options )
263
+ server = ::Rackup::Server.new( server_options )
263
264
  server.start
264
265
  }
265
266
  end
@@ -4,5 +4,9 @@ module Heel
4
4
  def binding_for_template()
5
5
  return binding()
6
6
  end
7
+
8
+ def highlighting?
9
+ self.highlighting
10
+ end
7
11
  end
8
12
  end
data/lib/heel.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  #++
5
5
 
6
6
  module Heel
7
- VERSION = '3.2.1'
7
+ VERSION = '4.0.1'
8
8
  end
9
9
 
10
10
  require 'heel/configuration'
@@ -6,19 +6,23 @@ describe Heel::Configuration do
6
6
  @proj_root = Pathname.new( __FILE__ ).parent.parent
7
7
  end
8
8
  it "finds files relative to root of gem" do
9
- Heel::Configuration.root_dir.must_equal @proj_root.expand_path.to_s + File::SEPARATOR
9
+ root_dir = Heel::Configuration.root_dir
10
+ _(root_dir).must_equal @proj_root.expand_path.to_s + File::SEPARATOR
10
11
  end
11
12
 
12
13
  it "finds files in the config dir of the project" do
13
- Heel::Configuration.config_path('config.rb').must_equal @proj_root.join("config", "config.rb").to_s
14
+ config_rb = Heel::Configuration.config_path('config.rb')
15
+ _(config_rb).must_equal @proj_root.join("config", "config.rb").to_s
14
16
  end
15
-
17
+
16
18
  it "finds files in the data dir of the project" do
17
- Heel::Configuration.data_path('famfamfam', 'icons').must_equal @proj_root.join( "data", "famfamfam", "icons" ).to_s
19
+ icons = Heel::Configuration.data_path('lineicons', 'icons')
20
+ _(icons).must_equal @proj_root.join( "data", "lineicons", "icons" ).to_s
18
21
  end
19
-
22
+
20
23
  it "finds files in the lib dir of the project" do
21
- Heel::Configuration.lib_path('heel.rb').must_equal @proj_root.join("lib", "heel.rb").to_s
24
+ heel_rb = Heel::Configuration.lib_path('heel.rb')
25
+ _(heel_rb).must_equal @proj_root.join("lib", "heel.rb").to_s
22
26
  end
23
27
 
24
28
  end
@@ -7,41 +7,44 @@ describe Heel::DirectoryIndexer do
7
7
 
8
8
  it "should ignore .htaccess files" do
9
9
  @indexer.options[:ignore_globs] = %w( *~ .htaccess . )
10
- @indexer.should_ignore?(".htaccess").must_equal true
10
+ _(@indexer.should_ignore?(".htaccess")).must_equal true
11
11
  end
12
12
 
13
13
  it "should not ignore .html files " do
14
14
  @indexer.options[:ignore_globs] = %w( *~ .htaccess . )
15
- @indexer.should_ignore?("something.html").must_equal false
15
+ _(@indexer.should_ignore?("something.html")).must_equal false
16
16
  end
17
17
 
18
18
  it "can tell if highlighting is to be performed" do
19
- @indexer.must_be :highlighting?
19
+ _(@indexer).must_be :highlighting?
20
20
  end
21
21
 
22
22
  it "knows if the template should be reloaded on changes" do
23
- @indexer.reload_on_template_change?.must_equal false
23
+ _(@indexer.reload_on_template_change?).must_equal false
24
24
  end
25
25
 
26
26
  it "uses icons" do
27
- @indexer.using_icons?.must_equal false
27
+ _(@indexer.using_icons?).must_equal false
28
28
  end
29
29
 
30
30
  it "uses a mime map" do
31
- @indexer.mime_map.must_be_instance_of(Heel::MimeMap)
31
+ _(@indexer.mime_map).must_be_instance_of(Heel::MimeMap)
32
32
  end
33
33
 
34
- [ { :ext => 'svg', :type => 'image/svg+xml' },
34
+ [
35
+ { :ext => 'svg', :type => 'image/svg+xml' },
35
36
  { :ext => 'flv', :type => 'video/x-flv' },
36
- { :ext => 'swf', :type => 'application/x-shockwave-flash' } ].each do |m|
37
+ { :ext => 'rb', :type => 'text/plain' },
38
+ { :ext => 'rhtml', :type => 'text/plain' }
39
+ ].each do |m|
37
40
  it "finds #{m[:ext]} extension in the map as #{m[:type]}" do
38
- @indexer.mime_map.mime_type_of( "test.#{m[:ext]}" ).must_equal m[:type]
41
+ _(@indexer.mime_map.mime_type_of( "test.#{m[:ext]}" )).must_equal m[:type]
39
42
  end
40
43
  end
41
44
 
42
- %w[ md markdown rdoc rb rhtml ].each do |ext|
45
+ %w[ md markdown rdoc ].each do |ext|
43
46
  it "finds #{ext} in the map as text/plain" do
44
- @indexer.mime_map.mime_type_of( "test.#{ext}" ).must_equal "text/plain"
47
+ _(@indexer.mime_map.mime_type_of( "test.#{ext}" )).must_equal "text/plain"
45
48
  end
46
49
  end
47
50
  end
data/spec/rackapp_spec.rb CHANGED
@@ -10,34 +10,34 @@ describe Heel::RackApp do
10
10
 
11
11
  it "should return the a listing for the currrent directory" do
12
12
  res = @request.get("/")
13
- res.must_be :ok?
14
- res['Content-Type'].must_equal "text/html"
15
- res.body.must_match( /Rakefile/ )
13
+ _(res).must_be :ok?
14
+ _(res['Content-Type']).must_equal "text/html"
15
+ _(res.body).must_match( /Rakefile/ )
16
16
  end
17
17
 
18
18
  it 'should highlight a ruby file' do
19
19
  res = @request.get("/lib/heel.rb")
20
- res.must_be :ok?
21
- res['Content-Type'].must_equal "text/html"
22
- res.body.must_match( /class="CodeRay"/ )
20
+ _(res).must_be :ok?
21
+ _(res['Content-Type']).must_equal "text/html"
22
+ _(res.body).must_match( /class="highlight"/ )
23
23
  end
24
24
 
25
25
  it "should not highlight a ruby file if told not to" do
26
26
  res = @request.get("/lib/heel.rb?highlighting=off")
27
- res.must_be :ok?
28
- res.body.size.must_equal File.size("lib/heel.rb")
29
- res['Content-Type'].must_equal "text/plain"
27
+ _(res).must_be :ok?
28
+ _(res.body.size).must_equal File.size("lib/heel.rb")
29
+ _(res['Content-Type']).must_equal "text/plain"
30
30
  end
31
31
 
32
32
  it "should return a 405 if given a non-GET request" do
33
33
  res = @request.post("/")
34
- res.wont_be :ok?
35
- res.status.must_equal 405
34
+ _(res).wont_be :ok?
35
+ _(res.status).must_equal 405
36
36
  end
37
37
 
38
38
  it "should return a 403 if accessing an invalid location" do
39
39
  res = @request.get("/../../../../etc/passwd")
40
- res.wont_be :ok?
41
- res.status.must_equal 403
40
+ _(res).wont_be :ok?
41
+ _(res.status).must_equal 403
42
42
  end
43
43
  end
data/spec/server_spec.rb CHANGED
@@ -19,8 +19,8 @@ describe Heel::Server do
19
19
  begin
20
20
  server.run
21
21
  rescue SystemExit => se
22
- se.status.must_equal 0
23
- @stdout.string.must_match( /version #{Heel::VERSION}/ )
22
+ _(se.status).must_equal 0
23
+ _(@stdout.string).must_match( /version #{Heel::VERSION}/ )
24
24
  end
25
25
  end
26
26
 
@@ -30,8 +30,8 @@ describe Heel::Server do
30
30
  begin
31
31
  server.run
32
32
  rescue SystemExit => se
33
- se.status.must_equal 0
34
- @stdout.string.must_match( /Usage/m )
33
+ _(se.status).must_equal 0
34
+ _(@stdout.string).must_match( /Usage/m )
35
35
  end
36
36
  end
37
37
 
@@ -41,8 +41,8 @@ describe Heel::Server do
41
41
  begin
42
42
  server.run
43
43
  rescue SystemExit => se
44
- se.status.must_equal 1
45
- @stdout.string.must_match( /Try .*--help/m )
44
+ _(se.status).must_equal 1
45
+ _(@stdout.string).must_match( /Try .*--help/m )
46
46
  end
47
47
  end
48
48
 
@@ -52,34 +52,34 @@ describe Heel::Server do
52
52
  begin
53
53
  server.run
54
54
  rescue SystemExit => se
55
- se.status.must_equal 1
56
- @stdout.string.must_match( /Try .*--help/m )
55
+ _(se.status).must_equal 1
56
+ _(@stdout.string).must_match( /Try .*--help/m )
57
57
  end
58
58
  end
59
59
 
60
60
  it "should allow port and address to be set" do
61
61
  server = Heel::Server.new(%w[--port 4242 --address 192.168.1.1])
62
62
  server.merge_options
63
- server.options.address.must_equal "192.168.1.1"
64
- server.options.port.must_equal 4242
63
+ _(server.options.address).must_equal "192.168.1.1"
64
+ _(server.options.port).must_equal 4242
65
65
  end
66
66
 
67
67
  it "should allow the highlighting option to be set" do
68
- server = Heel::Server.new(%w[--highlighting])
68
+ server = Heel::Server.new(%w[--no-highlighting])
69
69
  server.merge_options
70
- server.options.highlighting.must_equal true
70
+ _(server.options.highlighting).must_equal false
71
71
  end
72
72
 
73
- it "should have highlighting off as a default" do
73
+ it "should have highlighting on as a default" do
74
74
  server = Heel::Server.new
75
75
  server.merge_options
76
- server.options.highlighting.must_equal false
76
+ _(server.options.highlighting).must_equal true
77
77
  end
78
78
 
79
79
  it "should set no-launch-browser option" do
80
80
  server = Heel::Server.new(%w[--no-launch-browser])
81
81
  server.merge_options
82
- server.options.launch_browser.must_equal false
82
+ _(server.options.launch_browser).must_equal false
83
83
  end
84
84
 
85
85
  it "should attempt to kill the process" do
@@ -90,18 +90,18 @@ describe Heel::Server do
90
90
  server.run
91
91
  violated("Should have thrown SystemExit")
92
92
  rescue SystemExit => se
93
- se.status.must_equal 0
94
- @stdout.string.must_match( /Done/m )
93
+ _(se.status).must_equal 0
94
+ _(@stdout.string).must_match( /Done/m )
95
95
  end
96
96
  end
97
97
 
98
98
  it "should setup a heel directory" do
99
99
  server = Heel::Server.new(%w[--daemonize])
100
100
  server.set_io(@stdin,@stdout)
101
- File.directory?(server.default_directory).must_equal false
101
+ _(File.directory?(server.default_directory)).must_equal false
102
102
  server.setup_heel_dir
103
- File.directory?(server.default_directory).must_equal true
104
- @stdout.string.must_match( /Created/m )
103
+ _(File.directory?(server.default_directory)).must_equal true
104
+ _(@stdout.string).must_match( /Created/m )
105
105
  end
106
106
 
107
107
  it "should send a signal to a pid" do
@@ -114,20 +114,20 @@ describe Heel::Server do
114
114
  server.run
115
115
  violated("Should have exited")
116
116
  rescue SystemExit => se
117
- se.status.must_equal 0
118
- @stdout.string.must_match( /Sending TERM to process -42/m )
117
+ _(se.status).must_equal 0
118
+ _(@stdout.string).must_match( /Sending TERM to process -42/m )
119
119
  end
120
120
  end
121
121
 
122
122
  it "records the port of the server process in the pid filename" do
123
123
  server = Heel::Server.new( %w[ --port 4222 ] )
124
124
  server.merge_options
125
- File.basename( server.pid_file ).must_equal( "heel.4222.pid" )
125
+ _(File.basename( server.pid_file )).must_equal( "heel.4222.pid" )
126
126
  end
127
127
 
128
128
  it "records the port of the server process in the log filename" do
129
129
  server = Heel::Server.new( %w[ --port 4222 ] )
130
130
  server.merge_options
131
- File.basename( server.log_file ).must_equal( "heel.4222.log" )
131
+ _(File.basename( server.log_file )).must_equal( "heel.4222.log" )
132
132
  end
133
133
  end