gorp 0.28.1 → 0.28.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 29bdf58fd820cc12dfffc32f3648f7697605d56c
4
+ data.tar.gz: a9428e2bcc50bbdc419808359866303bb7ac269e
5
+ SHA512:
6
+ metadata.gz: bad09563e09eb6508bf607ee495a5074d64c8b5b86232ad5e68226c824962c836666c799630784c5d0e896d1a9602379bb7a227ecdc5d7ea40e0038cdeff5123
7
+ data.tar.gz: d9b40dabca7a05207bdb1f7cf515b20ffe6d0b0e424b31eb8ae4cdfc42ec73efa53859af8875a696b9809bc128b9adbbaed0016064b04481c127b9f2870c14ae
data/Rakefile CHANGED
@@ -24,6 +24,7 @@ Echoe.new('gorp', Gorp::VERSION::STRING) do |p|
24
24
  i18n
25
25
  rack
26
26
  rake
27
+ http-cookie
27
28
  )
28
29
  # Does not include mail -- as it depends on active_support
29
30
  # test-unit -- incompatible with i18n one hash required (testrunner.rb:116)
@@ -1,25 +1,26 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: gorp 0.28.2 ruby lib
2
3
 
3
4
  Gem::Specification.new do |s|
4
5
  s.name = "gorp"
5
- s.version = "0.28.1"
6
+ s.version = "0.28.2"
6
7
 
7
8
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
9
+ s.require_paths = ["lib"]
8
10
  s.authors = ["Sam Ruby"]
9
- s.date = "2011-10-22"
11
+ s.date = "2016-02-02"
10
12
  s.description = " Enables the creation of scenarios that involve creating a rails project,\n starting and stoppping of servers, generating projects, editing files,\n issuing http requests, running of commands, etc. Output is captured as\n a single HTML file that can be viewed locally or uploaded.\n\n Additionally, there is support for verification, in the form of defining\n assertions based on selections (typically CSS) against the generated HTML.\n"
11
13
  s.email = "rubys@intertwingly.net"
12
14
  s.extra_rdoc_files = ["README", "lib/gorp.rb", "lib/gorp/commands.rb", "lib/gorp/edit.rb", "lib/gorp/env.rb", "lib/gorp/net.rb", "lib/gorp/output.css", "lib/gorp/output.rb", "lib/gorp/rails.env", "lib/gorp/rails.rb", "lib/gorp/test.rb", "lib/gorp/xml.rb", "lib/version.rb"]
13
- s.files = ["Manifest", "README", "Rakefile", "lib/gorp.rb", "lib/gorp/commands.rb", "lib/gorp/edit.rb", "lib/gorp/env.rb", "lib/gorp/net.rb", "lib/gorp/output.css", "lib/gorp/output.rb", "lib/gorp/rails.env", "lib/gorp/rails.rb", "lib/gorp/test.rb", "lib/gorp/xml.rb", "lib/version.rb", "gorp.gemspec"]
15
+ s.files = ["Manifest", "README", "Rakefile", "gorp.gemspec", "lib/gorp.rb", "lib/gorp/commands.rb", "lib/gorp/edit.rb", "lib/gorp/env.rb", "lib/gorp/net.rb", "lib/gorp/output.css", "lib/gorp/output.rb", "lib/gorp/rails.env", "lib/gorp/rails.rb", "lib/gorp/test.rb", "lib/gorp/xml.rb", "lib/version.rb"]
14
16
  s.homepage = "http://github.com/rubys/gorp"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gorp", "--main", "README"]
16
- s.require_paths = ["lib"]
17
+ s.rdoc_options = ["--line-numbers", "--title", "Gorp", "--main", "README"]
17
18
  s.rubyforge_project = "gorp"
18
- s.rubygems_version = "1.8.11"
19
+ s.rubygems_version = "2.5.1"
19
20
  s.summary = "Rails scenario testing support library"
20
21
 
21
22
  if s.respond_to? :specification_version then
22
- s.specification_version = 3
23
+ s.specification_version = 4
23
24
 
24
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
26
  s.add_runtime_dependency(%q<builder>, [">= 0"])
@@ -27,12 +28,14 @@ Gem::Specification.new do |s|
27
28
  s.add_runtime_dependency(%q<i18n>, [">= 0"])
28
29
  s.add_runtime_dependency(%q<rack>, [">= 0"])
29
30
  s.add_runtime_dependency(%q<rake>, [">= 0"])
31
+ s.add_runtime_dependency(%q<http-cookie>, [">= 0"])
30
32
  else
31
33
  s.add_dependency(%q<builder>, [">= 0"])
32
34
  s.add_dependency(%q<bundler>, [">= 0"])
33
35
  s.add_dependency(%q<i18n>, [">= 0"])
34
36
  s.add_dependency(%q<rack>, [">= 0"])
35
37
  s.add_dependency(%q<rake>, [">= 0"])
38
+ s.add_dependency(%q<http-cookie>, [">= 0"])
36
39
  end
37
40
  else
38
41
  s.add_dependency(%q<builder>, [">= 0"])
@@ -40,5 +43,6 @@ Gem::Specification.new do |s|
40
43
  s.add_dependency(%q<i18n>, [">= 0"])
41
44
  s.add_dependency(%q<rack>, [">= 0"])
42
45
  s.add_dependency(%q<rake>, [">= 0"])
46
+ s.add_dependency(%q<http-cookie>, [">= 0"])
43
47
  end
44
48
  end
@@ -4,6 +4,7 @@
4
4
  # You have been warned.
5
5
 
6
6
  require 'gorp/env'
7
+ require 'gorp/config'
7
8
  require 'gorp/commands'
8
9
  require 'gorp/edit'
9
10
  require 'gorp/output'
@@ -21,11 +21,54 @@ module Gorp
21
21
  $sections << [number, title, steps]
22
22
  end
23
23
 
24
- $x = Builder::XmlMarkup.new(:indent => 2)
25
- $toc = Builder::XmlMarkup.new(:indent => 2)
26
- $todos = Builder::XmlMarkup.new(:indent => 2)
24
+ # workaround for https://github.com/jimweirich/builder/commit/7c824996637d2d76455c87ad47d76ba440937e38
25
+ x = Builder::XmlMarkup.new
26
+ x.pre ''
27
+ if x.target! == '<pre/>'
28
+ class XmlMarkup < Builder::XmlMarkup
29
+ def tag!(sym, *args, &block)
30
+ sym = "#{sym}:#{args.shift}" if args.first.kind_of?(::Symbol)
31
+ if not block and args.first == ''
32
+ attrs = {}
33
+ attrs.merge!(args.last) if ::Hash === args.last
34
+ _indent
35
+ _start_tag(sym, attrs)
36
+ _end_tag(sym)
37
+ _newline
38
+ else
39
+ super
40
+ end
41
+ end
42
+ end
43
+ else
44
+ XmlMarkup = Builder::XmlMarkup
45
+ end
46
+
47
+ # Determine which version of the rails cli to use. Over time, things
48
+ # change. The basic strategy is to code the scripts to the latest
49
+ # version of rails, and have the DSL automatically substitute prior
50
+ # equivalents when run against older baselines.
51
+ #
52
+ # This method returns a list of symbols that can be used to control
53
+ # which version of a given command is to be used.
54
+ def rails_epoc
55
+ return @rails_epoc if @rails_epoc
56
+ version = File.read('Gemfile.lock')[/^\s+rails \((\d+\.\d+)/, 1].
57
+ split('.').map(&:to_i)
58
+
59
+ @rails_epoc = []
60
+
61
+ @rails_epoc << :rake_test if (version <=> [5, 0]) == -1
62
+ @rails_epoc << :rake_db if (version <=> [5, 0]) == -1
63
+
64
+ @rails_epoc
65
+ end
66
+
67
+ $x = XmlMarkup.new(:indent => 2)
68
+ $toc = XmlMarkup.new(:indent => 2)
69
+ $todos = XmlMarkup.new(:indent => 2)
27
70
  $issue = 0
28
- $style = Builder::XmlMarkup.new(:indent => 2)
71
+ $style = XmlMarkup.new(:indent => 2)
29
72
 
30
73
  $semaphore = Mutex.new
31
74
  class Builder::XmlMarkup
@@ -55,12 +98,17 @@ module Gorp
55
98
  end
56
99
  alias :desc :note
57
100
 
101
+ def flag message
102
+ $x.p message, :class=>'traceback'
103
+ end
104
+ alias :warn :flag
105
+
58
106
  def log type, message
59
107
  Gorp.log type, message
60
108
  end
61
109
 
62
110
  @@section_number = 0
63
- def head number, title
111
+ def section_head number, title
64
112
  $section = "#{number} #{title}".strip
65
113
  number ||= (@@section_number+=1)
66
114
  log '====>', $section
@@ -74,19 +122,20 @@ module Gorp
74
122
 
75
123
  $issue+=1
76
124
  $x.p :class => 'issue', :id => "issue-#{$issue}" do
77
- $x.text! text
78
- if options[:ticket]
79
- $x.text! ' ('
80
- $x.a "ticket #{options[:ticket]}", :href=>
81
- 'https://rails.lighthouseapp.com/projects/8994/tickets/' +
82
- options[:ticket].to_s
83
- $x.text! ')'
84
- end
125
+ $x.text! text
126
+ if options[:pull]
127
+ $x.text! ' ('
128
+ repository = options[:repository] || 'rails'
129
+ $x.a "pull #{options[:pull]}", :href=>
130
+ "https://github.com/rails/#{repository}/pull/#{options[:pull]}"
131
+ options[:ticket].to_s
132
+ $x.text! ')'
133
+ end
85
134
  end
86
135
  $todos.li do
87
- section = $section.split(' ').first
88
- $todos.a "Section #{section}:", :href => "#section-#{section}"
89
- $todos.a "#{text}", :href => "#issue-#{$issue}"
136
+ section = $section.split(' ').first
137
+ $todos.a "Section #{section}:", :href => "#section-#{section}"
138
+ $todos.a "#{text}", :href => "#issue-#{$issue}"
90
139
  end
91
140
  end
92
141
 
@@ -101,16 +150,40 @@ module Gorp
101
150
  if args == 'script/server'
102
151
  restart_server
103
152
  else
104
- cmd "ruby #{args}"
153
+ args = args.split(' ')
154
+ args.map! do |arg|
155
+ if arg.include? '*'
156
+ files = Dir[arg]
157
+ arg = files.first if files.length == 1
158
+ end
159
+ arg
160
+ end
161
+ cmd "ruby #{args.join(' ')}"
105
162
  end
106
163
  end
107
164
 
108
- def rake args
109
- cmd "rake #{args}"
165
+ def rake args, opts = {}
166
+ if args == 'test:controllers' and File.exist? 'test/functional'
167
+ args = 'test:functionals'
168
+ elsif args == 'test:models' and File.exist? 'test/unit'
169
+ args = 'test:units'
170
+ end
171
+
172
+ status = cmd "rake #{args}"
173
+ if status and (opts[:pass] or opts[:fail])
174
+ if status.success? == true and opts[:pass]
175
+ issue opts[:pass], opts
176
+ end
177
+ if status.success? == false and opts[:fail]
178
+ issue opts[:fail], opts
179
+ end
180
+ end
110
181
  end
111
182
 
112
183
  def console script, env=nil
113
- if File.exist? 'script/rails'
184
+ if File.exist? 'bin/rails'
185
+ console_cmd = 'bin/rails console'
186
+ elsif File.exist? 'script/rails'
114
187
  console_cmd = 'script/rails console'
115
188
  else
116
189
  console_cmd = 'script/console'
@@ -137,18 +210,72 @@ module Gorp
137
210
 
138
211
  def generate *args
139
212
  if args.length == 1
140
- ruby "script/generate #{args.first}"
213
+ cmd "rails generate #{args.first}"
141
214
  else
142
215
  if args.last.respond_to? :keys
143
216
  args.push args.pop.map {|key,value| "#{key}:#{value}"}.join(' ')
144
217
  end
145
218
  args.map! {|arg| arg.inspect.include?('\\') ? arg.inspect : arg}
146
- ruby "script/generate #{args.join(' ')}"
219
+ cmd "rails generate #{args.join(' ')}"
147
220
  end
148
221
  end
149
222
 
150
223
  def runner *args
151
- ruby "script/runner #{args.join(' ')}"
224
+ cmd "rails runner #{args.join(' ')}"
225
+ end
226
+
227
+ def unbundle
228
+ save = {}
229
+ ENV.keys.dup.each {|key| save[key]=ENV.delete(key) if key =~ /^BUNDLE_/}
230
+ save['RUBYOPT'] = ENV.delete('RUBYOPT') if ENV['RUBYOPT']
231
+
232
+ yield
233
+ ensure
234
+ save.delete('BUNDLE_GEMFILE')
235
+ save.each {|key, value| ENV[key] = value}
236
+ end
237
+
238
+ def bundle *args
239
+ unbundle do
240
+ args << '--local' if args == ['install']
241
+ cmd "bundle #{args.join(' ')}"
242
+ end
243
+ end
244
+
245
+ def db action
246
+ if rails_epoc.include? :rake_db
247
+ cmd "rake db:#{action}"
248
+ else
249
+ cmd "rails db:#{action}"
250
+ end
251
+ end
252
+
253
+ def test *args
254
+ if args.length == 0
255
+ if rails_epoc.include? :rake_test
256
+ rake 'test'
257
+ else
258
+ cmd 'rails test'
259
+ end
260
+ elsif args.join.include? '.'
261
+ if File.exist? 'bin/rails'
262
+ # target = Dir[args.first].first.sub(/^test\//,'').sub(/\.rb$/,'')
263
+ target = Dir[args.first].first
264
+ if rails_epoc.include? :rake_test
265
+ cmd "rake test #{target}"
266
+ else
267
+ cmd "rails test #{target}"
268
+ end
269
+ else
270
+ ruby "-I test #{args.join(' ')}"
271
+ end
272
+ else
273
+ if rails_epoc.include? :rake_test
274
+ rake "test:#{args.first}"
275
+ else
276
+ cmd "rails test:#{args.first}"
277
+ end
278
+ end
152
279
  end
153
280
 
154
281
  def cmd args, opts={}
@@ -161,11 +288,11 @@ module Gorp
161
288
 
162
289
  if RUBY_PLATFORM =~ /w32/
163
290
  args.gsub! '/', '\\' unless args =~ /http:/
164
- args.sub! /^cmd \\c/, 'cmd /c'
165
- args.sub! /^cp -v/, 'xcopy /i /f /y'
166
- args.sub! /^ls -p/, 'dir/w'
167
- args.sub! /^ls/, 'dir'
168
- args.sub! /^cat/, 'type'
291
+ args.sub! /^cmd \\c/, 'cmd /c'
292
+ args.sub! /^cp -v/, 'xcopy /i /f /y'
293
+ args.sub! /^ls -p/, 'dir/w'
294
+ args.sub! /^ls/, 'dir'
295
+ args.sub! /^cat/, 'type'
169
296
  end
170
297
 
171
298
  as = opts[:as] || args
@@ -174,16 +301,17 @@ module Gorp
174
301
  log :cmd, as
175
302
  $x.pre as, :class=>'stdin'
176
303
 
177
- if args == 'rake db:migrate'
178
- Dir.chdir 'db/migrate' do
179
- date = '20110711000000'
304
+ if args == 'rake db:migrate' and File.exist? 'db/migrate'
305
+ Dir.chdir 'db/migrate' do
306
+ time = ((defined? DATETIME) ? Time.parse(DATETIME) : Time.now)
307
+ date = time.strftime('%Y%m%d000000')
180
308
  mask = Regexp.new("^#{date[0..-4]}")
181
- Dir['[0-9]*'].sort_by {|fn| fn=~mask ? fn : 'x'+fn}.each do |file|
182
- file =~ /^([0-9]*)_(.*)$/
183
- FileUtils.mv file, "#{date}_#{$2}" unless $1 == date.next!
184
- $x.pre "mv #{file} #{date}_#{$2}" unless $1 == date
185
- end
186
- end
309
+ Dir['[0-9]*'].sort_by {|fn| fn=~mask ? fn : 'x'+fn}.each do |file|
310
+ file =~ /^([0-9]*)_(.*)$/
311
+ FileUtils.mv file, "#{date}_#{$2}" unless $1 == date.next!
312
+ $x.pre "mv #{file} #{date}_#{$2}" unless $1 == date
313
+ end
314
+ end
187
315
  end
188
316
  args += ' -C' if args == 'ls -p'
189
317
  popen3 args, opts[:highlight] || []
@@ -195,44 +323,45 @@ module Gorp
195
323
  args = "bash -c #{$4.inspect}"
196
324
  echo = eval($1).gsub("\\n","\n")
197
325
  end
198
- Open3.popen3(args) do |pin, pout, perr|
199
- terr = Thread.new do
326
+ Open3.popen3(args) do |pin, pout, perr, wait|
327
+ terr = Thread.new do
200
328
  begin
201
- $x.pre! perr.readline.chomp, :class=>'stderr' until perr.eof?
329
+ $x.pre! perr.readline.chomp, :class=>'stderr' until perr.eof?
202
330
  rescue EOFError
203
331
  end
204
- end
205
- tin = Thread.new do
332
+ end
333
+ tin = Thread.new do
206
334
  echo.split("\n").each do |line|
207
- pin.puts line
335
+ pin.puts line
208
336
  end
209
- pin.close
210
- end
211
- until pout.eof?
337
+ pin.close
338
+ end
339
+ until pout.eof?
212
340
  begin
213
- line = pout.readline
341
+ line = pout.readline
214
342
  rescue EOFError
215
343
  break
216
344
  end
217
345
 
218
- if highlight.any? {|pattern| line.include? pattern}
219
- outclass='hilight'
220
- elsif line =~ /\x1b\[\d/
221
- outclass = 'logger'
222
- outclass = 'stderr' if line =~ /\x1b\[31m/
223
- line.gsub! /(\x1b\[1m)?\x1b\[3\dm(.*?)\x1b\[0m/, '\2'
224
- else
225
- outclass='stdout'
226
- end
227
-
228
- if line.strip.size == 0
229
- $x.pre! ' ', :class=>outclass
230
- else
231
- $x.pre! line.chomp, :class=>outclass
232
- end
233
- end
234
- terr.join
346
+ if highlight.any? {|pattern| line.include? pattern}
347
+ outclass='hilight'
348
+ elsif line =~ /\x1b\[\d/
349
+ outclass = 'logger'
350
+ outclass = 'stderr' if line =~ /\x1b\[31m/
351
+ line.gsub! /\x1b\[\d+m/, ''
352
+ else
353
+ outclass='stdout'
354
+ end
355
+
356
+ if line.strip.size == 0
357
+ $x.pre! ' ', :class=>outclass
358
+ else
359
+ $x.pre! line.chomp, :class=>outclass
360
+ end
361
+ end
362
+ terr.join
235
363
  tin.join
364
+ wait && wait.value
236
365
  end
237
366
  end
238
367
 
@@ -242,37 +371,37 @@ module Gorp
242
371
  cmd = "irb -f -rubygems -r ./config/boot --prompt-mode simple " +
243
372
  "#{$CODE}/#{file}"
244
373
  Open3.popen3(cmd) do |pin, pout, perr|
245
- terr = Thread.new do
246
- until perr.eof?
247
- line = perr.readline.chomp
248
- line.gsub! /\x1b\[4(;\d+)*m(.*?)\x1b\[0m/, '\2'
249
- line.gsub! /\x1b\[0(;\d+)*m(.*?)\x1b\[0m/, '\2'
250
- line.gsub! /\x1b\[0(;\d+)*m/, ''
251
- $x.pre! line, :class=>'stderr'
252
- end
253
- end
254
- pin.close
255
- prompt = nil
256
- until pout.eof?
257
- line = pout.readline
258
- if line =~ /^([?>]>)\s*#\s*(START|END):/
259
- prompt = $1
260
- elsif line =~ /^([?>]>)\s+$/
261
- $x.pre! ' ', :class=>'irb'
262
- prompt ||= $1
263
- elsif line =~ /^([?>]>)(.*)\n/
264
- prompt ||= $1
265
- $x.pre prompt + $2, :class=>'irb'
266
- prompt = nil
267
- elsif line =~ /^\w+(::\w+)*: /
268
- $x.pre! line.chomp, :class=>'stderr'
269
- elsif line =~ /^\s+from [\/.:].*:\d+:in `\w.*'\s*$/
270
- $x.pre! line.chomp, :class=>'stderr'
271
- else
272
- $x.pre! line.chomp, :class=>'stdout'
273
- end
274
- end
275
- terr.join
374
+ terr = Thread.new do
375
+ until perr.eof?
376
+ line = perr.readline.chomp
377
+ line.gsub! /\x1b\[4(;\d+)*m(.*?)\x1b\[0m/, '\2'
378
+ line.gsub! /\x1b\[0(;\d+)*m(.*?)\x1b\[0m/, '\2'
379
+ line.gsub! /\x1b\[0(;\d+)*m/, ''
380
+ $x.pre! line, :class=>'stderr'
381
+ end
382
+ end
383
+ pin.close
384
+ prompt = nil
385
+ until pout.eof?
386
+ line = pout.readline
387
+ if line =~ /^([?>]>)\s*#\s*(START|END):/
388
+ prompt = $1
389
+ elsif line =~ /^([?>]>)\s+$/
390
+ $x.pre! ' ', :class=>'irb'
391
+ prompt ||= $1
392
+ elsif line =~ /^([?>]>)(.*)\n/
393
+ prompt ||= $1
394
+ $x.pre prompt + $2, :class=>'irb'
395
+ prompt = nil
396
+ elsif line =~ /^\w+(::\w+)*: /
397
+ $x.pre! line.chomp, :class=>'stderr'
398
+ elsif line =~ /^\s+from [\/.:].*:\d+:in `\w.*'\s*$/
399
+ $x.pre! line.chomp, :class=>'stderr'
400
+ else
401
+ $x.pre! line.chomp, :class=>'stdout'
402
+ end
403
+ end
404
+ terr.join
276
405
  end
277
406
  end
278
407
  end