heel 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGES → HISTORY} +3 -3
- data/LICENSE +1 -1
- data/README +28 -26
- data/bin/heel +5 -1
- data/data/error.rhtml +1 -1
- data/data/listing.rhtml +2 -2
- data/gemspec.rb +42 -0
- data/lib/heel.rb +18 -13
- data/lib/heel/configuration.rb +64 -0
- data/lib/heel/directory_indexer.rb +114 -0
- data/lib/heel/error_response.rb +43 -0
- data/lib/heel/logger.rb +42 -0
- data/lib/heel/mime_map.rb +87 -0
- data/lib/heel/rackapp.rb +142 -0
- data/lib/heel/request.rb +66 -0
- data/lib/heel/server.rb +253 -219
- data/lib/heel/version.rb +21 -16
- data/spec/configuration_spec.rb +20 -0
- data/spec/directory_indexer_spec.rb +34 -0
- data/spec/rackapp_spec.rb +43 -0
- data/spec/server_spec.rb +107 -108
- data/tasks/announce.rake +42 -0
- data/tasks/config.rb +103 -0
- data/tasks/distribution.rake +52 -0
- data/tasks/documentation.rake +35 -0
- data/tasks/rspec.rb +33 -0
- data/tasks/rubyforge.rb +52 -0
- data/tasks/utils.rb +85 -0
- metadata +52 -44
- data/lib/heel/dir_handler.rb +0 -310
- data/lib/heel/error_handler.rb +0 -30
- data/lib/heel/gemspec.rb +0 -56
- data/lib/heel/specification.rb +0 -128
- data/spec/dir_handler_spec.rb +0 -128
- data/spec/error_handler_spec.rb +0 -29
data/lib/heel/version.rb
CHANGED
@@ -1,21 +1,26 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2007, 2008 Jeremy Hinegardner
|
3
|
+
# All rights reserved. Licensed under the BSD license. See LICENSE for details
|
4
|
+
#++
|
5
|
+
|
1
6
|
module Heel
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
7
|
+
module Version
|
8
|
+
MAJOR = 1
|
9
|
+
MINOR = 0
|
10
|
+
BUILD = 0
|
11
|
+
|
12
|
+
def to_a
|
13
|
+
[MAJOR, MINOR, BUILD]
|
14
|
+
end
|
6
15
|
|
7
|
-
|
8
|
-
|
9
|
-
|
16
|
+
def to_s
|
17
|
+
to_a.join(".")
|
18
|
+
end
|
19
|
+
module_function :to_a
|
20
|
+
module_function :to_s
|
10
21
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
module_function :to_a
|
15
|
-
module_function :to_s
|
16
|
-
|
17
|
-
STRING = Version.to_s
|
18
|
-
end
|
19
|
-
VERSION = Version.to_s
|
22
|
+
STRING = Version.to_s
|
23
|
+
end
|
24
|
+
VERSION = Version.to_s
|
20
25
|
end
|
21
26
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Heel::Configuration do
|
4
|
+
it "finds files relative to root of gem" do
|
5
|
+
Heel::Configuration.root_dir.should == File.expand_path(File.join(File.dirname(__FILE__), "..")) + "/"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "finds files in the config dir of the project" do
|
9
|
+
Heel::Configuration.config_path('config.rb').should == File.expand_path(File.join(File.dirname(__FILE__), "..", "config", "config.rb"))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "finds files in the data dir of the project" do
|
13
|
+
Heel::Configuration.data_path('famfamfam', 'icons').should == File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "famfamfam", "icons"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "finds files in the lib dir of the project" do
|
17
|
+
Heel::Configuration.lib_path('heel.rb').should == File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "heel.rb"))
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Heel::DirectoryIndexer do
|
4
|
+
before(:each) do
|
5
|
+
@indexer = Heel::DirectoryIndexer.new(Heel::Configuration.data_path("listing.rhtml"), { :highlighting => true })
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should ignore .htaccess files" do
|
9
|
+
@indexer.options[:ignore_globs] = %w( *~ .htaccess . )
|
10
|
+
@indexer.should_ignore?(".htaccess").should == true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should not ignore .html files " do
|
14
|
+
@indexer.options[:ignore_globs] = %w( *~ .htaccess . )
|
15
|
+
@indexer.should_ignore?("something.html").should == false
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can tell if highlighting is to be performed" do
|
19
|
+
@indexer.should be_highlighting
|
20
|
+
end
|
21
|
+
|
22
|
+
it "knows if the template should be reloaded on changes" do
|
23
|
+
@indexer.should_not be_reload_on_template_change
|
24
|
+
end
|
25
|
+
|
26
|
+
it "may or maynot use icons" do
|
27
|
+
@indexer.should_not be_using_icons
|
28
|
+
end
|
29
|
+
|
30
|
+
it "uses a mime map" do
|
31
|
+
@indexer.mime_map.should be_instance_of(Heel::MimeMap)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'rack/mock'
|
3
|
+
require 'heel/rackapp'
|
4
|
+
|
5
|
+
describe Heel::RackApp do
|
6
|
+
before(:each) do
|
7
|
+
@app = Heel::RackApp.new( { :highlighting => 'true' } )
|
8
|
+
@request = Rack::MockRequest.new(@app)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return the a listing for the currrent directory" do
|
12
|
+
res = @request.get("/")
|
13
|
+
res.should be_ok
|
14
|
+
res['Content-Type'].should == "text/html"
|
15
|
+
res.body.should =~ /Rakefile/
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should highlight a ruby file' do
|
19
|
+
res = @request.get("/gemspec.rb")
|
20
|
+
res.should be_ok
|
21
|
+
res['Content-Type'].should == "text/html"
|
22
|
+
res.body.should =~ /class="CodeRay"/
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not highlight a ruby file if told not to" do
|
26
|
+
res = @request.get("/gemspec.rb?highlighting=off")
|
27
|
+
res.should be_ok
|
28
|
+
res.body.size.should == File.size("gemspec.rb")
|
29
|
+
res['Content-Type'].should == "text/plain"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return a 405 if given a non-GET request" do
|
33
|
+
res = @request.post("/")
|
34
|
+
res.should_not be_ok
|
35
|
+
res.status.should == 405
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return a 403 if accessing an invalid location" do
|
39
|
+
res = @request.get("/../../../../etc/passwd")
|
40
|
+
res.should_not be_ok
|
41
|
+
res.status.should == 403
|
42
|
+
end
|
43
|
+
end
|
data/spec/server_spec.rb
CHANGED
@@ -1,115 +1,114 @@
|
|
1
|
-
require
|
1
|
+
require "spec/spec_helper"
|
2
2
|
describe Heel::Server do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
before(:each) do
|
4
|
+
@stdin = StringIO.new
|
5
|
+
@stdout = StringIO.new
|
6
|
+
@stderr = StringIO.new
|
7
|
+
ENV["HEEL_DEFAULT_DIRECTORY"] = "/tmp/heel"
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ENV.delete("HEEL_DEFAULT_DIRECTORY")
|
12
|
+
FileUtils.rm_rf "/tmp/heel"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should output the version when invoked with --version" do
|
16
|
+
server = Heel::Server.new(["--version"])
|
17
|
+
server.set_io(@stdin, @stdout)
|
18
|
+
begin
|
19
|
+
server.run
|
20
|
+
rescue SystemExit => se
|
21
|
+
se.status.should == 0
|
22
|
+
@stdout.string.should =~ /version #{Heel::VERSION}/
|
8
23
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should output the Usage when invoked with --help" do
|
27
|
+
server = Heel::Server.new(["--help"])
|
28
|
+
server.set_io(@stdin, @stdout)
|
29
|
+
begin
|
30
|
+
server.run
|
31
|
+
rescue SystemExit => se
|
32
|
+
se.status.should == 0
|
33
|
+
@stdout.string.should =~ /Usage/m
|
13
34
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have an error when invoked with invalid parameters" do
|
38
|
+
server = Heel::Server.new(["--junk"])
|
39
|
+
server.set_io(@stdin,@stdout)
|
40
|
+
begin
|
41
|
+
server.run
|
42
|
+
rescue SystemExit => se
|
43
|
+
se.status.should == 1
|
44
|
+
@stdout.string.should =~ /Try .*--help/m
|
24
45
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should raise print an error if the directory to serve does not exist" do
|
49
|
+
server = Heel::Server.new(%w[--root /not/valid])
|
50
|
+
server.set_io(@stdin,@stdout)
|
51
|
+
begin
|
52
|
+
server.run
|
53
|
+
rescue SystemExit => se
|
54
|
+
se.status.should == 1
|
55
|
+
@stdout.string.should =~ /Try .*--help/m
|
35
56
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should allow port and address to be set" do
|
60
|
+
server = Heel::Server.new(%w[--port 4242 --address 192.168.1.1])
|
61
|
+
server.merge_options
|
62
|
+
server.options.address.should == "192.168.1.1"
|
63
|
+
server.options.port.should == 4242
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow the highlighting option to be unset" do
|
67
|
+
server = Heel::Server.new(%w[--no-highlighting])
|
68
|
+
server.merge_options
|
69
|
+
server.options.highlighting.should == false
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should set no-launch-browser option and kill option" do
|
73
|
+
server = Heel::Server.new(%w[--no-launch-browser])
|
74
|
+
server.merge_options
|
75
|
+
server.options.launch_browser.should == false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should attempt to kill the process" do
|
79
|
+
server = Heel::Server.new(%w[--kill])
|
80
|
+
server.set_io(@stdin,@stdout)
|
81
|
+
|
82
|
+
begin
|
83
|
+
server.run
|
84
|
+
violated("Should have thrown SystemExit")
|
85
|
+
rescue SystemExit => se
|
86
|
+
se.status.should == 0
|
87
|
+
@stdout.string.should =~ /Done/m
|
46
88
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should setup a heel directory" do
|
92
|
+
server = Heel::Server.new(%w[--daemonize])
|
93
|
+
server.set_io(@stdin,@stdout)
|
94
|
+
File.directory?(server.default_directory).should == false
|
95
|
+
server.setup_heel_dir
|
96
|
+
File.directory?(server.default_directory).should == true
|
97
|
+
@stdout.string.should =~ /Created/m
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should send a signal to a pid" do
|
101
|
+
server = Heel::Server.new(%w[--kil])
|
102
|
+
server.set_io(@stdin,@stdout)
|
103
|
+
server.setup_heel_dir
|
104
|
+
|
105
|
+
File.open(server.pid_file,"w+") { |f| f.write("-42") }
|
106
|
+
begin
|
107
|
+
server.run
|
108
|
+
violated("Should have exited")
|
109
|
+
rescue SystemExit => se
|
110
|
+
se.status.should == 0
|
111
|
+
@stdout.string.should =~ /Sending TERM to process -42/m
|
57
112
|
end
|
58
|
-
|
59
|
-
|
60
|
-
server = Heel::Server.new(%w[--port 4242 --address 192.168.1.1])
|
61
|
-
server.merge_options
|
62
|
-
server.options.address.should == "192.168.1.1"
|
63
|
-
server.options.port.should == 4242
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should allow the highlighting option to be unset" do
|
67
|
-
server = Heel::Server.new(%w[--no-highlighting])
|
68
|
-
server.merge_options
|
69
|
-
server.options.highlighting.should == false
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should set no-launch-browser option and kill option" do
|
73
|
-
server = Heel::Server.new(%w[--no-launch-browser])
|
74
|
-
server.merge_options
|
75
|
-
server.options.launch_browser.should == false
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should attempt to kill the process" do
|
79
|
-
server = Heel::Server.new(%w[--kill])
|
80
|
-
server.set_io(@stdin,@stdout)
|
81
|
-
|
82
|
-
begin
|
83
|
-
server.run
|
84
|
-
violated("Should have thrown SystemExit")
|
85
|
-
rescue SystemExit => se
|
86
|
-
se.status.should == 0
|
87
|
-
@stdout.string.should =~ /Done/m
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should setup a heel directory" do
|
92
|
-
server = Heel::Server.new(%w[--daemonize])
|
93
|
-
server.set_io(@stdin,@stdout)
|
94
|
-
File.directory?(server.default_directory).should == false
|
95
|
-
server.setup_heel_dir
|
96
|
-
File.directory?(server.default_directory).should == true
|
97
|
-
@stdout.string.should =~ /Created/m
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should send a signal to a pid" do
|
101
|
-
server = Heel::Server.new(%w[--kil])
|
102
|
-
server.set_io(@stdin,@stdout)
|
103
|
-
server.setup_heel_dir
|
104
|
-
|
105
|
-
File.open(server.pid_file,"w+") { |f| f.write("-42") }
|
106
|
-
begin
|
107
|
-
server.run
|
108
|
-
violated("Should have exited")
|
109
|
-
rescue SystemExit => se
|
110
|
-
se.status.should == 0
|
111
|
-
@stdout.string.should =~ /Sending TERM to process -42/m
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
113
|
+
end
|
114
|
+
end
|
data/tasks/announce.rake
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2007, 2008 Jeremy Hinegardner
|
3
|
+
# All rights reserved. Licensed under the BSD license. See LICENSE for details
|
4
|
+
#++
|
5
|
+
|
6
|
+
require 'tasks/config'
|
7
|
+
#-------------------------------------------------------------------------------
|
8
|
+
# announcement methods
|
9
|
+
#-------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
proj_config = Configuration.for('project')
|
12
|
+
namespace :announce do
|
13
|
+
desc "create email for ruby-talk"
|
14
|
+
task :email do
|
15
|
+
info = Utils.announcement
|
16
|
+
|
17
|
+
File.open("email.txt", "w") do |mail|
|
18
|
+
mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
|
19
|
+
mail.puts "To: ruby-talk@ruby-lang.org"
|
20
|
+
mail.puts "Date: #{Time.now.rfc2822}"
|
21
|
+
mail.puts "Subject: [ANN] #{info[:subject]}"
|
22
|
+
mail.puts
|
23
|
+
mail.puts info[:title]
|
24
|
+
mail.puts
|
25
|
+
mail.puts info[:urls]
|
26
|
+
mail.puts
|
27
|
+
mail.puts info[:description]
|
28
|
+
mail.puts
|
29
|
+
mail.puts "{{ Release notes for Version #{Heel::VERSION} }}"
|
30
|
+
mail.puts
|
31
|
+
mail.puts info[:release_notes]
|
32
|
+
mail.puts
|
33
|
+
mail.puts info[:urls]
|
34
|
+
end
|
35
|
+
puts "Created the following as email.txt:"
|
36
|
+
puts "-" * 72
|
37
|
+
puts File.read("email.txt")
|
38
|
+
puts "-" * 72
|
39
|
+
end
|
40
|
+
|
41
|
+
CLOBBER << "email.txt"
|
42
|
+
end
|
data/tasks/config.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'configuration'
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'heel'
|
5
|
+
require 'heel/configuration'
|
6
|
+
require 'heel/version'
|
7
|
+
|
8
|
+
require 'tasks/utils'
|
9
|
+
|
10
|
+
#-----------------------------------------------------------------------
|
11
|
+
# General project configuration
|
12
|
+
#-----------------------------------------------------------------------
|
13
|
+
Configuration.for('project') {
|
14
|
+
name Heel.to_s.downcase
|
15
|
+
version Heel::VERSION
|
16
|
+
author "Jeremy Hinegardner"
|
17
|
+
email "jeremy at hinegardner dot org"
|
18
|
+
homepage Heel::Configuration::HOMEPAGE
|
19
|
+
description Utils.section_of("README", "description")
|
20
|
+
summary description.split(".").first
|
21
|
+
history "HISTORY"
|
22
|
+
license "LICENSE"
|
23
|
+
readme "README"
|
24
|
+
}
|
25
|
+
|
26
|
+
#-----------------------------------------------------------------------
|
27
|
+
# Packaging
|
28
|
+
#-----------------------------------------------------------------------
|
29
|
+
Configuration.for('packaging') {
|
30
|
+
# files in the project
|
31
|
+
proj_conf = Configuration.for('project')
|
32
|
+
files {
|
33
|
+
bin FileList["bin/*"]
|
34
|
+
lib FileList["lib/**/*.rb"]
|
35
|
+
test FileList["spec/**/*.rb"]
|
36
|
+
data FileList["data/**/*"]
|
37
|
+
tasks FileList["tasks/**/*.r{ake,b}"]
|
38
|
+
rdoc FileList[proj_conf.readme, proj_conf.history,
|
39
|
+
proj_conf.license] + lib
|
40
|
+
all bin + lib + test + data + rdoc + tasks
|
41
|
+
}
|
42
|
+
|
43
|
+
# ways to package the results
|
44
|
+
formats {
|
45
|
+
tgz true
|
46
|
+
zip true
|
47
|
+
gem Configuration::Table.has_key?('gem')
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
#-----------------------------------------------------------------------
|
52
|
+
# Gem packaging
|
53
|
+
#-----------------------------------------------------------------------
|
54
|
+
Configuration.for("gem") {
|
55
|
+
spec "gemspec.rb"
|
56
|
+
Configuration.for('packaging').files.all << spec
|
57
|
+
}
|
58
|
+
|
59
|
+
#-----------------------------------------------------------------------
|
60
|
+
# Testing
|
61
|
+
#-----------------------------------------------------------------------
|
62
|
+
Configuration.for('test') {
|
63
|
+
mode "spec"
|
64
|
+
files Configuration.for("packaging").files.test
|
65
|
+
options %w[ --format specdoc --color ]
|
66
|
+
ruby_opts %w[ ]
|
67
|
+
}
|
68
|
+
|
69
|
+
#-----------------------------------------------------------------------
|
70
|
+
# Rcov
|
71
|
+
#-----------------------------------------------------------------------
|
72
|
+
Configuration.for('rcov') {
|
73
|
+
output_dir "coverage"
|
74
|
+
libs %w[ lib ]
|
75
|
+
rcov_opts %w[ --html ]
|
76
|
+
ruby_opts %w[ ]
|
77
|
+
test_files Configuration.for('packaging').files.test
|
78
|
+
|
79
|
+
# hmm... how to configure remote publishing
|
80
|
+
}
|
81
|
+
|
82
|
+
#-----------------------------------------------------------------------
|
83
|
+
# Rdoc
|
84
|
+
#-----------------------------------------------------------------------
|
85
|
+
Configuration.for('rdoc') {
|
86
|
+
files Configuration.for('packaging').files.rdoc
|
87
|
+
main files.first
|
88
|
+
title Configuration.for('project').name
|
89
|
+
options %w[ --line-numbers --inline-source ]
|
90
|
+
output_dir "doc"
|
91
|
+
}
|
92
|
+
|
93
|
+
#-----------------------------------------------------------------------
|
94
|
+
# Rubyforge
|
95
|
+
#-----------------------------------------------------------------------
|
96
|
+
Configuration.for('rubyforge') {
|
97
|
+
project "copiousfreetime"
|
98
|
+
user "jjh"
|
99
|
+
host "rubyforge.org"
|
100
|
+
rdoc_location "#{user}@#{host}:/var/www/gforge-projects/copiousfreetime/heel"
|
101
|
+
}
|
102
|
+
|
103
|
+
|