up_and_down 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6db68b7b121e4af30a966d21bc90b75ee0bb9df2
4
+ data.tar.gz: 909251d835690f3878c394750cdf45e46606c486
5
+ SHA512:
6
+ metadata.gz: 40cd492fc2da91c59debd48ebafaaeddc9ca707678fba291ecc423360edca9a2d786030924bdecd4cc1dcefd37afb23d1bb9f45393dc4a6fa804a568fdaf4c3d
7
+ data.tar.gz: 210061fd4e81d33d122302670002a98eb2ee255af1979a5017f72e7b7743c5cd9eed7aafaada6e3ade9f1de373ba8a11cb08f7e0eeb4b0af189aac997371112f
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in up_and_down.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Abhishek kanojia
4
+
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:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
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.
@@ -0,0 +1,52 @@
1
+ # UpAndDown
2
+
3
+ Make your rails application down for maintenance. This gem provides three rake tasks for making application up, down and checking current status of application.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'up_and_down'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install up_and_down
20
+
21
+ ## Usage
22
+
23
+ ### Down your rails application for maintenance by using:
24
+
25
+ ``` rails site:down ```
26
+ or
27
+ ``` rake site:down ```
28
+
29
+ Now visit http://localhost:3000 after starting rails server.
30
+ You should see
31
+
32
+ # Site is Down for Maintenance
33
+
34
+ ### Make application up and running again by using:
35
+
36
+ ``` rails site:up ```
37
+ or
38
+ ``` rake site:up ```
39
+
40
+ ### Check status of Application by using:
41
+
42
+ ``` rails site:status ```
43
+ or
44
+ ``` rake site:status ```
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/abhishekkanojia/up_and_down.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "up_and_down"
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(__FILE__)
@@ -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
@@ -0,0 +1,26 @@
1
+ require 'rails/generators/base'
2
+
3
+ class UpAndDownGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../../../../templates', __FILE__)
5
+
6
+ def create_controller
7
+ create_file "app/controllers/up_and_down/base_controller.rb", controller_definition
8
+ end
9
+
10
+ def create_template
11
+ copy_file "maintenance.html.erb", "app/views/up_and_down/base/index.html.erb"
12
+ end
13
+
14
+ def create_route
15
+ route "root 'up_and_down/base#index'"
16
+ end
17
+
18
+ private
19
+
20
+ def controller_definition
21
+ "class UpAndDown::BaseController < ApplicationController
22
+ def index
23
+ end
24
+ end"
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ ACTION = 'index'
2
+ CONTROLLER = 'up_and_down/base'
3
+ LAYOUT_FILE_PATH = 'app/views/up_and_down/base/index.html.erb'
4
+ CONTROLLER_FILE_PATH = 'app/controllers/up_and_down/base_controller.rb'
@@ -0,0 +1,39 @@
1
+ require_relative '../initializers/constants.rb'
2
+
3
+ namespace :site do
4
+ desc "Down site for maintenence. will create site down page."
5
+ task down: :environment do
6
+ if system('rails g up_and_down -q')
7
+ puts "Site is down for maintenance."
8
+ end
9
+ end
10
+
11
+ desc "Up site. will remove site down page if exists"
12
+ task up: :environment do
13
+ if system('rails destroy up_and_down -q')
14
+ puts "Site is up and running."
15
+ end
16
+ end
17
+
18
+ desc "Check site status whether up or down"
19
+ task status: :environment do
20
+ if files_exists? && root_route_exists?
21
+ prompt_message 'Site is Down.'
22
+ else
23
+ prompt_message 'Site is Up.'
24
+ end
25
+ end
26
+ end
27
+
28
+ def files_exists?
29
+ [CONTROLLER_FILE_PATH, LAYOUT_FILE_PATH].all? { |file| File.exists?(file) }
30
+ end
31
+
32
+ def root_route_exists?
33
+ recognizer = Rails.application.routes.recognize_path('/')
34
+ recognizer[:controller].eql?(CONTROLLER) && recognizer[:action].eql?(ACTION)
35
+ end
36
+
37
+ def prompt_message(message)
38
+ puts message
39
+ end
@@ -0,0 +1,5 @@
1
+ require "up_and_down/version"
2
+ require 'up_and_down/railtie' if defined?(Rails::Railtie)
3
+
4
+ module UpAndDown
5
+ end
@@ -0,0 +1,6 @@
1
+ module UpAndDown
2
+ require 'rails'
3
+ class Railtie < Rails::Railtie
4
+ rake_tasks { load "tasks/site.rake" }
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module UpAndDown
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,74 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title><%= Rails.application.class.parent_name %></title>
6
+ <%= csrf_meta_tags %>
7
+ <%= stylesheet_link_tag 'application', media: 'all' %>
8
+ <%= javascript_include_tag 'application' %>
9
+ </head>
10
+ <style>
11
+ html, body {
12
+ background-color: #fff;
13
+ color: #636b6f;
14
+ font-family: 'Raleway', sans-serif;
15
+ font-weight: 100;
16
+ height: 100vh;
17
+ margin: 0;
18
+ }
19
+
20
+ .full-height {
21
+ height: 100vh;
22
+ }
23
+
24
+ .flex-center {
25
+ align-items: center;
26
+ display: flex;
27
+ justify-content: center;
28
+ }
29
+
30
+ .position-ref {
31
+ position: relative;
32
+ }
33
+
34
+ .top-right {
35
+ position: absolute;
36
+ right: 10px;
37
+ top: 18px;
38
+ }
39
+
40
+ .content {
41
+ text-align: center;
42
+ }
43
+
44
+ .title {
45
+ font-size: 84px;
46
+ }
47
+
48
+ .links > a {
49
+ color: #636b6f;
50
+ padding: 0 25px;
51
+ font-size: 12px;
52
+ font-weight: 600;
53
+ letter-spacing: .1rem;
54
+ text-decoration: none;
55
+ text-transform: uppercase;
56
+ }
57
+
58
+ .m-b-md {
59
+ margin-bottom: 30px;
60
+ }
61
+ </style>
62
+ <body>
63
+ <div class="flex-center position-ref full-height">
64
+ <div class="content">
65
+ <div class="title m-b-md">
66
+ Site is Under Maintenance.
67
+ </div>
68
+ <div class="links">
69
+ <h3>Come back Soon</h3>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ </body>
74
+ </html>
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "up_and_down/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "up_and_down"
8
+ spec.version = UpAndDown::VERSION
9
+ spec.authors = ["Abhishek kanojia"]
10
+ spec.email = ["abhishek.kanojia3193@gmail.com"]
11
+
12
+ spec.summary = "Site Up and Down for rails application."
13
+ spec.description = "Easily make your application up or down for maintenance"
14
+ spec.homepage = "https://github.com/abhishekkanojia/up_and_down"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.files << Dir.glob("{lib}/**/*")
21
+ spec.files << Dir.glob("{templates}/**")
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+
29
+ spec.add_dependency "rails", ">= 5.0.4"
30
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: up_and_down
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Abhishek kanojia
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 5.0.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 5.0.4
55
+ description: Easily make your application up or down for maintenance
56
+ email:
57
+ - abhishek.kanojia3193@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - lib/generators/up_and_down/up_and_down_generator.rb
70
+ - lib/initializers/constants.rb
71
+ - lib/tasks/site.rake
72
+ - lib/up_and_down.rb
73
+ - lib/up_and_down/railtie.rb
74
+ - lib/up_and_down/version.rb
75
+ - templates/maintenance.html.erb
76
+ - up_and_down.gemspec
77
+ homepage: https://github.com/abhishekkanojia/up_and_down
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.6.11
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Site Up and Down for rails application.
101
+ test_files: []