Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enable standalone scripts to start a server

  • Loading branch information...
commit 944b6c2e755b6897d689442dc0643f13a96db836 1 parent f2d9e5c
@rubys authored
View
2  gorp.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{gorp}
- s.version = "0.21.0"
+ s.version = "0.21.1"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Sam Ruby"]
View
3  lib/gorp/output.rb
@@ -70,8 +70,7 @@
$cleanup.call if $cleanup
# terminate server
- Process.kill "INT", $server if $server
- Process.wait($server) if $server
+ Gorp::Commands.stop_server
# optionally save a snapshot
if ARGV.include? 'save'
View
11 lib/gorp/rails.rb
@@ -157,13 +157,20 @@ def rails name, app=nil
$rails_app = name
end
+ # stop a server if it is currently running
+ def self.stop_server
+ return unless $server
+ Process.kill "INT", $server
+ Process.wait($server)
+ $server = nil
+ end
+
# start/restart a rails server in a separate process
def restart_server
log :server, 'restart'
if $server
$x.h3 'Restart the server.'
- Process.kill "INT", $server
- Process.wait($server)
+ Gorp::Commands.stop_server
else
$x.h3 'Start the server.'
end
View
20 lib/gorp/test.rb
@@ -1,7 +1,6 @@
require 'test/unit'
require 'builder'
require 'gorp/env'
-require 'gorp/edit'
require 'gorp/rails'
require 'gorp/commands'
@@ -13,8 +12,13 @@ def initialize(one, two)
end
def method_missing sym, *args, &block
- @one.method_missing sym, *args, &block
- @two.method_missing sym, *args, &block
+ if sym == :<<
+ @one << args.first
+ @two << args.first
+ else
+ @one.method_missing sym, *args, &block
+ @two.method_missing sym, *args, &block
+ end
end
def pre! *args
@@ -158,7 +162,7 @@ def self.sections
@@base = Object.new.extend(Gorp::Commands)
include Gorp::Commands
- %w(cmd get post rake ruby).each do |method|
+ %w(cmd post rake ruby).each do |method|
define_method(method) do |*args, &block|
begin
$y = Builder::XmlMarkup.new(:indent => 2)
@@ -246,6 +250,9 @@ def html_fault fault
end
def html_summary elapsed
+ # terminate server
+ at_exit { Gorp::Commands.stop_server }
+
open(File.join($WORK, "#{$output}.html"),'w') do |output|
sections = @@sections
output.write(sections.delete(:head))
@@ -303,10 +310,15 @@ def html_summary elapsed
next unless c.superclass == Gorp::TestCase
suite << c.suite
end
+
def suite.sections
style = open(File.join(File.dirname(__FILE__), 'output.css')) {|fh| fh.read}
head = "<head><title>#{$output}</title><style>\n#{style}</style></head>"
{:head=>"<html>\n#{head}\n ", :tail=>"\n</html>"}
end
+
+ require 'gorp/xml'
+ require 'gorp/edit'
+ require 'gorp/net'
HTMLRunner.run(suite)
end
View
2  lib/version.rb
@@ -2,7 +2,7 @@ module Gorp
module VERSION #:nodoc:
MAJOR = 0
MINOR = 21
- TINY = 0
+ TINY = 1
STRING = [MAJOR, MINOR, TINY].join('.')
end
Please sign in to comment.
Something went wrong with that request. Please try again.