rapporteur 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28ac116e491d1f943f1da89d5a5f953d890b6742
4
- data.tar.gz: 88ce0b43d51db0547a08ff8b06f768df29d51985
3
+ metadata.gz: df96dace0f56dd73b553b4e8e5740763df7d436e
4
+ data.tar.gz: a17856a53239ef0502e3204b4bb4f021ab217c20
5
5
  SHA512:
6
- metadata.gz: 9cf0b6b7e12e1d49502b069e922963c1619733143c55447d55f80016b838969127d35c8a6a3116bd3ac78a9de09a9df2e518c8a6f106e4f4906cfa8209595bb0
7
- data.tar.gz: 1a2c4eef857511251bd58980e015211d7a9339e667947caecc1ffb0680e91cf2d927da8fa88cc94d37bbf6732d78c4a75adad118cac4d3beb2260f542862259f
6
+ metadata.gz: 78544882974c0d03947f7f6672bddab451c202005bc12b5164e36473af1840f974b0f57d4a212779b1eb159e4bce7e6ff26e3ae1fe23b8c07f833fc16416e85f
7
+ data.tar.gz: cabde3e3047f46b5718206ce2fad85c32556ecab3192526bff3ebd54e32a2b4d90be52324e62a903c8c06b3c80c897fa5e19fd47456916a258dcb9a4cc9c6f88
data/.gitignore CHANGED
@@ -1,22 +1,13 @@
1
- .rvmrc
2
- .ruby-version
3
- .ruby-gemset
4
- *.gem
5
- *.rbc
6
- .bundle
7
- .config
8
- .yardoc
9
- Gemfile.lock
10
- *.gemfile.lock
11
- InstalledFiles
12
- _yardoc
13
- coverage
14
- doc/
15
- lib/bundler/man
16
- pkg
17
- rdoc
18
- spec/reports
19
- test/tmp
20
- test/version_tmp
21
- tmp
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /gemfiles/*.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ /.ruby-version
22
13
  *.sqlite
data/.travis.yml CHANGED
@@ -1,13 +1,30 @@
1
- language: ruby
2
- sudo: false
1
+ before_install: gem install bundler -v 1.13.7
3
2
  cache: bundler
4
- rvm:
5
- - 1.9.3
6
- - 2.2.0
7
- - jruby-19mode
8
3
  gemfile:
9
4
  - gemfiles/rails3.2.gemfile
10
5
  - gemfiles/rails4.x.gemfile
6
+ - gemfiles/rails5.x.gemfile
11
7
  - gemfiles/sinatra1.x.gemfile
8
+ language: ruby
9
+ matrix:
10
+ allow_failures:
11
+ # json 1.8.3 fails to build under 2.4.0
12
+ - rvm: 2.4.0
13
+ gemfile: gemfiles/rails3.2.gemfile
14
+ - rvm: 2.4.0
15
+ gemfile: gemfiles/rails4.x.gemfile
16
+ - rvm: 2.4.0
17
+ gemfile: gemfiles/sinatra1.x.gemfile
18
+ exclude:
19
+ # rails 5 requires Ruby 2.2.2+
20
+ - rvm: 2.1.10
21
+ gemfile: gemfiles/rails5.x.gemfile
22
+ fast_finish: true
12
23
  notifications:
13
24
  email: false
25
+ rvm:
26
+ - 2.1.10
27
+ - 2.2.6
28
+ - 2.3.3
29
+ - 2.4.0
30
+ sudo: false
data/Appraisals CHANGED
@@ -7,6 +7,10 @@ appraise "rails4.x" do
7
7
  gem "railties", "~> 4.0"
8
8
  end
9
9
 
10
+ appraise "rails5.x" do
11
+ gem "railties", "~> 5.0"
12
+ end
13
+
10
14
  appraise "sinatra1.x" do
11
15
  gem "sinatra", "~> 1.4"
12
16
  end
data/CHANGELOG.md CHANGED
@@ -1,15 +1,26 @@
1
1
  # Rapporteur changelog
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/rapporteur.svg?style=flat)](http://rubygems.org/gems/rapporteur)
4
- [![Build Status](http://img.shields.io/travis/codeschool/rapporteur/master.svg?style=flat)](https://travis-ci.org/codeschool/rapporteur)
5
- [![Code Climate](http://img.shields.io/codeclimate/github/codeschool/rapporteur.svg?style=flat)](https://codeclimate.com/github/codeschool/rapporteur)
6
- [![Dependency Status](https://gemnasium.com/codeschool/rapporteur.svg)](https://gemnasium.com/codeschool/rapporteur)
7
- [![Inline docs](http://inch-ci.org/github/codeschool/rapporteur.svg?branch=master)](http://inch-ci.org/github/codeschool/rapporteur)
4
+ [![Build Status](http://img.shields.io/travis/envylabs/rapporteur/master.svg?style=flat)](https://travis-ci.org/envylabs/rapporteur)
5
+ [![Code Climate](http://img.shields.io/codeclimate/github/envylabs/rapporteur.svg?style=flat)](https://codeclimate.com/github/envylabs/rapporteur)
6
+ [![Dependency Status](https://gemnasium.com/envylabs/rapporteur.svg)](https://gemnasium.com/envylabs/rapporteur)
7
+ [![Inline docs](http://inch-ci.org/github/envylabs/rapporteur.svg?branch=master)](http://inch-ci.org/github/envylabs/rapporteur)
8
8
 
9
9
  ## [HEAD][] / unreleased
10
10
 
11
11
  * No significant changes.
12
12
 
13
+ ## [3.5.0][] / 2016-01-28
14
+
15
+ * Add a backward-compatible fallback to auto-mount the `Rapporteur::Engine` in
16
+ a Rails application and deprecation warning if it is not explicitly mounted
17
+ by the application.
18
+ * Require the parent application to explicitly mount the `Rapporteur::Engine`
19
+ in their Rails application. This adds mount point flexibility at the cost of
20
+ configuration.
21
+ * Change ActiveRecord to use a more database agnostic `select_value` query to
22
+ determine availability. See #12.
23
+
13
24
  ## [3.4.0][] / 2016-01-06
14
25
 
15
26
  * Update the route generation code to no longer use a `.routes` method that
@@ -31,7 +42,7 @@
31
42
  * Update the Rails route definition to force (and default) a JSON format. The
32
43
  intent is to fix an issue where Rails auto-appended a `(.:format)` segment to
33
44
  the fixed route and broke `/status.json` route matching. See
34
- [codeschool/rapporteur#9](https://github.com/codeschool/rapporteur/issues/9).
45
+ [envylabs/rapporteur#9](https://github.com/envylabs/rapporteur/issues/9).
35
46
 
36
47
  ## [3.1.0][] / 2014-07-03
37
48
 
@@ -123,16 +134,17 @@
123
134
 
124
135
  [lsylvester]: https://github.com/lsylvester
125
136
 
126
- [HEAD]: https://github.com/codeschool/rapporteur/compare/v3.4.0...master
127
- [3.4.0]: https://github.com/codeschool/rapporteur/compare/v3.3.0...v3.4.0
128
- [3.3.0]: https://github.com/codeschool/rapporteur/compare/v3.2.0...v3.3.0
129
- [3.2.0]: https://github.com/codeschool/rapporteur/compare/v3.1.0...v3.2.0
130
- [3.1.0]: https://github.com/codeschool/rapporteur/compare/v3.0.2...v3.1.0
131
- [3.0.2]: https://github.com/codeschool/rapporteur/compare/v3.0.1...v3.0.2
132
- [3.0.1]: https://github.com/codeschool/rapporteur/compare/v3.0.0...v3.0.1
133
- [3.0.0]: https://github.com/codeschool/rapporteur/compare/v2.1.0...v3.0.0
134
- [2.1.0]: https://github.com/codeschool/rapporteur/compare/v2.0.1...v2.1.0
135
- [2.0.1]: https://github.com/codeschool/rapporteur/compare/v2.0.0...v2.0.1
136
- [2.0.0]: https://github.com/codeschool/rapporteur/compare/v1.1.0...v2.0.0
137
- [1.1.0]: https://github.com/codeschool/rapporteur/compare/v1.0.1...v1.1.0
138
- [1.0.1]: https://github.com/codeschool/rapporteur/compare/v1.0.0...v1.0.1
137
+ [HEAD]: https://github.com/envylabs/rapporteur/compare/v3.5.0...master
138
+ [3.5.0]: https://github.com/envylabs/rapporteur/compare/v3.4.0...v3.5.0
139
+ [3.4.0]: https://github.com/envylabs/rapporteur/compare/v3.3.0...v3.4.0
140
+ [3.3.0]: https://github.com/envylabs/rapporteur/compare/v3.2.0...v3.3.0
141
+ [3.2.0]: https://github.com/envylabs/rapporteur/compare/v3.1.0...v3.2.0
142
+ [3.1.0]: https://github.com/envylabs/rapporteur/compare/v3.0.2...v3.1.0
143
+ [3.0.2]: https://github.com/envylabs/rapporteur/compare/v3.0.1...v3.0.2
144
+ [3.0.1]: https://github.com/envylabs/rapporteur/compare/v3.0.0...v3.0.1
145
+ [3.0.0]: https://github.com/envylabs/rapporteur/compare/v2.1.0...v3.0.0
146
+ [2.1.0]: https://github.com/envylabs/rapporteur/compare/v2.0.1...v2.1.0
147
+ [2.0.1]: https://github.com/envylabs/rapporteur/compare/v2.0.0...v2.0.1
148
+ [2.0.0]: https://github.com/envylabs/rapporteur/compare/v1.1.0...v2.0.0
149
+ [1.1.0]: https://github.com/envylabs/rapporteur/compare/v1.0.1...v1.1.0
150
+ [1.0.1]: https://github.com/envylabs/rapporteur/compare/v1.0.0...v1.0.1
data/LICENSE.txt CHANGED
@@ -1,22 +1,21 @@
1
- Copyright (c) 2013 Envy Labs LLC and Code School LLC
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2013 Envy Labs LLC and Code School LLC
4
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:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
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.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Rapporteur (rap-or-TUHR)
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/rapporteur.svg?style=flat)](http://rubygems.org/gems/rapporteur)
4
- [![Build Status](http://img.shields.io/travis/codeschool/rapporteur/master.svg?style=flat)](https://travis-ci.org/codeschool/rapporteur)
5
- [![Code Climate](http://img.shields.io/codeclimate/github/codeschool/rapporteur.svg?style=flat)](https://codeclimate.com/github/codeschool/rapporteur)
6
- [![Dependency Status](https://gemnasium.com/codeschool/rapporteur.svg)](https://gemnasium.com/codeschool/rapporteur)
7
- [![Inline docs](http://inch-ci.org/github/codeschool/rapporteur.svg?branch=master)](http://inch-ci.org/github/codeschool/rapporteur)
4
+ [![Build Status](http://img.shields.io/travis/envylabs/rapporteur/master.svg?style=flat)](https://travis-ci.org/envylabs/rapporteur)
5
+ [![Code Climate](http://img.shields.io/codeclimate/github/envylabs/rapporteur.svg?style=flat)](https://codeclimate.com/github/envylabs/rapporteur)
6
+ [![Dependency Status](https://gemnasium.com/envylabs/rapporteur.svg)](https://gemnasium.com/envylabs/rapporteur)
7
+ [![Inline docs](http://inch-ci.org/github/envylabs/rapporteur.svg?branch=master)](http://inch-ci.org/github/envylabs/rapporteur)
8
8
 
9
9
 
10
10
  This gem provides a singular, status-checking endpoint to your application. The
@@ -51,14 +51,14 @@ $ bundle install
51
51
 
52
52
  Supported Ruby versions:
53
53
 
54
+ * MRI 2.4
55
+ * MRI 2.3
56
+ * MRI 2.2
54
57
  * MRI 2.1
55
- * MRI 2.0.0
56
- * MRI 1.9.3
57
- * MRI 1.9.2
58
- * JRuby 1.7
59
58
 
60
59
  Supported Rails versions:
61
60
 
61
+ * Rails 5.x.
62
62
  * Rails 4.x.
63
63
  * Rails 3.2.x.
64
64
 
@@ -84,29 +84,27 @@ requirement is that the check objects are callable (respond to `#call`, like a
84
84
  Proc). See more in the [Creating custom checks
85
85
  section](#creating-custom-checks), below.
86
86
 
87
- ### The endpoint
87
+ ### Usage in a Rails application
88
88
 
89
- This gem provides a new, single endpoint in your application. Specifically, it
90
- creates a named `/status.json` route, with the "status" name. It does not match
91
- on any other format or variation, which isolates the pollution of your
92
- application routes.
93
-
94
- If you'd like to link to the status endpoint from within your application (why,
95
- I couldn't guess), you can use a standard Rails URL helper:
89
+ If you're running in a Rails environment, then the included Rails Engine should
90
+ automatically get required and loaded. However, you will need to instruct your
91
+ application where to mount the status endpoint. In your `config/routes.rb`, add
92
+ a `mount` at the endpoint you desire:
96
93
 
97
94
  ```ruby
98
- link_to status_path
95
+ Rails.application.routes.draw do
96
+ mount Rapporteur::Engine, at: '/status'
97
+ end
99
98
  ```
100
99
 
101
- Were you already using the `/status.json` endpoint or the "status" route name?
102
- Hmm. Well... you just broke it.
100
+ This will mount the Rapporteur status endpoint at `/status` where it will
101
+ listen for and respond to JSON requests (`/status.json`, for example).
103
102
 
104
- ### Usage without Rails (i.e. Sinatra)
103
+ ### Usage in a Rack (non-Rails) application
105
104
 
106
- If your application does not have Rails loaded, the Rails Engine logic will be
107
- bypassed. In this case, you must configure and run your Rapporteur reports
108
- manually because, in the very least, your status route will not be
109
- automatically generated as previously described.
105
+ If you're running in a non-Rails, Rack environment (e.g. Sinatra), you can
106
+ `require "rapporteur"` and use the status generator directly from your own
107
+ endpoints.
110
108
 
111
109
  So, here is an example usage in Sinatra:
112
110
 
@@ -117,6 +115,7 @@ require "sinatra/base"
117
115
  class MyApp < Sinatra::Base
118
116
  get "/status.json" do
119
117
  content_type :json
118
+ status(result.errors.empty? ? 200 : 500)
120
119
  body Rapporteur.run.as_json.to_json
121
120
  end
122
121
  end
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
- require "rubygems"
2
- require "bundler/setup"
3
1
  require "bundler/gem_tasks"
4
2
  require "rspec/core/rake_task"
5
3
 
6
4
  RSpec::Core::RakeTask.new(:spec)
5
+
7
6
  task :default => :spec
@@ -0,0 +1,5 @@
1
+ module Rapporteur
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ module Rapporteur
2
+ class StatusesController < ApplicationController
3
+ def show
4
+ respond_to do |format|
5
+ format.json do
6
+ resource = Rapporteur.run
7
+
8
+ if resource.errors.empty?
9
+ render({:json => resource})
10
+ else
11
+ display_errors(resource, :json)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+ private
19
+
20
+
21
+ def display_errors(resource, format)
22
+ render({format => {:errors => resource.errors}, :status => :internal_server_error})
23
+ end
24
+ end
25
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rapporteur"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config/routes.rb CHANGED
@@ -1,20 +1,10 @@
1
1
  Rapporteur::Engine.routes.draw do
2
- get("status.:format", {
3
- :as => :status,
4
- :constraints => {:format => "json"},
5
- :defaults => {:format => "json"},
6
- :to => "statuses#show"
7
- })
2
+ get '/(.:format)', to: 'statuses#show', as: :status
8
3
  end
9
4
 
10
- Rails.application.routes.draw do
11
- unless Rails.application.routes.named_routes[:status]
12
- mount Rapporteur::Engine => "/"
13
- get("/status.:format", {
14
- :as => :status,
15
- :constraints => {:format => "json"},
16
- :defaults => {:format => "json"},
17
- :to => "statuses#show"
18
- })
5
+ unless Rails.application.routes.routes.any? { |r| Rapporteur::Engine == r.app.app }
6
+ ActiveSupport::Deprecation.warn('Rapporteur was not explicitly mounted in your application. Please add an explicit mount call to your /config/routes.rb. Automatically mounted Rapporteur::Engine to /status for backward compatibility. This will be no longer automatically mount in Rapporteur 4.')
7
+ Rails.application.routes.draw do
8
+ mount Rapporteur::Engine, at: '/status'
19
9
  end
20
10
  end
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
6
+ gem "sqlite3", :platforms => :ruby
7
+ gem "railties", "~> 5.0"
8
+
9
+ gemspec :path => "../"
@@ -2,7 +2,7 @@ module Rapporteur
2
2
  module Checks
3
3
  class ActiveRecordCheck
4
4
  def self.call(checker)
5
- ActiveRecord::Base.connection.execute("SELECT current_time AS time").first.fetch('time')
5
+ ActiveRecord::Base.connection.select_value("SELECT current_time AS time")
6
6
  rescue
7
7
  checker.add_error(:database, :unavailable)
8
8
  end
@@ -1,4 +1,5 @@
1
1
  module Rapporteur
2
2
  class Engine < Rails::Engine
3
+ isolate_namespace Rapporteur
3
4
  end
4
5
  end
@@ -1,43 +1,37 @@
1
1
  require 'rapporteur'
2
2
 
3
3
  shared_examples_for 'a successful status response' do
4
+ let(:parsed_body) { JSON.parse(response.body) }
5
+
4
6
  it 'responds with HTTP 200' do
5
- expect(subject.response_code).to(eq(200))
7
+ expect(response.response_code).to(eq(200))
6
8
  end
7
9
 
8
10
  it 'responds with a JSON content header' do
9
- expect(subject.content_type).to(eq(Mime[:json]))
10
- end
11
-
12
- it 'responds with valid JSON' do
13
- expect { JSON.parse(subject.body) }.not_to(raise_error)
11
+ expect(response.content_type).to(eq(Mime[:json]))
14
12
  end
15
13
 
16
14
  context 'the response payload' do
17
- subject { get(status_path) ; JSON.parse(response.body) }
18
-
19
15
  it 'does not contain errors' do
20
- expect(subject).not_to(have_key('errors'))
16
+ expect(parsed_body).not_to(have_key('errors'))
21
17
  end
22
18
  end
23
19
  end
24
20
 
25
21
  shared_examples_for 'an erred status response' do
22
+ let(:parsed_body) { JSON.parse(response.body) }
23
+
26
24
  it 'responds with HTTP 500' do
27
- expect(subject.response_code).to(eq(500))
25
+ expect(response.response_code).to(eq(500))
28
26
  end
29
27
 
30
28
  it 'responds with a JSON content header' do
31
- expect(subject.content_type).to(eq(Mime[:json]))
32
- end
33
-
34
- it 'responds with valid JSON' do
35
- expect { JSON.parse(subject.body) }.not_to(raise_error)
29
+ expect(response.content_type).to(eq(Mime[:json]))
36
30
  end
37
31
 
38
32
  it 'contains errors' do
39
- expect(JSON.parse(subject.body)).to(have_key('errors'))
40
- expect(JSON.parse(subject.body).fetch('errors')).not_to(be_empty)
33
+ expect(parsed_body).to(have_key('errors'))
34
+ expect(parsed_body.fetch('errors')).not_to(be_empty)
41
35
  end
42
36
  end
43
37
 
@@ -1,43 +1,37 @@
1
1
  require 'rapporteur'
2
2
 
3
3
  shared_examples_for 'a successful status response' do
4
+ let(:parsed_body) { JSON.parse(response.body) }
5
+
4
6
  it 'responds with HTTP 200' do
5
- expect(subject.response_code).to(eq(200))
7
+ expect(response.response_code).to(eq(200))
6
8
  end
7
9
 
8
10
  it 'responds with a JSON content header' do
9
- expect(subject.content_type).to(eq(Mime[:json]))
10
- end
11
-
12
- it 'responds with valid JSON' do
13
- expect { JSON.parse(subject.body) }.not_to(raise_error)
11
+ expect(response.content_type).to(eq(Mime[:json]))
14
12
  end
15
13
 
16
14
  context 'the response payload' do
17
- subject { get(status_path) ; JSON.parse(response.body) }
18
-
19
15
  it 'does not contain errors' do
20
- expect(subject).not_to(have_key('errors'))
16
+ expect(parsed_body).not_to(have_key('errors'))
21
17
  end
22
18
  end
23
19
  end
24
20
 
25
21
  shared_examples_for 'an erred status response' do
22
+ let(:parsed_body) { JSON.parse(response.body) }
23
+
26
24
  it 'responds with HTTP 500' do
27
- expect(subject.response_code).to(eq(500))
25
+ expect(response.response_code).to(eq(500))
28
26
  end
29
27
 
30
28
  it 'responds with a JSON content header' do
31
- expect(subject.content_type).to(eq(Mime[:json]))
32
- end
33
-
34
- it 'responds with valid JSON' do
35
- expect { JSON.parse(subject.body) }.not_to(raise_error)
29
+ expect(response.content_type).to(eq(Mime[:json]))
36
30
  end
37
31
 
38
32
  it 'contains errors' do
39
- expect(JSON.parse(subject.body)).to(have_key('errors'))
40
- expect(JSON.parse(subject.body).fetch('errors')).not_to(be_empty)
33
+ expect(parsed_body).to(have_key('errors'))
34
+ expect(parsed_body.fetch('errors')).not_to(be_empty)
41
35
  end
42
36
  end
43
37
 
@@ -1,3 +1,3 @@
1
1
  module Rapporteur
2
- VERSION = "3.4.0"
2
+ VERSION = "3.5.0".freeze
3
3
  end
data/rapporteur.gemspec CHANGED
@@ -10,17 +10,19 @@ Gem::Specification.new do |spec|
10
10
  spec.email = [""]
11
11
  spec.description = %q{An engine that provides common status polling endpoint.}
12
12
  spec.summary = %q{An engine that provides common status polling endpoint.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/envylabs/rapporteur"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
21
  spec.require_paths = ["lib"]
20
22
 
21
23
  spec.add_dependency 'i18n', '~> 0.6'
22
24
 
23
- spec.add_development_dependency "appraisal", "~> 1.0"
25
+ spec.add_development_dependency "appraisal", "~> 2.1"
24
26
  spec.add_development_dependency "bundler", "~> 1.3"
25
27
  spec.add_development_dependency "combustion", "~> 0.5", ">= 0.5.1"
26
28
  spec.add_development_dependency "rails", ">= 3.1", "< 6"
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapporteur
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Envy Labs
8
8
  - Code School
9
9
  autorequire:
10
- bindir: bin
10
+ bindir: exe
11
11
  cert_chain: []
12
- date: 2016-01-06 00:00:00.000000000 Z
12
+ date: 2017-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.0'
34
+ version: '2.1'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.0'
41
+ version: '2.1'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -137,12 +137,16 @@ files:
137
137
  - LICENSE.txt
138
138
  - README.md
139
139
  - Rakefile
140
- - app/controllers/statuses_controller.rb
140
+ - app/controllers/rapporteur/application_controller.rb
141
+ - app/controllers/rapporteur/statuses_controller.rb
142
+ - bin/console
143
+ - bin/setup
141
144
  - config.ru
142
145
  - config/locales/en.yml
143
146
  - config/routes.rb
144
147
  - gemfiles/rails3.2.gemfile
145
148
  - gemfiles/rails4.x.gemfile
149
+ - gemfiles/rails5.x.gemfile
146
150
  - gemfiles/sinatra1.x.gemfile
147
151
  - lib/rapporteur.rb
148
152
  - lib/rapporteur/check_list.rb
@@ -157,23 +161,7 @@ files:
157
161
  - lib/rapporteur/rspec3.rb
158
162
  - lib/rapporteur/version.rb
159
163
  - rapporteur.gemspec
160
- - spec/internal/config/database.yml
161
- - spec/internal/config/routes.rb
162
- - spec/internal/db/schema.rb
163
- - spec/internal/log/.gitignore
164
- - spec/internal/public/favicon.ico
165
- - spec/models/check_list_spec.rb
166
- - spec/models/message_list_spec.rb
167
- - spec/requests/active_record_check_spec.rb
168
- - spec/requests/halt_spec.rb
169
- - spec/requests/messsage_addition_spec.rb
170
- - spec/requests/no_checks_spec.rb
171
- - spec/requests/revision_check_spec.rb
172
- - spec/requests/sinatra_spec.rb
173
- - spec/requests/time_check_spec.rb
174
- - spec/routing/routes_spec.rb
175
- - spec/spec_helper.rb
176
- homepage: ''
164
+ homepage: https://github.com/envylabs/rapporteur
177
165
  licenses:
178
166
  - MIT
179
167
  metadata: {}
@@ -193,24 +181,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
181
  version: '0'
194
182
  requirements: []
195
183
  rubyforge_project:
196
- rubygems_version: 2.5.1
184
+ rubygems_version: 2.5.2
197
185
  signing_key:
198
186
  specification_version: 4
199
187
  summary: An engine that provides common status polling endpoint.
200
- test_files:
201
- - spec/internal/config/database.yml
202
- - spec/internal/config/routes.rb
203
- - spec/internal/db/schema.rb
204
- - spec/internal/log/.gitignore
205
- - spec/internal/public/favicon.ico
206
- - spec/models/check_list_spec.rb
207
- - spec/models/message_list_spec.rb
208
- - spec/requests/active_record_check_spec.rb
209
- - spec/requests/halt_spec.rb
210
- - spec/requests/messsage_addition_spec.rb
211
- - spec/requests/no_checks_spec.rb
212
- - spec/requests/revision_check_spec.rb
213
- - spec/requests/sinatra_spec.rb
214
- - spec/requests/time_check_spec.rb
215
- - spec/routing/routes_spec.rb
216
- - spec/spec_helper.rb
188
+ test_files: []
189
+ has_rdoc:
@@ -1,23 +0,0 @@
1
- class StatusesController < ActionController::Base
2
- def show
3
- respond_to do |format|
4
- format.json do
5
- resource = Rapporteur.run
6
-
7
- if resource.errors.empty?
8
- render({:json => resource})
9
- else
10
- display_errors(resource, :json)
11
- end
12
- end
13
- end
14
- end
15
-
16
-
17
- private
18
-
19
-
20
- def display_errors(resource, format)
21
- render({format => {:errors => resource.errors}, :status => :internal_server_error})
22
- end
23
- end
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: db/combustion_test.sqlite
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- #
3
- end
@@ -1,3 +0,0 @@
1
- ActiveRecord::Schema.define do
2
- #
3
- end
@@ -1 +0,0 @@
1
- *.log
File without changes
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Rapporteur::CheckList, :type => :model do
4
- let(:list) { described_class.new }
5
-
6
- context '#add' do
7
- it 'adds the given object to the list' do
8
- list.add(check = double)
9
- expect(list.to_a).to include(check)
10
- end
11
-
12
- it 'does not return duplicate entries' do
13
- list.add(check = double)
14
- list.add(check)
15
- expect(list.to_a).to have(1).check
16
- end
17
- end
18
-
19
- context '#clear' do
20
- it 'empties the list of objects' do
21
- list.add(double)
22
- expect { list.clear }.to change(list, :empty?).to(true)
23
- end
24
- end
25
-
26
- context '#each' do
27
- it 'yields each contained object in the order added' do
28
- list.add(check0 = double)
29
- list.add(check1 = double)
30
- list.add(check2 = double)
31
- returns = Array.new
32
-
33
- list.each do |object|
34
- returns << object
35
- end
36
-
37
- expect(returns[0]).to equal(check0)
38
- expect(returns[1]).to equal(check1)
39
- expect(returns[2]).to equal(check2)
40
- end
41
-
42
- it 'returns itself' do
43
- expect(list.each).to equal(list)
44
- end
45
- end
46
-
47
- context '#to_a' do
48
- it 'returns an Array' do
49
- expect(list.to_a).to be_an(Array)
50
- end
51
-
52
- it 'returns new different but equivalent Array instances' do
53
- return1 = list.to_a
54
- return2 = list.to_a
55
- expect(return1).to_not equal(return2)
56
- expect(return1).to eq(return2)
57
- end
58
- end
59
- end
@@ -1,88 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Rapporteur::MessageList, :type => :model do
4
- let(:list) { Rapporteur::MessageList.new(:errors) }
5
-
6
- before { I18n.backend.reload! }
7
-
8
- context '#add' do
9
- it 'returns the MessageList instance.' do
10
- expect(list.add(:test, 'message')).to equal(list)
11
- end
12
-
13
- it 'adds a String message to the #full_messages' do
14
- list.add(:test, 'message')
15
- expect(list.full_messages).to include('test message')
16
- end
17
-
18
- it 'adds unrecognized Symbols as Strings to the #full_messages' do
19
- list.add(:test, :message)
20
- expect(list.full_messages).to include('test message')
21
- end
22
-
23
- it 'adds multiple messages to an attribute' do
24
- list.add(:test, 'message 1')
25
- list.add(:test, 'message 2')
26
- expect(list.full_messages).to include('test message 1')
27
- expect(list.full_messages).to include('test message 2')
28
- end
29
-
30
- it 'translates and adds recognized I18n keys in the #full_messages' do
31
- add_translation(:errors, :test, :i18n_message, 'translated')
32
- list.add(:test, :i18n_message)
33
- expect(list.full_messages).to include('test translated')
34
- end
35
-
36
- it 'translates and adds recognized I18n keys with named parameters in the #full_messages' do
37
- add_translation(:errors, :test, :i18n_message, 'translated %{language}')
38
- list.add(:test, :i18n_message, :language => 'French')
39
- expect(list.full_messages).to include('test translated French')
40
- end
41
-
42
- it 'translates based on the initialized list type' do
43
- add_translation(:string, :test, :i18n_message, 'strings')
44
- add_translation(:messages, :test, :i18n_message, 'messages')
45
- add_translation(:errors, :test, :i18n_message, 'errors')
46
- message_list = Rapporteur::MessageList.new(:messages)
47
- error_list = Rapporteur::MessageList.new(:errors)
48
- message_list.add(:test, :i18n_message)
49
- error_list.add(:test, :i18n_message)
50
- expect(message_list.full_messages).to include('test messages')
51
- expect(message_list.full_messages).not_to include('test errors')
52
- expect(error_list.full_messages).to include('test errors')
53
- expect(error_list.full_messages).not_to include('test messages')
54
- end
55
- end
56
-
57
- context '#to_hash' do
58
- it 'flattens key/value pairs with only one value' do
59
- list.add(:test, 'message')
60
- expect(list.to_hash).to eq({:test => 'message'})
61
- end
62
-
63
- it 'retains multiple values for a single key' do
64
- list.add(:test, 'message1')
65
- list.add(:test, 'message2')
66
- result = list.to_hash
67
- expect(result).to have_key(:test)
68
- expect(result[:test]).to include('message1')
69
- expect(result[:test]).to include('message2')
70
- end
71
-
72
- it 'returns a new, unique, but equivalent Hash with each call' do
73
- list.add(:test, 'message')
74
- return1 = list.to_hash
75
- return2 = list.to_hash
76
- expect(return1).not_to equal(return2)
77
- expect(return1).to eq(return2)
78
- end
79
- end
80
-
81
-
82
- private
83
-
84
-
85
- def add_translation(type, key, message, string)
86
- I18n.backend.store_translations('en', {:rapporteur => {type.to_sym => {key.to_sym => {message.to_sym => string}}}})
87
- end
88
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'A status request with an ActiveRecordCheck', :type => :request do
4
- before do
5
- Rapporteur.add_check(Rapporteur::Checks::ActiveRecordCheck)
6
- end
7
-
8
- subject { get(status_path) ; response }
9
-
10
- context 'with an unerring ActiveRecord connection' do
11
- it_behaves_like 'a successful status response'
12
- end
13
-
14
- context 'with a failed ActiveRecord connection' do
15
- before do
16
- allow(ActiveRecord::Base.connection).to receive(:execute).
17
- and_raise(ActiveRecord::ConnectionNotEstablished)
18
- end
19
-
20
- it_behaves_like 'an erred status response'
21
-
22
- it 'contains a message regarding the database failure' do
23
- expect(subject).to include_status_error_message(:database, I18n.t('rapporteur.errors.database.unavailable'))
24
- end
25
- end
26
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'A check calling #halt!', :type => :request do
4
- before do
5
- Rapporteur.add_check { |checker| checker.add_message(:one, 1) }
6
- Rapporteur.add_check { |checker| checker.add_message(:two, 2).halt! }
7
- Rapporteur.add_check { |checker| checker.add_message(:three, 3) }
8
- end
9
-
10
- subject { get(status_path) ; JSON.parse(response.body) }
11
-
12
- it 'runs the first check' do
13
- expect(subject).to include('one')
14
- end
15
-
16
- it 'runs the second check' do
17
- expect(subject).to include('two')
18
- end
19
-
20
- it 'does not run any checks after #halt! is called' do
21
- expect(subject).not_to include('three')
22
- end
23
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'A status request with a check that modifies messages', :type => :request do
4
- subject { get(status_path) ; response }
5
-
6
- context 'creating a message with a block' do
7
- before do
8
- Rapporteur.add_check { |checker| checker.add_message('git_repo', 'git@github.com:organization/repo.git') }
9
- end
10
-
11
- context 'with an unerring response' do
12
- it_behaves_like 'a successful status response'
13
-
14
- it 'responds with the check\'s messages' do
15
- expect(subject).to include_status_message('git_repo', 'git@github.com:organization/repo.git')
16
- end
17
- end
18
-
19
- context 'with an erring response' do
20
- before do
21
- Rapporteur.add_check { |checker| checker.add_error(:base, 'failed') }
22
- end
23
-
24
- it_behaves_like 'an erred status response'
25
-
26
- it 'does not respond with the check\'s messages' do
27
- expect(subject).not_to include_status_message('git_repo', 'git@github.com:organization/repo.git')
28
- end
29
- end
30
-
31
- context 'with no message-modifying checks' do
32
- it_behaves_like 'a successful status response'
33
-
34
- it 'does not respond with a messages list' do
35
- expect(JSON.parse(subject.body)).not_to(have_key('messages'))
36
- end
37
- end
38
- end
39
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'A status request with no checks', :type => :request do
4
- subject { get(status_path) ; response }
5
-
6
- it_behaves_like 'a successful status response'
7
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'A status request with a RevisionCheck', :type => :request do
4
- before do
5
- allow(Rapporteur::Revision).to receive(:current).and_return('revisionidentifier')
6
- Rapporteur.add_check(Rapporteur::Checks::RevisionCheck)
7
- end
8
-
9
- subject { get(status_path) ; response }
10
-
11
- it_behaves_like 'a successful status response'
12
-
13
- context 'the response payload' do
14
- it 'contains the current application revision' do
15
- expect(subject).to include_status_message('revision', 'revisionidentifier')
16
- end
17
- end
18
- end
@@ -1,59 +0,0 @@
1
- require "spec_helper"
2
-
3
- ENV["RACK_ENV"] = "test"
4
-
5
- begin
6
- require "sinatra/base"
7
- require "rack/test"
8
-
9
- describe "Sinatra" do
10
- include Rack::Test::Methods
11
-
12
-
13
- class TestApp < Sinatra::Base
14
- get "/status.json" do
15
- content_type :json
16
- body Rapporteur.run.as_json.to_json
17
- end
18
- end
19
-
20
-
21
- def app
22
- TestApp
23
- end
24
-
25
- before do
26
- Rapporteur.add_check(Rapporteur::Checks::TimeCheck)
27
- end
28
-
29
-
30
- subject { get("/status.json") ; last_response }
31
-
32
- it 'responds with HTTP 200' do
33
- expect(subject.status).to(eq(200))
34
- end
35
-
36
- it 'responds with a JSON content header' do
37
- expect(subject.content_type).to(eq(Mime[:json]))
38
- end
39
-
40
- it 'responds with valid JSON' do
41
- expect { JSON.parse(subject.body) }.not_to(raise_error)
42
- end
43
-
44
- it 'contains the time in ISO8601' do
45
- allow(Time).to receive(:now).and_return(Time.gm(2013,8,23))
46
- expect(subject).to include_status_message('time', /^2013-08-23T00:00:00(?:.000)?Z$/)
47
- end
48
-
49
- context 'the response payload' do
50
- subject { get("/status.json") ; JSON.parse(last_response.body) }
51
-
52
- it 'does not contain errors' do
53
- expect(subject).not_to(have_key('errors'))
54
- end
55
-
56
- end
57
- end
58
- rescue LoadError
59
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'A status request with a TimeCheck', :type => :request do
4
- before do
5
- Rapporteur.add_check(Rapporteur::Checks::TimeCheck)
6
- end
7
-
8
- subject { get(status_path) ; response }
9
-
10
- it_behaves_like 'a successful status response'
11
-
12
- context 'the response payload' do
13
- it 'contains the time in ISO8601' do
14
- allow(Time).to receive(:now).and_return(Time.gm(2013,8,23))
15
- expect(subject).to include_status_message('time', /^2013-08-23T00:00:00(?:.000)?Z$/)
16
- end
17
- end
18
- end
19
-
@@ -1,27 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe "status route", :type => :routing do
4
- it 'routes /status.json to statuses#show' do
5
- expect({ :get => '/status.json'}).to route_to({
6
- :action => 'show',
7
- :controller => 'statuses',
8
- :format => 'json',
9
- })
10
- end
11
-
12
- it 'does not route /status' do
13
- expect({ :get => '/status'}).to_not be_routable
14
- end
15
-
16
- it 'does not route /status.html' do
17
- expect({ :get => '/status.html'}).to_not be_routable
18
- end
19
-
20
- it 'does not route /status.xml' do
21
- expect({ :get => '/status.xml'}).to_not be_routable
22
- end
23
-
24
- it 'does not route /status.json.json' do
25
- expect({ :get => '/status.json.json'}).to_not be_routable
26
- end
27
- end
data/spec/spec_helper.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'combustion'
4
-
5
- ENV["RAILS_ENV"] ||= 'test'
6
- Combustion.initialize! :action_controller, :active_record
7
-
8
- require 'rspec/rails'
9
- require 'rspec/collection_matchers'
10
- require 'rapporteur/rspec3'
11
-
12
- RSpec.configure do |config|
13
- config.run_all_when_everything_filtered = true
14
- config.filter_run :focus
15
-
16
- config.order = 'random'
17
-
18
- config.before { Rapporteur.clear_checks }
19
- end
20
-
21
-
22
- # This is a shim to allow for Ruby 1.9.3, Rails 3.2 testing to pass.
23
- # See https://github.com/rspec/rspec-rails/issues/1171.
24
- Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)