mama_search 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +119 -0
  4. data/LICENSE +20 -0
  5. data/README.md +46 -0
  6. data/Rakefile +7 -0
  7. data/cucumber.yml +8 -0
  8. data/features/rails_generator.feature +10 -0
  9. data/features/rake_tasks.feature +12 -0
  10. data/features/step_definitions/elasticsearch_steps.rb +5 -0
  11. data/features/step_definitions/rails_steps.rb +38 -0
  12. data/features/support/aruba.rb +1 -0
  13. data/features/support/hooks.rb +3 -0
  14. data/lib/mama_search.rb +5 -0
  15. data/lib/mama_search/generators/USAGE +12 -0
  16. data/lib/mama_search/generators/install_generator.rb +32 -0
  17. data/lib/mama_search/generators/templates/elasticsearch.app.yml +5 -0
  18. data/lib/mama_search/generators/templates/elasticsearch.in.sh +41 -0
  19. data/lib/mama_search/generators/templates/elasticsearch.rb +5 -0
  20. data/lib/mama_search/generators/templates/elasticsearch.yml +0 -0
  21. data/lib/mama_search/generators/templates/logging.yml +29 -0
  22. data/lib/mama_search/tasks.rb +8 -0
  23. data/lib/mama_search/version.rb +3 -0
  24. data/mama_search.gemspec +28 -0
  25. data/vendor/elasticsearch-0.14.2/LICENSE.txt +537 -0
  26. data/vendor/elasticsearch-0.14.2/NOTICE.txt +12 -0
  27. data/vendor/elasticsearch-0.14.2/README.textile +219 -0
  28. data/vendor/elasticsearch-0.14.2/bin/elasticsearch +180 -0
  29. data/vendor/elasticsearch-0.14.2/bin/elasticsearch.bat +37 -0
  30. data/vendor/elasticsearch-0.14.2/bin/elasticsearch.in.sh +41 -0
  31. data/vendor/elasticsearch-0.14.2/bin/plugin +33 -0
  32. data/vendor/elasticsearch-0.14.2/bin/plugin.bat +25 -0
  33. data/vendor/elasticsearch-0.14.2/config/elasticsearch.yml +0 -0
  34. data/vendor/elasticsearch-0.14.2/config/logging.yml +29 -0
  35. data/vendor/elasticsearch-0.14.2/lib/elasticsearch-0.14.2.jar +0 -0
  36. data/vendor/elasticsearch-0.14.2/lib/jline-0.9.94.jar +0 -0
  37. data/vendor/elasticsearch-0.14.2/lib/jna-3.2.7.jar +0 -0
  38. data/vendor/elasticsearch-0.14.2/lib/log4j-1.2.15.jar +0 -0
  39. data/vendor/elasticsearch-0.14.2/lib/lucene-analyzers-3.0.3.jar +0 -0
  40. data/vendor/elasticsearch-0.14.2/lib/lucene-core-3.0.3.jar +0 -0
  41. data/vendor/elasticsearch-0.14.2/lib/lucene-fast-vector-highlighter-3.0.3.jar +0 -0
  42. data/vendor/elasticsearch-0.14.2/lib/lucene-highlighter-3.0.3.jar +0 -0
  43. data/vendor/elasticsearch-0.14.2/lib/lucene-memory-3.0.3.jar +0 -0
  44. data/vendor/elasticsearch-0.14.2/lib/lucene-queries-3.0.3.jar +0 -0
  45. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-amd64-linux.so +0 -0
  46. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-amd64-solaris.so +0 -0
  47. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-sparc-solaris.so +0 -0
  48. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-sparc64-solaris.so +0 -0
  49. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-universal-macosx.dylib +0 -0
  50. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-universal64-macosx.dylib +0 -0
  51. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-x86-freebsd-5.so +0 -0
  52. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-x86-freebsd-6.so +0 -0
  53. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-x86-linux.so +0 -0
  54. data/vendor/elasticsearch-0.14.2/lib/sigar/libsigar-x86-solaris.so +0 -0
  55. data/vendor/elasticsearch-0.14.2/lib/sigar/sigar-1.6.3.jar +0 -0
  56. data/vendor/elasticsearch-0.14.2/lib/sigar/sigar-amd64-winnt.dll +0 -0
  57. data/vendor/elasticsearch-0.14.2/lib/sigar/sigar-x86-winnt.dll +0 -0
  58. data/vendor/elasticsearch-0.14.2/lib/sigar/sigar-x86-winnt.lib +0 -0
  59. metadata +218 -0
@@ -0,0 +1,5 @@
1
+ .bundle
2
+ *.gem
3
+ *.swp
4
+ pkg/*
5
+ tmp/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,119 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mama_search (0.0.1)
5
+ rails (~> 3.0)
6
+ rake
7
+ rubberband
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ abstract (1.0.0)
13
+ actionmailer (3.0.3)
14
+ actionpack (= 3.0.3)
15
+ mail (~> 2.2.9)
16
+ actionpack (3.0.3)
17
+ activemodel (= 3.0.3)
18
+ activesupport (= 3.0.3)
19
+ builder (~> 2.1.2)
20
+ erubis (~> 2.6.6)
21
+ i18n (~> 0.4)
22
+ rack (~> 1.2.1)
23
+ rack-mount (~> 0.6.13)
24
+ rack-test (~> 0.5.6)
25
+ tzinfo (~> 0.3.23)
26
+ activemodel (3.0.3)
27
+ activesupport (= 3.0.3)
28
+ builder (~> 2.1.2)
29
+ i18n (~> 0.4)
30
+ activerecord (3.0.3)
31
+ activemodel (= 3.0.3)
32
+ activesupport (= 3.0.3)
33
+ arel (~> 2.0.2)
34
+ tzinfo (~> 0.3.23)
35
+ activeresource (3.0.3)
36
+ activemodel (= 3.0.3)
37
+ activesupport (= 3.0.3)
38
+ activesupport (3.0.3)
39
+ arel (2.0.6)
40
+ aruba (0.3.2)
41
+ childprocess (~> 0.1.6)
42
+ cucumber (~> 0.10.0)
43
+ rspec (~> 2.3.0)
44
+ builder (2.1.2)
45
+ childprocess (0.1.6)
46
+ ffi (~> 0.6.3)
47
+ cucumber (0.10.0)
48
+ builder (>= 2.1.2)
49
+ diff-lcs (~> 1.1.2)
50
+ gherkin (~> 2.3.2)
51
+ json (~> 1.4.6)
52
+ term-ansicolor (~> 1.0.5)
53
+ diff-lcs (1.1.2)
54
+ erubis (2.6.6)
55
+ abstract (>= 1.0.0)
56
+ ffi (0.6.3)
57
+ rake (>= 0.8.7)
58
+ gherkin (2.3.3)
59
+ json (~> 1.4.6)
60
+ i18n (0.5.0)
61
+ json (1.4.6)
62
+ mail (2.2.12)
63
+ activesupport (>= 2.3.6)
64
+ i18n (>= 0.4.0)
65
+ mime-types (~> 1.16)
66
+ treetop (~> 1.4.8)
67
+ mime-types (1.16)
68
+ patron (0.4.11)
69
+ polyglot (0.3.1)
70
+ rack (1.2.1)
71
+ rack-mount (0.6.13)
72
+ rack (>= 1.0.0)
73
+ rack-test (0.5.6)
74
+ rack (>= 1.0)
75
+ rails (3.0.3)
76
+ actionmailer (= 3.0.3)
77
+ actionpack (= 3.0.3)
78
+ activerecord (= 3.0.3)
79
+ activeresource (= 3.0.3)
80
+ activesupport (= 3.0.3)
81
+ bundler (~> 1.0)
82
+ railties (= 3.0.3)
83
+ railties (3.0.3)
84
+ actionpack (= 3.0.3)
85
+ activesupport (= 3.0.3)
86
+ rake (>= 0.8.7)
87
+ thor (~> 0.14.4)
88
+ rake (0.8.7)
89
+ rspec (2.3.0)
90
+ rspec-core (~> 2.3.0)
91
+ rspec-expectations (~> 2.3.0)
92
+ rspec-mocks (~> 2.3.0)
93
+ rspec-core (2.3.0)
94
+ rspec-expectations (2.3.0)
95
+ diff-lcs (~> 1.1.2)
96
+ rspec-mocks (2.3.0)
97
+ rubberband (0.0.6)
98
+ patron
99
+ yajl-ruby
100
+ sqlite3-ruby (1.3.2)
101
+ term-ansicolor (1.0.5)
102
+ thor (0.14.6)
103
+ treetop (1.4.9)
104
+ polyglot (>= 0.3.1)
105
+ tzinfo (0.3.23)
106
+ yajl-ruby (0.7.9)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ aruba
113
+ cucumber
114
+ mama_search!
115
+ rails (~> 3.0)
116
+ rake
117
+ rspec
118
+ rubberband
119
+ sqlite3-ruby
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Carbon Five Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # Mama Search
2
+
3
+ Mama Search is a Rails 3 generator to install [elasticsearch](http://elasticsearch.com/). It also includes Rake tasks for starting elasticsearch.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add mama search to your Gemfile:
9
+
10
+ <pre>
11
+ gem 'mama_search'
12
+ </pre>
13
+
14
+ Use bundler to install it:
15
+
16
+ <pre>
17
+ bundle install
18
+ </pre>
19
+
20
+ Run the generator to install elasticsearch (currently version 0.14.2) in your app:
21
+
22
+ <pre>
23
+ rails g mama_search:install
24
+ </pre>
25
+
26
+ This installs the following directories and files:
27
+
28
+ * elasticsearch/server/ # elasticsearch server
29
+ * config/elasticsearch.yml # app configuration
30
+ * config/initializers/elasticsearch.rb # elasticsearch connection object setup
31
+
32
+ ## Rake tasks
33
+
34
+ <pre>
35
+ rake elasticsearch:start
36
+ </pre>
37
+
38
+ Start elasticsearch. Elasticsearch is run in the foreground and should be stopped via <code>Ctrl+C</code>.
39
+
40
+ ## CREDITS
41
+
42
+ Mama Search is heavily inspired by [Mama Cass](http://github.com/carbonfive/mama_cass)
43
+
44
+ ## LICENSE
45
+
46
+ Released under the MIT License. See the LICENSE file for further details.
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+ Cucumber::Rake::Task.new
6
+
7
+ task :default => :cucumber
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,10 @@
1
+ Feature: Rails generator to install elasticsearch
2
+ In order to use elasticsearch in a Rails app
3
+ As a Rails developer
4
+ I want to be able to run a Rails generator to install elasticsearch
5
+
6
+ @slow
7
+ Scenario: Install elasticsearch
8
+ Given a Rails app using mama search
9
+ When I run "rails g mama_search:install"
10
+ Then elasticsearch should be installed
@@ -0,0 +1,12 @@
1
+ @wip @slow
2
+ Feature: Elasticsearch Rake tasks
3
+ In order to manage elasticsearch in a Rails app
4
+ As a Rails developer
5
+ I want to use Rake tasks to interact with elasticsearch
6
+
7
+ Background:
8
+ Given a Rails app with elasticsearch installed via mama search
9
+
10
+ Scenario: Starting elasticsearch
11
+ When I run "rake elasticsearch:start" interactively
12
+ Then elasticsearch should be running
@@ -0,0 +1,5 @@
1
+ Then /^elasticsearch should be running$/ do
2
+ steps %q{
3
+ Then the output should contain "started"
4
+ }
5
+ end
@@ -0,0 +1,38 @@
1
+ Given /^a Rails app using mama search$/ do
2
+ steps %q{
3
+ When I run "rails new sample-app"
4
+ And I cd to "sample-app"
5
+ And I append to "Gemfile" with:
6
+ """
7
+ gem 'mama_search',
8
+ :path => './../../../'
9
+ """
10
+ And I run "bundle install --local"
11
+ }
12
+ end
13
+
14
+ Then /^elasticsearch should be installed$/ do
15
+ steps %q{
16
+ Then the output should contain "Installing elasticsearch..."
17
+ And the following directories should exist:
18
+ | elasticsearch |
19
+ | elasticsearch/server |
20
+ | elasticsearch/server/bin |
21
+ | elasticsearch/server/config |
22
+ | elasticsearch/server/lib |
23
+ And the output should contain "Installing config..."
24
+ And the following files should exist:
25
+ | config/elasticsearch.yml |
26
+ | config/elasticsearch/elasticsearch.in.sh |
27
+ | config/elasticsearch/elasticsearch.yml |
28
+ | config/elasticsearch/logging.yml |
29
+ | config/initializers/elasticsearch.rb |
30
+ }
31
+ end
32
+
33
+ Given /^a Rails app with elasticsearch installed via mama search$/ do
34
+ steps %q{
35
+ Given a Rails app using mama search
36
+ And I run "rails g mama_search:install"
37
+ }
38
+ end
@@ -0,0 +1 @@
1
+ require 'aruba/cucumber'
@@ -0,0 +1,3 @@
1
+ Before '@slow' do
2
+ @aruba_timeout_seconds = 10
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'mama_search/generators/install_generator'
2
+ require 'mama_search/tasks'
3
+
4
+ module MamaSearch
5
+ end
@@ -0,0 +1,12 @@
1
+ Description:
2
+ Install elasticsearch 0.14.2 server and configuration files.
3
+
4
+ Example:
5
+ `rails g mama_search:install`
6
+
7
+ elasticsearch/server/ # elasticsearch server
8
+ config/elasticsearch.yml # keyspace configuration
9
+ config/elasticsearch/elasticsearch.in.sh # start up options
10
+ config/elasticsearch/elasticsearch.yml # keyspace definitions
11
+ config/elasticsearch/logging.yml # logging configuration
12
+ config/initializers/elasticsearch.rb # elasticsearch connection object configuration
@@ -0,0 +1,32 @@
1
+ require 'rails/generators'
2
+
3
+ module MamaSearch
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.join(File.dirname(__FILE__), './templates')
7
+
8
+ def install
9
+ say 'Installing elasticsearch...'
10
+ source = File.join File.dirname(__FILE__), '/../../../vendor/elasticsearch-0.14.2'
11
+ destination = 'elasticsearch/server'
12
+ directory source, destination
13
+ chmod "#{destination}/bin/", 0755
14
+ end
15
+
16
+ def config
17
+ say 'Installing config...'
18
+ template 'elasticsearch.app.yml', 'config/elasticsearch.yml'
19
+ #copy_file 'elasticsearch.in.sh', 'config/elasticsearch/elasticsearch.in.sh'
20
+ #copy_file 'logging.yml', 'config/elasticsearch/logging.yml'
21
+ #copy_file 'elasticsearch.yml', 'config/elasticsearch/elasticsearch.yml'
22
+ copy_file 'elasticsearch.rb', 'config/initializers/elasticsearch.rb'
23
+ end
24
+
25
+ protected
26
+
27
+ def application_name
28
+ Rails.application.class.name.split('::').first.underscore
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ development:
2
+ servers: 127.0.0.1:9200
3
+
4
+ test:
5
+ servers: 127.0.0.1:9200
@@ -0,0 +1,41 @@
1
+ CLASSPATH=$CLASSPATH:$ES_HOME/lib/elasticsearch-0.14.2.jar:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*
2
+
3
+ if [ "x$ES_MIN_MEM" = "x" ]; then
4
+ ES_MIN_MEM=256m
5
+ fi
6
+ if [ "x$ES_MAX_MEM" = "x" ]; then
7
+ ES_MAX_MEM=1g
8
+ fi
9
+
10
+ # min and max heap sizes should be set to the same value to avoid
11
+ # stop-the-world GC pauses during resize, and so that we can lock the
12
+ # heap in memory on startup to prevent any of it from being swapped
13
+ # out.
14
+ JAVA_OPTS="$JAVA_OPTS -Xms${ES_MIN_MEM}"
15
+ JAVA_OPTS="$JAVA_OPTS -Xmx${ES_MAX_MEM}"
16
+
17
+ # reduce the per-thread stack size
18
+ JAVA_OPTS="$JAVA_OPTS -Xss128k"
19
+
20
+ JAVA_OPTS="$JAVA_OPTS -Djline.enabled=true"
21
+
22
+ # Enable aggressive optimizations in the JVM
23
+ JAVA_OPTS="$JAVA_OPTS -XX:+AggressiveOpts"
24
+
25
+ # Enable reference compression, reducing memory overhead on 64bit JVMs
26
+ # - Disabled by default as it is not stable for Sun JVM before 6u19
27
+ #JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops"
28
+
29
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
30
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
31
+ JAVA_OPTS="$JAVA_OPTS -XX:+CMSParallelRemarkEnabled"
32
+ JAVA_OPTS="$JAVA_OPTS -XX:SurvivorRatio=8"
33
+ JAVA_OPTS="$JAVA_OPTS -XX:MaxTenuringThreshold=1"
34
+ JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
35
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
36
+
37
+ # Causes the JVM to dump its heap on OutOfMemory.
38
+ JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
39
+ # The path to the heap dump location, note directory must exists and have enough
40
+ # space for a full heap dump.
41
+ #JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof"
@@ -0,0 +1,5 @@
1
+ require 'rubberband'
2
+ config = YAML.load_file(Rails.root.join("config", "elasticsearch.yml"))[Rails.env]
3
+ #TODO auto discover happens immediately, so this forces elasticsearch to be running.
4
+ # uncomment when this is fixed.
5
+ #$elasticsearch = ElasticSearch.new(config['servers'])
@@ -0,0 +1,29 @@
1
+ rootLogger: INFO, console, file
2
+ logger:
3
+ # log action execution errors for easier debugging
4
+ action: DEBUG
5
+ # reduce the logging for aws, too much is logged under the default INFO
6
+ com.amazonaws: WARN
7
+
8
+ # gateway
9
+ #gateway: DEBUG
10
+ #index.gateway: DEBUG
11
+
12
+ # peer shard recovery
13
+ #index.shard.recovery: DEBUG
14
+
15
+ appender:
16
+ console:
17
+ type: console
18
+ layout:
19
+ type: consolePattern
20
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
21
+
22
+ file:
23
+ type: dailyRollingFile
24
+ file: ${path.logs}/${cluster.name}.log
25
+ datePattern: "'.'yyyy-MM-dd"
26
+ layout:
27
+ type: pattern
28
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
29
+
@@ -0,0 +1,8 @@
1
+ require 'rake'
2
+
3
+ namespace :elasticsearch do
4
+ desc 'Start elasticsearch'
5
+ task :start do
6
+ sh 'elasticsearch/server/bin/elasticsearch -f'
7
+ end
8
+ end