kibana-sinatra 0.0.4 → 0.0.5

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: b90d776ed0faabd51b00e390a59c193d63c4eb94
4
- data.tar.gz: d38a9fb1987082bd9c38ff97be8763c985bf75d4
3
+ metadata.gz: 488b10d33481ec09a9be9de778d08b984898b6d8
4
+ data.tar.gz: 9b115a2965cba2cb58bc0f01e03c745f7c2af59a
5
5
  SHA512:
6
- metadata.gz: 9e7aa803378bd32ad9e524ed7c11cb77cff766d936496db3dd8e17ffa08048eddd9090afadf2eca7c67e26b413f875166c8f673a1ce1ba8e425e8f82eaf342cf
7
- data.tar.gz: 221b2797b0615c18553e404dcae19ba30fc32096c04137e22fc57cff53a703074dcc4b210113e392e1537986b86fe958dda0369218847ffc40bc067855cfa855
6
+ metadata.gz: 3a31c619687789b0f096ac3e9b86b864df72d6b7c07456cb4aae77a940ca8a3f02e486fe7ad4993c6dc531c4b7a6f81567b920dd7c231c809e880a759f15ae68
7
+ data.tar.gz: 8eae148863560503a60ee3685ca805e53304c574835fb646c0c8d46b7b56748587b2949425444cebfdad4537cfe8396c356f476cb340d4ca223ce9d617d1e43e
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0.0"
4
+ - "1.9.3"
5
+ - "1.9.2"
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Kibana::Sinatra
2
2
 
3
3
  [![Dependency Status](https://gemnasium.com/ianneub/kibana-sinatra.png)](https://gemnasium.com/ianneub/kibana-sinatra)
4
+ [![Build Status](https://travis-ci.org/ianneub/kibana-sinatra.png)](https://travis-ci.org/ianneub/kibana-sinatra)
4
5
 
5
6
  This gem provides [Kibana 3](https://github.com/elasticsearch/kibana) inside a [Sinatra](http://www.sinatrarb.com/) app that you can include in any Rack based system, including Rails.
6
7
 
@@ -31,11 +32,11 @@ Create a new file in `config/initializers` and include the following code. Repla
31
32
  ```ruby
32
33
  module Kibana::Sinatra
33
34
  class Web
34
- def self.elasticsearch_url
35
+ def elasticsearch_url
35
36
  "http://\"+window.location.hostname+\":9200"
36
37
  end
37
38
 
38
- def self.kibana_index
39
+ def kibana_index
39
40
  "kibana-int"
40
41
  end
41
42
  end
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "./lib/tasks/update"
3
+
4
+ task :default => :test
5
+
6
+ desc "Run tests"
7
+ task :test do
8
+ require './test/sinatra_test.rb'
9
+ end
@@ -22,5 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "uuid"
24
24
  spec.add_development_dependency "rubyzip"
25
+ spec.add_development_dependency "rack-test"
25
26
  spec.add_dependency "sinatra", "~> 1.4"
26
27
  end
@@ -1,5 +1,5 @@
1
1
  module Kibana
2
2
  module Sinatra
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -15,11 +15,11 @@ module Kibana
15
15
  erb :config
16
16
  end
17
17
 
18
- def self.elasticsearch_url
18
+ def elasticsearch_url
19
19
  "http://\"+window.location.hostname+\":9200"
20
20
  end
21
21
 
22
- def self.kibana_index
22
+ def kibana_index
23
23
  "kibana-int"
24
24
  end
25
25
  end
@@ -18,14 +18,14 @@ function (Settings) {
18
18
  * elasticsearch host
19
19
  * @type {String}
20
20
  */
21
- elasticsearch: "<%= Kibana::Sinatra::Web.elasticsearch_url %>",
21
+ elasticsearch: "<%= elasticsearch_url %>",
22
22
 
23
23
  /**
24
24
  * The default ES index to use for storing Kibana specific object
25
25
  * such as stored dashboards
26
26
  * @type {String}
27
27
  */
28
- kibana_index: "<%= Kibana::Sinatra::Web.kibana_index %>",
28
+ kibana_index: "<%= kibana_index %>",
29
29
 
30
30
  /**
31
31
  * Panel modules available. Panels will only be loaded when they are defined in the
@@ -35,8 +35,8 @@ task :update do
35
35
  config_file = "#{asset_path}/../views/config.erb"
36
36
  FileUtils.mv "#{asset_path}/config.js", config_file
37
37
  text = File.read(config_file)
38
- text.gsub!('http://"+window.location.hostname+":9200', '<%= Kibana::Sinatra::Web.elasticsearch_url %>')
39
- text.gsub!('"kibana-int"', '"<%= Kibana::Sinatra::Web.kibana_index %>"')
38
+ text.gsub!('http://"+window.location.hostname+":9200', '<%= elasticsearch_url %>')
39
+ text.gsub!('"kibana-int"', '"<%= kibana_index %>"')
40
40
  File.open(config_file, "w") {|file| file.write(text) }
41
41
  end
42
42
 
@@ -0,0 +1,65 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require 'kibana/sinatra'
4
+ require 'test/unit'
5
+ require 'rack/test'
6
+
7
+ class SinatraTest < Test::Unit::TestCase
8
+ include Rack::Test::Methods
9
+
10
+ def app
11
+ Kibana::Sinatra::Web
12
+ end
13
+
14
+ def test_it_outputs_dashboard
15
+ get '/'
16
+ assert last_response.ok?
17
+ assert last_response.body.include?('{{dashboard.current.title}}')
18
+ end
19
+
20
+ def test_it_renders_config_with_default_elasticsearch_url
21
+ get '/config.js'
22
+ assert last_response.ok?
23
+ assert last_response.body.include?('elasticsearch: "http://"+window.location.hostname+":9200"')
24
+ end
25
+
26
+ def test_it_renders_config_with_custom_elasticsearch_url
27
+ elasticsearch_url = Proc.new { "http://asdf.com:9200" }
28
+
29
+ monkey_patch "elasticsearch_url", elasticsearch_url do
30
+ get '/config.js'
31
+ assert last_response.ok?
32
+ assert last_response.body.include?('elasticsearch: "http://asdf.com:9200"')
33
+ end
34
+ end
35
+
36
+ def test_it_renders_config_with_default_kibana_index
37
+ get '/config.js'
38
+ assert last_response.ok?
39
+ assert last_response.body.include?('kibana_index: "kibana-int"')
40
+ end
41
+
42
+ def test_it_renders_config_with_custom_kibana_index
43
+ kibana_index = Proc.new { "asdf" }
44
+
45
+ monkey_patch "kibana_index", kibana_index do
46
+ get '/config.js'
47
+ assert last_response.ok?
48
+ assert last_response.body.include?('kibana_index: "asdf"')
49
+ end
50
+ end
51
+
52
+ def monkey_patch(method_name, method_replacement)
53
+ Kibana::Sinatra::Web.class_eval do
54
+ alias_method "old_#{method_name}", method_name
55
+ define_method method_name, method_replacement
56
+ end
57
+
58
+ yield
59
+
60
+ Kibana::Sinatra::Web.class_eval do
61
+ alias_method method_name, "old_#{method_name}"
62
+ remove_method "old_#{method_name}"
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kibana-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Neubert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-04 00:00:00.000000000 Z
11
+ date: 2013-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: sinatra
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +103,7 @@ extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
91
105
  - .gitignore
106
+ - .travis.yml
92
107
  - Gemfile
93
108
  - LICENSE.txt
94
109
  - README.md
@@ -348,6 +363,7 @@ files:
348
363
  - lib/kibana/sinatra/web.rb
349
364
  - lib/kibana/views/config.erb
350
365
  - lib/tasks/update.rb
366
+ - test/sinatra_test.rb
351
367
  homepage: http://github.com/ianneub/kibana-sinatra
352
368
  licenses:
353
369
  - MIT
@@ -373,4 +389,5 @@ signing_key:
373
389
  specification_version: 4
374
390
  summary: This gem packages up Kibana 3 into a Sinatra app that can be used stand alone,
375
391
  or with Rails.
376
- test_files: []
392
+ test_files:
393
+ - test/sinatra_test.rb