timcharper-spork 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/bin/spork +12 -38
- data/lib/spork/runner.rb +61 -0
- data/lib/spork.rb +2 -1
- data/spec/spec_helper.rb +9 -0
- data/spec/spork_spec.rb +7 -0
- metadata +12 -10
data/History.txt
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
== 0.3.x (Git)
|
2
|
+
=== New Features
|
3
|
+
|
4
|
+
=== Bugfixes
|
5
|
+
|
6
|
+
== 0.3.1 2009-05-25
|
7
|
+
* Extracted bin logic into Runner file, improved requiring and load path setup, and cleaned up file organization. (Ben Mabey)
|
8
|
+
|
9
|
+
== 0.3.0 2009-05
|
10
|
+
* Initial release with SpecServer, Bootstraper, and basic option parsing. (Tim Harper)
|
data/bin/spork
CHANGED
@@ -1,45 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
3
|
-
|
4
2
|
require 'rubygems'
|
5
|
-
|
6
|
-
require 'optparse'
|
7
|
-
|
8
|
-
ENV["DRB"] = 'true'
|
9
|
-
ENV["RAILS_ENV"] ||= 'test' if Spork.using_rails?
|
10
|
-
|
11
|
-
options = {}
|
12
|
-
parser = OptionParser.new
|
13
|
-
parser.on("-d", "--daemon") {|ignore| options[:daemon] = true }
|
14
|
-
parser.on("-b", "--bootstrap") {|ignore| options[:bootstrap] = true }
|
15
|
-
parser.on("-p", "--pid PIDFILE"){|pid| options[:pid] = pid }
|
16
|
-
parser.parse!(ARGV)
|
17
|
-
|
18
|
-
unless File.exist?(Spork::SPEC_HELPER_FILE)
|
19
|
-
puts <<-USEFUL_ERROR
|
20
|
-
Bummer!
|
3
|
+
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 # Why do we need this?
|
21
4
|
|
22
|
-
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
|
23
6
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
7
|
+
require 'spork'
|
8
|
+
require 'spork/runner'
|
9
|
+
|
10
|
+
begin
|
11
|
+
success = Spork::Runner.run(ARGV, STDOUT, STDERR)
|
12
|
+
Kernel.exit(success ? 0 : 1)
|
13
|
+
rescue Exception => e
|
14
|
+
STDERR.puts("#{e.message} (#{e.class})")
|
15
|
+
STDERR.puts(e.backtrace.join("\n"))
|
16
|
+
Kernel.exit 1
|
35
17
|
end
|
36
18
|
|
37
|
-
require 'spork/spec_server'
|
38
|
-
Spork.preload || exit(1)
|
39
|
-
|
40
|
-
if options[:daemon]
|
41
|
-
::Spork::SpecServer.daemonize(options[:pid])
|
42
|
-
else
|
43
|
-
::Spork::SpecServer.run
|
44
|
-
end
|
45
19
|
|
data/lib/spork/runner.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Spork
|
4
|
+
class Runner
|
5
|
+
|
6
|
+
def self.run(args, output, error)
|
7
|
+
self.new(args, output, error).run
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(args, output, error)
|
11
|
+
@output = output
|
12
|
+
@error = error
|
13
|
+
@options = {}
|
14
|
+
parser = OptionParser.new
|
15
|
+
parser.on("-d", "--daemon") {|ignore| @options[:daemon] = true }
|
16
|
+
parser.on("-b", "--bootstrap") {|ignore| @options[:bootstrap] = true }
|
17
|
+
parser.on("-p", "--pid PIDFILE"){|pid| @options[:pid] = pid }
|
18
|
+
parser.parse!(args)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def run
|
23
|
+
ENV["DRB"] = 'true'
|
24
|
+
ENV["RAILS_ENV"] ||= 'test' if Spork.using_rails?
|
25
|
+
|
26
|
+
unless File.exist?(Spork::SPEC_HELPER_FILE)
|
27
|
+
@output.puts <<-USEFUL_ERROR
|
28
|
+
Bummer!
|
29
|
+
|
30
|
+
I can't find the file spec/spec_helper.rb, which I need in order to run.
|
31
|
+
|
32
|
+
Are you running me from a project directory that has rspec set up?
|
33
|
+
USEFUL_ERROR
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
return Spork.bootstrap if options[:bootstrap]
|
39
|
+
|
40
|
+
require 'spork/spec_server'
|
41
|
+
return(false) unless Spork.preload
|
42
|
+
|
43
|
+
if options[:daemon]
|
44
|
+
::Spork::SpecServer.daemonize(options[:pid])
|
45
|
+
else
|
46
|
+
::Spork::SpecServer.run
|
47
|
+
end
|
48
|
+
return true
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
attr_reader :options
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
data/lib/spork.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
1
2
|
module Spork
|
2
3
|
SPEC_HELPER_FILE = File.join(Dir.pwd, "spec/spec_helper.rb")
|
3
4
|
|
@@ -64,4 +65,4 @@ module Spork
|
|
64
65
|
end
|
65
66
|
true
|
66
67
|
end
|
67
|
-
end
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/spork_spec.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timcharper-spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Harper
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-05-25 00:00:00 -07:00
|
13
|
+
default_executable: spork
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: A forking Drb spec server
|
@@ -23,12 +23,13 @@ extensions: []
|
|
23
23
|
extra_rdoc_files:
|
24
24
|
- README.rdoc
|
25
25
|
files:
|
26
|
+
- History.txt
|
26
27
|
- README.rdoc
|
27
|
-
- lib/spork
|
28
|
-
- lib/spork/spec_server.rb
|
29
|
-
- lib/spork.rb
|
30
28
|
- assets/bootstrap.rb
|
31
|
-
|
29
|
+
- lib/spork.rb
|
30
|
+
- lib/spork/runner.rb
|
31
|
+
- lib/spork/spec_server.rb
|
32
|
+
has_rdoc: false
|
32
33
|
homepage: http://github.com/timcharper/spork
|
33
34
|
post_install_message:
|
34
35
|
rdoc_options:
|
@@ -53,7 +54,8 @@ requirements: []
|
|
53
54
|
rubyforge_project: spork
|
54
55
|
rubygems_version: 1.2.0
|
55
56
|
signing_key:
|
56
|
-
specification_version:
|
57
|
+
specification_version: 3
|
57
58
|
summary: spork 0.3
|
58
|
-
test_files:
|
59
|
-
|
59
|
+
test_files:
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- spec/spork_spec.rb
|