snailgun-rr 1.1.1.3

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.
@@ -0,0 +1,15 @@
1
+ If you use ruby-1.9.2-p0 on Snow Leopard snailgun won't work out of the Box!
2
+
3
+ I have included a small patch to the ruby-sources that make it work:
4
+
5
+ (this is assuming you use rvm)
6
+
7
+ cd $HOME/.rvm/src/ruby-1.9.2-p0/ext/socket
8
+ patch -p1 < wherever_snailgun_was_installed/ruby-1.9.2-p0.patch
9
+ ruby extconf.rb
10
+ make clean
11
+ make clean install
12
+
13
+ Patch was taken from http://redmine.ruby-lang.org/repositories/revision/ruby-19?rev=29242
14
+
15
+ thieso@gmail.com 20101024
data/README-textmate ADDED
@@ -0,0 +1,26 @@
1
+ To get ultra fast CMD-R results in textmate you need to patch the run_script.rb that comes with textmate:
2
+
3
+ cd /Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/
4
+
5
+ patch -p0 < wherever_snailgun_was_installed/textmate.patch
6
+
7
+ To run test in never before seen speed simply cd into your rails-app (tested with rails 3) and say:
8
+
9
+ > snailgun
10
+
11
+ the output should read something like:
12
+ Now entering subshell for RAILS_ENV=test. Use 'exit' to terminate snailgun
13
+ Server starting for RAILS_ENV=test
14
+ .. some seconds later ...
15
+ Server ready for RAILS_ENV=test
16
+
17
+ Now you can either use fruby instead of ruby to start tests "by hand":
18
+
19
+ fruby -Itest test/unit/your_test.rb
20
+
21
+ or - in TextMate - simply navigate to your_test.rb and hit CMD-R
22
+
23
+ enjoy!
24
+
25
+ thieso@gmail.com 20101024 at #rchh
26
+
data/README.markdown ADDED
@@ -0,0 +1,216 @@
1
+ Snailgun
2
+ ========
3
+
4
+ Snailgun accelerates the startup of Ruby applications which require large
5
+ numbers of libraries. It does this by preparing a Ruby process with your
6
+ chosen libraries preloaded, and then forking that process whenever a new
7
+ command-line Ruby interpreter is required.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ sudo gem install mysql_retry_lost_connection
13
+ sudo gem install snailgun-rr
14
+
15
+ Case 1: standalone
16
+ ------------------
17
+
18
+ # WITHOUT SNAILGUN
19
+ $ time ruby -rubygems -e 'require "active_support"' -e 'puts "".blank?'
20
+ true
21
+
22
+ real 0m2.123s
23
+ user 0m1.424s
24
+ sys 0m0.168s
25
+
26
+ # WITH SNAILGUN
27
+ $ snailgun -rubygems -ractive_support
28
+ Snailgun starting on /home/brian/.snailgun/14781 - 'exit' to end
29
+ $ time fruby -e 'puts "".blank?'
30
+ true
31
+
32
+ real 0m0.064s
33
+ user 0m0.020s
34
+ sys 0m0.004s
35
+
36
+ $ exit
37
+ logout
38
+ Snailgun ended
39
+ $
40
+
41
+ Case 2: Rails app
42
+ -----------------
43
+
44
+ When using Rails or Merb, snailgun will start a process preloaded for the
45
+ `test` environment only unless told otherwise.
46
+
47
+ You need to edit `config/environments/test.rb` and set
48
+ `config.cache_classes = false`. This is so that your application classes
49
+ are loaded each time you run a test, rather than being preloaded into
50
+ the test environment.
51
+
52
+ Snailgun will take several seconds to be ready to process requests. Start
53
+ with `snailgun -v` if you wish to be notified when it is ready.
54
+
55
+ $ rails testapp
56
+ $ cd testapp
57
+ $ vi config/environments/test.rb
58
+ ... set config.cache_classes = false
59
+ $ snailgun -I test
60
+ Now entering subshell. Use 'exit' to terminate snailgun
61
+
62
+ $ time RAILS_ENV=test fruby script/runner 'puts 1+2'
63
+ 3
64
+
65
+ real 0m0.169s
66
+ user 0m0.040s
67
+ sys 0m0.008s
68
+
69
+ # To run your test suite
70
+ $ frake test # or frake spec
71
+
72
+ Your preloaded process will remain around until you type `exit` to terminate
73
+ it.
74
+
75
+ Note that any attempt by `fruby` or `frake` to perform an action in an
76
+ environment other than 'test' will fail. See below for how to run multiple
77
+ snailgun environments.
78
+
79
+ Merb support has been contributed (using MERB_ENV), but it is untested by
80
+ me.
81
+
82
+ Case 3: Rails with multiple environments
83
+ ----------------------------------------
84
+
85
+ After reading the warnings below, you may choose to start multiple snailgun
86
+ processes each configured for a different environment, as follows:
87
+
88
+ $ snailgun --rails test,development
89
+
90
+ This gives the potential for faster startup of rake tasks which involve
91
+ the development environment (such as migrations) and the console. The
92
+ utility `fconsole` is provided for this.
93
+
94
+ However, beware that frake and fruby need to decide which of the preloaded
95
+ environments to dispatch the command to. The safest way is to force the
96
+ correct one explicitly:
97
+
98
+ RAILS_ENV=test frake test:units
99
+ RAILS_ENV=development fruby script/server
100
+ RAILS_ENV=test fruby script/runner 'puts "".blank?'
101
+
102
+ If you do not specify the environment, then a simple heuristic is used:
103
+
104
+ * `fruby` always defaults to the 'development' environment.
105
+
106
+ * `frake` honours any `RAILS_ENV=xxx` setting on the command line. If
107
+ missing, `frake` defaults to the 'test' environment if no args are given or
108
+ if an arg containing the word 'test' or 'spec' is given; otherwise it falls
109
+ back to the 'development' environment.
110
+
111
+ WARNING: The decision as to which of the preloaded environments to use is
112
+ made *before* actually running the command. If the wrong choice is made, it
113
+ can lead to problems.
114
+
115
+ In the worst case, you may have a 'test'-type task, but find that it is
116
+ wrongly dispatched to your 'development' environment - and possibly ends up
117
+ blowing away your development database. This actually happened to me while
118
+ developing snailgun. SO IF YOUR DEVELOPMENT DATABASE CONTAINS USEFUL DATA,
119
+ KEEP IT BACKED UP.
120
+
121
+ If you run test files individually, it is especially critical that you set
122
+ the correct environment. e.g.
123
+
124
+ RAILS_ENV=test fruby -Ilib -Itest test/unit/some_test.rb
125
+
126
+ Case 4: Rails with cucumber
127
+ ---------------------------
128
+
129
+ Cucumber creates its own Rails environment called "cucumber", so you can
130
+ setup snailgun like this:
131
+
132
+ $ snailgun --rails test,cucumber
133
+
134
+ Then use `frake cucumber` to exercise the features. frake selects the
135
+ "cucumber" environment if run with "cucumber" as an argument.
136
+
137
+ NOTE: to make your model classes be loaded on each run you need to set
138
+ `config.cache_classes = false` in `config/environments/cucumber.rb`.
139
+ Cucumber will give a big warning saying that this is known to be a
140
+ problem with transactional fixtures. I don't use transactional fixtures
141
+ so this isn't a problem for me.
142
+
143
+ For a substantial performance boost, remove `:lib=>false` lines from
144
+ `config/environments/cucumber.rb` so that cucumber, webrat, nokogiri etc
145
+ are preloaded.
146
+
147
+ Smaller performance boosts can be had from further preloading. For example,
148
+ cucumber makes use of some rspec libraries for diffing even if you're not
149
+ using rspec, so you can preload those. Add something like this to the end of
150
+ `config/environments/cucumber.rb`
151
+
152
+ begin
153
+ require 'spec/expectations'
154
+ require 'spec/runner/differs/default'
155
+ rescue LoadError
156
+ end
157
+ require 'test_help'
158
+ require 'test/unit/testresult'
159
+ require 'active_support/secure_random'
160
+ require 'active_support/time_with_zone'
161
+
162
+ autotest
163
+ --------
164
+
165
+ There is some simple support for autotest (from the ZenTest package).
166
+ Just type `fautotest` instead of `autotest` after snailgun has been started.
167
+ This hasn't been tested for a while.
168
+
169
+ Bypassing rubygems
170
+ ------------------
171
+
172
+ You can get noticeably faster startup if you don't use rubygems to invoke
173
+ the programs. To do this, you can add the binary directory directly into
174
+ the front of your PATH, e.g. for Ubuntu
175
+
176
+ PATH=/var/lib/gems/1.8/gems/snailgun-1.0.3/bin:$PATH
177
+
178
+ Alternatively, create a file called `fruby` somewhere early on in your PATH
179
+ (e.g. under `$HOME/bin`), like this:
180
+
181
+ #!/usr/bin/env ruby
182
+ load '/path/to/the/real/fruby'
183
+
184
+ Repeat for `frake` etc.
185
+
186
+ Other bugs and limitations
187
+ --------------------------
188
+ Only works with Linux/BSD systems, due to use of passing open file
189
+ descriptors across a socket.
190
+
191
+ Ctrl-C doesn't terminate frake processes.
192
+
193
+ `fruby script/console` doesn't give any speedup, because script/console uses
194
+ exec to invoke irb. Use the supplied `fconsole` instead.
195
+
196
+ The environment is not currently passed across the socket to the ruby
197
+ process. This means it's not usable as a fast CGI replacement.
198
+
199
+ In Rails, you need to beware that any changes to your `config/environment*`
200
+ will not be reflected until you stop and restart snailgun.
201
+
202
+ Licence
203
+ -------
204
+ This code is released under the same licence as Ruby itself.
205
+
206
+ Author
207
+ ------
208
+ Brian Candler <B.Candler@pobox.com>
209
+
210
+ Credits:
211
+
212
+ * Jan X <jan.h.xie@gmail.com>
213
+ * George Ogata <george.ogata@gmail.com>
214
+ * Niklas Hofer <niklas+dev@lanpartei.de>
215
+ * Thies C. Arntzen <thieso@gmail.com>
216
+ * Scott Herrimn <schalias-snailgun@yahoo.com>
data/bin/fautotest ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) Brian Candler 2009. Released under the Ruby licence.
3
+
4
+ # shortcut for: RAILS_ENV=test fruby /path/to/autotest
5
+
6
+ ENV["RAILS_ENV"] = "test"
7
+ Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
8
+ ARGV[0,0] = ["-e","gem 'ZenTest'","-e","load Gem.bin_path('ZenTest', 'autotest')","--"]
9
+ load File.join(File.dirname(__FILE__), "fruby")
data/bin/fconsole ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) Brian Candler 2009. Released under the Ruby licence.
3
+
4
+ ENV['RAILS_ENV'] = ARGV.shift if ARGV[0] =~ /^\w/
5
+
6
+ ARGV[0,0] = [
7
+ "-rirb",
8
+ "-rirb/completion",
9
+ "-rconsole_app",
10
+ "-rconsole_with_helpers",
11
+ "-eIRB.start", "--", "--simple-prompt"
12
+ ]
13
+ load File.join(File.dirname(__FILE__), "fruby")
data/bin/fcucumber ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) Brian Candler 2009. Released under the Ruby licence.
3
+
4
+ $DEFAULT_ENV='cucumber'
5
+ ARGV[0,0] = ['cucumber']
6
+ load File.join(File.dirname(__FILE__), 'fruby')
data/bin/frake ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) Brian Candler 2009. Released under the Ruby licence.
3
+ # Here we run rake within a pre-forked ruby process
4
+
5
+ # Pre-parse environment - see collect_tasks in rake/lib/rake.rb
6
+ ARGV.each do |arg|
7
+ if arg =~ /^(\w+)=(.*)$/
8
+ ENV[$1] = $2
9
+ end
10
+ end
11
+
12
+ # Rails/Merb: make a guess at the correct environment
13
+ if File.exist?("config/boot.rb") || File.exist?("config/init.rb")
14
+ if ARGV.find { |arg| arg =~ /\bcucumber\b/ }
15
+ $DEFAULT_ENV='cucumber'
16
+ elsif ARGV.find { |arg| arg =~ /\b(test|spec)\b/ } || !ARGV.find { |arg| arg !~ /^-/ }
17
+ $DEFAULT_ENV='test'
18
+ end
19
+ end
20
+
21
+ ARGV[0,0] = ["-rrake", "-eRake.application.run", "--"]
22
+ load File.join(File.dirname(__FILE__), "fruby")
data/bin/fruby ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) Brian Candler 2009. Released under the Ruby licence.
3
+ # This could be rewritten in C for even faster startup
4
+
5
+ require 'socket'
6
+ if ENV['SNAILGUN_SOCK']
7
+ sockname = ENV['SNAILGUN_SOCK']
8
+ elsif File.directory?('tmp/sockets/snailgun')
9
+ env = ENV['RAILS_ENV'] || ENV['MERB_ENV']
10
+ unless env
11
+ # Normally default to development: see railties/lib/tasks/misc.rake
12
+ env = $DEFAULT_ENV || 'development'
13
+ STDERR.puts "Snailgun assuming environment '#{env}'"
14
+ end
15
+ sockname = "tmp/sockets/snailgun/#{env}"
16
+ end
17
+
18
+ unless sockname and File.exists? sockname
19
+ STDERR.puts <<EOS
20
+ Unable to find path to snailgun socket.
21
+ - did you run this in a session with a snailgun parent?
22
+ - you can do 'SNAILGUN_SOCK=/path/to/sock #{$0} ...'
23
+ EOS
24
+ exit 1
25
+ end
26
+
27
+ server = UNIXSocket.open(sockname)
28
+ server.send_io(STDIN)
29
+ server.send_io(STDOUT)
30
+ server.send_io(STDERR)
31
+ args = Marshal.dump([ARGV, ENV.to_hash, Dir.pwd, Process.getpgrp])
32
+ server.write [args.size].pack("N")
33
+ server.write args
34
+ begin
35
+ rc = (server.read(1) || "\000").unpack("C").first
36
+ exit rc
37
+ rescue Interrupt
38
+ server.write('X')
39
+ exit 1
40
+ end
data/bin/snailgun ADDED
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) Brian Candler 2009. Released under the Ruby licence.
3
+ # Turn on copy-on-write garbage collection in REE: see
4
+ # http://www.rubyenterpriseedition.com/documentation.html#_copy_on_write_friendliness
5
+ begin
6
+ GC.copy_on_write_friendly = true
7
+ rescue NoMethodError
8
+ end
9
+
10
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
11
+ require 'snailgun/server'
12
+ require 'optparse'
13
+
14
+ sockpath = nil
15
+ mode = nil
16
+ envs = "test"
17
+ rake = false
18
+ verbose = false
19
+
20
+ def fix_rake
21
+ require 'rbconfig'
22
+ Config::CONFIG['bindir'] = File.expand_path(File.dirname(__FILE__))
23
+ Config::CONFIG['ruby_install_name'] = 'fruby'
24
+ require 'rubygems'
25
+ require 'rake'
26
+ require 'rake/testtask'
27
+ require 'rake/rdoctask'
28
+ end
29
+
30
+ OptionParser.new do |opts|
31
+ opts.on("-I DIR", "add to load path") { |v| $:.unshift v }
32
+ opts.on("-r LIB", "require library") { |v| require v }
33
+ opts.on("--rails [ENVS]", "rails mode") { |v| mode = :rails; envs = v }
34
+ opts.on("--ruby [SOCKPATH]", "ruby mode") { |v| mode = :ruby; sockpath = v }
35
+ opts.on("--rake", "add rake support") { rake = true }
36
+ opts.on("-v", "--verbose", "show progress") { verbose = true }
37
+ end.parse!
38
+
39
+ mode ||= if File.exist?("config/boot.rb")
40
+ :rails
41
+ elsif File.exist?("config/init.rb")
42
+ :merb
43
+ else
44
+ :ruby
45
+ end
46
+
47
+ STDERR.puts "Starting in #{mode} mode" if verbose
48
+ case mode
49
+ when :ruby
50
+ unless sockpath
51
+ dir = File.join(ENV['HOME'], '.snailgun')
52
+ begin
53
+ Dir.mkdir dir, 0700
54
+ rescue Errno::EEXIST
55
+ File.chmod 0700, dir
56
+ end
57
+ sockpath = File.join dir, $$.to_s
58
+ end
59
+ fix_rake if rake
60
+ server = Snailgun::Server.new(sockpath)
61
+ server.interactive!
62
+
63
+ when :rails
64
+ conf = File.expand_path('config/boot.rb')
65
+ unless File.exist?(conf)
66
+ raise "#{conf} does not exist, cannot continue"
67
+ end
68
+ sockdir = File.expand_path('tmp/sockets/snailgun')
69
+ begin
70
+ Dir.mkdir sockdir, 0700
71
+ rescue Errno::EEXIST
72
+ File.chmod 0700, sockdir
73
+ end
74
+ pids = {}
75
+ fix_rake # TODO: separate process for rake (but then need to choose right RAILS_ENV)
76
+
77
+ start_for_envs = envs.split(/[\s,]+/).uniq
78
+ start_for_envs.each do |env|
79
+ pids[env] = fork do
80
+ STDERR.puts "Server starting for RAILS_ENV=#{env}"
81
+ server = Snailgun::Server.new("#{sockdir}/#{env}")
82
+ ENV['SNAILGUN'] = 'yes'
83
+ ENV['RAILS_ENV'] = env
84
+ load conf
85
+ # We can get some drastic test speedups by preloading test frameworks
86
+ # (although user could do that in config/environments/test.rb)
87
+ if env != 'test'
88
+ if File.exist?('./config/environment.rb')
89
+ require './config/environment.rb'
90
+ end
91
+ elsif File.exist?('./test/test_helper.rb')
92
+ require './test/test_helper'
93
+ elsif File.exist?('spec/spec_helper.rb')
94
+ require 'spec'
95
+ require 'spec/rails'
96
+ end
97
+ if Rails.respond_to?(:configuration) && Rails.configuration.cache_classes
98
+ STDERR.puts <<-EOS
99
+ WARNING: Snailgun doesn't work well with `cache_classes`. Strongly recommend
100
+ `config.cache_classes = false` in config/environments/#{env}.rb
101
+ EOS
102
+ end
103
+ STDERR.puts "Server ready for RAILS_ENV=#{env}"
104
+ server.run
105
+ end
106
+ end
107
+ if start_for_envs.size == 1
108
+ ENV['RAILS_ENV'] = start_for_envs.first
109
+ STDERR.puts "Now entering subshell for RAILS_ENV=#{ENV['RAILS_ENV']}. Use 'exit' to terminate snailgun"
110
+ else
111
+ STDERR.puts "Now entering subshell Don't forget to set your RAILS_ENV!. Use 'exit' to terminate snailgun"
112
+ end
113
+ Snailgun::Server.shell
114
+ pids.each do |env,pid|
115
+ Process.kill('TERM',pid)
116
+ end
117
+ # TODO: wait a few secs for them to die, 'KILL' if required
118
+ STDERR.puts "Snailgun ended"
119
+
120
+ when :merb
121
+ conf = File.expand_path('config/init.rb')
122
+ unless File.exist?(conf)
123
+ raise '#{conf} does not exist, cannot continue'
124
+ end
125
+ sockdir = File.expand_path('tmp/sockets/snailgun')
126
+ begin
127
+ require 'fileutils'
128
+ FileUtils.mkdir_p sockdir
129
+ ensure
130
+ File.chmod 0700, sockdir
131
+ end
132
+ pids = {}
133
+ fix_rake # TODO: separate process for rake (but then need to choose right RAILS_ENV)
134
+ envs.split(/\s*,\s*/).uniq.each do |env|
135
+ pids[env] = fork do
136
+ server = Snailgun::Server.new("#{sockdir}/#{env}")
137
+ ENV['MERB_ENV'] = env
138
+
139
+ require 'rubygems'
140
+ gem 'merb-core'
141
+ require 'merb'
142
+ Merb.start_environment([env])
143
+
144
+ STDERR.puts "Started server for #{env}" if verbose
145
+ server.run
146
+ end
147
+ end
148
+ STDERR.puts "Use 'exit' to terminate snailgun"
149
+ Snailgun::Server.shell
150
+ pids.each do |env,pid|
151
+ Process.kill('TERM',pid)
152
+ end
153
+ # TODO: wait a few secs for them to die, 'KILL' if required
154
+ STDERR.puts "Snailgun ended"
155
+ end
@@ -0,0 +1,129 @@
1
+ # Copyright (C) Brian Candler 2009. Released under the Ruby licence.
2
+
3
+ # Our at_exit handler must be called *last*, so register it first
4
+ at_exit { $SNAILGUN_EXIT.call if $SNAILGUN_EXIT }
5
+
6
+ # Fix truncation of $0. See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/336743
7
+ $progname = $0
8
+ alias $PROGRAM_NAME $0
9
+ alias $0 $progname
10
+ trace_var(:$0) {|val| $PROGRAM_NAME = val} # update for ps
11
+
12
+ require 'socket'
13
+ require 'optparse'
14
+ require 'shellwords'
15
+
16
+ module Snailgun
17
+ class Server
18
+ attr_accessor :sockname
19
+
20
+ def initialize(sockname = nil)
21
+ @sockname = sockname || "/tmp/snailgun#{$$}"
22
+ File.delete(@sockname) rescue nil
23
+ @socket = UNIXServer.open(@sockname)
24
+ yield self if block_given?
25
+ end
26
+
27
+ def run
28
+ while client = @socket.accept
29
+ pid = fork do
30
+ rubylib = nil
31
+ begin
32
+ STDIN.reopen(client.recv_io)
33
+ STDOUT.reopen(client.recv_io)
34
+ STDERR.reopen(client.recv_io)
35
+ nbytes = client.read(4).unpack("N").first
36
+ args, env, cwd, pgid = Marshal.load(client.read(nbytes))
37
+ Dir.chdir(cwd)
38
+ $LOAD_PATH.unshift rubylib if (rubylib = env['RUBYLIB'])
39
+ begin
40
+ Process.setpgid(0, pgid)
41
+ rescue Errno::EPERM
42
+ end
43
+ exit_status = 0
44
+ $SNAILGUN_EXIT = lambda {
45
+ begin
46
+ client.write [exit_status].pack("C")
47
+ rescue Errno::EPIPE
48
+ end
49
+ }
50
+ #This doesn't work in 1.8.6:
51
+ #Thread.new { client.read(1); Thread.main.raise Interrupt }
52
+ Thread.new { client.read(1); exit 1 }
53
+ Dispatcher.cleanup_application
54
+ Dispatcher.reload_application
55
+ start_ruby(args)
56
+ rescue SystemExit => e
57
+ exit_status = e.status
58
+ raise # for the benefit of Test::Unit
59
+ rescue Exception => e
60
+ STDERR.puts "#{e}\n\t#{e.backtrace.join("\n\t")}"
61
+ exit 1
62
+ ensure
63
+ $LOAD_PATH.shift if rubylib
64
+ end
65
+ end
66
+ Process.detach(pid) if pid && pid > 0
67
+ client.close
68
+ end
69
+ ensure
70
+ File.delete(@sockname) rescue nil
71
+ end
72
+
73
+ # Process the received ruby command line. (TODO: implement more options)
74
+ def start_ruby(args)
75
+ e = []
76
+ OptionParser.new do |opts|
77
+ opts.on("-e EXPR") do |v|
78
+ e << v
79
+ end
80
+ opts.on("-I DIR") do |v|
81
+ v.split(':').each do |value|
82
+ $:.unshift value
83
+ end
84
+ end
85
+ opts.on("-r LIB") do |v|
86
+ require v
87
+ end
88
+ # opts.on("-rcatch_exception") do |v|
89
+ # end
90
+ opts.on("-KU") do |v|
91
+ $KCODE = 'u' if RUBY_VERSION < "1.9"
92
+ end
93
+ end.order!(args)
94
+
95
+ ARGV.replace(args)
96
+ if !e.empty?
97
+ $0 = '-e'
98
+ e.each { |expr| eval(expr, TOPLEVEL_BINDING) }
99
+ elsif ARGV.empty?
100
+ $0 = '-'
101
+ eval(STDIN.read, TOPLEVEL_BINDING)
102
+ else
103
+ cmd = ARGV.shift
104
+ $0 = cmd
105
+ load(cmd)
106
+ end
107
+ end
108
+
109
+ def self.shell
110
+ shell_opts = ENV['SNAILGUN_SHELL_OPTS'] || "-i"
111
+ args = shell_opts ? Shellwords.shellwords(shell_opts) : []
112
+ system(ENV['SHELL'] || 'bash', *args)
113
+ end
114
+
115
+ # Interactive mode (start a subshell with SNAILGUN_SOCK set up,
116
+ # and terminate the snailgun server when the subshell exits)
117
+ def interactive!
118
+ ENV['SNAILGUN_SOCK'] = @sockname
119
+ pid = Process.fork {
120
+ STDERR.puts "Snailgun starting on #{sockname} - 'exit' to end"
121
+ run
122
+ }
123
+ self.class.shell
124
+ Process.kill('TERM',pid)
125
+ # TODO: wait a few secs for it to die, 'KILL' if required
126
+ STDERR.puts "Snailgun ended"
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,54 @@
1
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: Makefile
2
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: ancdata.o
3
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: basicsocket.o
4
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: constants.o
5
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: constdefs.c
6
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: constdefs.h
7
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: extconf.h
8
+ diff -u socket/extconf.rb /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket/extconf.rb
9
+ --- socket/extconf.rb 2010-05-19 15:48:50.000000000 +0200
10
+ +++ /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket/extconf.rb 2010-10-24 10:44:17.000000000 +0200
11
+ @@ -117,7 +117,7 @@
12
+ }
13
+ end
14
+
15
+ -if (have_func("sendmsg") | have_func("recvmsg")) && /64-darwin/ !~ RUBY_PLATFORM
16
+ +if have_func("sendmsg") | have_func("recvmsg")
17
+ # CMSG_ macros are broken on 64bit darwin, because of use of __DARWIN_ALIGN.
18
+ have_struct_member('struct msghdr', 'msg_control', ['sys/types.h', 'sys/socket.h'])
19
+ have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
20
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: init.o
21
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: ipsocket.o
22
+ Common subdirectories: socket/lib and /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket/lib
23
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: mkmf.log
24
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: option.o
25
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: raddrinfo.o
26
+ diff -u socket/rubysocket.h /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket/rubysocket.h
27
+ --- socket/rubysocket.h 2010-04-28 09:16:30.000000000 +0200
28
+ +++ /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket/rubysocket.h 2010-10-24 10:43:51.000000000 +0200
29
+ @@ -138,6 +138,17 @@
30
+ };
31
+ #endif
32
+
33
+ +#if defined __APPLE__ && defined __MACH__
34
+ +/*
35
+ + * CMSG_ macros are broken on 64bit darwin, because __DARWIN_ALIGN
36
+ + * aligns up to __darwin_size_t which is 64bit, but CMSG_DATA is
37
+ + * 32bit-aligned.
38
+ + */
39
+ +#undef __DARWIN_ALIGNBYTES
40
+ +#define __DARWIN_ALIGNBYTES (sizeof(unsigned int) - 1)
41
+ +#endif
42
+ +
43
+ +
44
+ #if defined(_AIX)
45
+ #ifndef CMSG_SPACE
46
+ # define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
47
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: socket.bundle
48
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: socket.o
49
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: sockssocket.o
50
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: tcpserver.o
51
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: tcpsocket.o
52
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: udpsocket.o
53
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: unixserver.o
54
+ Only in /Users/thieso/.rvm/src/ruby-1.9.2-p0/ext/socket: unixsocket.o
data/textmate.patch ADDED
@@ -0,0 +1,25 @@
1
+ --- run_script.rb.orig 2010-10-25 09:23:45.000000000 +0200
2
+ +++ run_script.rb 2010-10-25 09:24:06.000000000 +0200
3
+ @@ -90,6 +90,22 @@
4
+ return path, '', path
5
+ end
6
+
7
+ +def snailgun_socket
8
+ + Pathname.new(Dir.pwd).ascend do |path|
9
+ + if File.exists?(path.join("config", "boot.rb"))
10
+ + if File.exists?(path.join("tmp", "sockets", "snailgun", "test"))
11
+ + return path.join("tmp", "sockets", "snailgun", "test").to_s
12
+ + end
13
+ + end
14
+ + end
15
+ + nil
16
+ +end
17
+ +
18
+ +if socket = snailgun_socket
19
+ + ENV['SNAILGUN_SOCK'] = socket
20
+ + cmd[0] = 'fruby'
21
+ +end
22
+ +
23
+ TextMate::Executor.run( cmd, :version_args => ["--version"],
24
+ :script_args => args ) do |line, type|
25
+ if is_test_script and type == :out
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snailgun-rr
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 1
9
+ - 3
10
+ version: 1.1.1.3
11
+ platform: ruby
12
+ authors:
13
+ - Brian Candler
14
+ - Scott Herriman
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-07-16 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: mysql_retry_lost_connection
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Snailgun accelerates the startup of Ruby applications which require large numbers of libraries
35
+ email: schalias-snailgun@yahoo.com
36
+ executables:
37
+ - fautotest
38
+ - fconsole
39
+ - fcucumber
40
+ - frake
41
+ - fruby
42
+ - snailgun
43
+ extensions: []
44
+
45
+ extra_rdoc_files:
46
+ - README.markdown
47
+ files:
48
+ - bin/fautotest
49
+ - bin/fconsole
50
+ - bin/fcucumber
51
+ - bin/frake
52
+ - bin/fruby
53
+ - bin/snailgun
54
+ - lib/snailgun/server.rb
55
+ - README.markdown
56
+ - README-snowleopard
57
+ - ruby-1.9.2-p0.patch
58
+ - textmate.patch
59
+ - README-textmate
60
+ has_rdoc: true
61
+ homepage: http://github.com/sherriman/snailgun
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --inline-source
67
+ - --charset=UTF-8
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project: snailgun
87
+ rubygems_version: 1.3.6
88
+ signing_key:
89
+ specification_version: 2
90
+ summary: Command-line startup accelerator
91
+ test_files: []
92
+