solr_wrapper 0.0.2 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 236a1eced6b831ca9b182fb6a69031495567acd7
4
- data.tar.gz: e053e51b06aad6e8420675b1b7718c259fa98c64
3
+ metadata.gz: 4e14fa14a9312c6c712b005ec75a66ec5e03a403
4
+ data.tar.gz: d3c1df1a8fe6020270d0292a332ac604cfd23375
5
5
  SHA512:
6
- metadata.gz: 74b2782c628c9fc4903dec66dd405a66cf01212ee126ac768325745f6ee6c5d22b7772facb0c28f7f82d2cfeb24634c3faccdec24d27b76c84d324f1a47de5ed
7
- data.tar.gz: b81687cee34cdc5feeffbf3fea6868c08aff80cfd664e9e88b4cf252ae18cb1f435406373b7ae322c57840a0eb3c7d6c637b7211afb5fefe794f8d3cc6a95c86
6
+ metadata.gz: 29912c73b25928c7fbd87a64186a943d4a085e5ca1869e90677dcee225fe470df52264fe95570da6593165d25a6f1184d9fd51422ed21a31c4207a1cc7277a7b
7
+ data.tar.gz: 398139305bf2facd9f5417b28ad6623f8480751c369270edf76f322967fea177a2a8e5d34b1cdc55a901d07cefe10e49aeced7c125a35954dc2de7b96344ea51
@@ -3,6 +3,7 @@ require 'fileutils'
3
3
  require 'open-uri'
4
4
  require 'ruby-progressbar'
5
5
  require 'securerandom'
6
+ require 'stringio'
6
7
  require 'tmpdir'
7
8
  require 'zip'
8
9
 
@@ -24,10 +25,19 @@ module SolrWrapper
24
25
  def start
25
26
  extract
26
27
  IO.popen([solr_binary, "start", "-p", port, err: [:child, :out]]) do |io|
28
+ stringio = StringIO.new
27
29
  if verbose?
28
30
  IO.copy_stream(io,$stderr)
31
+ else
32
+ IO.copy_stream(io, stringio)
33
+ end
34
+ _, status = Process.wait2(io.pid)
35
+ if status != 0
36
+ stringio.rewind
37
+ raise "Unable to start solr: #{stringio.read}"
29
38
  end
30
39
  end if managed?
40
+
31
41
  started!
32
42
  end
33
43
 
@@ -35,14 +45,45 @@ module SolrWrapper
35
45
  return unless started?
36
46
 
37
47
  IO.popen([solr_binary, "stop", "-p", port, err: [:child, :out]]) do |io|
48
+ stringio = StringIO.new
38
49
  if verbose?
39
50
  IO.copy_stream(io,$stderr)
51
+ else
52
+ IO.copy_stream(io, stringio)
53
+ end
54
+ _, status = Process.wait2(io.pid)
55
+
56
+ if status != 0
57
+ stringio.rewind
58
+ raise "Unable to start solr: #{stringio.read}"
40
59
  end
41
60
  end if managed?
42
61
  end
43
62
 
63
+ def status
64
+ return true unless managed?
65
+
66
+ stringio = StringIO.new
67
+
68
+ IO.popen([solr_binary, "status", "-p", port, err: [:child, :out]]) do |io|
69
+ IO.copy_stream(io, stringio)
70
+
71
+ _, status = Process.wait2(io.pid)
72
+
73
+ stringio.rewind
74
+
75
+ if status != 0
76
+ raise "Unable to query solr status: #{stringio.read}"
77
+ end
78
+ end
79
+
80
+ out = stringio.read
81
+
82
+ out =~ /running on port #{port}/
83
+ end
84
+
44
85
  def started?
45
- !!@started
86
+ !!status
46
87
  end
47
88
 
48
89
  def extract
@@ -1,3 +1,3 @@
1
1
  module SolrWrapper
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solr_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-22 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip