elasticsearch-node 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.8.7
3
4
  - 1.9.2
4
5
  - 1.9.3
5
6
  - jruby-19mode
6
7
  env:
7
8
  - ES_VERSION=0.18.7
8
- - ES_VERSION=0.19.1
9
+ - ES_VERSION=0.19.2
9
10
  before_script: "bin/install_elasticsearch"
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## Version 0.7.0
4
+
5
+ - Added windows compatibility
6
+ - Added compatibility for Rubies without Kernel.spawn
7
+
8
+ ## Version 0.6.0
9
+
10
+ - Initial release
data/README.md CHANGED
@@ -83,11 +83,6 @@ Please be aware that this library does not add any `at_exit`-hooks to your appli
83
83
 
84
84
  at_exit { node.close }
85
85
 
86
- ## Flaws
87
-
88
- * No windows support at the moment.
89
- * No 1.8 support at the moment.
90
-
91
86
  ### License
92
87
 
93
88
  See `COPYING.md` for all details.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- es_version = ENV['ES_VERSION'] || "0.19.1"
3
+ es_version = ENV['ES_VERSION'] || "0.19.2"
4
4
 
5
5
  puts "Installing elasticsearch-#{es_version}.
6
6
  To install a different version, specify it using the ES_VERSION environment variable.
@@ -13,10 +13,7 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.rubyforge_project = "elasticsearch-node"
15
15
 
16
- s.files = (
17
- `git ls-files`.split("\n") +
18
- Dir["elasticsearch/{bin,config,lib,README.textile,NOTICE.txt,LICENSE.txt}"]
19
- ).uniq
16
+ s.files = `git ls-files`.split("\n")
20
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
19
  s.require_paths = ["lib"]
@@ -14,26 +14,25 @@ module ElasticSearch
14
14
 
15
15
  commandline = opts.map {|opt,value| "-Des.#{opt}=#{value}" }.join(" ")
16
16
 
17
- capture_ip_and_port do
18
- self.pid = Kernel.spawn("#{Node.binary} -f #{commandline}", :out => :out, :err => :err)
17
+ if Kernel.respond_to? :spawn
18
+ capture_ip_and_port do
19
+ self.pid = Kernel.spawn("#{Node.binary} -f #{commandline}", :out => :out, :err => :err)
20
+ end
21
+ else
22
+ process = IO.popen("#{Node.binary} -f #{commandline}", "r")
23
+ parse_ip_and_port(process)
24
+ start_slurper(process)
25
+ self.pid = process.pid
19
26
  end
20
27
 
21
28
  super(opts)
22
29
  end
23
30
 
24
31
  def port
25
- unless @port
26
- parse_ip_and_port
27
- end
28
-
29
32
  @port
30
33
  end
31
34
 
32
35
  def ip
33
- unless @ip
34
- parse_ip_and_port
35
- end
36
-
37
36
  @ip
38
37
  end
39
38
 
@@ -68,6 +67,21 @@ module ElasticSearch
68
67
 
69
68
  $stdout.reopen(old_stdout)
70
69
  end
70
+
71
+ def parse_ip_and_port(process)
72
+ process.each do |line|
73
+ $stdout << line
74
+ if line =~ /\[http\s*\].*\/(.*):([0-9]+)/
75
+ @ip = $1
76
+ @port = Integer($2)
77
+ break
78
+ end
79
+ end
80
+ end
81
+
82
+ def start_slurper(process)
83
+ Thread.new { process.each { |line| $stdout << line } }
84
+ end
71
85
  end
72
86
  end
73
87
  end
@@ -1,5 +1,5 @@
1
1
  module Elsearch
2
2
  module Node
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -4,17 +4,21 @@ require 'elasticsearch-node/client_provider'
4
4
  module ElasticSearch
5
5
  module Node
6
6
  attr_accessor :version
7
-
7
+
8
8
  def self.root(*args)
9
9
  File.join(File.dirname(__FILE__), "..", *args)
10
10
  end
11
-
11
+
12
12
  def self.path
13
13
  File.expand_path(File.join(root, "elasticsearch-#{version}"))
14
14
  end
15
-
15
+
16
16
  def self.binary
17
- File.join(path, 'bin', 'elasticsearch')
17
+ if self.windows?
18
+ File.join(path, 'bin', 'elasticsearch.bat')
19
+ else
20
+ File.join(path, 'bin', 'elasticsearch')
21
+ end
18
22
  end
19
23
 
20
24
  def self.version
@@ -24,17 +28,22 @@ module ElasticSearch
24
28
  def self.lib
25
29
  File.join(path, 'lib')
26
30
  end
27
-
31
+
28
32
  def self.config(name)
29
33
  root('configs', name.to_s, "config")
30
34
  end
31
-
35
+
32
36
  def self.default_config(name)
33
37
  ENV["ES_JAVA_OPTS"] = "-Des.path.conf=#{self.config(name)}"
34
38
  end
35
-
39
+
36
40
  def self.version
37
- @version || ENV["ES_VERSION"] || "0.19.1"
41
+ @version || ENV["ES_VERSION"] || "0.19.2"
42
+ end
43
+
44
+ def self.windows?
45
+ require 'rbconfig'
46
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
38
47
  end
39
48
  end
40
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-01 00:00:00.000000000Z
12
+ date: 2012-04-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riot
16
- requirement: &2165532760 !ruby/object:Gem::Requirement
16
+ requirement: &2152180140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2165532760
24
+ version_requirements: *2152180140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &2165532100 !ruby/object:Gem::Requirement
27
+ requirement: &2152172260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2165532100
35
+ version_requirements: *2152172260
36
36
  description: Helper gem to install and start an elasticsearch node
37
37
  email:
38
38
  - florian.gilcher@asquera.de
@@ -43,6 +43,7 @@ extra_rdoc_files: []
43
43
  files:
44
44
  - .gitignore
45
45
  - .travis.yml
46
+ - CHANGELOG.md
46
47
  - COPYING.md
47
48
  - Gemfile
48
49
  - README.md
@@ -51,7 +52,6 @@ files:
51
52
  - configs/testing/config/elasticsearch.yml
52
53
  - configs/testing/config/logging.yml
53
54
  - elasticsearch-node.gemspec
54
- - fetch_es.rb
55
55
  - lib/elasticsearch-node.rb
56
56
  - lib/elasticsearch-node/client_provider.rb
57
57
  - lib/elasticsearch-node/embedded.rb
data/fetch_es.rb DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- es_version = ENV['ES_VERSION'] || "0.19.1"
4
-
5
- `curl https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-#{es_version}.tar.gz -L -o elasticsearch.tar.gz`
6
- `tar xvf elasticsearch.tar.gz`
7
- #mv elasticsearch-$ES_VERSION elasticsearch
8
- File.unlink "elasticsearch-#{es_version}.tar.gz"