Class: MiniCheck::VersionRackApp
- Inherits:
-
Object
- Object
- MiniCheck::VersionRackApp
- Defined in:
- lib/mini_check/version_rack_app.rb
Defined Under Namespace
Classes: JsonResponse, PlainTextResponse
Constant Summary collapse
- REQUEST_METHOD =
'REQUEST_METHOD'.freeze
- PATH_INFO =
'PATH_INFO'.freeze
- APP_KEY =
'Application Name'.freeze
- CONTENT_TYPE_HEADER =
'Content-Type'.freeze
- JSON_MIME_TYPE =
'application/json'.freeze
- TEXT_MIME_TYPE =
'text/plain'.freeze
Instance Attribute Summary collapse
-
#build_file ⇒ Object
Returns the value of attribute build_file.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(args = {}) ⇒ VersionRackApp
constructor
A new instance of VersionRackApp.
- #metadata ⇒ Object
- #new(app) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ VersionRackApp
Returns a new instance of VersionRackApp.
14 15 16 |
# File 'lib/mini_check/version_rack_app.rb', line 14 def initialize args = {} set_attributes args end |
Instance Attribute Details
#build_file ⇒ Object
Returns the value of attribute build_file.
5 6 7 |
# File 'lib/mini_check/version_rack_app.rb', line 5 def build_file @build_file end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/mini_check/version_rack_app.rb', line 5 def path @path end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mini_check/version_rack_app.rb', line 22 def call env case "#{env[REQUEST_METHOD]} #{env[PATH_INFO]}" when "GET #{path}.json" JsonResponse.render(output_hash) when "GET #{path}" PlainTextResponse.render(output_hash) else host_app.call(env) end end |
#metadata ⇒ Object
18 19 20 |
# File 'lib/mini_check/version_rack_app.rb', line 18 def @metadata ||= Hash.new end |
#new(app) ⇒ Object
33 34 35 36 37 |
# File 'lib/mini_check/version_rack_app.rb', line 33 def new(app) copy = self.dup copy.host_app = app copy end |