gorp 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/gorp.gemspec +2 -2
- data/lib/gorp.rb +15 -4
- data/lib/version.rb +2 -2
- metadata +2 -2
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.12.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-09}
|
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
|
data/lib/gorp.rb
CHANGED
@@ -420,8 +420,8 @@ def get path
|
|
420
420
|
post path, {}
|
421
421
|
end
|
422
422
|
|
423
|
-
def post path, form
|
424
|
-
$x.pre "get #{path}", :class=>'stdin'
|
423
|
+
def post path, form, options={}
|
424
|
+
$x.pre "get #{path}", :class=>'stdin' unless options[:snapget] == false
|
425
425
|
|
426
426
|
if path.include? ':'
|
427
427
|
host, port, path = URI.parse(path).select(:host, :port, :path)
|
@@ -433,7 +433,7 @@ def post path, form
|
|
433
433
|
get = Net::HTTP::Get.new(path)
|
434
434
|
get['Cookie'] = $COOKIE if $COOKIE
|
435
435
|
response = http.request(get)
|
436
|
-
snap response, form
|
436
|
+
snap response, form unless options[:snapget] == false
|
437
437
|
$COOKIE = response.response['set-cookie'] if response.response['set-cookie']
|
438
438
|
|
439
439
|
if ! form.empty?
|
@@ -442,7 +442,7 @@ def post path, form
|
|
442
442
|
xform = body.at('//form[.//input[@name="commit"]]')
|
443
443
|
|
444
444
|
if !xform
|
445
|
-
# if page isn't one big form, find matching button
|
445
|
+
# if page isn't one big form, find matching button by action
|
446
446
|
require 'cgi'
|
447
447
|
query = form.map{|key,val| /[&?]#{key}=#{CGI.escape(val.to_s)}(&|$)/}
|
448
448
|
xform = body.search('//form').find do |element|
|
@@ -450,6 +450,16 @@ def post path, form
|
|
450
450
|
end
|
451
451
|
end
|
452
452
|
|
453
|
+
if !xform
|
454
|
+
# if all else fails, find matching button by input values
|
455
|
+
xform = body.search('//form').find do |element|
|
456
|
+
form.all? do |name, value|
|
457
|
+
element.search("//input[@name=#{name.inspect} and
|
458
|
+
@value=#{value.inspect}]")
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
453
463
|
return unless xform
|
454
464
|
path = xform.attribute('action').to_s unless
|
455
465
|
xform.attribute('action').to_s.empty?
|
@@ -480,6 +490,7 @@ def post path, form
|
|
480
490
|
get['Cookie'] = $COOKIE if $COOKIE
|
481
491
|
response = http.request(get)
|
482
492
|
snap response
|
493
|
+
$COOKIE=response.response['set-cookie'] if response.response['set-cookie']
|
483
494
|
end
|
484
495
|
end
|
485
496
|
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.12.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-09 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|