[DRE-commits] [ruby-elasticsearch] 01/09: Imported Upstream version 1.0.4

Tim Potter tpot-guest at moszumanska.debian.org
Mon Sep 8 04:34:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

tpot-guest pushed a commit to branch master
in repository ruby-elasticsearch.

commit d044dea4edd44873ee02dd92dfd732459a93da80
Author: Tim Potter <tpot at hp.com>
Date:   Wed Aug 6 16:52:16 2014 +1000

    Imported Upstream version 1.0.4
---
 .gitignore                                  |  17 ++
 Gemfile                                     |  16 ++
 LICENSE.txt                                 |  13 ++
 README.md                                   |  99 +++++++++
 Rakefile                                    |  48 ++++
 checksums.yaml.gz                           | Bin 0 -> 427 bytes
 elasticsearch.gemspec                       |  60 +++++
 lib/elasticsearch-ruby.rb                   |   1 +
 lib/elasticsearch.rb                        |  12 +
 lib/elasticsearch/version.rb                |   3 +
 metadata.yml                                | 331 ++++++++++++++++++++++++++++
 test/integration/client_integration_test.rb |  56 +++++
 test/test_helper.rb                         |  61 +++++
 test/unit/wrapper_gem_test.rb               |  26 +++
 14 files changed, 743 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d87d4be
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..902e608
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,16 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in elasticsearch.gemspec
+gemspec
+
+if File.exists? File.expand_path("../../elasticsearch-api/elasticsearch-api.gemspec", __FILE__)
+  gem 'elasticsearch-api', :path => File.expand_path("../../elasticsearch-api", __FILE__), :require => false
+end
+
+if File.exists? File.expand_path("../../elasticsearch-transport/elasticsearch-transport.gemspec", __FILE__)
+  gem 'elasticsearch-transport', :path => File.expand_path("../../elasticsearch-transport", __FILE__), :require => false
+end
+
+if File.exists? File.expand_path("../../elasticsearch-extensions", __FILE__)
+  gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => true
+end
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..0c77c00
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,13 @@
+   Copyright 2013 Elasticsearch
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8a75d78
--- /dev/null
+++ b/README.md
@@ -0,0 +1,99 @@
+# Elasticsearch
+
+The `elasticsearch` library provides a Ruby client and API for [Elasticsearch](http://elasticsearch.org).
+
+Features overview:
+
+* Pluggable logging and tracing
+* Plugabble connection selection strategies (round-robin, random, custom)
+* Pluggable transport implementation, customizable and extendable
+* Pluggable serializer implementation
+* Request retries and dead connections handling
+* Node reloading (based on cluster state) on errors or on demand
+* Consistent API support for the whole Elasticsearch API
+* Extensive documentation and examples
+* Emphasis on modularity and extendability of both the client and API libraries
+
+(For integration with Ruby models and Rails applications,
+see the <https://github.com/elasticsearch/elasticsearch-rails> project.)
+
+## Compatibility
+
+The library is compatible with Ruby 1.8.7 and higher.
+
+The library is compatible with Elasticsearch 0.90 and 1.0 -- you have to install and use a matching version, though.
+
+The 1.x versions and the master branch are compatible with **Elasticsearch 1.0** API.
+
+To use the **Elasticsearch 0.90** API, install the **0.4.x** gem version or use the corresponding
+[`0.4`](https://github.com/elasticsearch/elasticsearch-ruby/tree/0.4) branch.
+
+## Installation
+
+Install the package from [Rubygems](https://rubygems.org):
+
+    gem install elasticsearch
+
+To use an unreleased version, either add it to your `Gemfile` for [Bundler](http://gembundler.com):
+
+    gem 'elasticsearch', git: 'git://github.com/elasticsearch/elasticsearch-ruby.git'
+
+or install it from a source code checkout:
+
+    git clone https://github.com/elasticsearch/elasticsearch-ruby.git
+    cd elasticsearch-ruby/elasticsearch
+    bundle install
+    rake install
+
+## Usage
+
+This library is a wrapper for two separate libraries:
+
+* [`elasticsearch-transport`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport),
+  which provides a low-level Ruby client for connecting to an [Elasticsearch](http://elasticsearch.org) cluster
+* [`elasticsearch-api`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-api),
+  which provides a Ruby API for the Elasticsearch RESTful API
+
+Install the `elasticsearch` package and use the API directly:
+
+```ruby
+require 'elasticsearch'
+
+client = Elasticsearch::Client.new log: true
+
+client.cluster.health
+
+client.transport.reload_connections!
+
+client.search q: 'test'
+
+# etc.
+```
+
+Please refer to the specific library documentation for details:
+
+* **Transport**:
+   [[README]](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-transport/README.md)
+   [[Documentation]](http://rubydoc.info/gems/elasticsearch-transport/file/README.markdown)
+
+* **API**:
+   [[README]](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-api/README.md)
+   [[Documentation]](http://rubydoc.info/gems/elasticsearch-api/file/README.markdown)
+
+## License
+
+This software is licensed under the Apache 2 license, quoted below.
+
+    Copyright (c) 2013 Elasticsearch <http://www.elasticsearch.org>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..b0b5e0d
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,48 @@
+require "bundler/gem_tasks"
+
+desc "Run unit tests"
+task :test    => 'test:unit'
+
+# ----- Test tasks ------------------------------------------------------------
+
+require 'rake/testtask'
+namespace :test do
+  task :ci_reporter do
+    ENV['CI_REPORTS'] ||= 'tmp/reports'
+    if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
+      require 'ci/reporter/rake/test_unit'
+      Rake::Task['ci:setup:testunit'].invoke
+    else
+      require 'ci/reporter/rake/minitest'
+      Rake::Task['ci:setup:minitest'].invoke
+    end
+  end
+
+  Rake::TestTask.new(:unit) do |test|
+    Rake::Task['test:ci_reporter'].invoke if ENV['CI']
+    test.libs << 'lib' << 'test'
+    test.test_files = FileList["test/unit/**/*_test.rb"]
+    # test.verbose = true
+    # test.warning = true
+  end
+
+  Rake::TestTask.new(:integration) do |test|
+    Rake::Task['test:ci_reporter'].invoke if ENV['CI']
+    test.libs << 'lib' << 'test'
+    test.test_files = FileList["test/integration/**/*_test.rb"]
+  end
+
+  Rake::TestTask.new(:all) do |test|
+    Rake::Task['test:ci_reporter'].invoke if ENV['CI']
+    test.libs << 'lib' << 'test'
+    test.test_files = FileList["test/unit/**/*_test.rb", "test/integration/**/*_test.rb"]
+  end
+
+end
+
+# ----- Documentation tasks ---------------------------------------------------
+
+require 'yard'
+YARD::Rake::YardocTask.new(:doc) do |t|
+  t.options = %w| --embed-mixins --markup=markdown |
+end
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
new file mode 100644
index 0000000..7af267d
Binary files /dev/null and b/checksums.yaml.gz differ
diff --git a/elasticsearch.gemspec b/elasticsearch.gemspec
new file mode 100644
index 0000000..edd621c
--- /dev/null
+++ b/elasticsearch.gemspec
@@ -0,0 +1,60 @@
+# coding: utf-8
+lib = File.expand_path('../lib', __FILE__)
+$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
+require 'elasticsearch/version'
+
+Gem::Specification.new do |s|
+  s.name          = "elasticsearch"
+  s.version       = Elasticsearch::VERSION
+  s.authors       = ["Karel Minarik"]
+  s.email         = ["karel.minarik at elasticsearch.org"]
+  s.summary       = "Ruby integrations for Elasticsearch"
+  s.homepage      = "http://github.com/elasticsearch/elasticsearch-ruby"
+  s.license       = "Apache 2"
+
+  s.files         = `git ls-files`.split($/)
+  s.executables   = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
+  s.test_files    = s.files.grep(%r{^(test|spec|features)/})
+  s.require_paths = ["lib"]
+
+  s.extra_rdoc_files  = [ "README.md", "LICENSE.txt" ]
+  s.rdoc_options      = [ "--charset=UTF-8" ]
+
+  s.add_dependency "elasticsearch-transport", '1.0.4'
+  s.add_dependency "elasticsearch-api",       '1.0.4'
+
+  s.add_development_dependency "bundler", "> 1"
+  s.add_development_dependency "rake"
+
+  if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
+    s.add_development_dependency "elasticsearch-extensions"
+  end
+
+  s.add_development_dependency "ansi"
+  s.add_development_dependency "shoulda-context"
+  s.add_development_dependency "mocha"
+  s.add_development_dependency "turn"
+  s.add_development_dependency "yard"
+  s.add_development_dependency "pry"
+  s.add_development_dependency "ci_reporter"
+
+  # Prevent unit test failures on Ruby 1.8
+  if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
+    s.add_development_dependency "test-unit", '~> 2'
+    s.add_development_dependency "json"
+  end
+
+  if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
+    s.add_development_dependency "minitest", "~> 4.0"
+    s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION) || defined?(Rubinius)
+    s.add_development_dependency "require-prof" unless defined?(JRUBY_VERSION) || defined?(Rubinius)
+    s.add_development_dependency "simplecov"
+    s.add_development_dependency "simplecov-rcov"
+    s.add_development_dependency "cane"
+    s.add_development_dependency "coveralls"
+  end
+
+  s.description = <<-DESC.gsub(/^    /, '')
+    Ruby integrations for Elasticsearch (client, API, etc.)
+  DESC
+end
diff --git a/lib/elasticsearch-ruby.rb b/lib/elasticsearch-ruby.rb
new file mode 100644
index 0000000..748eeac
--- /dev/null
+++ b/lib/elasticsearch-ruby.rb
@@ -0,0 +1 @@
+require 'elasticsearch'
diff --git a/lib/elasticsearch.rb b/lib/elasticsearch.rb
new file mode 100644
index 0000000..dd6c3e3
--- /dev/null
+++ b/lib/elasticsearch.rb
@@ -0,0 +1,12 @@
+require "elasticsearch/version"
+
+require 'elasticsearch/transport'
+require 'elasticsearch/api'
+
+module Elasticsearch
+  module Transport
+    class Client
+      include Elasticsearch::API
+    end
+  end
+end
diff --git a/lib/elasticsearch/version.rb b/lib/elasticsearch/version.rb
new file mode 100644
index 0000000..e9fca97
--- /dev/null
+++ b/lib/elasticsearch/version.rb
@@ -0,0 +1,3 @@
+module Elasticsearch
+  VERSION = "1.0.4"
+end
diff --git a/metadata.yml b/metadata.yml
new file mode 100644
index 0000000..b3a4045
--- /dev/null
+++ b/metadata.yml
@@ -0,0 +1,331 @@
+--- !ruby/object:Gem::Specification
+name: elasticsearch
+version: !ruby/object:Gem::Version
+  version: 1.0.4
+platform: ruby
+authors:
+- Karel Minarik
+autorequire: 
+bindir: bin
+cert_chain: []
+date: 2014-06-25 00:00:00.000000000 Z
+dependencies:
+- !ruby/object:Gem::Dependency
+  name: elasticsearch-transport
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - '='
+      - !ruby/object:Gem::Version
+        version: 1.0.4
+  type: :runtime
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - '='
+      - !ruby/object:Gem::Version
+        version: 1.0.4
+- !ruby/object:Gem::Dependency
+  name: elasticsearch-api
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - '='
+      - !ruby/object:Gem::Version
+        version: 1.0.4
+  type: :runtime
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - '='
+      - !ruby/object:Gem::Version
+        version: 1.0.4
+- !ruby/object:Gem::Dependency
+  name: bundler
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>'
+      - !ruby/object:Gem::Version
+        version: '1'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>'
+      - !ruby/object:Gem::Version
+        version: '1'
+- !ruby/object:Gem::Dependency
+  name: rake
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: elasticsearch-extensions
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: ansi
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: shoulda-context
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: mocha
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: turn
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: yard
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: pry
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: ci_reporter
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: minitest
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ~>
+      - !ruby/object:Gem::Version
+        version: '4.0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ~>
+      - !ruby/object:Gem::Version
+        version: '4.0'
+- !ruby/object:Gem::Dependency
+  name: ruby-prof
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: require-prof
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: simplecov
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: simplecov-rcov
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: cane
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+- !ruby/object:Gem::Dependency
+  name: coveralls
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+  type: :development
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - ! '>='
+      - !ruby/object:Gem::Version
+        version: '0'
+description: ! 'Ruby integrations for Elasticsearch (client, API, etc.)
+
+'
+email:
+- karel.minarik at elasticsearch.org
+executables: []
+extensions: []
+extra_rdoc_files:
+- README.md
+- LICENSE.txt
+files:
+- .gitignore
+- Gemfile
+- LICENSE.txt
+- README.md
+- Rakefile
+- elasticsearch.gemspec
+- lib/elasticsearch-ruby.rb
+- lib/elasticsearch.rb
+- lib/elasticsearch/version.rb
+- test/integration/client_integration_test.rb
+- test/test_helper.rb
+- test/unit/wrapper_gem_test.rb
+homepage: http://github.com/elasticsearch/elasticsearch-ruby
+licenses:
+- Apache 2
+metadata: {}
+post_install_message: 
+rdoc_options:
+- --charset=UTF-8
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+  requirements:
+  - - ! '>='
+    - !ruby/object:Gem::Version
+      version: '0'
+required_rubygems_version: !ruby/object:Gem::Requirement
+  requirements:
+  - - ! '>='
+    - !ruby/object:Gem::Version
+      version: '0'
+requirements: []
+rubyforge_project: 
+rubygems_version: 2.2.2
+signing_key: 
+specification_version: 4
+summary: Ruby integrations for Elasticsearch
+test_files:
+- test/integration/client_integration_test.rb
+- test/test_helper.rb
+- test/unit/wrapper_gem_test.rb
+has_rdoc: 
diff --git a/test/integration/client_integration_test.rb b/test/integration/client_integration_test.rb
new file mode 100644
index 0000000..6f7934a
--- /dev/null
+++ b/test/integration/client_integration_test.rb
@@ -0,0 +1,56 @@
+require 'test_helper'
+require 'logger'
+
+module Elasticsearch
+  module Test
+    class ClientIntegrationTest < Elasticsearch::Test::IntegrationTestCase
+      startup do
+        Elasticsearch::Extensions::Test::Cluster.start(nodes: 2) if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
+      end
+
+      context "Elasticsearch client" do
+        setup do
+          @port  = (ENV['TEST_CLUSTER_PORT'] || 9250).to_i
+          system "curl -X DELETE http://localhost:#{@port}/_all > /dev/null 2>&1"
+
+          @logger =  Logger.new(STDERR)
+          @logger.formatter = proc do |severity, datetime, progname, msg|
+            color = case severity
+              when /INFO/ then :green
+              when /ERROR|WARN|FATAL/ then :red
+              when /DEBUG/ then :cyan
+              else :white
+            end
+            ANSI.ansi(severity[0] + ' ', color, :faint) + ANSI.ansi(msg, :white, :faint) + "\n"
+          end
+
+          @client = Elasticsearch::Client.new host: "localhost:#{@port}", logger: (ENV['QUIET'] ? nil : @logger)
+        end
+
+        should "perform the API methods" do
+          assert_nothing_raised do
+            # Index a document
+            #
+            @client.index index: 'test-index', type: 'test-type', id: '1', body: { title: 'Test' }
+
+            # Refresh the index
+            #
+            @client.indices.refresh index: 'test-index'
+
+            # Search
+            #
+            response = @client.search index: 'test-index', body: { query: { match: { title: 'test' } } }
+
+            assert_equal 1,      response['hits']['total']
+            assert_equal 'Test', response['hits']['hits'][0]['_source']['title']
+
+            # Delete the index
+            #
+            @client.indices.delete index: 'test-index'
+          end
+        end
+
+      end
+    end
+  end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..c34b36a
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,61 @@
+RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
+JRUBY    = defined?(JRUBY_VERSION)
+
+if RUBY_1_8 and not ENV['BUNDLE_GEMFILE']
+  require 'rubygems'
+  gem 'test-unit'
+end
+
+if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
+  require 'simplecov'
+  SimpleCov.start { add_filter "/test|test_/" }
+end
+
+if ENV['CI'] && !RUBY_1_8
+  require 'simplecov'
+  require 'simplecov-rcov'
+  SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
+  SimpleCov.start { add_filter "/test|test_" }
+end
+
+# Register `at_exit` handler for integration tests shutdown.
+# MUST be called before requiring `test/unit`.
+if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
+  at_exit { Elasticsearch::Test::IntegrationTestCase.__run_at_exit_hooks }
+end
+
+require 'test/unit'
+require 'shoulda-context'
+require 'mocha/setup'
+require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || RUBY_1_8
+
+require 'require-prof' if ENV["REQUIRE_PROF"]
+require 'elasticsearch'
+RequireProf.print_timing_infos if ENV["REQUIRE_PROF"]
+
+if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
+  require 'elasticsearch/extensions/test/cluster'
+  require 'elasticsearch/extensions/test/startup_shutdown'
+  require 'elasticsearch/extensions/test/profiling' unless JRUBY
+end
+
+module Elasticsearch
+  module Test
+    class IntegrationTestCase < ::Test::Unit::TestCase
+      extend Elasticsearch::Extensions::Test::StartupShutdown
+
+      shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
+      context "IntegrationTest" do; should "noop on Ruby 1.8" do; end; end if RUBY_1_8
+    end if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
+  end
+
+  module Test
+    class ProfilingTest < ::Test::Unit::TestCase
+      extend Elasticsearch::Extensions::Test::StartupShutdown
+      extend Elasticsearch::Extensions::Test::Profiling
+
+      shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
+      context "IntegrationTest" do; should "noop on Ruby 1.8" do; end; end if RUBY_1_8
+    end unless RUBY_1_8 || JRUBY
+  end
+end
diff --git a/test/unit/wrapper_gem_test.rb b/test/unit/wrapper_gem_test.rb
new file mode 100644
index 0000000..19e946f
--- /dev/null
+++ b/test/unit/wrapper_gem_test.rb
@@ -0,0 +1,26 @@
+require 'test_helper'
+
+module Elasticsearch
+  module Test
+    class WrapperGemTest < ::Test::Unit::TestCase
+
+      context "Wrapper gem" do
+
+        should "require all neccessary subgems" do
+          assert defined? Elasticsearch::Client
+          assert defined? Elasticsearch::API
+        end
+
+        should "mix the API into the client" do
+          client = Elasticsearch::Client.new
+
+          assert_respond_to client, :search
+          assert_respond_to client, :cluster
+          assert_respond_to client, :indices
+        end
+
+      end
+
+    end
+  end
+end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-elasticsearch.git



More information about the Pkg-ruby-extras-commits mailing list