peek-elasticsearch 0.1.0

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,8 @@
1
+ # Contributing
2
+
3
+ 1. Fork it
4
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
5
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
6
+ 4. Push to the branch (`git push origin my-new-feature`)
7
+ 5. Create new Pull Request
8
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in peek-elasticsearch.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Will Farrington
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Peek::Elasticsearch
2
+
3
+ Take a peek into your Elasticsearch indices.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'peek-elasticsearch'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install peek-elasticsearch
18
+
19
+ ## Usage
20
+
21
+ ``` ruby
22
+ Peek.into Peek::Views::Elasticsearch, :index => 'myapp-stuff'
23
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ $(document).on 'peek:update', ->
2
+ elasticsearchContext = $('#peek-context-elasticsearch')
3
+ if elasticsearchContext.size()
4
+ context = elasticsearchContext.data('context')
5
+ primaries = context.primaries
6
+ replicas = context.replicas
7
+ $('#elasticsearch-active-tooltip').
8
+ attr('title', "Primaries: #{primaries}; Replicas: #{replicas}").
9
+ tipsy()
@@ -0,0 +1 @@
1
+ <strong><span data-defer-to="<%= view.defer_key %>-status">...</span> / <span id="elasticsearch-active-tooltip"><span data-defer-to="<%= view.defer_key %>-active">...</span> active</span> / <span data-defer-to="<%= view.defer_key %>-inactive">...</span> inactive</strong> elasticsearch
@@ -0,0 +1,57 @@
1
+ require "stretch"
2
+
3
+ module Peek
4
+ module Views
5
+ class Elasticsearch < View
6
+ def initialize options = {}
7
+ @index = options.fetch(:index, nil)
8
+
9
+ if defined?($stretch)
10
+ @client = $stretch
11
+ else
12
+ raise "$stretch must be defined!"
13
+ end
14
+ end
15
+
16
+ def status
17
+ index_health["status"]
18
+ end
19
+
20
+ def active_primary_shards
21
+ index_health["active_primary_shards"]
22
+ end
23
+
24
+ def active_replica_shards
25
+ active_shards - active_primary_shards
26
+ end
27
+
28
+ def active_shards
29
+ index_health["active_shards"]
30
+ end
31
+
32
+ def total_shards
33
+ index_health["number_of_shards"]
34
+ end
35
+
36
+ def context
37
+ {
38
+ :primaries => active_primary_shards,
39
+ :replicas => active_replica_shards,
40
+ }
41
+ end
42
+
43
+ def results
44
+ {
45
+ :active => active_shards,
46
+ :inactive => (total_shards - active_shards),
47
+ :status => status
48
+ }
49
+ end
50
+
51
+ private
52
+ def index_health
53
+ @index_health ||= @client.cluster.health(:indices => @index)["indices"][@index]
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,6 @@
1
+ module Peek
2
+ module Elasticsearch
3
+ class Railtie < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,2 @@
1
+ require "peek/views/elasticsearch"
2
+ require "peek-elasticsearch/railtie"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "peek-elasticsearch"
5
+ spec.version = "0.1.0"
6
+ spec.authors = ["Will Farrington"]
7
+ spec.email = ["wfarr@github.com"]
8
+ spec.description = %q{Take a peek into your Elasticsearch indices.}
9
+ spec.summary = %q{Take a peek into your Elasticsearch indices.}
10
+ spec.homepage = ""
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency "stretch", "~> 0.1.3"
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.2"
21
+ spec.add_development_dependency "rake"
22
+ end
data/script/bootstrap ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ bundle install --path .bundle --binstubs .bundle/binstubs "$@"
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: peek-elasticsearch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Will Farrington
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: stretch
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.2'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Take a peek into your Elasticsearch indices.
63
+ email:
64
+ - wfarr@github.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - CONTRIBUTING.md
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - app/assets/javascripts/peek/views/elasticsearch.coffee
76
+ - app/views/peek/views/_elasticsearch.html.erb
77
+ - lib/peek-elasticsearch.rb
78
+ - lib/peek-elasticsearch/railtie.rb
79
+ - lib/peek/views/elasticsearch.rb
80
+ - peek-elasticsearch.gemspec
81
+ - script/bootstrap
82
+ homepage: ''
83
+ licenses:
84
+ - MIT
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.23
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Take a peek into your Elasticsearch indices.
107
+ test_files: []