gorp 0.22.2 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -0,0 +1,16 @@
1
+ Manifest
2
+ README
3
+ Rakefile
4
+ gorp.gemspec
5
+ lib/gorp.rb
6
+ lib/gorp/commands.rb
7
+ lib/gorp/edit.rb
8
+ lib/gorp/env.rb
9
+ lib/gorp/net.rb
10
+ lib/gorp/output.css
11
+ lib/gorp/output.rb
12
+ lib/gorp/rails.env
13
+ lib/gorp/rails.rb
14
+ lib/gorp/test.rb
15
+ lib/gorp/xml.rb
16
+ lib/version.rb
data/Rakefile CHANGED
@@ -27,6 +27,7 @@ Echoe.new('gorp', Gorp::VERSION::STRING) do |p|
27
27
  rack-mount
28
28
  rack-test
29
29
  rake
30
+ thor
30
31
  sqlite3-ruby
31
32
  tzinfo
32
33
  )
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.22.2"
5
+ s.version = "0.23.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{2010-01-17}
9
+ s.date = %q{2010-02-25}
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
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
38
38
  s.add_runtime_dependency(%q<rack-mount>, [">= 0"])
39
39
  s.add_runtime_dependency(%q<rack-test>, [">= 0"])
40
40
  s.add_runtime_dependency(%q<rake>, [">= 0"])
41
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
41
42
  s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 0"])
42
43
  s.add_runtime_dependency(%q<tzinfo>, [">= 0"])
43
44
  else
@@ -49,6 +50,7 @@ Gem::Specification.new do |s|
49
50
  s.add_dependency(%q<rack-mount>, [">= 0"])
50
51
  s.add_dependency(%q<rack-test>, [">= 0"])
51
52
  s.add_dependency(%q<rake>, [">= 0"])
53
+ s.add_dependency(%q<thor>, [">= 0"])
52
54
  s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
53
55
  s.add_dependency(%q<tzinfo>, [">= 0"])
54
56
  end
@@ -61,6 +63,7 @@ Gem::Specification.new do |s|
61
63
  s.add_dependency(%q<rack-mount>, [">= 0"])
62
64
  s.add_dependency(%q<rack-test>, [">= 0"])
63
65
  s.add_dependency(%q<rake>, [">= 0"])
66
+ s.add_dependency(%q<thor>, [">= 0"])
64
67
  s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
65
68
  s.add_dependency(%q<tzinfo>, [">= 0"])
66
69
  end
data/lib/gorp/commands.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'fileutils'
2
2
  require 'builder'
3
- require 'open3'
4
3
  require 'time'
5
4
 
6
5
  module Gorp
@@ -50,9 +49,10 @@ module Gorp
50
49
  $x.p message.gsub(/(^|\n)\s+/, ' ').strip, :class=>'overview'
51
50
  end
52
51
 
53
- def desc message
54
- $x.p message, :class=>'desc'
52
+ def note message
53
+ $x.p message, :class=>'note'
55
54
  end
55
+ alias :desc :note
56
56
 
57
57
  def log type, message
58
58
  Gorp.log type, message
@@ -89,11 +89,11 @@ module Gorp
89
89
  end
90
90
  end
91
91
 
92
- def db statement, hilight=[]
92
+ def db statement, highlight=[]
93
93
  log :db, statement
94
94
  $x.pre "sqlite3> #{statement}", :class=>'stdin'
95
95
  cmd = "sqlite3 --line db/development.sqlite3 #{statement.inspect}"
96
- popen3 cmd, hilight
96
+ popen3 cmd, highlight
97
97
  end
98
98
 
99
99
  def ruby args
@@ -109,14 +109,61 @@ module Gorp
109
109
  end
110
110
 
111
111
  def console script
112
+ if File.exist? 'script/rails'
113
+ console_cmd = 'script/rails console'
114
+ else
115
+ console_cmd = 'script/console'
116
+ end
117
+
112
118
  open('tmp/irbrc','w') {|fh| fh.write('IRB.conf[:PROMPT_MODE]=:SIMPLE')}
113
- cmd "echo #{script.inspect} | IRBRC=tmp/irbrc ruby script/console"
119
+ if RUBY_PLATFORM =~ /cygwin/i
120
+ open('tmp/irbin','w') {|fh| fh.write(script.gsub('\n',"\n")+"\n")}
121
+ cmd "IRBRC=tmp/irbrc ruby #{console_cmd} < tmp/irbin"
122
+ FileUtils.rm_rf 'tmp/irbin'
123
+ else
124
+ cmd "echo #{script.inspect} | IRBRC=tmp/irbrc ruby #{console_cmd}"
125
+ end
114
126
  FileUtils.rm_rf 'tmp/irbrc'
115
127
  end
116
128
 
117
- def cmd args, hilight=[]
118
- log :cmd, args
119
- $x.pre args, :class=>'stdin'
129
+ def generate *args
130
+ if args.length == 1
131
+ ruby "script/generate #{args.first}"
132
+ else
133
+ if args.last.respond_to? :keys
134
+ args.push args.pop.map {|key,value| "#{key}:#{value}"}.join(' ')
135
+ end
136
+ args.map! {|arg| arg.inspect.include?('\\') ? arg.inspect : arg}
137
+ ruby "script/generate #{args.join(' ')}"
138
+ end
139
+ end
140
+
141
+ def runner *args
142
+ ruby "script/runner #{args.join(' ')}"
143
+ end
144
+
145
+ def cmd args, opts={}
146
+ if args =~ /^ruby script\/(\w+)/ and File.exist?('script/rails')
147
+ unless File.exist? "script/#{$1}"
148
+ args.sub! 'ruby script/performance/', 'ruby script/'
149
+ args.sub! 'ruby script/', 'ruby script/rails '
150
+ end
151
+ end
152
+
153
+ if RUBY_PLATFORM =~ /w32/
154
+ args.gsub! '/', '\\' unless args =~ /http:/
155
+ args.sub! /^cp -v/, 'xcopy /i /f /y'
156
+ args.sub! /^ls -p/, 'dir/w'
157
+ args.sub! /^ls/, 'dir'
158
+ args.sub! /^cat/, 'type'
159
+ end
160
+
161
+ as = opts[:as] || args
162
+ as = as.sub('ruby script/rails ', 'rails ')
163
+
164
+ log :cmd, as
165
+ $x.pre as, :class=>'stdin'
166
+
120
167
  if args == 'rake db:migrate'
121
168
  Dir.chdir 'db/migrate' do
122
169
  date = '20100301000000'
@@ -128,22 +175,31 @@ module Gorp
128
175
  end
129
176
  end
130
177
  args += ' -C' if args == 'ls -p'
131
- popen3 args, hilight
178
+ popen3 args, opts[:highlight] || []
132
179
  end
133
180
 
134
- def popen3 args, hilight=[]
181
+ def popen3 args, highlight=[]
135
182
  Open3.popen3(args) do |pin, pout, perr|
136
183
  terr = Thread.new do
137
- $x.pre! perr.readline.chomp, :class=>'stderr' until perr.eof?
184
+ begin
185
+ $x.pre! perr.readline.chomp, :class=>'stderr' until perr.eof?
186
+ rescue EOFError
187
+ end
138
188
  end
139
189
  pin.close
140
190
  until pout.eof?
141
- line = pout.readline
142
- if hilight.any? {|pattern| line.include? pattern}
191
+ begin
192
+ line = pout.readline
193
+ rescue EOFError
194
+ break
195
+ end
196
+
197
+ if highlight.any? {|pattern| line.include? pattern}
143
198
  outclass='hilight'
144
199
  elsif line =~ /\x1b\[\d/
145
- line.gsub! /\x1b\[1m\x1b\[3\dm(.*?)\x1b\[0m/, '\1'
146
200
  outclass = 'logger'
201
+ outclass = 'stderr' if line =~ /\x1b\[31m/
202
+ line.gsub! /(\x1b\[1m)?\x1b\[3\dm(.*?)\x1b\[0m/, '\2'
147
203
  else
148
204
  outclass='stdout'
149
205
  end
data/lib/gorp/edit.rb CHANGED
@@ -7,6 +7,29 @@ class String
7
7
  end
8
8
  end
9
9
 
10
+ unless defined? instance_exec # Rails, Ruby 1.9
11
+ class Proc #:nodoc:
12
+ def bind(object)
13
+ block, time = self, Time.now
14
+ (class << object; self end).class_eval do
15
+ method_name = "__bind_#{time.to_i}_#{time.usec}"
16
+ define_method(method_name, &block)
17
+ method = instance_method(method_name)
18
+ remove_method(method_name)
19
+ method
20
+ end.bind(object)
21
+ end
22
+ end
23
+
24
+ module Gorp
25
+ module StringEditingFunctions
26
+ def instance_exec(*arguments, &block)
27
+ block.bind(self)[*arguments]
28
+ end
29
+ end
30
+ end
31
+ end
32
+
10
33
  module Gorp
11
34
  module StringEditingFunctions
12
35
  def highlight
@@ -43,7 +66,7 @@ module Gorp
43
66
  end
44
67
  end
45
68
 
46
- def edit(from, *options)
69
+ def edit(from, *options, &block)
47
70
  if from.instance_of? String
48
71
  from = Regexp.new('.*' + Regexp.escape(from) + '.*')
49
72
  end
@@ -52,21 +75,23 @@ module Gorp
52
75
 
53
76
  sub!(from) do |base|
54
77
  base.extend Gorp::StringEditingFunctions
55
- yield base if block_given?
78
+ base.instance_exec(base, &block) if block_given?
56
79
  base.highlight if options.include? :highlight
57
80
  base.mark(options.last[:mark]) if options.last.respond_to? :keys
58
81
  base
59
82
  end
60
83
  end
61
84
 
62
- def dcl(name, *options)
85
+ def dcl(name, *options, &block)
86
+ options[-1] = {:mark => name} if options.last == :mark
87
+
63
88
  re = Regexp.new '^(\s*)(class|def|test)\s+"?' + name +
64
89
  '"?.*?\n\1end\n', Regexp::MULTILINE
65
90
  raise IndexError.new('regexp not matched') unless match(re)
66
91
 
67
92
  self.sub!(re) do |lines|
68
93
  lines.extend Gorp::StringEditingFunctions
69
- yield lines if block_given?
94
+ lines.instance_exec(lines, &block) if block_given?
70
95
  lines.mark(options.last[:mark]) if options.last.respond_to? :[]
71
96
  lines
72
97
  end
@@ -106,8 +131,8 @@ module Gorp
106
131
  end
107
132
  end
108
133
 
109
- def edit filename, tag=nil
110
- $x.pre "edit #{filename}", :class=>'stdin'
134
+ def edit filename, tag=nil, &block
135
+ $x.pre "edit #{filename.gsub('/',FILE_SEPARATOR)}", :class=>'stdin'
111
136
 
112
137
  stale = File.mtime(filename) rescue Time.now-2
113
138
  data = open(filename) {|file| file.read} rescue ''
@@ -115,7 +140,7 @@ def edit filename, tag=nil
115
140
 
116
141
  begin
117
142
  data.extend Gorp::StringEditingFunctions
118
- yield data if block_given?
143
+ data.instance_exec(data, &block) if block_given?
119
144
 
120
145
  # ensure that the file timestamp changed
121
146
  now = Time.now
@@ -136,18 +161,18 @@ def edit filename, tag=nil
136
161
  log :edit, filename
137
162
 
138
163
  include = tag.nil?
139
- hilight = false
164
+ highlight = false
140
165
  data.split("\n").each do |line|
141
166
  if line =~ /START:(\w+)/
142
167
  include = true if $1 == tag
143
168
  elsif line =~ /END:(\w+)/
144
169
  include = false if $1 == tag
145
170
  elsif line =~ /START_HIGHLIGHT/
146
- hilight = true
171
+ highlight = true
147
172
  elsif line =~ /END_HIGHLIGHT/
148
- hilight = false
173
+ highlight = false
149
174
  elsif include
150
- if hilight or ! before.include?(line)
175
+ if highlight or ! before.include?(line)
151
176
  outclass='hilight'
152
177
  else
153
178
  outclass='stdout'
data/lib/gorp/env.rb CHANGED
@@ -1,6 +1,16 @@
1
1
  require 'fileutils'
2
2
  require 'pathname'
3
3
 
4
+ unless RUBY_PLATFORM =~ /mingw32/
5
+ require 'open3'
6
+ FILE_SEPARATOR = '/'
7
+ DEV_NULL = '/dev/null'
8
+ else
9
+ require 'win32/open3'
10
+ FILE_SEPARATOR = '\\'
11
+ DEV_NULL = 'NUL'
12
+ end
13
+
4
14
  # determine port
5
15
  if ARGV.find {|arg| arg =~ /--port=(\d+)/}
6
16
  $PORT=$1.to_i
@@ -34,17 +44,21 @@ module Gorp
34
44
  cmd "#{$ruby} -v"
35
45
  cmd 'gem -v'
36
46
  Dir.chdir(File.join($WORK, $rails_app.to_s)) do
37
- caches = Dir['vendor/gems/ruby/*/cache']
38
- if caches.empty?
47
+ if $bundle
48
+ cmd 'bundle show'
49
+ else
39
50
  cmd 'gem list'
40
51
  cmd 'echo $RUBYLIB | sed "s/:/\n/g"'
41
- else
42
- cmd 'gem list | grep "^bundler "'
43
- caches.each {|cache| cmd "ls #{cache}"}
44
52
  end
45
53
  end
46
54
 
47
- cmd Gorp.which_rails($rails) + ' -v'
55
+ if File.exist? 'Gemfile'
56
+ rake 'about'
57
+ elsif File.exist? 'script/rails'
58
+ cmd 'ruby script/rails application -v'
59
+ else
60
+ cmd Gorp.which_rails($rails) + ' -v'
61
+ end
48
62
 
49
63
  if $rails != 'rails'
50
64
  Dir.chdir($rails) do
@@ -61,11 +75,13 @@ module Gorp
61
75
  end
62
76
  end
63
77
  end
78
+ rescue
64
79
  end
65
80
 
66
81
  def self.log type, message
67
82
  type = type.to_s.ljust(5).upcase
68
83
  $stdout.puts Time.now.strftime("[%Y-%m-%d %H:%M:%S] #{type} #{message}")
84
+ $stdout.flush
69
85
  end
70
86
 
71
87
  def self.path *segments
data/lib/gorp/net.rb CHANGED
@@ -108,8 +108,8 @@ def post path, form, options={}
108
108
 
109
109
  # find matching button by action
110
110
  xform = xforms.find do |element|
111
- next unless element.attribute('action').to_s.include?('?')
112
- query = CGI.parse(URI.parse(element.attribute('action').to_s).query)
111
+ next unless element['action'].include?('?')
112
+ query = CGI.parse(URI.parse(element['action']).query)
113
113
  query.all? {|key,values| values.include?(form[key].to_s)}
114
114
  end
115
115
 
@@ -117,7 +117,7 @@ def post path, form, options={}
117
117
  xform ||= xforms.find do |element|
118
118
  form.all? do |name, value|
119
119
  element.search('.//input | .//textarea | ..//select').any? do |input|
120
- input.attribute('name').to_s==name.to_s
120
+ input['name']==name.to_s
121
121
  end
122
122
  end
123
123
  end
@@ -126,16 +126,15 @@ def post path, form, options={}
126
126
  xform ||= xforms.find do |element|
127
127
  form.all? do |name, value|
128
128
  element.search('.//input[@type="submit"]').any? do |input|
129
- input.attribute('value').to_s==form['submit']
129
+ input['value']==form['submit']
130
130
  end
131
131
  end
132
132
  end
133
133
 
134
134
  # match based on action itself
135
135
  xform ||= xforms.find do |element|
136
- form.all? do |name, value|
137
- element.attribute('action').to_s.include?(path)
138
- end
136
+ action=CGI.unescape(element['action'])
137
+ form.all? {|name, value| action.include? "#{name}=#{value}"}
139
138
  end
140
139
 
141
140
  # look for a commit button
@@ -143,8 +142,8 @@ def post path, form, options={}
143
142
 
144
143
  return unless xform
145
144
 
146
- path = xform.attribute('action').to_s unless
147
- xform.attribute('action').to_s.empty?
145
+ path = xform['action'] unless xform['action'].empty?
146
+ path = CGI::unescapeHTML(path)
148
147
  $x.pre "post #{path}", :class=>'stdin'
149
148
 
150
149
  $x.ul do
data/lib/gorp/output.css CHANGED
@@ -19,8 +19,8 @@ ul a:hover {text-decoration: underline; color: #000;
19
19
  a.toc h2 {background-color: #981A21; color:#FFF; padding: 6px}
20
20
  ul a:visited {color: #000}
21
21
  h2 {clear: both}
22
- p.desc {font-style: italic}
22
+ p.note {font-style: italic}
23
23
  p.overview {border-width: 2px; border-color: #000;
24
24
  border-style: solid; border-radius: 4em;
25
25
  background-color: #CCF; margin: 1.5em 1.5em; padding: 1em 2em;
26
- -webkit-border-radius: 4em; -moz-border-radius: 4em;}
26
+ -webkit-border-radius: 1.5em; -moz-border-radius: 4em;}
data/lib/gorp/output.rb CHANGED
@@ -11,7 +11,7 @@ at_exit do
11
11
  $x.html :xmlns => 'http://www.w3.org/1999/xhtml' do
12
12
  $x.header do
13
13
  $x.title $title
14
- $x.meta 'http-equiv'=>'text/html; charset=UTF-8'
14
+ $x.meta 'charset'=>'utf-8'
15
15
  $x.style :type => "text/css" do
16
16
  open(File.join(File.dirname(__FILE__), 'output.css')) do |file|
17
17
  $x.text! file.read.gsub(/^/, ' ')
data/lib/gorp/rails.env CHANGED
@@ -5,13 +5,16 @@
5
5
  # What it does is ensure that requires of things like 'active_script' are
6
6
  # satisfied by the vendored rails, and not by whatever gems you have
7
7
  # installed.
8
+ #
9
+ # if vendor/rails is not present, the provided boot.rb procedure will be run
10
+ # unchanged. If bundler is ever run on this application, this file will be
11
+ # overwritten, and therefore will not interfere with bundling operations.
8
12
 
9
- vendor = File.expand_path(File.dirname(File.dirname(__FILE__)))
10
- vendor_rails = File.join(vendor, 'rails')
13
+ require 'rubygems'
11
14
 
12
- if File.exist? vendor_rails
13
- require 'rubygems'
15
+ vendor_rails = File.expand_path('../../vendor/rails', __FILE__)
14
16
 
17
+ if File.exist? vendor_rails
15
18
  Dir.chdir(vendor_rails) do
16
19
  rails_version = open('railties/lib/rails/version.rb') do |file|
17
20
  eval(file.read.gsub(/\s*(module|end).*\n/, '').downcase)
@@ -34,8 +37,17 @@ if File.exist? vendor_rails
34
37
  Gem.source_index.add_spec spec
35
38
  end
36
39
  end
37
- end
38
40
 
39
- module Gem
40
- @loaded_stacks = Hash.new { |h,k| h[k] = [] }
41
+ module Gem
42
+ @loaded_stacks = Hash.new { |h,k| h[k] = [] }
43
+ end
44
+
45
+ module Bundler
46
+ def self.require *args
47
+ end
48
+ end
49
+ else
50
+ require 'bundler'
51
+ Bundler.setup
41
52
  end
53
+
data/lib/gorp/rails.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'fileutils'
2
- require 'open3'
3
2
  require 'builder'
4
3
  require 'stringio'
5
4
  require 'time'
@@ -45,21 +44,26 @@ end
45
44
 
46
45
  # verify version of rails
47
46
  if $rails =~ /^rails( |$)/
48
- `#{$rails} -v 2>/dev/null`
47
+ `#{$rails} -v 2>#{DEV_NULL}`
49
48
  else
50
- `ruby #{$rails}/railties/bin/rails -v 2>/dev/null`
49
+ `ruby #{$rails}/railties/bin/rails -v 2>#{DEV_NULL}`
51
50
  end
52
51
 
53
52
  if $?.success?
54
53
  # setup vendored environment
55
- FileUtils.mkdir_p File.join($WORK, 'vendor', 'gems')
56
54
  FileUtils.rm_f File.join($WORK, 'vendor', 'rails')
57
55
  if $rails =~ /^rails( |$)/
58
- FileUtils.rm_f File.join($WORK, 'vendor', 'gems', 'environment.rb')
56
+ FileUtils.rm_f File.join($WORK, '.bundle', 'environment.rb')
59
57
  else
60
- FileUtils.ln_s $rails, File.join($WORK, 'vendor', 'rails')
58
+ FileUtils.mkdir_p File.join($WORK, 'vendor')
59
+ begin
60
+ FileUtils.ln_s $rails, File.join($WORK, 'vendor', 'rails')
61
+ rescue NotImplementedError
62
+ FileUtils.cp_r $rails, File.join($WORK, 'vendor', 'rails')
63
+ end
64
+ FileUtils.mkdir_p File.join($WORK, '.bundle')
61
65
  FileUtils.cp File.join(File.dirname(__FILE__), 'rails.env'),
62
- File.join($WORK, 'vendor', 'gems', 'environment.rb')
66
+ File.join($WORK, '.bundle', 'environment.rb')
63
67
  end
64
68
  else
65
69
  puts "Install rails or specify path to git clone of rails as the " +
@@ -67,7 +71,10 @@ else
67
71
  Process.exit!
68
72
  end
69
73
 
70
- $bundle = ARGV.include?('bundle') || ARGV.include?('--bundle')
74
+ # http://redmine.ruby-lang.org/issues/show/2717
75
+ $bundle = File.exist?(File.join($rails, 'Gemfile'))
76
+ $bundle = true if ARGV.include?('--bundle')
77
+ $bundle = false if ARGV.include?('--vendor')
71
78
 
72
79
  module Gorp
73
80
  # determine which version of rails is running
@@ -89,10 +96,11 @@ module Gorp
89
96
  log :rails, name
90
97
 
91
98
  # determine how to invoke rails
92
- rails = Gorp.which_rails $rails
99
+ rails = Gorp.which_rails($rails)
100
+ rails.sub! 'ruby ', 'ruby -rubygems '
93
101
 
94
- opt = ($bundle ? ' --dev' : '')
95
- $x.pre "#{rails} #{name}#{opt}", :class=>'stdin'
102
+ opt = (ARGV.include?('--dev') ? ' --dev' : '')
103
+ $x.pre "#{rails.gsub('/',FILE_SEPARATOR)} #{name}#{opt}", :class=>'stdin'
96
104
  popen3 "#{rails} #{name}#{opt}"
97
105
 
98
106
  # canonicalize the reference to Ruby
@@ -111,42 +119,17 @@ module Gorp
111
119
 
112
120
  if $rails != 'rails' and File.directory?($rails)
113
121
  if File.exist? 'Gemfile'
114
- if $bundle
115
- if ENV['RUBYLIB'] or ARGV.include?('--system')
116
- gem=open('Gemfile') {|file| file.read}
117
-
118
- gem.sub! /gem "rails", :path => "(.*)"/ do
119
- rails = "directory \"#{$1}\", :glob => '{*/,}*.gemspec'\n"
120
-
121
- version = open("#{$1}/railties/lib/rails/version.rb") do |file|
122
- eval(file.read.gsub(/\s*(module|end).*\n/, '').downcase)
123
- end
124
-
125
- if ARGV.include?('--system')
126
- rails = <<-EOF.gsub(/^\s+/,'') + rails
127
- @environment.clear_sources
128
- @environment.add_source SystemGemSource.instance
129
- EOF
130
- end
122
+ gemfile=open('Gemfile') {|file| file.read}
123
+ gemfile[/gem 'rails',()/,1] = " :path => #{$rails.inspect} #"
124
+ gemfile[/^()source/, 1] = '# '
131
125
 
132
- if ENV['RUBYLIB']
133
- ENV['RUBYLIB'].split(File::PATH_SEPARATOR).each do |lib|
134
- rails << "directory #{lib.sub(/\/lib$/,'').inspect}\n"
135
- end
136
- end
137
-
138
- rails + "gem \"rails\", #{version.inspect}"
139
- end
140
-
141
- open('Gemfile','w') {|file| file.write gem}
142
- end
143
-
144
- cmd 'gem bundle --only default'
126
+ open('Gemfile','w') {|file| file.write gemfile}
127
+ if $bundle
128
+ cmd "bundle install"
145
129
  else
146
- system 'mkdir -p vendor/gems'
147
130
  cmd "ln -s #{$rails} vendor/rails"
148
- system "cp #{__FILE__.sub(/\.rb$/,'.env')} " +
149
- "vendor/gems/environment.rb"
131
+ system "mkdir -p .bundle"
132
+ system "cp #{__FILE__.sub(/\.rb$/,'.env')} .bundle/environment.rb"
150
133
  end
151
134
  else
152
135
  system 'mkdir -p vendor'
@@ -174,10 +157,18 @@ module Gorp
174
157
  end
175
158
 
176
159
  if $server
177
- Process.kill "INT", $server
178
- Process.wait($server)
179
- $server = nil
160
+ if $server.respond_to?(:process_id)
161
+ # Windows
162
+ Process.kill 1, $server.process_id
163
+ Process.waitpid($server.process_id) rescue nil
164
+ else
165
+ # UNIX
166
+ Process.kill "INT", $server
167
+ Process.wait($server)
168
+ end
180
169
  end
170
+ ensure
171
+ $server = nil
181
172
  end
182
173
 
183
174
  # start/restart a rails server in a separate process
@@ -191,7 +182,20 @@ module Gorp
191
182
  $x.h3 'Start the server.'
192
183
  end
193
184
 
194
- $server = fork
185
+ if File.exist? 'script/rails'
186
+ rails_server = "#{$ruby} script/rails server --port #{$PORT}"
187
+ else
188
+ rails_server = "#{$ruby} script/server --port #{$PORT}"
189
+ end
190
+
191
+ if RUBY_PLATFORM !~ /mingw32/
192
+ $server = fork
193
+ else
194
+ require 'win32/process'
195
+ $server = Process.create(:app_name => rails_server)
196
+ # :startup_info => {:stdout => File.open('NUL','w+')}
197
+ end
198
+
195
199
  if $server
196
200
  # wait for server to start
197
201
  60.times do
@@ -211,7 +215,7 @@ module Gorp
211
215
  #
212
216
  unless ENV['GATEWAY_INTERFACE'].to_s =~ /CGI/
213
217
  STDOUT.reopen '/dev/null', 'a'
214
- exec "#{$ruby} script/server --port #{$PORT}"
218
+ exec rails_server
215
219
  end
216
220
 
217
221
  # alternatives to the above, with backtrace
data/lib/gorp/test.rb CHANGED
@@ -7,8 +7,8 @@ require 'gorp/commands'
7
7
  class Gorp::TestCase < Test::Unit::TestCase
8
8
  def self.suite
9
9
  # Deferred loading of Rails infrastructure
10
- if File.exist? "#{$WORK}/vendor/gems/environment.rb"
11
- require "#{$WORK}/vendor/gems/environment.rb"
10
+ if File.exist? "#{$WORK}/.bundle/environment.rb"
11
+ require "#{$WORK}/.bundle/environment.rb"
12
12
  end
13
13
 
14
14
  require 'active_support'
@@ -100,7 +100,7 @@ class Gorp::TestCase < Test::Unit::TestCase
100
100
  # reattach anchors
101
101
  @@sections.each do |key,value|
102
102
  next unless key =~ /^\d/
103
- @@sections[key] = "<a class=\"toc\" name=\"section-#{key}\">#{value}"
103
+ @@sections[key] = "<a class=\"toc\" id=\"section-#{key}\">#{value}"
104
104
  end
105
105
 
106
106
  # report version
@@ -145,7 +145,7 @@ class Gorp::TestCase < Test::Unit::TestCase
145
145
  @@base = Object.new.extend(Gorp::Commands)
146
146
  include Gorp::Commands
147
147
 
148
- %w(cmd get post rake ruby).each do |method|
148
+ %w(cmd get post rake ruby console).each do |method|
149
149
  define_method(method) do |*args, &block|
150
150
  before = $x.target.length
151
151
  @@base.send method, *args
@@ -186,7 +186,9 @@ class HTMLRunner < Test::Unit::UI::Console::TestRunner
186
186
 
187
187
  tickets = {
188
188
  'rails' => 'https://rails.lighthouseapp.com/projects/8994/tickets/',
189
- 'ruby' => 'http://redmine.ruby-lang.org/issues/show/'
189
+ 'ruby' => 'http://redmine.ruby-lang.org/issues/show/',
190
+ 'bundler' => 'http://github.com/carlhuda/bundler/issues/issue/',
191
+ 'will_paginate' => 'http://github.com/mislav/will_paginate/issues#issue/'
190
192
  }
191
193
 
192
194
  if fault.respond_to? :location
@@ -220,10 +222,10 @@ class HTMLRunner < Test::Unit::UI::Console::TestRunner
220
222
  x = Builder::XmlMarkup.new(:indent => 2)
221
223
  x.li do
222
224
  x.a "Section #{name}", :href => "#section-#{name}"
223
- if fault.message =~ /RuntimeError: Ticket (\d+): (.*)/
225
+ if fault.message =~ /RuntimeError: Ticket (\w+):(\d+): (.*)/
224
226
  x.text! '['
225
- x.a "Ticket #{$1}", :href => tickets+$1
226
- x.text! ']: ' + $2
227
+ x.a "Ticket #{$2}", :href => tickets[$1]+$2
228
+ x.text! ']: ' + $3
227
229
  else
228
230
  x.text! ': '
229
231
  x.tt fault.message.sub(".\n<false> is not true",'').
data/lib/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Gorp
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 22
5
- TINY = 2
4
+ MINOR = 23
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.22.2
4
+ version: 0.23.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: 2010-01-17 00:00:00 -05:00
12
+ date: 2010-02-25 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -92,6 +92,16 @@ dependencies:
92
92
  - !ruby/object:Gem::Version
93
93
  version: "0"
94
94
  version:
95
+ - !ruby/object:Gem::Dependency
96
+ name: thor
97
+ type: :runtime
98
+ version_requirement:
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: "0"
104
+ version:
95
105
  - !ruby/object:Gem::Dependency
96
106
  name: sqlite3-ruby
97
107
  type: :runtime