gorp 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest CHANGED
@@ -1,7 +1,8 @@
1
1
  README
2
2
  Rakefile
3
- Manifest
4
3
  gorp.gemspec
5
- lib/version.rb
6
4
  lib/gorp.rb
5
+ lib/gorp/env.rb
7
6
  lib/gorp/test.rb
7
+ lib/version.rb
8
+ Manifest
data/gorp.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gorp}
5
- s.version = "0.7.2"
5
+ s.version = "0.8.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sam Ruby"]
9
- s.date = %q{2009-10-28}
9
+ s.date = %q{2009-11-24}
10
10
  s.description = %q{ Enables the creation of scenarios that involve creating a rails project,
11
11
  starting and stoppping of servers, generating projects, editing files,
12
12
  issuing http requests, running of commands, etc. Output is captured as
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
16
16
  assertions based on selections (typically CSS) against the generated HTML.
17
17
  }
18
18
  s.email = %q{rubys@intertwingly.net}
19
- s.extra_rdoc_files = ["README", "lib/version.rb", "lib/gorp.rb", "lib/gorp/test.rb"]
20
- s.files = ["README", "Rakefile", "Manifest", "gorp.gemspec", "lib/version.rb", "lib/gorp.rb", "lib/gorp/test.rb"]
19
+ s.extra_rdoc_files = ["README", "lib/gorp.rb", "lib/gorp/env.rb", "lib/gorp/test.rb", "lib/version.rb"]
20
+ s.files = ["README", "Rakefile", "gorp.gemspec", "lib/gorp.rb", "lib/gorp/env.rb", "lib/gorp/test.rb", "lib/version.rb", "Manifest"]
21
21
  s.homepage = %q{http://github.com/rubys/gorp}
22
22
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gorp", "--main", "README"]
23
23
  s.require_paths = ["lib"]
data/lib/gorp.rb CHANGED
@@ -8,6 +8,7 @@ require 'open3'
8
8
  require 'net/http'
9
9
  require 'builder'
10
10
  require 'stringio'
11
+ require 'gorp/env'
11
12
 
12
13
  require 'rbconfig'
13
14
  $ruby = File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])
@@ -20,15 +21,11 @@ def section number, title, &steps
20
21
  end
21
22
 
22
23
  # verify that port is available for testing
23
- if (Net::HTTP.get_response('localhost','/',3000).code == '200' rescue false)
24
- STDERR.puts 'local server already running on port 3000'
24
+ if (Net::HTTP.get_response('localhost','/',$PORT).code == '200' rescue false)
25
+ STDERR.puts "local server already running on port #{$PORT}"
25
26
  exit
26
27
  end
27
28
 
28
- $BASE=File.expand_path(File.dirname(caller.last.split(':').first)) unless $BASE
29
- $WORK = File.join($BASE,'work')
30
- $DATA = File.join($BASE,'data')
31
- $CODE = File.join($DATA,'code')
32
29
  $x = Builder::XmlMarkup.new(:indent => 2)
33
30
  $toc = Builder::XmlMarkup.new(:indent => 2)
34
31
  $todos = Builder::XmlMarkup.new(:indent => 2)
@@ -101,7 +98,9 @@ def ruby args
101
98
  end
102
99
 
103
100
  def console script
104
- cmd "echo #{script.inspect} | ruby script/console '--irb=irb -f'"
101
+ open('tmp/irbrc','w') {|file| file.write('IRB.conf[:PROMPT_MODE]=:SIMPLE')}
102
+ cmd "echo #{script.inspect} | IRBRC=tmp/irbrc ruby script/console"
103
+ FileUtils.rm_rf 'tmp/irbrc'
105
104
  end
106
105
 
107
106
  def cmd args, hilight=[]
@@ -376,7 +375,7 @@ def snap response, form={}
376
375
  name = xpath[/@(\w+)/,1]
377
376
  body.search("//#{xpath}").each do |element|
378
377
  next if element[name] =~ /^http:\/\//
379
- element[name] = URI.join('http://localhost:3000/', element[name]).to_s
378
+ element[name] = URI.join("http://localhost:#{$PORT}/", element[name]).to_s
380
379
  end
381
380
  end
382
381
 
@@ -414,7 +413,7 @@ def post path, form
414
413
  if path.include? ':'
415
414
  host, port, path = URI.parse(path).select(:host, :port, :path)
416
415
  else
417
- host, port = '127.0.0.1', 3000
416
+ host, port = '127.0.0.1', $PORT
418
417
  end
419
418
 
420
419
  Net::HTTP.start(host, port) do |http|
@@ -529,7 +528,7 @@ def restart_server
529
528
  60.times do
530
529
  sleep 0.5
531
530
  begin
532
- status = Net::HTTP.get_response('localhost','/',3000).code
531
+ status = Net::HTTP.get_response('localhost','/',$PORT).code
533
532
  break if %(200 404).include? status
534
533
  rescue Errno::ECONNREFUSED
535
534
  end
@@ -539,7 +538,7 @@ def restart_server
539
538
  if File.exist?('config.ru')
540
539
  require 'rack'
541
540
  server = Rack::Builder.new {eval open('config.ru').read}
542
- Rack::Handler::WEBrick.run(server, :Port => 3000)
541
+ Rack::Handler::WEBrick.run(server, :Port => $PORT)
543
542
  else
544
543
  # start server, redirecting stdout to a string
545
544
  $stdout = StringIO.open('','w')
@@ -616,8 +615,8 @@ at_exit do
616
615
  if ARGV.include? 'restore'
617
616
  log :snap, 'restore'
618
617
  Dir.chdir $BASE
619
- FileUtils.rm_rf "work"
620
- FileUtils.cp_r "snapshot", "work", :preserve => true
618
+ FileUtils.rm_rf $WORK
619
+ FileUtils.cp_r "snapshot", $WORK, :preserve => true
621
620
  Dir.chdir $WORK
622
621
  if $autorestart and File.directory? $autorestart
623
622
  Dir.chdir $autorestart
@@ -657,7 +656,7 @@ at_exit do
657
656
  log :snap, 'save'
658
657
  Dir.chdir $BASE
659
658
  FileUtils.rm_rf "snapshot"
660
- FileUtils.cp_r "work", "snapshot", :preserve => true
659
+ FileUtils.cp_r $WORK, "snapshot", :preserve => true
661
660
  end
662
661
  end
663
662
  end
@@ -683,7 +682,7 @@ at_exit do
683
682
  "<ul class=\"todos\">\n#{$todos.target!.gsub(/^/,' '*6)} </ul>"
684
683
  $x.target!.gsub! '<strong/>', '<strong></strong>'
685
684
  log :WRITE, "#{$output}.html"
686
- open("#{$BASE}/#{$output}.html",'w') do |file|
685
+ open("#{$WORK}/#{$output}.html",'w') do |file|
687
686
  file.write <<-EOF.unindent(6)
688
687
  <!DOCTYPE html
689
688
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
data/lib/gorp/env.rb ADDED
@@ -0,0 +1,19 @@
1
+ # determine port
2
+ if ARGV.find {|arg| arg =~ /--port=(\d+)/}
3
+ $PORT=$1.to_i
4
+ else
5
+ $PORT=3000
6
+ end
7
+
8
+ # base directories
9
+ $BASE=File.expand_path(File.dirname(caller.last.split(':').first)) unless $BASE
10
+ $DATA = File.join($BASE,'data')
11
+ $CODE = File.join($DATA,'code')
12
+
13
+ # work directory
14
+ if (work=ARGV.find {|arg| arg =~ /--work=(.*)/})
15
+ ARGV.delete(work)
16
+ $WORK = File.join($BASE,$1)
17
+ else
18
+ $WORK = File.join($BASE,'work')
19
+ end
data/lib/gorp/test.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'test/unit'
2
2
  require 'builder'
3
+ require 'gorp/env'
3
4
 
4
5
  begin
5
6
  # installed Rails (2.3.3 ish)
@@ -49,7 +50,7 @@ class Book::TestCase < ActiveSupport::TestCase
49
50
  # read and pre-process $input.html (only done once, and cached)
50
51
  def self.input filename
51
52
  # read $input output; remove front matter and footer
52
- input = open("#{filename}.html").read
53
+ input = open(File.join($WORK, "#{filename}.html")).read
53
54
  head, body, tail = input.split /<body>\s+|\s+<\/body>/m
54
55
 
55
56
  # split into sections
@@ -152,14 +153,17 @@ class HTMLRunner < Test::Unit::UI::Console::TestRunner
152
153
  x.li do
153
154
  x.a "Section #{name}", :href => "#section-#{name}"
154
155
  x.tt fault.message.sub(".\n<false> is not true",'').
155
- sub(/ but was\n.*/, '.')
156
+ sub(/ but was\n.*/, '.').
157
+ sub(/"((?:\\"|[^"])+)"/) {
158
+ '"' + ($1.length>80 ? $1[0..72]+'...' : $1) + '"'
159
+ }
156
160
  end
157
161
  sections[:todos][/() *<\/ul>/,1] = x.target!.gsub(/^/,' ')
158
162
  end
159
163
  end
160
164
 
161
165
  def html_summary elapsed
162
- open("#{$output}.html",'w') do |output|
166
+ open(File.join($WORK, "#{$output}.html"),'w') do |output|
163
167
  sections = @@sections
164
168
  output.write(sections.delete(:head))
165
169
  output.write("<body>\n ")
data/lib/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Gorp
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 7
5
- TINY = 2
4
+ MINOR = 8
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-28 00:00:00 -04:00
12
+ date: 2009-11-24 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -90,17 +90,19 @@ extensions: []
90
90
 
91
91
  extra_rdoc_files:
92
92
  - README
93
- - lib/version.rb
94
93
  - lib/gorp.rb
94
+ - lib/gorp/env.rb
95
95
  - lib/gorp/test.rb
96
+ - lib/version.rb
96
97
  files:
97
98
  - README
98
99
  - Rakefile
99
- - Manifest
100
100
  - gorp.gemspec
101
- - lib/version.rb
102
101
  - lib/gorp.rb
102
+ - lib/gorp/env.rb
103
103
  - lib/gorp/test.rb
104
+ - lib/version.rb
105
+ - Manifest
104
106
  has_rdoc: true
105
107
  homepage: http://github.com/rubys/gorp
106
108
  licenses: []