gorp 0.25.1 → 0.26.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gorp}
5
- s.version = "0.25.1"
5
+ s.version = "0.26.1"
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{2010-06-07}
9
+ s.date = %q{2010-12-08}
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
@@ -22,14 +22,14 @@ Gem::Specification.new do |s|
22
22
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gorp", "--main", "README"]
23
23
  s.require_paths = ["lib"]
24
24
  s.rubyforge_project = %q{gorp}
25
- s.rubygems_version = %q{1.3.6}
25
+ s.rubygems_version = %q{1.3.7}
26
26
  s.summary = %q{Rails scenario testing support library}
27
27
 
28
28
  if s.respond_to? :specification_version then
29
29
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
30
30
  s.specification_version = 3
31
31
 
32
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
32
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
33
33
  s.add_runtime_dependency(%q<builder>, [">= 0"])
34
34
  s.add_runtime_dependency(%q<bundler>, [">= 0"])
35
35
  s.add_runtime_dependency(%q<erubis>, [">= 0"])
@@ -175,8 +175,8 @@ module Gorp
175
175
 
176
176
  if args == 'rake db:migrate'
177
177
  Dir.chdir 'db/migrate' do
178
- date = '20100301000000'
179
- Dir['[0-9]*'].sort_by {|fn| fn=~/201003/ ? fn : 'x'+fn}.each do |file|
178
+ date = '20110211000000'
179
+ Dir['[0-9]*'].sort_by {|fn| fn=~/201102/ ? fn : 'x'+fn}.each do |file|
180
180
  file =~ /^([0-9]*)_(.*)$/
181
181
  FileUtils.mv file, "#{date}_#{$2}" unless $1 == date.next!
182
182
  $x.pre "mv #{file} #{date}_#{$2}" unless $1 == date
@@ -129,7 +129,11 @@ module Gorp
129
129
  self[pattern, 1] = replacement
130
130
  end
131
131
 
132
- def all=replacement
132
+ def all
133
+ self
134
+ end
135
+
136
+ def all=(replacement)
133
137
  self[/(.*)/m,1]=replacement
134
138
  end
135
139
  end
@@ -31,6 +31,24 @@ else
31
31
  $WORK = File.join($BASE, ENV['GORP_WORK'] || 'work')
32
32
  end
33
33
 
34
+ # deduce environment based on provided Gemfile
35
+ unless ENV['GORP_RAILS']
36
+ gemfile = "#{$BASE}/Gemfile" if File.exist? "#{$BASE}/Gemfile"
37
+ gemfile = "#{$WORK}/Gemfile" if File.exist? "#{$WORK}/Gemfile"
38
+ if gemfile
39
+ open(gemfile) do |file|
40
+ pattern = /^gem\s+['"](\w+)['"],\s*:path\s*=>\s*['"](.*?)['"]/
41
+ file.read.scan(pattern).each do |name,path|
42
+ if name == 'rails'
43
+ ENV['GORP_RAILS'] ||= path
44
+ else
45
+ $: << "#{path}/lib"
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
34
52
  require 'rbconfig'
35
53
  $ruby = File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])
36
54
 
@@ -13,6 +13,9 @@ def snap response, form=nil
13
13
 
14
14
  if response.body =~ /<body/
15
15
  body = response.body
16
+ elsif response.body =~ /<BODY/
17
+ body = response.body.gsub(/<\/?\w+/) {|tag| tag.downcase}
18
+ body.gsub! '<hr>', '<hr/>'
16
19
  else
17
20
  body = "<body>#{response.body}</body>"
18
21
  end
@@ -96,14 +99,15 @@ def post path, form, options={}
96
99
  accept = 'application/xml' if path =~ /\.xml$/
97
100
 
98
101
  get = Net::HTTP::Get.new(path, 'Accept' => accept)
102
+ get.basic_auth *options[:auth] if options[:auth]
99
103
  get['Cookie'] = $COOKIE if $COOKIE
100
104
  response = http.request(get)
101
105
  snap response, form unless options[:snapget] == false
102
106
  $COOKIE = response.response['set-cookie'] if response.response['set-cookie']
103
107
 
104
108
  if form
105
- body = xhtmlparse(response.body).at('//body')
106
- body = xhtmlparse(response.body).root unless body
109
+ body = xhtmlparse(response.body).at('//body') rescue nil
110
+ body = xhtmlparse(response.body).root unless body rescue nil
107
111
  return unless body
108
112
  xforms = body.search('//form')
109
113
 
@@ -170,7 +174,7 @@ def post path, form, options={}
170
174
  $COOKIE=response.response['set-cookie'] if response.response['set-cookie']
171
175
  path = response['Location']
172
176
  $x.pre "get #{path}", :class=>'stdin'
173
- get = Net::HTTP::Get.new(path)
177
+ get = Net::HTTP::Get.new(path, 'Accept' => accept)
174
178
  get['Cookie'] = $COOKIE if $COOKIE
175
179
  response = http.request(get)
176
180
  snap response
@@ -43,7 +43,7 @@ elsif File.directory?(ARGV.first.to_s.split(File::PATH_SEPARATOR).first.to_s)
43
43
  end
44
44
  end
45
45
  $rails = libs.shift
46
- ENV['RUBYLIBS'] = libs.join(File::PATH_SEPARATOR)
46
+ $:.unshift *libs
47
47
  else
48
48
  $rails = ARGV.first
49
49
  end
@@ -98,11 +98,15 @@ module Gorp
98
98
  Dir.chdir($WORK)
99
99
  FileUtils.rm_rf name
100
100
  log :rails, name
101
+ $rails_app = name
101
102
 
102
103
  # determine how to invoke rails
103
104
  rails = Gorp.which_rails($rails)
104
105
  rails += ' new' if `#{rails} -v` !~ /Rails 2/
105
- rails.sub! 'ruby ', 'ruby -rubygems '
106
+ if `ruby -v` =~ /1\.8/
107
+ rails.sub! /^/, 'ruby ' unless rails =~ /^ruby /
108
+ rails.sub! 'ruby ', 'ruby -rubygems '
109
+ end
106
110
 
107
111
  opt = (ARGV.include?('--dev') ? ' --dev' : '')
108
112
  $x.pre "#{rails.gsub('/',FILE_SEPARATOR)} #{name}#{opt}", :class=>'stdin'
@@ -126,6 +130,15 @@ module Gorp
126
130
  if File.exist? 'Gemfile'
127
131
  gemfile=open('Gemfile') {|file| file.read}
128
132
  gemfile[/gem 'rails',()/,1] = " :path => #{$rails.inspect} #"
133
+ ENV['RUBYLIB'].split(File::PATH_SEPARATOR).each do |path|
134
+ path.sub! /\/lib$/, ''
135
+ name = path.split(File::SEPARATOR).last
136
+ next if name == 'gorp'
137
+ if File.exist?(File.join(path, "/#{name}.gemspec"))
138
+ gemfile[/gem 'rails',.*\n()/,1] =
139
+ "gem #{name.inspect}, :path => #{path.inspect}\n"
140
+ end
141
+ end
129
142
  gemfile[/^()source/, 1] = '# '
130
143
 
131
144
  open('Gemfile','w') {|file| file.write gemfile}
@@ -150,8 +163,6 @@ module Gorp
150
163
  EOF
151
164
  end
152
165
  end
153
-
154
- $rails_app = name
155
166
  end
156
167
 
157
168
  # stop a server if it is currently running
@@ -1,3 +1,4 @@
1
+ gem 'test-unit'
1
2
  require 'test/unit'
2
3
  require 'builder'
3
4
  require 'gorp/env'
@@ -9,6 +10,8 @@ class Gorp::TestCase < Test::Unit::TestCase
9
10
  # Deferred loading of Rails infrastructure
10
11
  if File.exist? "#{$WORK}/.bundle/environment.rb"
11
12
  require "#{$WORK}/.bundle/environment.rb"
13
+ elsif File.exist? "#{$WORK}/Gemfile"
14
+ Dir.chdir($WORK) { require 'bundler/setup' }
12
15
  end
13
16
 
14
17
  require 'active_support'
@@ -308,7 +311,10 @@ at_exit do
308
311
 
309
312
  def suite.sections
310
313
  style = open(File.join(File.dirname(__FILE__), 'output.css')) {|fh| fh.read}
311
- head = "<html>\n<head>\n<title>#{$output}</title>\n<style></style>\n</head>"
314
+ head = "<!DOCTYPE html>" +
315
+ "<html xmlns='http://www.w3.org/1999/xhtml'>\n<head>\n" +
316
+ "<meta charset='utf-8'/>\n<title>#{$output}</title>\n" +
317
+ "<style></style>\n</head>"
312
318
  $cleanup = Proc.new do
313
319
  Dir['public/stylesheets/*.css'].each do |css|
314
320
  File.open(css) {|file| style+= file.read}
@@ -1,7 +1,7 @@
1
1
  module Gorp
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 25
4
+ MINOR = 26
5
5
  TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorp
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 117
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 25
8
+ - 26
8
9
  - 1
9
- version: 0.25.1
10
+ version: 0.26.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Sam Ruby
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-07 00:00:00 -04:00
18
+ date: 2010-12-08 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: builder
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: bundler
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
@@ -45,9 +50,11 @@ dependencies:
45
50
  name: erubis
46
51
  prerelease: false
47
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
57
+ hash: 3
51
58
  segments:
52
59
  - 0
53
60
  version: "0"
@@ -57,9 +64,11 @@ dependencies:
57
64
  name: i18n
58
65
  prerelease: false
59
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
69
  - - ">="
62
70
  - !ruby/object:Gem::Version
71
+ hash: 3
63
72
  segments:
64
73
  - 0
65
74
  version: "0"
@@ -69,9 +78,11 @@ dependencies:
69
78
  name: rack
70
79
  prerelease: false
71
80
  requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ">="
74
84
  - !ruby/object:Gem::Version
85
+ hash: 3
75
86
  segments:
76
87
  - 0
77
88
  version: "0"
@@ -81,9 +92,11 @@ dependencies:
81
92
  name: rack-mount
82
93
  prerelease: false
83
94
  requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
84
96
  requirements:
85
97
  - - ">="
86
98
  - !ruby/object:Gem::Version
99
+ hash: 3
87
100
  segments:
88
101
  - 0
89
102
  version: "0"
@@ -93,9 +106,11 @@ dependencies:
93
106
  name: rack-test
94
107
  prerelease: false
95
108
  requirement: &id007 !ruby/object:Gem::Requirement
109
+ none: false
96
110
  requirements:
97
111
  - - ">="
98
112
  - !ruby/object:Gem::Version
113
+ hash: 3
99
114
  segments:
100
115
  - 0
101
116
  version: "0"
@@ -105,9 +120,11 @@ dependencies:
105
120
  name: rake
106
121
  prerelease: false
107
122
  requirement: &id008 !ruby/object:Gem::Requirement
123
+ none: false
108
124
  requirements:
109
125
  - - ">="
110
126
  - !ruby/object:Gem::Version
127
+ hash: 3
111
128
  segments:
112
129
  - 0
113
130
  version: "0"
@@ -117,9 +134,11 @@ dependencies:
117
134
  name: thor
118
135
  prerelease: false
119
136
  requirement: &id009 !ruby/object:Gem::Requirement
137
+ none: false
120
138
  requirements:
121
139
  - - ">="
122
140
  - !ruby/object:Gem::Version
141
+ hash: 3
123
142
  segments:
124
143
  - 0
125
144
  version: "0"
@@ -129,9 +148,11 @@ dependencies:
129
148
  name: sqlite3-ruby
130
149
  prerelease: false
131
150
  requirement: &id010 !ruby/object:Gem::Requirement
151
+ none: false
132
152
  requirements:
133
153
  - - ">="
134
154
  - !ruby/object:Gem::Version
155
+ hash: 3
135
156
  segments:
136
157
  - 0
137
158
  version: "0"
@@ -141,9 +162,11 @@ dependencies:
141
162
  name: tzinfo
142
163
  prerelease: false
143
164
  requirement: &id011 !ruby/object:Gem::Requirement
165
+ none: false
144
166
  requirements:
145
167
  - - ">="
146
168
  - !ruby/object:Gem::Version
169
+ hash: 3
147
170
  segments:
148
171
  - 0
149
172
  version: "0"
@@ -201,16 +224,20 @@ rdoc_options:
201
224
  require_paths:
202
225
  - lib
203
226
  required_ruby_version: !ruby/object:Gem::Requirement
227
+ none: false
204
228
  requirements:
205
229
  - - ">="
206
230
  - !ruby/object:Gem::Version
231
+ hash: 3
207
232
  segments:
208
233
  - 0
209
234
  version: "0"
210
235
  required_rubygems_version: !ruby/object:Gem::Requirement
236
+ none: false
211
237
  requirements:
212
238
  - - ">="
213
239
  - !ruby/object:Gem::Version
240
+ hash: 11
214
241
  segments:
215
242
  - 1
216
243
  - 2
@@ -218,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
245
  requirements: []
219
246
 
220
247
  rubyforge_project: gorp
221
- rubygems_version: 1.3.6
248
+ rubygems_version: 1.3.7
222
249
  signing_key:
223
250
  specification_version: 3
224
251
  summary: Rails scenario testing support library