gorp 0.16.6 → 0.17.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/Rakefile +1 -0
- data/gorp.gemspec +5 -2
- data/lib/gorp.rb +1 -157
- data/lib/gorp/edit.rb +22 -5
- data/lib/gorp/net.rb +15 -1
- data/lib/gorp/rails.rb +15 -4
- data/lib/gorp/test.rb +3 -0
- data/lib/version.rb +2 -2
- metadata +12 -2
data/Rakefile
CHANGED
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.
|
5
|
+
s.version = "0.17.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-12-
|
9
|
+
s.date = %q{2009-12-31}
|
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
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_runtime_dependency(%q<builder>, [">= 0"])
|
34
34
|
s.add_runtime_dependency(%q<erubis>, [">= 0"])
|
35
35
|
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
36
|
+
s.add_runtime_dependency(%q<mail>, [">= 0"])
|
36
37
|
s.add_runtime_dependency(%q<rack>, [">= 0"])
|
37
38
|
s.add_runtime_dependency(%q<rack-mount>, [">= 0"])
|
38
39
|
s.add_runtime_dependency(%q<rack-test>, [">= 0"])
|
@@ -44,6 +45,7 @@ Gem::Specification.new do |s|
|
|
44
45
|
s.add_dependency(%q<builder>, [">= 0"])
|
45
46
|
s.add_dependency(%q<erubis>, [">= 0"])
|
46
47
|
s.add_dependency(%q<i18n>, [">= 0"])
|
48
|
+
s.add_dependency(%q<mail>, [">= 0"])
|
47
49
|
s.add_dependency(%q<rack>, [">= 0"])
|
48
50
|
s.add_dependency(%q<rack-mount>, [">= 0"])
|
49
51
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
@@ -56,6 +58,7 @@ Gem::Specification.new do |s|
|
|
56
58
|
s.add_dependency(%q<builder>, [">= 0"])
|
57
59
|
s.add_dependency(%q<erubis>, [">= 0"])
|
58
60
|
s.add_dependency(%q<i18n>, [">= 0"])
|
61
|
+
s.add_dependency(%q<mail>, [">= 0"])
|
59
62
|
s.add_dependency(%q<rack>, [">= 0"])
|
60
63
|
s.add_dependency(%q<rack-mount>, [">= 0"])
|
61
64
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
data/lib/gorp.rb
CHANGED
@@ -10,6 +10,7 @@ require 'time'
|
|
10
10
|
|
11
11
|
require 'gorp/env'
|
12
12
|
require 'gorp/edit'
|
13
|
+
require 'gorp/output'
|
13
14
|
require 'gorp/net'
|
14
15
|
require 'gorp/rails'
|
15
16
|
|
@@ -293,160 +294,3 @@ def secinclude ranges, section
|
|
293
294
|
(range.first <=> ss) <= 0 and (range.last <=> ss) >= 0
|
294
295
|
end
|
295
296
|
end
|
296
|
-
|
297
|
-
at_exit do
|
298
|
-
$x.declare! :DOCTYPE, :html
|
299
|
-
$x.html :xmlns => 'http://www.w3.org/1999/xhtml' do
|
300
|
-
$x.header do
|
301
|
-
$x.title $title
|
302
|
-
$x.meta 'http-equiv'=>'text/html; charset=UTF-8'
|
303
|
-
$x.style :type => "text/css" do
|
304
|
-
$x.text! <<-'EOF'.unindent(2)
|
305
|
-
body {background-color: #F5F5DC}
|
306
|
-
#banner {margin-top: 0}
|
307
|
-
pre {font-weight: bold; margin: 0; padding: 0}
|
308
|
-
pre.stdin {color: #800080; margin-top: 1em; padding: 0}
|
309
|
-
pre.irb {color: #800080; padding: 0}
|
310
|
-
pre.stdout {color: #000; padding: 0}
|
311
|
-
pre.logger {color: #088; padding: 0}
|
312
|
-
pre.hilight {color: #000; background-color: #FF0; padding: 0}
|
313
|
-
pre.stderr {color: #F00; padding: 0}
|
314
|
-
div.body {border-style: solid; border-color: #800080; padding: 0.5em}
|
315
|
-
.issue, .traceback {background:#FDD; border: 4px solid #F00;
|
316
|
-
font-weight: bold; margin-top: 1em; padding: 0.5em}
|
317
|
-
div.body, .issue, .traceback {
|
318
|
-
-webkit-border-radius: 0.7em; -moz-border-radius: 0.7em;}
|
319
|
-
ul.toc {list-style: none}
|
320
|
-
ul a {text-decoration: none}
|
321
|
-
ul a:hover {text-decoration: underline; color: #000;
|
322
|
-
background-color: #F5F5DC}
|
323
|
-
a.toc h2 {background-color: #981A21; color:#FFF; padding: 6px}
|
324
|
-
ul a:visited {color: #000}
|
325
|
-
h2 {clear: both}
|
326
|
-
p.desc {font-style: italic}
|
327
|
-
p.overview {border-width: 2px; border-color: #000;
|
328
|
-
border-style: solid; border-radius: 4em;
|
329
|
-
background-color: #CCF; margin: 1.5em 1.5em; padding: 1em 2em;
|
330
|
-
-webkit-border-radius: 4em; -moz-border-radius: 4em;}
|
331
|
-
EOF
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
$x.body do
|
336
|
-
$x.h1 $title, :id=>'banner'
|
337
|
-
$x.h2 'Table of Contents'
|
338
|
-
$x.ul :class => 'toc'
|
339
|
-
|
340
|
-
# determine which range(s) of steps are to be executed
|
341
|
-
ranges = ARGV.grep(/^ \d+(.\d+)? ( (-|\.\.) \d+(.\d+)? )? /x).map do |arg|
|
342
|
-
bounds = arg.split(/-|\.\./)
|
343
|
-
Range.new(secsplit(bounds.first), secsplit(bounds.last))
|
344
|
-
end
|
345
|
-
|
346
|
-
# optionally save a snapshot
|
347
|
-
if ARGV.include? 'restore'
|
348
|
-
log :snap, 'restore'
|
349
|
-
Dir.chdir $BASE
|
350
|
-
FileUtils.rm_rf $WORK
|
351
|
-
FileUtils.cp_r "snapshot", $WORK, :preserve => true
|
352
|
-
Dir.chdir $WORK
|
353
|
-
if $autorestart and File.directory? $autorestart
|
354
|
-
Dir.chdir $autorestart
|
355
|
-
restart_server
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
# run steps
|
360
|
-
e = nil
|
361
|
-
begin
|
362
|
-
$sections.each do |section, title, steps|
|
363
|
-
omit = secinclude($omit, section)
|
364
|
-
omit ||= (!ranges.empty? and !secinclude(ranges, section))
|
365
|
-
|
366
|
-
if omit
|
367
|
-
$x.a(:class => 'omit', :id => "section-#{section}") do
|
368
|
-
$x.comment! title
|
369
|
-
end
|
370
|
-
else
|
371
|
-
head section, title
|
372
|
-
steps.call
|
373
|
-
end
|
374
|
-
end
|
375
|
-
rescue Exception => e
|
376
|
-
$x.pre :class => 'traceback' do
|
377
|
-
STDERR.puts e.inspect
|
378
|
-
$x.text! "#{e.inspect}\n"
|
379
|
-
e.backtrace.each {|line| $x.text! " #{line}\n"}
|
380
|
-
end
|
381
|
-
ensure
|
382
|
-
if e.class != SystemExit
|
383
|
-
$cleanup.call if $cleanup
|
384
|
-
|
385
|
-
# terminate server
|
386
|
-
Process.kill "INT", $server if $server
|
387
|
-
Process.wait($server) if $server
|
388
|
-
|
389
|
-
# optionally save a snapshot
|
390
|
-
if ARGV.include? 'save'
|
391
|
-
log :snap, 'save'
|
392
|
-
Dir.chdir $BASE
|
393
|
-
FileUtils.rm_rf "snapshot"
|
394
|
-
FileUtils.cp_r $WORK, "snapshot", :preserve => true
|
395
|
-
end
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
$x.a(:class => 'toc', :id => 'env') {$x.h2 'Environment'}
|
400
|
-
$x.pre Time.now.httpdate, :class=>'stdout'
|
401
|
-
|
402
|
-
cmd "#{$ruby} -v"
|
403
|
-
cmd 'gem -v'
|
404
|
-
cmd 'gem list'
|
405
|
-
cmd 'echo $RUBYLIB | sed "s/:/\n/g"'
|
406
|
-
|
407
|
-
cmd which_rails($rails) + ' -v'
|
408
|
-
|
409
|
-
if $rails != 'rails'
|
410
|
-
Dir.chdir($rails) do
|
411
|
-
log :cmd, 'git log -1'
|
412
|
-
$x.pre 'git log -1', :class=>'stdin'
|
413
|
-
`git log -1`.strip.split(/\n/).each do |line|
|
414
|
-
line.sub! /commit (\w{40})/,
|
415
|
-
'commit <a href="http://github.com/rails/rails/commit/\1">\1</a>'
|
416
|
-
if $1
|
417
|
-
$x.pre(:class=>'stdout') {$x << line.chomp}
|
418
|
-
else
|
419
|
-
$x.pre line.chomp, :class=>'stdout'
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
$x.a(:class => 'toc', :id => 'todos') {$x.h2 'Todos'}
|
426
|
-
$x.ul :class => 'todos'
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
# output results as HTML, after inserting style and toc information
|
431
|
-
$x.target![/<style.*?>()/,1] = "\n#{$style.target!.strip.gsub(/^/,' '*6)}\n"
|
432
|
-
$x.target!.sub! /<ul class="toc"\/>/,
|
433
|
-
"<ul class=\"toc\">\n#{$toc.target!.gsub(/^/,' '*6)} </ul>"
|
434
|
-
$x.target!.sub! /<ul class="todos"\/>/,
|
435
|
-
"<ul class=\"todos\">\n#{$todos.target!.gsub(/^/,' '*6)} </ul>"
|
436
|
-
$x.target!.gsub! '<strong/>', '<strong></strong>'
|
437
|
-
$x.target!.gsub! /(<textarea[^>]+)\/>/, '\1></textarea>'
|
438
|
-
log :WRITE, "#{$output}.html"
|
439
|
-
open("#{$WORK}/#{$output}.html",'w') { |file| file.write $x.target! }
|
440
|
-
|
441
|
-
# run tests
|
442
|
-
if $checker
|
443
|
-
log :CHECK, "#{$output}.html"
|
444
|
-
Dir.chdir $BASE
|
445
|
-
STDOUT.puts
|
446
|
-
if $checker =~ /^[-\w]+$/
|
447
|
-
require File.join($BASE,$checker)
|
448
|
-
else
|
449
|
-
require $checker
|
450
|
-
end
|
451
|
-
end
|
452
|
-
end
|
data/lib/gorp/edit.rb
CHANGED
@@ -48,6 +48,8 @@ module Gorp
|
|
48
48
|
from = Regexp.new('.*' + Regexp.escape(from) + '.*')
|
49
49
|
end
|
50
50
|
|
51
|
+
raise IndexError.new('regexp not matched') unless match(from)
|
52
|
+
|
51
53
|
sub!(from) do |base|
|
52
54
|
base.extend Gorp::StringEditingFunctions
|
53
55
|
yield base if block_given?
|
@@ -58,9 +60,13 @@ module Gorp
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def dcl(name, *options)
|
61
|
-
|
63
|
+
re = Regexp.new '\n(\s*)(class|def|test)\s+"?' + name +
|
64
|
+
'"?.*?\n\1end\n', Regexp::MULTILINE
|
65
|
+
raise IndexError.new('regexp not matched') unless match(re)
|
66
|
+
|
67
|
+
self.sub!(re) do |lines|
|
62
68
|
lines.extend Gorp::StringEditingFunctions
|
63
|
-
yield lines
|
69
|
+
yield lines if block_given?
|
64
70
|
lines.mark(options.last[:mark]) if options.last.respond_to? :[]
|
65
71
|
lines
|
66
72
|
end
|
@@ -68,14 +74,25 @@ module Gorp
|
|
68
74
|
|
69
75
|
def clear_highlights
|
70
76
|
self.gsub! /^\s*(#|<!--)\s*(START|END)_HIGHLIGHT(\s*-->)?\n/, ''
|
71
|
-
self.gsub! /^\s*(#|<!--)\s*(START|END)_HIGHLIGHT(\s*-->)?\n/, ''
|
72
77
|
end
|
73
78
|
|
74
79
|
def clear_all_marks
|
75
|
-
self.gsub!
|
80
|
+
self.gsub! /^\s*(#|<!--)\s*(START|END)(_HIGHLIGHT|:\w+)(\s*-->)?\n/, ''
|
76
81
|
end
|
77
82
|
|
78
|
-
def msub pattern, replacement
|
83
|
+
def msub pattern, replacement, option=nil
|
84
|
+
if option == :highlight
|
85
|
+
replacement.extend Gorp::StringEditingFunctions
|
86
|
+
replacement.highlight if option == :highlight
|
87
|
+
end
|
88
|
+
|
89
|
+
if replacement =~ /\\[1-9]/
|
90
|
+
replacement.gsub! /\\([1-9])/, '#{$\1}'
|
91
|
+
replacement = replacement.inspect.gsub('\#','#')
|
92
|
+
match(pattern)
|
93
|
+
replacement = eval(replacement)
|
94
|
+
end
|
95
|
+
|
79
96
|
self[pattern, 1] = replacement
|
80
97
|
end
|
81
98
|
|
data/lib/gorp/net.rb
CHANGED
@@ -90,7 +90,12 @@ def post path, form, options={}
|
|
90
90
|
end
|
91
91
|
|
92
92
|
Net::HTTP.start(host, port) do |http|
|
93
|
-
|
93
|
+
accept = 'text/html'
|
94
|
+
accept = 'application/atom+xml' if path =~ /\.atom$/
|
95
|
+
accept = 'application/json' if path =~ /\.json$/
|
96
|
+
accept = 'application/xml' if path =~ /\.xml$/
|
97
|
+
|
98
|
+
get = Net::HTTP::Get.new(path, 'Accept' => accept)
|
94
99
|
get['Cookie'] = $COOKIE if $COOKIE
|
95
100
|
response = http.request(get)
|
96
101
|
snap response, form unless options[:snapget] == false
|
@@ -117,6 +122,15 @@ def post path, form, options={}
|
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
125
|
+
# find matching submit button
|
126
|
+
xform ||= xforms.find do |element|
|
127
|
+
form.all? do |name, value|
|
128
|
+
element.search('.//input[@type="submit"]').any? do |input|
|
129
|
+
input.attribute('value').to_s==form['submit']
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
120
134
|
# match based on action itself
|
121
135
|
xform ||= xforms.find do |element|
|
122
136
|
form.all? do |name, value|
|
data/lib/gorp/rails.rb
CHANGED
@@ -42,8 +42,9 @@ def rails name, app=nil
|
|
42
42
|
# determine how to invoke rails
|
43
43
|
rails = which_rails $rails
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
opt = (ARGV.include?('bundle') ? ' --dev' : '')
|
46
|
+
$x.pre "#{rails} #{name}#{opt}", :class=>'stdin'
|
47
|
+
popen3 "#{rails} #{name}#{opt}"
|
47
48
|
|
48
49
|
# canonicalize the reference to Ruby
|
49
50
|
Dir["#{name}/script/**/*"].each do |script|
|
@@ -60,8 +61,18 @@ def rails name, app=nil
|
|
60
61
|
cmd 'rake rails:freeze:edge' if ARGV.include? 'edge'
|
61
62
|
|
62
63
|
if $rails != 'rails' and File.directory?($rails)
|
63
|
-
|
64
|
-
|
64
|
+
if File.exist? 'Gemfile'
|
65
|
+
if ARGV.include? 'bundle'
|
66
|
+
cmd 'gem bundle'
|
67
|
+
else
|
68
|
+
system 'mkdir -p vendor/gems'
|
69
|
+
system "ln -s #{$rails} vendor/rails"
|
70
|
+
system "cp #{__FILE__.sub(/\.rb$/,'.env')} vendor/gems/environment.rb"
|
71
|
+
end
|
72
|
+
else
|
73
|
+
system 'mkdir -p vendor'
|
74
|
+
system "ln -s #{$rails} vendor/rails"
|
75
|
+
end
|
65
76
|
end
|
66
77
|
end
|
67
78
|
|
data/lib/gorp/test.rb
CHANGED
@@ -89,6 +89,7 @@ class Book::TestCase < ActiveSupport::TestCase
|
|
89
89
|
@@version = $1
|
90
90
|
@@version += ' (git)' if body =~ /ln -s.*vendor.rails/
|
91
91
|
@@version += ' (edge)' if body =~ /rails:freeze:edge/
|
92
|
+
@@version += ' (bundle)' if body =~ /gem bundle/
|
92
93
|
STDERR.puts @@version
|
93
94
|
end
|
94
95
|
|
@@ -215,5 +216,7 @@ class HTMLRunner < Test::Unit::UI::Console::TestRunner
|
|
215
216
|
open(File.join($WORK, 'status'), 'w') do |status|
|
216
217
|
status.puts @result.to_s
|
217
218
|
end
|
219
|
+
|
220
|
+
at_exit { raise SystemExit.new(1) } unless @result.passed?
|
218
221
|
end
|
219
222
|
end
|
data/lib/version.rb
CHANGED
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.
|
4
|
+
version: 0.17.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-12-
|
12
|
+
date: 2009-12-31 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,16 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: "0"
|
44
44
|
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: mail
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
45
55
|
- !ruby/object:Gem::Dependency
|
46
56
|
name: rack
|
47
57
|
type: :runtime
|