status 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ Gemfile.lock
3
+
4
+ spec/dummy_apps/rails_app/log/
5
+ spec/dummy_apps/rails_app/tmp/
6
+ spec/dummy_apps/rails_app/db/*.sqlite3
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,10 @@
1
+ # Status
2
+
3
+ It doesn't really do anything apart from printing 'OK' from `/status` right now. More features to come.
4
+
5
+ ## Author
6
+
7
+ Released under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
8
+
9
+ - Copyright (c) 2011 Fred Wu - (<http://fredwu.me/>)
10
+ - Copyright (c) 2011 PlayUp - (<http://playup.com/>)
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
4
+ rescue Exception => e
5
+ end
6
+
7
+ require 'rspec/core'
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new(:spec) do |spec|
10
+ spec.pattern = FileList['spec/**/*_spec.rb']
11
+ end
12
+
13
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require 'status/middleware'
2
+ require 'status/handlers/rails' if Object.const_defined?(:Rails)
@@ -0,0 +1,5 @@
1
+ module Status
2
+ class Engine < ::Rails::Engine
3
+ config.app_middleware.use Middleware
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ module Status
2
+ class Middleware
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ if env['PATH_INFO'] == '/status'
9
+ [200, { 'Content-Type' => 'application/json' }, ['{"status": "OK"}']]
10
+ else
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ RailsApp::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run RailsApp::Application
@@ -0,0 +1,40 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ load File.expand_path('../../../../../lib/status.rb', __FILE__)
6
+
7
+ module RailsApp
8
+ class Application < Rails::Application
9
+ # Settings in config/environments/* take precedence over those specified here.
10
+ # Application configuration should go into files in config/initializers
11
+ # -- all .rb files in that directory are automatically loaded.
12
+
13
+ # Custom directories with classes and modules you want to be autoloadable.
14
+ # config.autoload_paths += %W(#{config.root}/extras)
15
+
16
+ # Only load the plugins named here, in the order given (default is alphabetical).
17
+ # :all can be used as a placeholder for all plugins not explicitly named.
18
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
19
+
20
+ # Activate observers that should always be running.
21
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
22
+
23
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
24
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
25
+ # config.time_zone = 'Central Time (US & Canada)'
26
+
27
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
28
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
29
+ # config.i18n.default_locale = :de
30
+
31
+ # JavaScript files you want as :defaults (application.js is always included).
32
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
33
+
34
+ # Configure the default encoding used in templates for Ruby 1.9.
35
+ config.encoding = "utf-8"
36
+
37
+ # Configure sensitive parameters which will be filtered from the log file.
38
+ config.filter_parameters += [:password]
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ require 'rubygems'
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,26 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ # config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end
@@ -0,0 +1,35 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ RailsApp::Application.config.secret_token = '123a9119fb14a410f485f9390286b33f2743b9d348246cf3e4434522078f77c202d7a1fb7e42666dd0844bcb10d0ff3d8b4ee087796269d4c574837948512dbf'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ RailsApp::Application.config.session_store :cookie_store, :key => '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # RailsApp::Application.config.session_store :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ RailsApp::Application.routes.draw do
2
+ match ':controller(/:action(/:id(.:format)))'
3
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ require 'status'
2
+ require 'rubygems'
3
+ require 'rack'
4
+
5
+ Dir[File.join(File.dirname(__FILE__), 'support', '**/*.rb')].each { |f| require f }
6
+
7
+ RSpec.configure do |config|
8
+ config.color_enabled = true
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+
5
+ require 'rails'
6
+ require File.expand_path('../../../dummy_apps/rails_app/config/environment.rb', __FILE__)
7
+ require 'rspec/rails'
8
+
9
+ describe 'RailsApp', :type => :request do
10
+ it "shows /status" do
11
+ get '/status'
12
+
13
+ response.body.should == '{"status": "OK"}'
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'date'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'status'
6
+ s.version = '0.0.1'
7
+ s.date = Date.today.to_s
8
+ s.authors = ['Fred Wu']
9
+ s.email = ['ifredwu@gmail.com']
10
+ s.summary = 'Provides application status information.'
11
+ s.description = "#{s.summary}"
12
+ s.homepage = 'http://github.com/playup/status'
13
+ s.extra_rdoc_files = %w(README.md)
14
+ s.rdoc_options = %w(--charset=UTF-8)
15
+ s.rubyforge_project = s.name
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = %w(lib)
20
+
21
+ s.add_dependency('rack', '>= 1.0')
22
+
23
+ s.add_development_dependency('rspec-rails', '~> 2.6')
24
+ s.add_development_dependency('rails', '>= 3.0')
25
+ s.add_development_dependency('sqlite3')
26
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: status
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fred Wu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-21 00:00:00.000000000 +10:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ requirement: &2165749860 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2165749860
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec-rails
28
+ requirement: &2165749380 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *2165749380
37
+ - !ruby/object:Gem::Dependency
38
+ name: rails
39
+ requirement: &2165748920 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '3.0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2165748920
48
+ - !ruby/object:Gem::Dependency
49
+ name: sqlite3
50
+ requirement: &2165748540 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *2165748540
59
+ description: Provides application status information.
60
+ email:
61
+ - ifredwu@gmail.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files:
65
+ - README.md
66
+ files:
67
+ - .gitignore
68
+ - Gemfile
69
+ - README.md
70
+ - Rakefile
71
+ - lib/status.rb
72
+ - lib/status/handlers/rails.rb
73
+ - lib/status/middleware.rb
74
+ - spec/dummy_apps/rails_app/Rakefile
75
+ - spec/dummy_apps/rails_app/app/controllers/application_controller.rb
76
+ - spec/dummy_apps/rails_app/config.ru
77
+ - spec/dummy_apps/rails_app/config/application.rb
78
+ - spec/dummy_apps/rails_app/config/boot.rb
79
+ - spec/dummy_apps/rails_app/config/database.yml
80
+ - spec/dummy_apps/rails_app/config/environment.rb
81
+ - spec/dummy_apps/rails_app/config/environments/development.rb
82
+ - spec/dummy_apps/rails_app/config/environments/production.rb
83
+ - spec/dummy_apps/rails_app/config/environments/test.rb
84
+ - spec/dummy_apps/rails_app/config/initializers/backtrace_silencers.rb
85
+ - spec/dummy_apps/rails_app/config/initializers/inflections.rb
86
+ - spec/dummy_apps/rails_app/config/initializers/mime_types.rb
87
+ - spec/dummy_apps/rails_app/config/initializers/secret_token.rb
88
+ - spec/dummy_apps/rails_app/config/initializers/session_store.rb
89
+ - spec/dummy_apps/rails_app/config/locales/en.yml
90
+ - spec/dummy_apps/rails_app/config/routes.rb
91
+ - spec/dummy_apps/rails_app/script/rails
92
+ - spec/spec_helper.rb
93
+ - spec/status/dummy_apps/rails_spec.rb
94
+ - status.gemspec
95
+ has_rdoc: true
96
+ homepage: http://github.com/playup/status
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options:
100
+ - --charset=UTF-8
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project: status
117
+ rubygems_version: 1.6.2
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: Provides application status information.
121
+ test_files: []