mysql_isolated_server 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8b7662ca8f87b1988b019b96f8402e3ad6f72b0
4
- data.tar.gz: 3b93b99749cdd0ad7a06dbbd6d654fa42eb5adfb
3
+ metadata.gz: 863d2316779205d27fe664054028571cb1f2ed9a
4
+ data.tar.gz: 76b68adfd94069a2bed8f6c87847db7cf8ab0264
5
5
  SHA512:
6
- metadata.gz: ff18d5c9930b3f7e6e3053f0b02f5b0bf300e726b6c598d74a9060433f551a05a5dc24676acad052c3528e03ddc19a61f16add134bf9c531dc1e1d5972d578c4
7
- data.tar.gz: 0adce2429a5ccb7be43829188301069c2f99ec59d3f03d12d2e4e323c973cf677a80e0ff01bb3c83ccc4cc24cf07cedd8a7058785e9b2531100969e2eeb9c84b
6
+ metadata.gz: 095538f3c91dc94b0c1979896fa3b8eb5c37702f38e63a50508746cae4d3a15d92ab699ed0fee48f60e7e92a5f01f514fd46c75d5dfcb945f59b9ccd6d844fbe
7
+ data.tar.gz: 1f56358d3b3ec4e0afee945ada82f31b40f1d7baddd8b7f8a044c839036890724fc2943ab9782f0a10ad70b9c54f03409dce840e91d91437aeb76cdd28d2ed5e
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
- require 'rubygems'
3
2
  $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
3
+ require 'rubygems'
4
4
  require 'mysql_isolated_server'
5
5
  require 'getoptlong'
6
6
 
@@ -27,18 +27,22 @@ class MysqlIsolatedServer
27
27
  end
28
28
 
29
29
  def self.thread_boot(*params)
30
- bin = File.dirname(__FILE__) + "/../bin/boot_isolated_server"
30
+ bin = [File.dirname(__FILE__) + "/../bin/boot_isolated_server"]
31
31
  mysql_dir, mysql_port = nil, nil
32
32
  restore_env = {}
33
33
 
34
+ if `which ruby` =~ (/rvm/)
35
+ bin = ["rvm", "1.8.7", "do", "ruby"] + bin
36
+ end
37
+
38
+ params = ["--pid", $$.to_s] + params
39
+
34
40
  Thread.abort_on_exception = true
35
41
  Thread.new do
36
42
  ENV.keys.grep(/GEM|BUNDLE|RUBYOPT/).each do |k|
37
43
  restore_env[k] = ENV.delete(k)
38
44
  end
39
- params = ["--pid", $$.to_s] + params
40
-
41
- pipe = IO.popen(["#{bin}"].concat(params), "r") do |pipe|
45
+ pipe = IO.popen(bin + params, "r") do |pipe|
42
46
  mysql_dir = pipe.readline.split(' ').last
43
47
  mysql_port = pipe.readline.split(' ').last.to_i
44
48
  sleep
@@ -136,17 +140,17 @@ class MysqlIsolatedServer
136
140
  connection.query("SET GLOBAL server_id=#{@server_id}")
137
141
  end
138
142
 
143
+ include Socket::Constants
139
144
  def grab_free_port
140
145
  while true
141
146
  candidate=9000 + rand(50_000)
142
147
 
143
148
  begin
144
- socket = Socket.new(:INET, :STREAM, 0)
149
+ socket = Socket.new(AF_INET, SOCK_STREAM, 0)
145
150
  socket.bind(Socket.pack_sockaddr_in(candidate, '127.0.0.1'))
146
151
  socket.close
147
152
  return candidate
148
153
  rescue Exception => e
149
- puts e
150
154
  end
151
155
  end
152
156
  end
@@ -1,3 +1,3 @@
1
1
  class MysqlIsolatedServer
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_isolated_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A small library that allows you to easily spin up new local mysql servers
14
14
  for testing purposes.