[
  {
    "path": ".dockerignore",
    "content": "logs/*\ndoc/*\nvendor/*\ncoverage/*\ntmp/*\n"
  },
  {
    "path": ".github/workflows/rails.yml",
    "content": "name: Rails\n\non: [push]\n\njobs:\n\n  build:\n    runs-on: ubuntu-latest\n    services:\n      mysql:\n        image: mysql:5.7\n        env:\n          MYSQL_ALLOW_EMPTY_PASSWORD: \"yes\"\n    container:\n      image: ruby:2.6.5\n      env:\n        MYSQL_HOST: mysql\n    steps:\n    - uses: actions/checkout@v1\n    - name: Setup YARN and NodeJS\n      run: |\n        curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -\n        echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | tee /etc/apt/sources.list.d/yarn.list\n        curl -sL https://deb.nodesource.com/setup_12.x | bash -\n        apt-get install -y yarn nodejs\n    - name: Build and setup\n      run: |\n        gem install bundler --no-document\n        bundle install --jobs 4 --retry 3 --deployment\n        bundle exec rails yarn:install db:setup assets:precompile\n        bundle exec rake\n      env:\n        RAILS_ENV: \"test\"\n"
  },
  {
    "path": ".gitignore",
    "content": "# See https://help.github.com/articles/ignoring-files for more about ignoring files.\n#\n# If you find yourself ignoring temporary files generated by your text editor\n# or operating system, you probably want to add a global ignore instead:\n#   git config --global core.excludesfile '~/.gitignore_global'\n\n# Ignore bundler config.\n/.bundle\n\n# Ignore the default SQLite database.\n/db/*.sqlite3\n/db/*.sqlite3-journal\n\n# Ignore all logfiles and tempfiles.\n/log/*\n!/log/.keep\n/tmp\n*.rdb\n.env\ncoverage\n"
  },
  {
    "path": ".rspec",
    "content": "--color\n--require spec_helper\n"
  },
  {
    "path": ".rubocop.yml",
    "content": "AllCops:\n  TargetRubyVersion: 2.4\n  DisplayCopNames: true\n  DisabledByDefault: true\n  Exclude:\n    - 'db/**/*'\n    - 'vendor/**/*'\n\nRails:\n  Enabled: true\n\nRails/ActionFilter:\n  EnforcedStyle: action\n  Enabled: true\n\nStyle/HashSyntax:\n  Enabled: true\n\nStyle/MethodDefParentheses:\n  Enabled: true\n\nStyle/Encoding:\n  Enabled: true\n\nStyle/For:\n  EnforcedStyle: each\n  Enabled: true\n\nStyle/FrozenStringLiteralComment:\n  EnforcedStyle: never\n  Enabled: true\n\nStyle/NumericLiteralPrefix:\n  EnforcedOctalStyle: zero_only\n  Enabled: true\n\nStyle/StabbyLambdaParentheses:\n  EnforcedStyle: require_parentheses\n  Enabled: true\n\nLayout/EmptyLines:\n  Enabled: true\n\nLayout/TrailingBlankLines:\n  Enabled: true\n\nLayout/TrailingWhitespace:\n  Enabled: true\n\nLayout/AccessModifierIndentation:\n  EnforcedStyle: indent\n  Enabled: true\n\nLayout/CaseIndentation:\n  EnforcedStyle: end\n  Enabled: true\n\nLayout/MultilineHashBraceLayout:\n  EnforcedStyle: symmetrical\n  Enabled: true\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM ruby:2.6.5\n\nRUN apt update -qqy && apt -qqy install nodejs\n\nWORKDIR /tmp\nADD Gemfile* /tmp/\n\nRUN gem install bundler:2.1.4\nRUN bundle install --deployment -j4 --without development test\n\nADD . /app\nWORKDIR /app\nRUN cp -a /tmp/vendor/bundle /app/vendor/bundle && \\\n    bundle exec rake assets:precompile\nCMD [\"bundle\", \"exec\", \"foreman\", \"start\", \"-f\", \"Procfile.docker\"]\n"
  },
  {
    "path": "Gemfile",
    "content": "source 'https://rubygems.org'\n\n# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\ngem 'rails', '5.2.4.1'\n\n# Use SCSS for stylesheets\ngem 'sass-rails', '~> 5.0'\n# Use Uglifier as compressor for JavaScript assets\ngem 'uglifier', '>= 1.3.0'\n# Use CoffeeScript for .coffee assets and views\ngem 'coffee-rails'\n# See https://github.com/sstephenson/execjs#readme for more supported runtimes\n# gem 'therubyracer', platforms: :ruby\n\n# Use jquery as the JavaScript library\ngem 'jquery-rails'\n# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\ngem 'jbuilder', '~> 2.0'\n# bundle exec rake doc:rails generates the API under doc/api.\ngem 'sdoc'\n\n# Use ActiveModel has_secure_password\n# gem 'bcrypt', '~> 3.1.7'\n\n# Use Unicorn as the app server\n# gem 'unicorn'\n\n# Use Capistrano for deployment\n# gem 'capistrano-rails', group: :development\n\ngem 'sidekiq', '~> 3.3.0'\ngem 'sinatra'\n\ngem 'faraday', '~> 0.15.4'\ngem 'holiday_jp'\ngem 'hipchat'\ngem 'kaminari'\n\ngem 'puma'\ngem 'rack-health'\ngem 'omniauth-google-oauth2', '~> 0.6'\ngem 'retriable', '3.0.1'\ngem 'twilio-ruby'\ngem 'mysql2'\n\ngem 'google-api-client', '~> 0.7.1'\n\ngem 'foreman'\n\ngroup :development do\n  gem 'web-console'\nend\n\ngroup :development, :test do\n  # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n  gem 'byebug'\n\n  # Access an IRB console on exception pages or by using <%= console %> in views\n\n  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n  gem 'spring'\n\n  gem 'rspec-rails'\n\n  gem 'database_rewinder'\n\n  gem 'pry-byebug'\n  gem 'dotenv-rails'\n  gem 'factory_bot_rails'\n  gem 'rubocop', require: false\nend\n\ngroup :test do\n  gem 'simplecov', require: false\nend\n\ngem 'dogapi'\ngem 'aws-sdk'\ngem 'rails_autolink'\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2014-2015 Ryota Arai\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "Procfile",
    "content": "web: bin/rails s\nworker: bundle exec sidekiq\nupdate_escalations: while true; do bundle exec rails runner 'EscalationUpdateWorker.perform_async()'; sleep 60; done\n"
  },
  {
    "path": "Procfile.docker",
    "content": "web: puma -C docker/puma.rb\nworker: bundle exec sidekiq\nupdate_escalations: while true; do bundle exec rails runner 'EscalationUpdateWorker.perform_async()'; sleep 60; done\n"
  },
  {
    "path": "README.md",
    "content": "# Waker [![Build Status](https://travis-ci.org/ryotarai/waker.svg?branch=master)](https://travis-ci.org/ryotarai/waker)\n\nAlert Escalation System\n\n![](https://raw.githubusercontent.com/ryotarai/waker/master/doc/incidents.png)\n\n## Overview\n\n![](https://raw.githubusercontent.com/ryotarai/waker/master/doc/overview.png)\n\n![](https://raw.githubusercontent.com/ryotarai/waker/master/doc/escalation.png)\n\n## Tutorial\n\n### 1. (Optional) Configure auth provider\n\nYou can use external auth provider **optionally**. Currently, Google Auth is only supported (Patches are welcome :) )\n\n```\n$ echo 'GOOGLE_CLIENT_ID=...' >> .env\n$ echo 'GOOGLE_CLIENT_SECRET=...' >> .env\n$ echo 'GOOGLE_DOMAIN=...' >> .env # If you restrict to use Google Apps domain\n```\n\n### 2. Start the server\n\n```\n$ bundle install\n$ foreman start\n```\n\nIt starts an application server and a Sidekiq worker.\n\n### 3. (If you uses auth provider) Log in\n\nVisit [http://localhost:3000](http://localhost:3000) and log in with your credentials.\nA new user account is automatically created and suspended by default. You can activate a user from [http://localhost:3000/users](http://localhost:3000/users) but you have to activate it from `rails console` because you are the first user:\n\n```\n$ bundle exec rails c\n> User.first.update!(active: true)\n```\n\n### 4. Create users\n\nVisit [http://localhost:3000/users/new](http://localhost:3000/users/new) and create new users.\n\n### 5. Create a notifier provider\n\nVisit [http://localhost:3000/notifier_providers/new](http://localhost:3000/notifier_providers/new) and create a notifier provider. See [Notifier Providers](https://github.com/ryotarai/waker#notifier-providers) section for detailed information.\n\n### 6. Create a notifier\n\nVisit [http://localhost:3000/notifiers/new](http://localhost:3000/notifiers/new) and create a notifier. See [Notifier](https://github.com/ryotarai/waker#notifiers) section for detailed information.\n\n### 7. Create an escalation series\n\nVisit [http://localhost:3000/escalation_series/new](http://localhost:3000/escalation_series/new) and create a escalation series. Escalation series is a series of escalations.\n\n### 8. Create escalations\n\nVisit [http://localhost:3000/escalations/new](http://localhost:3000/escalations/new) and create escalations.\n\n- `Escalate to`: Who gets escalated incidents\n- `Escalate after sec`: Seconds to escalate incidents since the incidents created\n\n### 9. Create a topic\n\nVisit [http://localhost:3000/topics/new](http://localhost:3000/topics/new) and create topics.\n\n### 10. Send alerts to the topic\n\nSuppoted alerts generaters are below:\n\n- Mailgun ( `http://localhost:3000/topics/1/mailgun` )\n- Mackerel ( `http://localhost:3000/topics/1/mackerel` )\n- Alertmanager ( `http://localhost:3000/topics/1/alertmanager` )\n- Slack( `http://localhost:3000/topics/1/slack` )\n\nIf you want to use Mailgun, you can configure Mailgun route setting with Mailgun endpoint you can see in [http://localhost:3000/topics/1/mailgun](http://localhost:3000/topics/1/mailgun)\n## Configuration\n\n### Notifier Providers\n\n#### HipChat\n\n- `api_token`\n- `api_version`: `v1` or `v2`\n\n#### Twilio\n\n- `account_sid`\n- `auth_token`\n- `from`: Phone number\n\n#### Mailgun\n\n- `api_key`\n- `from`: Email address\n\n### Notifiers\n\n#### Common fields\n\nThese are supported by all notifier provider\n\n```\nor_conditions:\n- japanese_weekday: true\n  not_between: 9:30+0900-18:30+0900\n- not_japanese_weekday: true\n```\n\n#### HipChat\n\n- `room`: Room name or ID\n\n#### Twilio\n\n- `to`: Phone number\n\n#### Mailgun\n\n- `to`: Email address\n"
  },
  {
    "path": "Rakefile",
    "content": "# Add your own tasks in files placed in lib/tasks ending in .rake,\n# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.\n\nrequire File.expand_path('../config/application', __FILE__)\n\nRails.application.load_tasks\n"
  },
  {
    "path": "app/assets/images/.keep",
    "content": ""
  },
  {
    "path": "app/assets/javascripts/application.js",
    "content": "// This is a manifest file that'll be compiled into application.js, which will include all the files\n// listed below.\n//\n// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,\n// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.\n//\n// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the\n// compiled file.\n//\n// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details\n// about supported directives.\n//\n//= require jquery\n//= require jquery_ujs\n//= require_tree .\n"
  },
  {
    "path": "app/assets/javascripts/comments.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/escalation_series.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/escalations.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/home.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/incident_events.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/incidents.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/maintenances.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/notifier_providers.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/notifiers.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/sessions.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/slack.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/topics.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/javascripts/users.coffee",
    "content": "# Place all the behaviors and hooks related to the matching controller here.\n# All this logic will automatically be available in application.js.\n# You can use CoffeeScript in this file: http://coffeescript.org/\n"
  },
  {
    "path": "app/assets/stylesheets/application.css",
    "content": "/*\n * This is a manifest file that'll be compiled into application.css, which will include all the files\n * listed below.\n *\n * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,\n * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.\n *\n * You're free to add application-wide styles to this file and they'll appear at the bottom of the\n * compiled file so the styles you add here take precedence over styles defined in any styles\n * defined in the other CSS/SCSS files in this directory. It is generally better to create a new\n * file per style scope.\n *\n *= require_tree .\n *= require_self\n */\n"
  },
  {
    "path": "app/assets/stylesheets/comments.scss",
    "content": "// Place all the styles related to the comments controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/escalation_series.scss",
    "content": "// Place all the styles related to the EscalationSeries controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/escalations.scss",
    "content": "// Place all the styles related to the escalations controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/home.scss",
    "content": "// Place all the styles related to the home controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/incident_events.scss",
    "content": "// Place all the styles related to the incident_events controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/incidents.scss",
    "content": "// Place all the styles related to the incidents controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/maintenances.scss",
    "content": "// Place all the styles related to the maintenances controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/notifier_providers.scss",
    "content": "// Place all the styles related to the NotifierProviders controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/notifiers.scss",
    "content": "// Place all the styles related to the notifiers controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/scaffolds.scss",
    "content": "body {\n  background-color: #fff;\n  color: #333;\n  font-family: verdana, arial, helvetica, sans-serif;\n  font-size: 13px;\n  line-height: 18px;\n}\n\np, ol, ul, td {\n  font-family: verdana, arial, helvetica, sans-serif;\n  font-size: 13px;\n  line-height: 18px;\n}\n\npre {\n  background-color: #eee;\n  padding: 10px;\n  font-size: 11px;\n}\n\na {\n  color: #000;\n  &:visited {\n    color: #666;\n  }\n  &:hover {\n    color: #fff;\n    background-color: #000;\n  }\n}\n\ndiv {\n  &.field, &.actions {\n    margin-bottom: 10px;\n  }\n}\n\n#notice {\n  color: green;\n}\n\n.field_with_errors {\n  padding: 2px;\n  background-color: red;\n  display: table;\n}\n\n#error_explanation {\n  width: 450px;\n  border: 2px solid red;\n  padding: 7px;\n  padding-bottom: 0;\n  margin-bottom: 20px;\n  background-color: #f0f0f0;\n  h2 {\n    text-align: left;\n    font-weight: bold;\n    padding: 5px 5px 5px 15px;\n    font-size: 12px;\n    margin: -7px;\n    margin-bottom: 0px;\n    background-color: #c00;\n    color: #fff;\n  }\n  ul li {\n    font-size: 12px;\n    list-style: square;\n  }\n}\n"
  },
  {
    "path": "app/assets/stylesheets/sessions.scss",
    "content": "// Place all the styles related to the sessions controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/slack.scss",
    "content": "// Place all the styles related to the slack controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/topics.scss",
    "content": "// Place all the styles related to the topics controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/assets/stylesheets/users.scss",
    "content": "// Place all the styles related to the users controller here.\n// They will automatically be included in application.css.\n// You can use Sass (SCSS) here: http://sass-lang.com/\n"
  },
  {
    "path": "app/controllers/application_controller.rb",
    "content": "class ApplicationController < ActionController::Base\n  # Prevent CSRF attacks by raising an exception.\n  # For APIs, you may want to use :null_session instead.\n  protect_from_forgery with: :null_session\n  helper_method :current_user\n\n  if ENV[\"GOOGLE_CLIENT_ID\"]\n    before_action :login_required\n  end\n\n  def login_required\n    unless current_user\n      session[:user_id] = nil\n      redirect_to '/auth/google_oauth2_with_calendar'\n      return\n    end\n\n    unless current_user.active\n      render text: \"You are not activated yet. Please ask administrator to activate you\"\n      return\n    end\n  end\n\n  private\n  def current_user=(user)\n    session[:user_id] = user.id\n  end\n\n  def current_user\n    if user_id = session[:user_id]\n      User.find(user_id)\n    elsif login_token = request.headers['X-Login-Token']\n      User.find_by(login_token: login_token)\n    end\n  end\nend\n"
  },
  {
    "path": "app/controllers/comments_controller.rb",
    "content": "class CommentsController < ApplicationController\n  before_action :set_comment, only: [:show, :edit, :update, :destroy]\n  before_action :set_incident\n\n  # GET /comments\n  # GET /comments.json\n  def index\n    @comments = Comment.where(incident: @incident)\n  end\n\n  # GET /comments/1\n  # GET /comments/1.json\n  def show\n  end\n\n  # GET /comments/new\n  def new\n    @comment = Comment.new\n  end\n\n  # GET /comments/1/edit\n  def edit\n  end\n\n  # POST /comments\n  # POST /comments.json\n  def create\n    p comment_params\n    @comment = Comment.new(comment_params)\n\n    respond_to do |format|\n      if @comment.save\n        format.html { redirect_to [@incident, @comment], notice: 'Comment was successfully created.' }\n        format.json { render :show, status: :created, location: [@incident, @comment] }\n      else\n        format.html { render :new }\n        format.json { render json: @comment.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /comments/1\n  # PATCH/PUT /comments/1.json\n  def update\n    respond_to do |format|\n      if @comment.update(comment_params)\n        format.html { redirect_to [@incident, @comment], notice: 'Comment was successfully updated.' }\n        format.json { render :show, status: :ok, location: [@incident, @comment] }\n      else\n        format.html { render :edit }\n        format.json { render json: @comment.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /comments/1\n  # DELETE /comments/1.json\n  def destroy\n    @comment.destroy\n    respond_to do |format|\n      format.html { redirect_to incident_comments_url, notice: 'Comment was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_comment\n      @comment = Comment.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def comment_params\n      params.require(:comment).permit(:incident_id, :user_id, :comment)\n    end\n\n    def set_incident\n      @incident = Incident.find(params[:incident_id])\n    end\nend\n"
  },
  {
    "path": "app/controllers/concerns/.keep",
    "content": ""
  },
  {
    "path": "app/controllers/escalation_series_controller.rb",
    "content": "class EscalationSeriesController < ApplicationController\n  before_action :set_escalation_series, only: [:show, :edit, :update, :destroy, :update_escalations]\n\n  # GET /escalation_series\n  # GET /escalation_series.json\n  def index\n    @escalation_series = EscalationSeries.all\n  end\n\n  # GET /escalation_series/1\n  # GET /escalation_series/1.json\n  def show\n  end\n\n  # GET /escalation_series/new\n  def new\n    @escalation_series = EscalationSeries.new\n  end\n\n  # GET /escalation_series/1/edit\n  def edit\n  end\n\n  # POST /escalation_series\n  # POST /escalation_series.json\n  def create\n    @escalation_series = EscalationSeries.new(escalation_series_params)\n\n    respond_to do |format|\n      if @escalation_series.save\n        format.html { redirect_to @escalation_series, notice: 'Escalation series was successfully created.' }\n        format.json { render :show, status: :created, location: @escalation_series }\n      else\n        format.html { render :new }\n        format.json { render json: @escalation_series.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /escalation_series/1\n  # PATCH/PUT /escalation_series/1.json\n  def update\n    respond_to do |format|\n      if @escalation_series.update(escalation_series_params)\n        format.html { redirect_to @escalation_series, notice: 'Escalation series was successfully updated.' }\n        format.json { render :show, status: :ok, location: @escalation_series }\n      else\n        format.html { render :edit }\n        format.json { render json: @escalation_series.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /escalation_series/1\n  # DELETE /escalation_series/1.json\n  def destroy\n    @escalation_series.destroy\n    respond_to do |format|\n      format.html { redirect_to escalation_series_index_url, notice: 'Escalation series was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  def update_escalations\n    @escalation_series.update_escalations!\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_escalation_series\n      @escalation_series = EscalationSeries.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def escalation_series_params\n      params.require(:escalation_series).permit(:name, :settings).tap do |v|\n        v[:settings] = YAML.load(v[:settings])\n      end\n    end\nend\n"
  },
  {
    "path": "app/controllers/escalations_controller.rb",
    "content": "class EscalationsController < ApplicationController\n  before_action :set_escalation, only: [:show, :edit, :update, :destroy]\n\n  # GET /escalations\n  # GET /escalations.json\n  def index\n    @escalations = Escalation.all.order('escalate_after_sec')\n  end\n\n  # GET /escalations/1\n  # GET /escalations/1.json\n  def show\n  end\n\n  # GET /escalations/new\n  def new\n    @escalation = Escalation.new\n  end\n\n  # GET /escalations/1/edit\n  def edit\n  end\n\n  # POST /escalations\n  # POST /escalations.json\n  def create\n    @escalation = Escalation.new(escalation_params)\n\n    respond_to do |format|\n      if @escalation.save\n        format.html { redirect_to @escalation, notice: 'Escalation was successfully created.' }\n        format.json { render :show, status: :created, location: @escalation }\n      else\n        format.html { render :new }\n        format.json { render json: @escalation.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /escalations/1\n  # PATCH/PUT /escalations/1.json\n  def update\n    respond_to do |format|\n      if @escalation.update(escalation_params)\n        format.html { redirect_to @escalation, notice: 'Escalation was successfully updated.' }\n        format.json { render :show, status: :ok, location: @escalation }\n      else\n        format.html { render :edit }\n        format.json { render json: @escalation.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /escalations/1\n  # DELETE /escalations/1.json\n  def destroy\n    @escalation.destroy\n    respond_to do |format|\n      format.html { redirect_to escalations_url, notice: 'Escalation was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_escalation\n      @escalation = Escalation.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def escalation_params\n      params.require(:escalation).permit(:escalate_to_id, :escalate_after_sec, :escalation_series_id)\n    end\nend\n"
  },
  {
    "path": "app/controllers/home_controller.rb",
    "content": "class HomeController < ApplicationController\n  def index\n    redirect_to incidents_path\n  end\nend\n"
  },
  {
    "path": "app/controllers/incident_events_controller.rb",
    "content": "require 'securerandom'\n\nclass IncidentEventsController < ApplicationController\n  skip_before_action :login_required, only: [:twilio], raise: false\n\n  def twilio\n    @event = IncidentEvent.find(params[:id])\n    language = ENV['TWILIO_LANGUAGE'] || 'en-US'\n    resp = nil\n\n    if params[:Digits]\n      case params[:Digits]\n      when '1'\n        @event.incident.acknowledge! rescue nil\n      when '2'\n        @event.incident.resolve! rescue nil\n      end\n      resp = Twilio::TwiML::VoiceResponse.new do |r|\n        r.say message: @event.incident.status, voice: 'alice', language: language\n        r.hangup\n      end\n    else\n      resp = Twilio::TwiML::VoiceResponse.new do |r|\n        r.gather timeout: 10, numDigits: 1 do |g|\n          g.say message: \"This is Waker alert.\", voice: 'alice', language: language\n          g.say message: @event.incident.subject, voice: 'alice', language: language\n          g.say message: \"To acknowledge, press 1.\", voice: 'alice', language: language\n          g.say message: \"To resolve, press 2.\", voice: 'alice', language: language\n        end\n      end\n    end\n\n    render xml: resp.to_s\n  end\nend\n"
  },
  {
    "path": "app/controllers/incidents_controller.rb",
    "content": "class IncidentsController < ApplicationController\n  before_action :set_incidents, only: [:index, :bulk_acknowledge, :bulk_resolve]\n  before_action :set_incident, only: [:show, :edit, :update, :destroy, :acknowledge, :resolve]\n  before_action :ensure_hash, only: [:acknowledge, :resolve]\n  skip_before_action :login_required, only: [:acknowledge, :resolve], raise: false\n\n  # GET /incidents\n  # GET /incidents.json\n  def index\n    @page = (params[:page] || 1).to_i\n    @incidents = @incidents.order('id DESC').page(@page).per(25)\n  end\n\n  # GET /incidents/1\n  # GET /incidents/1.json\n  def show\n  end\n\n  # GET /incidents/new\n  def new\n    @incident = Incident.new\n  end\n\n  # GET /incidents/1/edit\n  def edit\n  end\n\n  # POST /incidents\n  # POST /incidents.json\n  def create\n    @incident = Incident.new(incident_params)\n\n    respond_to do |format|\n      if @incident.save\n        format.html { redirect_to @incident, notice: 'Incident was successfully created.' }\n        format.json { render :show, status: :created, location: @incident }\n      else\n        format.html { render :new }\n        format.json { render json: @incident.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /incidents/1\n  # PATCH/PUT /incidents/1.json\n  def update\n    respond_to do |format|\n      if @incident.update(incident_params)\n        format.html { redirect_to @incident, notice: 'Incident was successfully updated.' }\n        format.json { render :show, status: :ok, location: @incident }\n      else\n        format.html { render :edit }\n        format.json { render json: @incident.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  def bulk_acknowledge\n    @incidents.opened.update_all(status: Incident.statuses[:acknowledged])\n    respond_to do |format|\n      format.html { redirect_to incidents_url, notice: 'Incidents were successfully acknowledged.' }\n      format.json { head :no_content }\n    end\n  end\n\n  def bulk_resolve\n    @incidents.update_all(status: Incident.statuses[:resolved])\n    respond_to do |format|\n      format.html { redirect_to incidents_url, notice: 'Incidents were successfully resolved.' }\n      format.json { head :no_content }\n    end\n  end\n\n  # DELETE /incidents/1\n  # DELETE /incidents/1.json\n  def destroy\n    @incident.destroy\n    respond_to do |format|\n      format.html { redirect_to incidents_url, notice: 'Incident was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  def acknowledge\n    @incident.acknowledge!\n    respond_to do |format|\n      if current_user\n        format.html { redirect_to incidents_url, notice: 'Incident was successfully acknowledged.' }\n      else\n        format.html { render text: \"Acknowledged\" }\n      end\n      format.json { render json: {status: 'ok'} }\n    end\n  end\n\n  def resolve\n    @incident.resolve!\n    respond_to do |format|\n      if current_user\n        format.html { redirect_to incidents_url, notice: 'Incident was successfully resolved.' }\n      else\n        format.html { render text: \"Resolved\" }\n      end\n      format.json { render json: {status: 'ok'} }\n    end\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_incident\n      @incident = Incident.find(params[:id])\n    end\n\n    def set_incidents\n      set_visible_statuses\n      set_visible_topic\n\n      @incidents = Incident.all\n\n      if @visible_statuses\n        @incidents = @incidents.where(status: @visible_statuses)\n      end\n      if @visible_topic\n        @incidents = @incidents.where(topic: @visible_topic)\n      end\n    end\n\n    def set_visible_statuses\n      @visible_statuses = session[:incidents_statuses]\n\n      # for transition from rev 0a2dd42 or earlier\n      @visible_statuses = nil if @visible_statuses.try(:empty?)\n\n      if params[:statuses]\n        if params[:statuses] == ''\n          @visible_statuses = nil # all\n        else\n          @visible_statuses = params[:statuses].split(',').map(&:to_i)\n        end\n        session[:incidents_statuses] = @visible_statuses\n      end\n    end\n\n    def set_visible_topic\n      @visible_topic = session[:incidents_topic]\n\n      # for transition from rev 0a2dd42 or earlier\n      @visible_topic = nil if @visible_topic == 'all'\n\n      if params[:topic]\n        if params[:topic] == 'all'\n          @visible_topic = nil # all\n        else\n          @visible_topic = params[:topic].to_i\n        end\n        session[:incidents_topic] = @visible_topic\n      end\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def incident_params\n      params.require(:incident).permit(:subject, :description, :topic_id, :occured_at)\n    end\n\n    def ensure_hash\n      unless params[:hash] == @incident.confirmation_hash\n        render text: \"Wrong hash\", status: 403\n      end\n    end\nend\n"
  },
  {
    "path": "app/controllers/maintenances_controller.rb",
    "content": "class MaintenancesController < ApplicationController\n  before_action :set_maintenance, only: [:show, :edit, :update, :destroy]\n\n  # GET /maintenances\n  # GET /maintenances.json\n  def index\n    @maintenances = Maintenance.not_expired\n  end\n\n  # GET /maintenances/1\n  # GET /maintenances/1.json\n  def show\n  end\n\n  # GET /maintenances/new\n  def new\n    now = Time.now\n    @maintenance = Maintenance.new(\n      start_time: now,\n      end_time: now + 60*60\n    )\n  end\n\n  # GET /maintenances/1/edit\n  def edit\n  end\n\n  # POST /maintenances\n  # POST /maintenances.json\n  def create\n    @maintenance = Maintenance.new(maintenance_params)\n\n    respond_to do |format|\n      if @maintenance.save\n        format.html { redirect_to @maintenance, notice: 'Maintenance was successfully created.' }\n        format.json { render :show, status: :created, location: @maintenance }\n      else\n        format.html { render :new }\n        format.json { render json: @maintenance.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /maintenances/1\n  # PATCH/PUT /maintenances/1.json\n  def update\n    respond_to do |format|\n      if @maintenance.update(maintenance_params)\n        format.html { redirect_to @maintenance, notice: 'Maintenance was successfully updated.' }\n        format.json { render :show, status: :ok, location: @maintenance }\n      else\n        format.html { render :edit }\n        format.json { render json: @maintenance.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /maintenances/1\n  # DELETE /maintenances/1.json\n  def destroy\n    @maintenance.destroy\n    respond_to do |format|\n      format.html { redirect_to maintenances_url, notice: 'Maintenance was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_maintenance\n      @maintenance = Maintenance.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def maintenance_params\n      params.require(:maintenance).permit(:topic_id, :start_time, :end_time, :filter)\n    end\nend\n"
  },
  {
    "path": "app/controllers/notifier_providers_controller.rb",
    "content": "class NotifierProvidersController < ApplicationController\n  before_action :set_notifier_provider, only: [:show, :edit, :update, :destroy]\n\n  # GET /notifier_providers\n  # GET /notifier_providers.json\n  def index\n    @notifier_providers = NotifierProvider.all\n  end\n\n  # GET /notifier_providers/1\n  # GET /notifier_providers/1.json\n  def show\n  end\n\n  # GET /notifier_providers/new\n  def new\n    @notifier_provider = NotifierProvider.new\n  end\n\n  # GET /notifier_providers/1/edit\n  def edit\n  end\n\n  # POST /notifier_providers\n  # POST /notifier_providers.json\n  def create\n    @notifier_provider = NotifierProvider.new(notifier_provider_params)\n\n    respond_to do |format|\n      if @notifier_provider.save\n        format.html { redirect_to @notifier_provider, notice: 'Notifier provider was successfully created.' }\n        format.json { render :show, status: :created, location: @notifier_provider }\n      else\n        format.html { render :new }\n        format.json { render json: @notifier_provider.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /notifier_providers/1\n  # PATCH/PUT /notifier_providers/1.json\n  def update\n    respond_to do |format|\n      if @notifier_provider.update(notifier_provider_params)\n        format.html { redirect_to @notifier_provider, notice: 'Notifier provider was successfully updated.' }\n        format.json { render :show, status: :ok, location: @notifier_provider }\n      else\n        format.html { render :edit }\n        format.json { render json: @notifier_provider.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /notifier_providers/1\n  # DELETE /notifier_providers/1.json\n  def destroy\n    @notifier_provider.destroy\n    respond_to do |format|\n      format.html { redirect_to notifier_providers_url, notice: 'Notifier provider was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_notifier_provider\n      @notifier_provider = NotifierProvider.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def notifier_provider_params\n      params.require(:notifier_provider).permit(:name, :kind, :settings).tap do |v|\n        v[:settings] = YAML.load(v[:settings])\n      end\n    end\nend\n"
  },
  {
    "path": "app/controllers/notifiers_controller.rb",
    "content": "class NotifiersController < ApplicationController\n  before_action :set_notifier, only: [:show, :edit, :update, :destroy]\n\n  # GET /notifiers\n  # GET /notifiers.json\n  def index\n    @notifiers = Notifier.all\n  end\n\n  # GET /notifiers/1\n  # GET /notifiers/1.json\n  def show\n  end\n\n  # GET /notifiers/new\n  def new\n    @notifier = Notifier.new\n  end\n\n  # GET /notifiers/1/edit\n  def edit\n  end\n\n  # POST /notifiers\n  # POST /notifiers.json\n  def create\n    @notifier = Notifier.new(notifier_params)\n\n    respond_to do |format|\n      if @notifier.save\n        format.html { redirect_to @notifier, notice: 'Notifier was successfully created.' }\n        format.json { render :show, status: :created, location: @notifier }\n      else\n        format.html { render :new }\n        format.json { render json: @notifier.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /notifiers/1\n  # PATCH/PUT /notifiers/1.json\n  def update\n    respond_to do |format|\n      if @notifier.update(notifier_params)\n        format.html { redirect_to @notifier, notice: 'Notifier was successfully updated.' }\n        format.json { render :show, status: :ok, location: @notifier }\n      else\n        format.html { render :edit }\n        format.json { render json: @notifier.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /notifiers/1\n  # DELETE /notifiers/1.json\n  def destroy\n    @notifier.destroy\n    respond_to do |format|\n      format.html { redirect_to notifiers_url, notice: 'Notifier was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_notifier\n      @notifier = Notifier.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def notifier_params\n      params.require(:notifier).permit(:user_id, :kind, :settings, :notify_after_sec, :provider_id, :topic_id, :enabled).tap do |v|\n        v[:settings] = YAML.load(v[:settings])\n      end\n    end\nend\n"
  },
  {
    "path": "app/controllers/sessions_controller.rb",
    "content": "class SessionsController < ApplicationController\n  skip_before_action :login_required, only: [:create]\n\n  def create\n    @user = User.find_or_create_from_auth_hash(auth_hash)\n    @user.update_credentials_from_auth_hash(auth_hash)\n    self.current_user = @user\n    redirect_to '/'\n  end\n\n  private\n\n  def auth_hash\n    request.env['omniauth.auth']\n  end\nend\n"
  },
  {
    "path": "app/controllers/slack_controller.rb",
    "content": "class SlackController < ApplicationController\n  skip_before_action :login_required, only: [:interactive], raise: false\n\n  def interactive\n    verify!\n\n    message = payload['original_message']\n    message['attachments'][0].delete('actions')\n\n    user = payload['user']['name']\n\n    text = ''\n    payload['actions'].each do |a|\n      case a['value']\n      when 'acknowledge'\n        incident.acknowledge!\n        text = \":white_check_mark: @#{user} acknowledged\"\n      when 'resolve'\n        incident.resolve!\n        text = \":white_check_mark: @#{user} resolved\"\n      end\n    end\n\n    message['attachments'][0]['fields'] = [{\n      'title' => text,\n      'value' => '',\n      'short' => false,\n    }]\n\n    render json: message\n  end\n\n  private def payload\n    JSON.parse(params[:payload])\n  end\n\n  private def verify!\n    verified = false\n    Notifier.preload(:provider).find_each do |n|\n      settings = n.provider.settings.merge(n.settings)\n      token = settings['verification_token']\n      if n.provider.slack? && settings['enable_buttons'] && payload['token'] == token\n        verified = true\n        break\n      end\n    end\n\n    unless verified\n      raise 'token verification failed'\n    end\n  end\n\n  private def incident_id\n    payload['callback_id'].match(/\\Aincident\\.(\\d+)\\z/)[1].to_i\n  end\n\n  private def incident\n    Incident.find(incident_id)\n  end\nend\n"
  },
  {
    "path": "app/controllers/topics_controller.rb",
    "content": "class TopicsController < ApplicationController\n  before_action :set_topic, only: [:show, :edit, :update, :destroy, :mailgun, :mackerel, :alertmanager, :slack]\n  skip_before_action :login_required, only: [:mailgun, :mackerel, :alertmanager, :slack], raise: false\n\n  # GET /topics\n  # GET /topics.json\n  def index\n    @topics = Topic.all\n  end\n\n  # GET /topics/1\n  # GET /topics/1.json\n  def show\n  end\n\n  # GET /topics/new\n  def new\n    @topic = Topic.new\n  end\n\n  # GET /topics/1/edit\n  def edit\n  end\n\n  # POST /topics\n  # POST /topics.json\n  def create\n    @topic = Topic.new(topic_params)\n\n    respond_to do |format|\n      if @topic.save\n        format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n        format.json { render :show, status: :created, location: @topic }\n      else\n        format.html { render :new }\n        format.json { render json: @topic.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /topics/1\n  # PATCH/PUT /topics/1.json\n  def update\n    respond_to do |format|\n      if @topic.update(topic_params)\n        format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n        format.json { render :show, status: :ok, location: @topic }\n      else\n        format.html { render :edit }\n        format.json { render json: @topic.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /topics/1\n  # DELETE /topics/1.json\n  def destroy\n    @topic.destroy\n    respond_to do |format|\n      format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  # POST /topics/1/mailgun\n  def mailgun\n    unless @topic.enabled\n      Rails.logger.info \"Incident creation is skipped because the topic is disabled.\"\n      render json: {}, status: 200\n      return\n    end\n\n    # http://documentation.mailgun.com/user_manual.html#routes\n    subject = params[:subject]\n    description = params['body-plain']\n\n    if @topic.in_maintenance?(subject, description)\n      Rails.logger.info \"Incident creation is skipped because the topic is in maintenance.\"\n      render json: {}, status: 200\n      return\n    end\n\n    @topic.incidents.create!(\n      subject: subject,\n      description: description,\n    )\n\n    render json: {}, status: 200\n  end\n\n  # POST /topics/1/mackerel\n  def mackerel\n    data = JSON.parse(request.body.read)\n    return  render json: {}, status: 200 if data.dig('alert', 'status') == 'ok' || data.dig('alertGroup', 'status') == 'OK'\n\n    unless @topic.enabled\n      Rails.logger.info \"Incident creation is skipped because the topic is disabled.\"\n      render json: {}, status: 200\n      return\n    end\n\n    if data['event'] == 'alertGroup' then\n      subject = \"[#{data['alertGroup']['status']}] #{data['alertGroupSetting']['name']}\"\n    else\n      name = data.key?('host') ?  data['host']['name'] : data['alert']['monitorName']\n      subject = \"[#{data['alert']['status']}] #{name}\"\n    end\n    description = JSON.pretty_generate(data)\n\n    if @topic.in_maintenance?(subject, description)\n      Rails.logger.info \"Incident creation is skipped because the topic is in maintenance\"\n      render json: {}, status: 200\n      return\n    end\n\n    @topic.incidents.create!(\n      subject: subject,\n      description: description,\n    )\n    render json: {}, status: 200\n  end\n\n  # POST /topics/1/alertmanager\n  def alertmanager\n    data = JSON.parse(request.body.read)\n\n    unless @topic.enabled\n      Rails.logger.info \"Incident creation is skipped because the topic is disabled.\"\n      render json: {}, status: 200\n      return\n    end\n\n    subject = \"[#{data['commonLabels']['severity']}] #{data['commonLabels']['alertname']}: #{data['commonAnnotations']['summary']}\"\n    description = JSON.pretty_generate(data)\n\n    if @topic.in_maintenance?(subject, description)\n      Rails.logger.info \"Incident creation is skipped because the topic is in maintenance\"\n      render json: {}, status: 200\n      return\n    end\n\n    @topic.incidents.create!(\n      subject: subject,\n      description: description,\n    )\n    render json: {}, status: 200\n  end\n\n  def slack\n    unless @topic.enabled\n      Rails.logger.info \"Incident creation is skipped because the topic is disabled.\"\n      render json: {}, status: 200\n      return\n    end\n\n    subject = \"escalation from slack,channel name:#{params['channel_name']} #{params['text']}\"\n    description = \"channel:#{params['channel_name']} user:#{params['user_name']} #{params['text']}\"\n\n    if @topic.in_maintenance?(subject, description)\n      Rails.logger.info \"Incident creation is skipped because the topic is in maintenance.\"\n      render json: {}, status: 200\n      return\n    end\n\n    @topic.incidents.create!(\n      subject: subject,\n      description: description,\n    )\n\n    render json: {text: 'accept your page'}, status: 200\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_topic\n      @topic = Topic.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def topic_params\n      params.require(:topic).permit(:name, :kind, :escalation_series_id, :enabled)\n    end\nend\n"
  },
  {
    "path": "app/controllers/users_controller.rb",
    "content": "class UsersController < ApplicationController\n  before_action :set_user, only: [:show, :edit, :update, :destroy, :activation, :deactivation]\n\n  # GET /users\n  # GET /users.json\n  def index\n    @users = User.all\n  end\n\n  # GET /users/1\n  # GET /users/1.json\n  def show\n  end\n\n  # GET /users/new\n  def new\n    @user = User.new\n  end\n\n  # GET /users/1/edit\n  def edit\n  end\n\n  # POST /users\n  # POST /users.json\n  def create\n    @user = User.new(user_params)\n\n    respond_to do |format|\n      if @user.save\n        format.html { redirect_to @user, notice: 'User was successfully created.' }\n        format.json { render :show, status: :created, location: @user }\n      else\n        format.html { render :new }\n        format.json { render json: @user.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # PATCH/PUT /users/1\n  # PATCH/PUT /users/1.json\n  def update\n    respond_to do |format|\n      if @user.update(user_params)\n        format.html { redirect_to @user, notice: 'User was successfully updated.' }\n        format.json { render :show, status: :ok, location: @user }\n      else\n        format.html { render :edit }\n        format.json { render json: @user.errors, status: :unprocessable_entity }\n      end\n    end\n  end\n\n  # DELETE /users/1\n  # DELETE /users/1.json\n  def destroy\n    @user.destroy\n    respond_to do |format|\n      format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }\n      format.json { head :no_content }\n    end\n  end\n\n  # PATCH/PUT /users/1/activation\n  def activation\n    @user.update!(active: true)\n    respond_to do |format|\n      format.html { redirect_to users_url, notice: 'User was successfully activated.' }\n    end\n  end\n\n  # PATCH/PUT /users/1/deactivation\n  def deactivation\n    @user.update!(active: false)\n    respond_to do |format|\n      format.html { redirect_to users_url, notice: 'User was successfully deactivated.' }\n    end\n  end\n\n  private\n    # Use callbacks to share common setup or constraints between actions.\n    def set_user\n      @user = User.find(params[:id])\n    end\n\n    # Never trust parameters from the scary internet, only allow the white list through.\n    def user_params\n      params.require(:user).permit(:name)\n    end\nend\n"
  },
  {
    "path": "app/helpers/application_helper.rb",
    "content": "module ApplicationHelper\nend\n"
  },
  {
    "path": "app/helpers/comments_helper.rb",
    "content": "module CommentsHelper\nend\n"
  },
  {
    "path": "app/helpers/escalation_series_helper.rb",
    "content": "module EscalationSeriesHelper\nend\n"
  },
  {
    "path": "app/helpers/escalations_helper.rb",
    "content": "module EscalationsHelper\nend\n"
  },
  {
    "path": "app/helpers/home_helper.rb",
    "content": "module HomeHelper\nend\n"
  },
  {
    "path": "app/helpers/incident_events_helper.rb",
    "content": "module IncidentEventsHelper\nend\n"
  },
  {
    "path": "app/helpers/incidents_helper.rb",
    "content": "module IncidentsHelper\nend\n"
  },
  {
    "path": "app/helpers/maintenances_helper.rb",
    "content": "module MaintenancesHelper\nend\n"
  },
  {
    "path": "app/helpers/notifier_providers_helper.rb",
    "content": "module NotifierProvidersHelper\nend\n"
  },
  {
    "path": "app/helpers/notifiers_helper.rb",
    "content": "module NotifiersHelper\nend\n"
  },
  {
    "path": "app/helpers/sessions_helper.rb",
    "content": "module SessionsHelper\nend\n"
  },
  {
    "path": "app/helpers/slack_helper.rb",
    "content": "module SlackHelper\nend\n"
  },
  {
    "path": "app/helpers/topics_helper.rb",
    "content": "module TopicsHelper\nend\n"
  },
  {
    "path": "app/helpers/users_helper.rb",
    "content": "module UsersHelper\nend\n"
  },
  {
    "path": "app/mailers/.keep",
    "content": ""
  },
  {
    "path": "app/models/.keep",
    "content": ""
  },
  {
    "path": "app/models/application_record.rb",
    "content": "# Base ApplicationRecord Class\nclass ApplicationRecord < ActiveRecord::Base\n  self.abstract_class = true\nend\n"
  },
  {
    "path": "app/models/comment.rb",
    "content": "class Comment < ApplicationRecord\n  belongs_to :incident\n  belongs_to :user\n\n  validates :incident, presence: true\n  validates :user, presence: true\n  validates :comment, presence: true\nend\n"
  },
  {
    "path": "app/models/concerns/.keep",
    "content": ""
  },
  {
    "path": "app/models/escalation.rb",
    "content": "class Escalation < ApplicationRecord\n  belongs_to :escalation_series\n  belongs_to :escalate_to, class_name: 'User'\n\n  validates :escalation_series, presence: true\n  validates :escalate_to, presence: true\n  validates :escalate_after_sec, numericality: {greater_than_or_equal_to: 5}\nend\n"
  },
  {
    "path": "app/models/escalation_series.rb",
    "content": "class EscalationSeries < ApplicationRecord\n  has_many :escalations, dependent: :destroy\n  has_many :topics, dependent: :destroy\n\n  validates :name, presence: true\n\n  serialize :settings, JSON\n  after_initialize :set_defaults\n\n  def set_defaults\n    self.settings ||= {}\n  end\n\n  def update_escalations!\n    updater_class = case self.settings['update_by']\n                    when 'google_calendar'\n                      GoogleCalendarEscalationUpdater\n                    else\n                      nil\n                    end\n    if updater_class\n      updater = updater_class.new(self)\n      updater.update!\n    end\n  end\n\n  class EscalationUpdater\n    def initialize(series)\n      @series = series\n    end\n\n    def update!\n      raise NotImplementedError\n    end\n\n    private\n\n    def settings\n      @series.settings\n    end\n  end\n\n  class GoogleCalendarEscalationUpdater < EscalationUpdater\n    def initialize(*)\n      super\n      require 'google/api_client'\n    end\n\n    def update!\n      Rails.logger.info \"Update #{@series.inspect} by Google Calendar\"\n\n      if user_as.provider && user_as.provider != 'google_oauth2_with_calendar'\n        raise \"User ##{user_as.id} is not authenticated by 'google_oauth2_with_calendar' provider\"\n      end\n\n      client = Google::APIClient.new(\n        application_name: \"Waker\",\n        application_version: \"2.0.0\",\n        user_agent: \"Waker/2.0.0 google-api-client\"\n      )\n      auth = client.authorization\n\n      expired = Time.at(user_as.credentials.fetch('expires_at')) < Time.now\n      if user_as.credentials.fetch('expires') && expired\n        Rails.logger.info \"Refreshing access token...\"\n\n        auth.client_id = ENV[\"GOOGLE_CLIENT_ID\"]\n        auth.client_secret = ENV[\"GOOGLE_CLIENT_SECRET\"]\n        auth.refresh_token = user_as.credentials.fetch('refresh_token')\n        auth.grant_type = \"refresh_token\"\n        auth.refresh!\n\n        user_as.update!(\n          credentials: user_as.credentials.merge(\n            'token' => auth.access_token,\n            'expires_at' => auth.expires_at.to_i,\n          )\n        )\n      else\n        auth.access_token = user_as.credentials.fetch('token')\n      end\n\n      calendar_api = client.discovered_api('calendar', 'v3')\n\n      calendar = client.execute(\n        api_method: calendar_api.calendar_list.list,\n        parameters: {},\n      ).data.items.find do |cal|\n        cal['summary'] == calendar_name\n      end\n\n      events = client.execute(\n        api_method: calendar_api.events.list,\n        parameters: {\n          'calendarId' => calendar['id'],\n          'timeMax' => (Time.now + 1).iso8601,\n          'timeMin' => (Time.now).iso8601,\n          'singleEvents' => true,\n        },\n      ).data.items\n\n      events.each do |event|\n        unless event['end']['dateTime'] && event['start']['dateTime']\n          raise \"dateTime field is not found (The event may be all-day event)\\n#{event}\"\n        end\n      end\n\n      events.sort! do |a, b|\n        a['end']['dateTime'] - a['start']['dateTime'] <=>\n          b['end']['dateTime'] - b['start']['dateTime']\n      end\n\n      # shortest event\n      event = events.first\n\n      persons = event['summary'].split(event_delimiter).map(&:strip)\n      escalations = @series.escalations.order('escalate_after_sec')\n\n      persons.each_with_index do |name, i|\n        user = User.find_by(name: name)\n        raise \"User '#{name}' is not found.\" unless user\n        escalation = escalations[i]\n        escalation.update!(escalate_to: user)\n      end\n    end\n\n    private\n\n    def user_as\n      User.find(settings.fetch('user_as_id'))\n    end\n\n    def calendar_name\n      settings.fetch('calendar')\n    end\n\n    def event_delimiter\n      settings.fetch('event_delimiter')\n    end\n  end\nend\n"
  },
  {
    "path": "app/models/escalation_update_worker.rb",
    "content": "class EscalationUpdateWorker\n  include Sidekiq::Worker\n\n  def perform\n    EscalationSeries.all.each do |series|\n      handle_series(series)\n    end\n  rescue => err\n    Rails.logger.error \"#{err.class}: #{err}\\n#{err.backtrace.join(\"\\n\")}\"\n  end\n\n  private\n\n  def handle_series(series)\n    series.update_escalations!\n  end\nend\n"
  },
  {
    "path": "app/models/escalation_worker.rb",
    "content": "class EscalationWorker\n  include Sidekiq::Worker\n\n  def self.enqueue(incident, escalation)\n    Rails.logger.info \"Enqueue EscalaionWorker job\"\n    self.perform_in(escalation.escalate_after_sec, incident.id, escalation.id)\n  end\n\n  def perform(incident_id, escalation_id)\n    incident = Incident.find(incident_id)\n    escalation = Escalation.find(escalation_id)\n\n    if incident.opened?\n      incident.events.create(\n        kind: :escalated,\n        info: {\n          escalation: escalation,\n          escalated_to: escalation.escalate_to,\n        },\n      )\n    end\n  end\nend\n"
  },
  {
    "path": "app/models/incident.rb",
    "content": "require 'digest/sha1'\n\nclass Incident < ApplicationRecord\n  STATUSES = [:opened, :acknowledged, :resolved]\n\n  belongs_to :topic\n  has_many :events, class_name: 'IncidentEvent', dependent: :destroy\n  enum status: STATUSES\n  has_many :comments\n\n  validates :topic, presence: true\n  validates :subject, presence: true\n  validates :description, presence: true\n  validates :occured_at, presence: true\n\n  after_initialize :set_defaults\n  after_create :enqueue\n\n  def acknowledge!\n    return if self.acknowledged? || self.resolved?\n\n    self.acknowledged!\n\n    events.create(kind: :acknowledged)\n  end\n\n  def resolve!\n    return if self.resolved?\n\n    self.resolved!\n\n    events.create(kind: :resolved)\n  end\n\n  def confirmation_hash\n    Digest::SHA1.hexdigest(\"#{Rails.application.secrets.secret_key_base}#{self.id}\")\n  end\n\n  private\n\n  def set_defaults\n    self.status ||= :opened\n    self.occured_at ||= Time.now\n  end\n\n  def enqueue\n    topic.escalation_series.escalations.each do |escalation|\n      EscalationWorker.enqueue(self, escalation)\n    end\n\n    events.create(kind: :opened)\n  end\nend\n"
  },
  {
    "path": "app/models/incident_event.rb",
    "content": "class IncidentEvent < ApplicationRecord\n  belongs_to :incident\n\n  enum kind: [:opened, :acknowledged, :resolved, :escalated, :commented, :notified]\n\n  validates :incident, presence: true\n  validates :kind, presence: true\n\n  serialize :info, JSON\n  after_create :notify\n  after_initialize :set_defaults\n\n  def set_defaults\n    self.info ||= {}\n  end\n\n  def notify\n    return if self.notified?\n\n    Notifier.all.each do |notifier|\n      next if notifier.topic && self.incident.topic != notifier.topic\n      notifier.notify(self)\n    end\n  end\n\n  def escalated_to\n    self.info['escalated_to'] && User.find(self.info['escalated_to']['id'])\n  end\n\n  def escalation\n    self.info['escalation'] && Escalation.find(self.info['escalation']['id'])\n  end\n\n  def notifier\n    self.info['notifier'] && Notifier.find(self.info['notifier']['id'])\n  end\n\n  def event\n    self.info['event'] && IncidentEvent.find(self.info['event']['id'])\n  end\nend\n"
  },
  {
    "path": "app/models/maintenance.rb",
    "content": "class Maintenance < ApplicationRecord\n  scope :active, -> { t = Time.now; where('start_time <= ? AND ? <= end_time', t, t) }\n  scope :not_expired, -> { where('? <= end_time', Time.now) }\n  scope :expired,     -> { where('end_time < ?', Time.now) }\n\n  belongs_to :topic\n\n  def filter_regexp\n    Regexp.new(filter)\n  end\nend\n"
  },
  {
    "path": "app/models/notification_worker.rb",
    "content": "class NotificationWorker\n  include Sidekiq::Worker\n\n  def self.enqueue(event:, notifier:)\n    Rails.logger.info \"Enqueue NotificationWorker job\"\n\n    self.perform_in(notifier.notify_after_sec, event.id, notifier.id)\n  end\n\n  def perform(event_id, notifier_id)\n    event = IncidentEvent.find(event_id)\n    notifier = Notifier.find(notifier_id)\n\n    if notifier.enabled\n      notifier.notify_immediately(event)\n    end\n  end\nend\n"
  },
  {
    "path": "app/models/notifier.rb",
    "content": "class Notifier < ApplicationRecord\n  belongs_to :provider, class_name: 'NotifierProvider'\n  belongs_to :user\n  belongs_to :topic\n\n  validates :provider, presence: true\n  validates :notify_after_sec, numericality: {greater_than_or_equal_to: 5}\n\n  serialize :settings, JSON\n  after_initialize :set_defaults\n\n  def set_defaults\n    self.settings ||= {}\n  end\n\n  def notify(event)\n    NotificationWorker.enqueue(event: event, notifier: self)\n  end\n\n  def notify_immediately(event)\n    provider.notify(event: event, notifier: self)\n  end\nend\n"
  },
  {
    "path": "app/models/notifier_provider.rb",
    "content": "class NotifierProvider < ApplicationRecord\n  serialize :settings, JSON\n  enum kind: [:mailgun, :file, :rails_logger, :hipchat, :twilio, :slack, :datadog, :sns]\n\n  validates :name, presence: true\n\n  after_initialize :set_defaults\n\n  def set_defaults\n    self.settings ||= {}\n  end\n\n  def concrete_class\n    self.class.const_get(\"#{kind.to_s.camelize}ConcreteProvider\")\n  end\n\n  def notify(event:, notifier:)\n    concrete_class.new(provider: self, notifier: notifier, event: event).notify\n  end\n\n  class ConcreteProvider\n    def initialize(provider:, notifier:, event:)\n      @provider = provider\n      @notifier = notifier\n      @event = event\n    end\n\n    def notify\n      if skip?\n        Rails.logger.info \"Notification skipped.\"\n      else\n        if target_events.include?(kind_of_event)\n          _notify\n          @event.incident.events.create(\n            kind: :notified,\n            info: {notifier: @notifier, event: @event}\n          )\n        else\n          Rails.logger.info \"Notification skipped due to target events (#{target_events} doesn't include #{kind_of_event})\"\n        end\n      end\n    end\n\n    def _notify\n      raise NotImplementedError\n    end\n\n    def settings\n      @provider.settings.merge(@notifier.settings)\n    end\n\n    def skip?\n      # or_conditions = [\n      #   {\n      #     'only_japanese_weekday' => true,\n      #     'not_between' => '9:30-18:30',\n      #   },\n      #   {\n      #     'not_japanese_weekday' => true,\n      #   }\n      # ]\n      return skip_due_to_or_conditions? ||\n        skip_due_to_status_of_incident?\n    end\n\n    def skip_due_to_status_of_incident?\n      if !@event.incident.opened? && !([:acknowledged, :resolved].include?(kind_of_event))\n        return true\n      end\n\n      false\n    end\n\n    def skip_due_to_or_conditions?\n      or_conditions = settings['or_conditions']\n      return false unless or_conditions\n\n      matched = or_conditions.any? do |condition|\n        # japanese_weekday\n        holiday = HolidayJp.holiday?(Date.today) || Time.now.saturday? || Time.now.sunday?\n\n        if holiday && condition['japanese_weekday']\n          next false\n        end\n\n        if !holiday && condition['not_japanese_weekday']\n          next false\n        end\n\n        # between\n        skip_due_to_between_condition = %w!between not_between!.any? do |k|\n          if s = condition[k]\n            start_time, end_time = s.split('-')\n            start_time = Time.parse(start_time)\n            end_time   = Time.parse(end_time)\n            between = start_time < Time.now && Time.now < end_time\n            if (between && k == 'not_between') || (!between && k == 'between')\n              next true\n            end\n          end\n\n          false\n        end\n\n        next false if skip_due_to_between_condition\n\n        true\n      end\n\n      return !matched\n    end\n\n    def all_events\n      [:escalated, :escalated_to_me, :opened, :acknowledged, :resolved, :commented]\n    end\n\n    def target_events\n      settings['events'] &&\n        settings['events'].map {|v| v.to_sym }\n    end\n\n    def body(formats: [:text])\n      template_names = [kind_of_event, 'default']\n      template_names.each_with_index do |template_name, i|\n        begin\n          rendered = ApplicationController.new.render_to_string(\n            template: \"notifier_providers/#{@provider.kind}/#{template_name}\",\n            formats: formats,\n            layout: nil,\n            locals: {event: @event},\n          )\n\n          return rendered.strip\n        rescue ActionView::MissingTemplate\n          raise if template_names.size - 1 == i\n        end\n      end\n    end\n\n    def kind_of_event\n      if @event.escalated? && @event.escalated_to == @notifier.user\n        :escalated_to_me\n      else\n        @event.kind.to_sym\n      end\n    end\n  end\n\n  class FileConcreteProvider < ConcreteProvider\n    def _notify\n    end\n  end\n\n  class RailsLoggerConcreteProvider < ConcreteProvider\n    def _notify\n      Rails.logger.info(body)\n    end\n\n    def target_events\n      all_events\n    end\n  end\n\n  class HipchatConcreteProvider < ConcreteProvider\n    def _notify\n      case kind_of_event\n      when :opened\n        color = 'red'\n      when :acknowledged, :escalated\n        color = 'yellow'\n      when :resolved\n        color = 'green'\n      else\n        return\n      end\n\n      client = HipChat::Client.new(api_token, api_version: api_version)\n      client[room].send('Waker', body, color: color, notify: notify?)\n    end\n\n    private\n\n    def api_token\n      settings.fetch('api_token')\n    end\n\n    def room\n      settings.fetch('room')\n    end\n\n    def api_version\n      case settings.fetch('api_version')\n      when '2', 'v2'\n        'v2'\n      when '1', 'v1'\n        'v1'\n      else\n        'v2'\n      end\n    end\n\n    def notify?\n      !!settings['notify']\n    end\n\n    def target_events\n      super || [:escalated, :opened, :acknowledged, :resolved]\n    end\n  end\n\n  class MailgunConcreteProvider < ConcreteProvider\n    def _notify\n      conn = Faraday.new(url: 'https://api.mailgun.net') do |faraday|\n        faraday.request  :url_encoded\n        faraday.response :logger\n        faraday.adapter  Faraday.default_adapter\n      end\n\n      conn.basic_auth('api', api_key)\n\n      response = conn.post \"/v2/#{domain}/messages\", {\n        from: from,\n        to: to,\n        subject: \"[Waker] #{@event.incident.subject}\",\n        text: body,\n        html: body(formats: [:html]),\n      }\n\n      Rails.logger.info \"response status: #{response.status}\"\n      Rails.logger.info JSON.parse(response.body)\n    end\n\n    private\n    def api_key\n      settings.fetch('api_key')\n    end\n\n    def domain\n      from.split('@').last\n    end\n\n    def from\n      settings.fetch('from')\n    end\n\n    def to\n      settings.fetch('to')\n    end\n\n    def target_events\n      super || [:escalated_to_me]\n    end\n  end\n\n  class TwilioConcreteProvider < ConcreteProvider\n    def _notify\n      options = {}\n      options[:user] =     basic_auth_user if basic_auth_user\n      options[:password] = basic_auth_password if basic_auth_password\n\n      url = Rails.application.routes.url_helpers.twilio_incident_event_url(\n        @event, options\n      )\n\n      Twilio::REST::Client.new(account_sid, auth_token).calls.create(\n        from: from,\n        to: to,\n        url: url,\n      )\n    end\n\n    def account_sid\n      settings.fetch('account_sid')\n    end\n\n    def auth_token\n      settings.fetch('auth_token')\n    end\n\n    def from\n      settings.fetch('from')\n    end\n\n    def to\n      settings.fetch('to')\n    end\n\n    def target_events\n      super || [:escalated_to_me]\n    end\n\n    def basic_auth_user\n      ENV['BASIC_AUTH_USER']\n    end\n\n    def basic_auth_password\n      ENV['BASIC_AUTH_PASSWORD']\n    end\n  end\n\n  class SlackConcreteProvider < ConcreteProvider\n    def _notify\n      fields = []\n\n      acknowledge_url = Rails.application.routes.url_helpers.acknowledge_incident_url(@event.incident, hash: @event.incident.confirmation_hash)\n      resolve_url = Rails.application.routes.url_helpers.resolve_incident_url(@event.incident, hash: @event.incident.confirmation_hash)\n      comment_url = Rails.application.routes.url_helpers.new_incident_comment_url(@event.incident)\n      actions = []\n      case kind_of_event\n      when :opened\n        color = 'danger'\n        title = 'New incident opened'\n        if buttons_enabled?\n          action_links = \"<#{comment_url}|Comment>\"\n          actions = [:acknowledge, :resolve]\n        else\n          action_links = \"<#{acknowledge_url}|Acknowledge> or <#{resolve_url}|Resolve> | <#{comment_url}|Comment>\"\n        end\n      when :acknowledged\n        color = 'warning'\n        title = 'Incident acknowledged'\n        if buttons_enabled?\n          action_links = \"<#{comment_url}|Comment>\"\n          actions = [:resolve]\n        else\n          action_links = \"<#{resolve_url}|Resolve> | <#{comment_url}|Comment>\"\n        end\n      when :escalated\n        color = 'warning'\n        title = \"Incident escalated to #{@event.escalated_to.name}\"\n        if buttons_enabled?\n          action_links = \"<#{comment_url}|Comment>\"\n          actions = [:acknowledge, :resolve]\n        else\n          action_links = \"<#{acknowledge_url}|Acknowledge> or <#{resolve_url}|Resolve> | <#{comment_url}|Comment>\"\n        end\n      when :resolved\n        color = 'good'\n        title = 'Incident resolved'\n        action_links = \"<#{comment_url}|Comment>\"\n      end\n\n      text = @event.incident.subject\n      if action_links\n        text += \" (#{action_links})\"\n      end\n\n      action_types = {\n        acknowledge: {\n          \"name\" => \"response\",\n          \"text\" => \"Acknowledge\",\n          \"type\" => \"button\",\n          \"value\" => \"acknowledge\",\n        },\n        resolve: {\n          \"name\" => \"response\",\n          \"text\" => \"Resolve\",\n          \"type\" => \"button\",\n          \"value\" => \"resolve\",\n          \"style\" => \"primary\",\n        },\n      }\n\n      attachments = [{\n        \"fallback\" => \"[#{kind_of_event.to_s.capitalize}] #{@event.incident.subject}\",\n        \"color\" => color,\n        \"title\" => title,\n        \"text\" => text,\n        \"fields\" => fields,\n        \"callback_id\" => \"incident.#{@event.incident.id}\",\n        \"actions\" => actions.map {|t| action_types[t] },\n      }]\n\n      payload = {'attachments' => attachments}\n      if channel\n        payload['channel'] = channel\n      end\n\n      url = URI.parse(webhook_url)\n      conn = Faraday.new(url: \"#{url.scheme}://#{url.host}\") do |faraday|\n        faraday.adapter Faraday.default_adapter\n      end\n\n      conn.post do |req|\n        req.url url.path\n        req.headers['Content-Type'] = 'application/json'\n        req.body = payload.to_json\n      end\n    end\n\n    private\n\n    def webhook_url\n      settings.fetch('webhook_url')\n    end\n\n    def channel\n      settings['channel']\n    end\n\n    def buttons_enabled?\n      settings['enable_buttons']\n    end\n\n    def target_events\n      [:escalated, :opened, :acknowledged, :resolved]\n    end\n  end\n\n  class DatadogConcreteProvider < ConcreteProvider\n    def _notify\n      dog = Dogapi::Client.new(api_key, app_key)\n\n      res = dog.emit_event(Dogapi::Event.new(\n              @event.incident.description, {\n                msg_title: @event.incident.subject,\n                alert_type: alert_type,\n                tags: tags,\n                source_type_name: source_type_name,\n              }\n            ))\n\n      Rails.logger.info res\n    end\n\n    private\n\n    def api_key\n      settings.fetch('api_key')\n    end\n\n    def app_key\n      settings.fetch('app_key')\n    end\n\n    def alert_type\n      settings['alert_type'] || 'error'\n    end\n\n    def tags\n      settings['tags'] || 'waker'\n    end\n\n    def source_type_name\n      settings['source_type_name'] || 'waker'\n    end\n\n    def target_events\n      [:opened]\n    end\n  end\n\n  class SnsConcreteProvider < ConcreteProvider\n    def _notify\n      aws_config = {}\n      aws_config[:region] = region if region\n      aws_config[:access_key_id] = access_key_id if access_key_id\n      aws_config[:secret_access_key] = secret_access_key if secret_access_key\n\n      sns = Aws::SNS::Client.new(aws_config)\n\n      res = sns.publish(\n        topic_arn: topic_arn,\n        message: @event.incident.description,\n        subject: @event.incident.subject,\n        message_attributes: {\n          'kind_of_event' => {\n            data_type: 'String',\n            string_value: kind_of_event.to_s,\n          }\n        }\n      )\n\n      Rails.logger.info res\n    end\n\n    private\n\n    def topic_arn\n      settings.fetch('topic_arn')\n    end\n\n    def region\n      settings['region']\n    end\n\n    def access_key_id\n      settings['access_key_id']\n    end\n\n    def secret_access_key\n      settings['secret_access_key']\n    end\n\n    def target_events\n      all_events\n    end\n  end\nend\n"
  },
  {
    "path": "app/models/topic.rb",
    "content": "class Topic < ApplicationRecord\n  enum kind: [:api]\n  belongs_to :escalation_series\n  has_many :incidents\n\n  validates :name, presence: true\n  validates :kind, presence: true\n  validates :escalation_series, presence: true\n\n  def in_maintenance?(*bodies)\n    maints = Maintenance.active.where(topic: self)\n    maints.any? do |m|\n      if m.filter.blank?\n        true\n      else\n        r = m.filter_regexp\n        bodies.any? do |body|\n          !!r.match(body)\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "app/models/user.rb",
    "content": "require 'securerandom'\n\nclass User < ApplicationRecord\n  scope :active, -> { where(active: true) }\n\n  has_many :notifiers\n\n  serialize :credentials, JSON\n\n  validates :name, presence: true\n\n  before_save :set_defaults\n\n  def self.find_or_create_from_auth_hash(auth_hash)\n    user = self.find_by(provider: auth_hash[:provider], uid: auth_hash[:uid])\n    return user if user\n\n    user = self.find_by(email: auth_hash[:info][:email])\n    if user\n      # email is deprecated\n      user.update!(provider: auth_hash[:provider], uid: auth_hash[:uid], email: nil)\n      return user\n    end\n\n    self.create!(provider: auth_hash[:provider], uid: auth_hash[:uid], name: auth_hash[:info][:name])\n  end\n\n  def update_credentials_from_auth_hash(auth_hash)\n    self.update!(credentials: auth_hash.fetch(:credentials))\n  end\n\n  private\n\n  def set_defaults\n    self.login_token ||= SecureRandom.hex\n  end\nend\n"
  },
  {
    "path": "app/views/comments/_form.html.erb",
    "content": "<%= form_for([@incident, @comment]) do |f| %>\n  <% if @comment.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@comment.errors.count, \"error\") %> prohibited this comment from being saved:</h2>\n\n      <ul>\n      <% @comment.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <%= f.hidden_field :incident_id, value: @incident.id %>\n  <%= f.hidden_field :user_id, value: current_user.id %>\n\n  <p>\n    <strong>Incident:</strong>\n    <pre><%= @incident.subject %></pre>\n  </p>\n\n  <div class=\"form-group\">\n    <%= f.label :comment %>\n    <%= f.text_area :comment, class: 'form-control', rows: 8 %>\n  </div>\n\n  <div class=\"actions\">\n    <%= f.submit(class: 'btn btn-default') %>\n  </div>\n<% end %>\n"
  },
  {
    "path": "app/views/comments/edit.html.erb",
    "content": "<h1>Editing Comment</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', [@incident, @comment] %> |\n<%= link_to 'Back', incident_comments_path %>\n"
  },
  {
    "path": "app/views/comments/index.html.erb",
    "content": "<h1>Listing Comments</h1>\n\n<p>\n  <strong>Incident:</strong>\n  <pre><%= @incident.subject %></pre>\n</p>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Comment</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @comments.each do |comment| %>\n      <tr>\n        <td><%= comment.comment %> (<%= comment.user.name %>)</td>\n        <td><%= link_to 'Show', [@incident, comment] %></td>\n        <td><%= link_to 'Edit', edit_incident_comment_path(@incident, comment) %></td>\n        <td><%= link_to 'Destroy', [@incident, comment], method: :delete, data: { confirm: 'Are you sure?' } %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n\n<%= link_to 'New Comment', new_incident_comment_path %> |\n<%= link_to 'Incident', @incident %>\n\n"
  },
  {
    "path": "app/views/comments/index.json.jbuilder",
    "content": "json.array!(@comments) do |comment|\n  json.extract! comment, :id\n  json.url comment_url(comment, format: :json)\nend\n"
  },
  {
    "path": "app/views/comments/new.html.erb",
    "content": "<h1>New Comment</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', incident_comments_path %>\n"
  },
  {
    "path": "app/views/comments/show.html.erb",
    "content": "\n<p>\n  <strong>Incident:</strong>\n  <pre><%= @incident.subject %></pre>\n</p>\n\n<p>\n  <strong>Comment:</strong>\n  <pre style=><%= auto_link(@comment.comment, :html => { :target => '_blank' }) %></pre>\n</p>\n\n<p>\n  <strong>User:</strong>\n  <pre><%= @comment.user.name %></pre>\n</p>\n\n<%= link_to 'Edit', edit_incident_comment_path(@incident, @comment) %> |\n<%= link_to 'Back', incident_comments_path %>\n"
  },
  {
    "path": "app/views/comments/show.json.jbuilder",
    "content": "json.extract! @comment, @user, :id, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/escalation_series/_form.html.erb",
    "content": "<%= form_for(@escalation_series) do |f| %>\n  <% if @escalation_series.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@escalation_series.errors.count, \"error\") %> prohibited this escalation_series from being saved:</h2>\n\n      <ul>\n      <% @escalation_series.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :name %>\n    <%= f.text_field :name, required: true, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :settings %>\n    <%= f.text_area :settings, value: @escalation_series.settings.to_yaml, class: 'form-control', rows: 8 %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/escalation_series/edit.html.erb",
    "content": "<h1>Editing Escalation Series</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @escalation_series %> |\n<%= link_to 'Back', escalation_series_index_path %>\n"
  },
  {
    "path": "app/views/escalation_series/index.html.erb",
    "content": "\n<h1>Listing Escalation Series</h1>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @escalation_series.each do |escalation_series| %>\n      <tr>\n        <td><%= escalation_series.name %></td>\n        <td><%= link_to 'Show', escalation_series %></td>\n        <td><%= link_to 'Edit', edit_escalation_series_path(escalation_series) %></td>\n        <td><%= link_to 'Destroy', escalation_series, method: :delete, data: { confirm: 'Are you sure?' } %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n\n<%= link_to 'New Escalation series', new_escalation_series_path %>\n"
  },
  {
    "path": "app/views/escalation_series/index.json.jbuilder",
    "content": "json.array!(@escalation_series) do |escalation_series|\n  json.extract! escalation_series, :id, :name\n  json.url escalation_series_url(escalation_series, format: :json)\nend\n"
  },
  {
    "path": "app/views/escalation_series/new.html.erb",
    "content": "<h1>New Escalation Series</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', escalation_series_index_path %>\n"
  },
  {
    "path": "app/views/escalation_series/show.html.erb",
    "content": "\n<p>\n  <strong>Name:</strong>\n  <%= @escalation_series.name %>\n</p>\n\n<table class=\"table\">\n  <% @escalation_series.escalations.order(\"escalate_after_sec\").each do |escalation| %>\n    <tr>\n      <td><%= escalation.escalate_to.name %></td>\n      <td>escalate after <%= escalation.escalate_after_sec %> sec</td>\n    </tr>\n  <% end %>\n</table>\n<ul>\n</ul>\n\n<%= link_to 'Edit', edit_escalation_series_path(@escalation_series) %> |\n<%= link_to 'Back', escalation_series_index_path %>\n"
  },
  {
    "path": "app/views/escalation_series/show.json.jbuilder",
    "content": "json.extract! @escalation_series, :id, :name, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/escalations/_form.html.erb",
    "content": "<%= form_for(@escalation) do |f| %>\n  <% if @escalation.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@escalation.errors.count, \"error\") %> prohibited this escalation from being saved:</h2>\n\n      <ul>\n      <% @escalation.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :escalate_to_id %>\n    <%= f.collection_select(:escalate_to_id, User.all, :id, :name, {}, class: 'form-control') %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :escalate_after_sec %>\n    <%= f.number_field :escalate_after_sec, min: 5, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :escalation_series_id %>\n    <%= f.collection_select(:escalation_series_id, EscalationSeries.all, :id, :name, {}, class: 'form-control') %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/escalations/edit.html.erb",
    "content": "<h1>Editing Escalation</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @escalation %> |\n<%= link_to 'Back', escalations_path %>\n"
  },
  {
    "path": "app/views/escalations/index.html.erb",
    "content": "\n<h1>Listing Escalations</h1>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Escalation Series</th>\n      <th>Escalate to</th>\n      <th>Escalate after sec</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @escalations.each do |escalation| %>\n      <tr>\n        <td><%= escalation.escalation_series.name %></td>\n        <td><%= escalation.escalate_to.name %></td>\n        <td><%= escalation.escalate_after_sec %></td>\n        <td><%= link_to 'Show', escalation %></td>\n        <td><%= link_to 'Edit', edit_escalation_path(escalation) %></td>\n        <td><%= link_to 'Destroy', escalation, method: :delete, data: { confirm: 'Are you sure?' } %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n\n<%= link_to 'New Escalation', new_escalation_path %>\n"
  },
  {
    "path": "app/views/escalations/index.json.jbuilder",
    "content": "json.array!(@escalations) do |escalation|\n  json.extract! escalation, :id, :escalate_to_id, :escalate_after_sec, :escalation_series_id\n  json.url escalation_url(escalation, format: :json)\nend\n"
  },
  {
    "path": "app/views/escalations/new.html.erb",
    "content": "<h1>New Escalation</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', escalations_path %>\n"
  },
  {
    "path": "app/views/escalations/show.html.erb",
    "content": "\n<p>\n  <strong>Escalation series:</strong>\n  <%= @escalation.escalation_series.name %>\n</p>\n\n<p>\n  <strong>Escalate to:</strong>\n  <%= @escalation.escalate_to.name %>\n</p>\n\n<p>\n  <strong>Escalate after sec:</strong>\n  <%= @escalation.escalate_after_sec %>\n</p>\n\n<%= link_to 'Edit', edit_escalation_path(@escalation) %> |\n<%= link_to 'Back', escalations_path %>\n"
  },
  {
    "path": "app/views/escalations/show.json.jbuilder",
    "content": "json.extract! @escalation, :id, :escalate_to_id, :escalate_after_sec, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/home/index.html.erb",
    "content": "<h1>Home#index</h1>\n<p>Find me in app/views/home/index.html.erb</p>\n"
  },
  {
    "path": "app/views/incident_events/twilio.html.erb",
    "content": "<h1>IncidentEvents#twilio</h1>\n<p>Find me in app/views/incident_events/twilio.html.erb</p>\n"
  },
  {
    "path": "app/views/incidents/_form.html.erb",
    "content": "<%= form_for(@incident) do |f| %>\n  <% if @incident.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@incident.errors.count, \"error\") %> prohibited this incident from being saved:</h2>\n\n      <ul>\n      <% @incident.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :subject %>\n    <%= f.text_field :subject, required: true, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :description %>\n    <%= f.text_area :description, required: true, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :topic_id %>\n    <%= f.collection_select(:topic_id, Topic.all, :id, :name, {}, class: 'form-control') %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :occured_at %>\n    <%= f.datetime_select :occured_at %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/incidents/edit.html.erb",
    "content": "<h1>Editing Incident</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @incident %> |\n<%= link_to 'Back', incidents_path %>\n"
  },
  {
    "path": "app/views/incidents/index.html.erb",
    "content": "\n<h1>Listing Incidents</h1>\n\n<div class=\"btn-toolbar\" role=\"toolbar\" style=\"margin-bottom: 15px\">\n  <div class=\"btn-group\" role=\"group\">\n    <%-\n    {\n      nil => 'All',\n      Incident.statuses.values_at(*%w!opened acknowledged!) => 'Opened or Acked',\n      Incident.statuses.values_at(*%w!opened!) => 'Opened',\n      Incident.statuses.values_at(*%w!acknowledged!) => 'Acked',\n      Incident.statuses.values_at(*%w!resolved!) => 'Resolved',\n    }.each do |statuses, desc| -%>\n      <a href=\"<%= \"?statuses=#{statuses && statuses.join(',')}\" %>\" class=\"btn btn-default\">\n        <%- if statuses == @visible_statuses %>\n          <span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"></span>\n        <%- end -%>\n        <%= desc %>\n      </a>\n    <%- end -%>\n  </div>\n\n  <div class=\"btn-group\" role=\"group\">\n    <button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">\n      Topic\n      <span class=\"caret\"></span>\n    </button>\n    <ul class=\"dropdown-menu\" role=\"menu\">\n      <li><a href=\"?topic=all\">\n        <%- if @visible_topic.nil? -%>\n          <span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"></span>\n        <%- end -%>\n        All\n      </a></li>\n      <% Topic.all.each do |topic| %>\n        <li><a href=\"?topic=<%= topic.id %>\">\n          <%- if @visible_topic == topic.id -%>\n            <span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"></span>\n          <%- end -%>\n          <%= topic.name %>\n        </a></li>\n      <% end %>\n    </ul>\n  </div>\n</div>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Status</th>\n      <th>Subject</th>\n      <th>Topic</th>\n      <th>Occured at</th>\n      <th colspan=\"4\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @incidents.each do |incident| %>\n      <tr>\n        <td rowspan=\"<%= incident.comments.present? ? 2 : 1 %>\">\n          <% if incident.opened? %>\n            <span class=\"label label-danger\">Opened</span>\n          <% elsif incident.acknowledged? %>\n            <span class=\"label label-warning\">Acknowledged</span>\n          <% elsif incident.resolved? %>\n            <span class=\"label label-success\">Resolved</span>\n          <% end %>\n        </td>\n        <td><%= incident.subject %></td>\n        <td><%= incident.topic.name %></td>\n        <td><%= incident.occured_at %></td>\n        <td><%= link_to 'Show', incident %></td>\n        <td><%= link_to 'Ack', acknowledge_incident_path(incident, hash: incident.confirmation_hash) %></td>\n        <td><%= link_to 'Resolve', resolve_incident_path(incident, hash: incident.confirmation_hash) %></td>\n        <td><%= link_to 'Comment', new_incident_comment_path(incident) %></td>\n      </tr>\n      <% if incident.comments.present? %>\n        <tr>\n          <td colspan=\"7\">\n            <% incident.comments.each_with_index do |comment, i| %>\n              <pre style=\"font-size: xx-small;\"><%= auto_link(comment.comment, :html => { :target => '_blank' }) %><br>(<%= comment.user.name %>)</pre>\n            <% end %>\n          </td>\n        </tr>\n      <% end %>\n    <% end %>\n  </tbody>\n</table>\n\n<%= paginate @incidents %>\n\n<br>\n\n<%= link_to 'Ack All', acknowledge_incidents_path, class: \"btn btn-default\", method: :patch, data: { confirm: \"#{@incidents.count} incidents will be marked as acked. Are you sure?\" } %>\n<%= link_to 'Resolve All', resolve_incidents_path, class: \"btn btn-success\", method: :patch, data: { confirm: \"#{@incidents.count} incidents will be marked as resolved. Are you sure?\" } %>\n"
  },
  {
    "path": "app/views/incidents/index.json.jbuilder",
    "content": "json.array!(@incidents) do |incident|\n  json.extract! incident, :id, :subject, :description, :topic_id, :occured_at\n  json.url incident_url(incident, format: :json)\nend\n"
  },
  {
    "path": "app/views/incidents/new.html.erb",
    "content": "<h1>New Incident</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', incidents_path %>\n"
  },
  {
    "path": "app/views/incidents/show.html.erb",
    "content": "\n<p>\n  <strong>Subject:</strong>\n  <%= @incident.subject %>\n</p>\n\n<p>\n  <strong>Description:</strong>\n  <pre><%= @incident.description %></pre>\n</p>\n\n<p>\n  <strong>Topic:</strong>\n  <%= @incident.topic.name %>\n</p>\n\n<p>\n  <strong>Occured at:</strong>\n  <%= @incident.occured_at %>\n</p>\n\n<table class=\"table\">\n  <tr>\n    <th>Time</th>\n    <th>Event</th>\n    <th>Description</th>\n  </tr>\n  <% @incident.events.each do |event| %>\n    <tr>\n      <td><%= event.created_at %></td>\n      <td><%= event.kind %></td>\n      <td>\n        <% if event.escalated? %>\n          to <%= link_to(event.escalated_to.name, event.escalated_to) %>\n        <% elsif event.notified? %>\n          notified by <%= link_to('notifier', event.notifier) %>\n        <% end %>\n      </td>\n    </tr>\n  <% end %>\n</table>\n\n<p>\n  <strong>Comment:</strong>\n</p>\n\n<table class=\"table\">\n  <tr>\n    <th>Time</th>\n    <th>Comment</th>\n  </tr>\n  <% @incident.comments.each do |comment| %>\n    <tr>\n      <td><%= comment.created_at %></td>\n      <td><%= comment.comment %> (<%= comment.user.name %>)</td>\n    </tr>\n  <% end %>\n</table>\n\n<%= link_to 'Edit', edit_incident_path(@incident) %> |\n<%= link_to 'Destroy', @incident, method: :delete, data: { confirm: 'Are you sure?' } %> |\n<%= link_to 'Back', incidents_path %>\n"
  },
  {
    "path": "app/views/incidents/show.json.jbuilder",
    "content": "json.extract! @incident, :id, :subject, :description, :topic_id, :occured_at, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/layouts/application.html.erb",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>Waker</title>\n  <%= stylesheet_link_tag    'application', media: 'all' %>\n  <%= javascript_include_tag 'application' %>\n  <!-- Latest compiled and minified CSS -->\n  <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css\">\n  <style>\nbody {\n  padding-top: 70px;\n}\n  </style>\n\n  <%= csrf_meta_tags %>\n</head>\n<body>\n\n<nav class=\"navbar navbar-inverse navbar-fixed-top\">\n  <div class=\"container\">\n    <div class=\"navbar-header\">\n      <button type=\"button\" class=\"navbar-toggle collapsed\" data-toggle=\"collapse\" data-target=\"#navbar\" aria-expanded=\"false\" aria-controls=\"navbar\">\n        <span class=\"sr-only\">Toggle navigation</span>\n        <span class=\"icon-bar\"></span>\n        <span class=\"icon-bar\"></span>\n        <span class=\"icon-bar\"></span>\n      </button>\n      <a class=\"navbar-brand\" href=\"/\">Waker</a>\n    </div>\n    <div id=\"navbar\" class=\"collapse navbar-collapse\">\n      <ul class=\"nav navbar-nav\">\n        <li><%= link_to 'Incidents', incidents_path %></li>\n        <li><%= link_to 'Topics', topics_path %></li>\n        <li><%= link_to 'Escalation Series', escalation_series_index_path %></li>\n        <li><%= link_to 'Escalations', escalations_path %></li>\n        <li><%= link_to 'Users', users_path %></li>\n        <li><%= link_to 'Notifiers', notifiers_path %></li>\n        <li><%= link_to 'Notifier Providers', notifier_providers_path %></li>\n        <li><%= link_to 'Maintenances', maintenances_path %></li>\n      </ul>\n      <ul class=\"nav navbar-nav navbar-right\">\n        <%- if current_user -%>\n          <p class=\"navbar-text\">Logged in as <%= current_user.name %></p>\n        <%- end -%>\n      </ul>\n    </div><!--/.nav-collapse -->\n  </div>\n</nav>\n\n<div class=\"container\">\n  <% if notice %>\n    <div class=\"alert alert-success\" role=\"alert\"><%= notice %></div>\n  <% end %>\n  <%= yield %>\n</div><!-- /.container -->\n\n<!-- Latest compiled and minified JavaScript -->\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js\"></script>\n<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "app/views/maintenances/_form.html.erb",
    "content": "<%= form_for(@maintenance) do |f| %>\n  <% if @maintenance.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@maintenance.errors.count, \"error\") %> prohibited this maintenance from being saved:</h2>\n\n      <ul>\n      <% @maintenance.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :topic_id %><br>\n    <%= f.collection_select(:topic_id, Topic.all, :id, :name, {}, class: 'form-control') %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :filter %><br>\n    <%= f.text_field(:filter, class: 'form-control', placeholder: 'regexp') %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :start_time %><br>\n    <%= f.datetime_select :start_time, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :end_time %><br>\n    <%= f.datetime_select :end_time, class: 'form-control' %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/maintenances/edit.html.erb",
    "content": "<h1>Editing Maintenance</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @maintenance %> |\n<%= link_to 'Back', maintenances_path %>\n"
  },
  {
    "path": "app/views/maintenances/index.html.erb",
    "content": "\n<h1>Listing Maintenances</h1>\n\n<p>Expired maintanances are not shown</p>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Topic</th>\n      <th>Filter Regexp</th>\n      <th>Start time</th>\n      <th>End time</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @maintenances.each do |maintenance| %>\n      <tr>\n        <td><%= maintenance.topic.name %></td>\n        <td><code><%= maintenance.filter %></code></td>\n        <td><%= maintenance.start_time %></td>\n        <td><%= maintenance.end_time %></td>\n        <td><%= link_to 'Show', maintenance %></td>\n        <td><%= link_to 'Edit', edit_maintenance_path(maintenance) %></td>\n        <td><%= link_to 'Destroy', maintenance, method: :delete, data: { confirm: 'Are you sure?' } %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n\n<%= link_to 'New Maintenance', new_maintenance_path %>\n"
  },
  {
    "path": "app/views/maintenances/index.json.jbuilder",
    "content": "json.array!(@maintenances) do |maintenance|\n  json.extract! maintenance, :id, :topic_id, :start_time, :end_time\n  json.url maintenance_url(maintenance, format: :json)\nend\n"
  },
  {
    "path": "app/views/maintenances/new.html.erb",
    "content": "<h1>New Maintenance</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', maintenances_path %>\n"
  },
  {
    "path": "app/views/maintenances/show.html.erb",
    "content": "<p id=\"notice\"><%= notice %></p>\n\n<p>\n  <strong>Topic:</strong>\n  <%= @maintenance.topic.name %>\n</p>\n\n<p>\n  <strong>Filter (regexp):</strong>\n  <code><%= @maintenance.filter %></code>\n</p>\n\n<p>\n  <strong>Start time:</strong>\n  <%= @maintenance.start_time %>\n</p>\n\n<p>\n  <strong>End time:</strong>\n  <%= @maintenance.end_time %>\n</p>\n\n<%= link_to 'Edit', edit_maintenance_path(@maintenance) %> |\n<%= link_to 'Back', maintenances_path %>\n"
  },
  {
    "path": "app/views/maintenances/show.json.jbuilder",
    "content": "json.extract! @maintenance, :id, :topic_id, :start_time, :end_time, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/notifier_providers/_form.html.erb",
    "content": "<%= form_for(@notifier_provider) do |f| %>\n  <% if @notifier_provider.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@notifier_provider.errors.count, \"error\") %> prohibited this notifier_provider from being saved:</h2>\n\n      <ul>\n      <% @notifier_provider.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :name %>\n    <%= f.text_field :name, required: true, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :kind %>\n    <%= f.select :kind, nil, {}, class: 'form-control' do %>\n      <%= options_for_select(\n        NotifierProvider.kinds.map do |kind, _|\n          [kind.camelize, kind, {}]\n        end, @notifier_provider.kind\n      ) %>\n    <% end %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :settings %>\n    <%= f.text_area :settings, value: @notifier_provider.settings.to_yaml, class: 'form-control', rows: 8 %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/notifier_providers/edit.html.erb",
    "content": "<h1>Editing Notifier Provider</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @notifier_provider %> |\n<%= link_to 'Back', notifier_providers_path %>\n"
  },
  {
    "path": "app/views/notifier_providers/hipchat/acknowledged.text.erb",
    "content": "Incident acknowledged: <%= event.incident.subject %> (<a href=\"<%= Rails.application.routes.url_helpers.resolve_incident_url(event.incident, hash: event.incident.confirmation_hash) %>\">Resolve</a>)\n"
  },
  {
    "path": "app/views/notifier_providers/hipchat/escalated.text.erb",
    "content": "Incident escalated to <%= event.escalated_to.name %>: <%= event.incident.subject %> (<a href=\"<%= Rails.application.routes.url_helpers.acknowledge_incident_url(event.incident, hash: event.incident.confirmation_hash) %>\">Acknowledge</a>) (<a href=\"<%= Rails.application.routes.url_helpers.resolve_incident_url(event.incident, hash: event.incident.confirmation_hash) %>\">Resolve</a>)\n"
  },
  {
    "path": "app/views/notifier_providers/hipchat/opened.text.erb",
    "content": "New incident opened: <%= event.incident.subject %> (<a href=\"<%= Rails.application.routes.url_helpers.acknowledge_incident_url(event.incident, hash: event.incident.confirmation_hash) %>\">Acknowledge</a>) (<a href=\"<%= Rails.application.routes.url_helpers.resolve_incident_url(event.incident, hash: event.incident.confirmation_hash) %>\">Resolve</a>)\n"
  },
  {
    "path": "app/views/notifier_providers/hipchat/resolved.text.erb",
    "content": "Incident resolved: <%= event.incident.subject %>\n"
  },
  {
    "path": "app/views/notifier_providers/index.html.erb",
    "content": "\n<h1>Listing Notifier Providers</h1>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Kind</th>\n      <th>Settings</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @notifier_providers.each do |notifier_provider| %>\n      <tr>\n        <td><%= notifier_provider.name %></td>\n        <td><%= notifier_provider.kind %></td>\n        <td><%= notifier_provider.settings %></td>\n        <td><%= link_to 'Show', notifier_provider %></td>\n        <td><%= link_to 'Edit', edit_notifier_provider_path(notifier_provider) %></td>\n        <td><%= link_to 'Destroy', notifier_provider, method: :delete, data: { confirm: 'Are you sure?' } %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n\n<%= link_to 'New Notifier provider', new_notifier_provider_path %>\n"
  },
  {
    "path": "app/views/notifier_providers/index.json.jbuilder",
    "content": "json.array!(@notifier_providers) do |notifier_provider|\n  json.extract! notifier_provider, :id, :name, :kind, :settings\n  json.url notifier_provider_url(notifier_provider, format: :json)\nend\n"
  },
  {
    "path": "app/views/notifier_providers/mailgun/default.html.erb",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n    <title>[Waker] <%= event.incident.subject %></title>\n  </head>\n  <body>\n    <%\n      ack_url = Rails.application.routes.url_helpers.acknowledge_incident_url(event.incident, hash: event.incident.confirmation_hash)\n      ack_url_json = Rails.application.routes.url_helpers.acknowledge_incident_url(event.incident, hash: event.incident.confirmation_hash, format: :json)\n      resolve_url = Rails.application.routes.url_helpers.resolve_incident_url(event.incident, hash: event.incident.confirmation_hash)\n\n      email_markup = {\n        \"@context\" => \"http://schema.org\",\n        \"@type\" => \"EmailMessage\",\n        \"potentialAction\" => {\n          \"@type\" => \"ConfirmAction\",\n          \"name\" => \"Acknowledge incident\",\n          \"handler\" => {\n            \"@type\" => \"HttpActionHandler\",\n            \"url\" => ack_url_json,\n          },\n        },\n        \"description\" => \"Acknowledge incident: #{event.incident.subject}\",\n      }\n\n    %>\n\n    <script type=\"application/ld+json\"><%= email_markup.to_json.html_safe %></script>\n\n    <h1><%= event.incident.subject %></h1>\n\n    <div>\n      <%\n        btn_style = 'border-radius: 4px;' \\\n          'text-decoration: none;' \\\n          'display: inline-block;' \\\n          'font-size: 1.3em;' \\\n          'padding: 5px 8px;' \\\n          'margin-right: 12px;' \\\n      %>\n      <a href=\"<%= ack_url %>\"><div style=\"<%= btn_style %>; border: 1px solid #ccc; color: black;\">Acknowledge</div></a> <a href=\"<%= resolve_url %>\"><div style=\"<%= btn_style %>; background-color: #5cb85c; color: white;\">Resolve</div></a>\n    </div>\n\n    <div style=\"margin-top: 12px;\">\n      <pre style=\"font-size: 1.1em; white-space: pre; word-wrap: break-word;\"><code>\n<%= event.incident.description %>\n      </code></pre>\n    </div>\n  </body>\n</body>\n"
  },
  {
    "path": "app/views/notifier_providers/mailgun/default.text.erb",
    "content": "<%= event.incident.subject %>\n====\n\nActions:\n\n- To ack: <%= Rails.application.routes.url_helpers.acknowledge_incident_url(event.incident, hash: event.incident.confirmation_hash) %>\n- To resolve: <%= Rails.application.routes.url_helpers.resolve_incident_url(event.incident, hash: event.incident.confirmation_hash) %>\n\n----\n\n<%= event.incident.description %>\n"
  },
  {
    "path": "app/views/notifier_providers/new.html.erb",
    "content": "<h1>New Notifier Provider</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', notifier_providers_path %>\n"
  },
  {
    "path": "app/views/notifier_providers/rails_logger/default.text.erb",
    "content": "Notification: <%= event.kind %>\n"
  },
  {
    "path": "app/views/notifier_providers/show.html.erb",
    "content": "\n<p>\n  <strong>Name:</strong>\n  <%= @notifier_provider.name %>\n</p>\n\n<p>\n  <strong>Kind:</strong>\n  <%= @notifier_provider.kind %>\n</p>\n\n<p>\n  <strong>Settings:</strong>\n  <%= @notifier_provider.settings %>\n</p>\n\n<%= link_to 'Edit', edit_notifier_provider_path(@notifier_provider) %> |\n<%= link_to 'Back', notifier_providers_path %>\n"
  },
  {
    "path": "app/views/notifier_providers/show.json.jbuilder",
    "content": "json.extract! @notifier_provider, :id, :name, :kind, :settings, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/notifiers/_form.html.erb",
    "content": "<%= form_for(@notifier) do |f| %>\n  <% if @notifier.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@notifier.errors.count, \"error\") %> prohibited this notifier from being saved:</h2>\n\n      <ul>\n      <% @notifier.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :user_id %>\n    <%= f.collection_select(:user_id, User.all, :id, :name, { include_blank: true }, class: 'form-control') %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :topic_id %>\n    <%= f.collection_select(:topic_id, Topic.all, :id, :name, { include_blank: true }, class: 'form-control') %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :provider_id %>\n    <%= f.collection_select(:provider_id, NotifierProvider.all, :id, :name, {}, class: 'form-control') %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :settings %>\n    <%= f.text_area :settings, value: @notifier.settings.to_yaml, class: 'form-control', rows: 8 %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :notify_after_sec %>\n    <%= f.number_field :notify_after_sec, min: 5, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :enabled do %>\n      <%= f.check_box :enabled %>\n      Enabled\n    <% end %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/notifiers/edit.html.erb",
    "content": "<h1>Editing Notifier</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @notifier %> |\n<%= link_to 'Back', notifiers_path %>\n"
  },
  {
    "path": "app/views/notifiers/index.html.erb",
    "content": "\n<h1>Listing Notifiers</h1>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>User</th>\n      <th>Topic</th>\n      <th>Provider</th>\n      <th>Settings</th>\n      <th>Notify after sec</th>\n      <th>Enabled</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @notifiers.each do |notifier| %>\n      <tr>\n        <td><%= notifier.user && notifier.user.name %></td>\n        <td><%= notifier.topic && notifier.topic.name %></td>\n        <td><%= notifier.provider.name %></td>\n        <td><%= notifier.settings %></td>\n        <td><%= notifier.notify_after_sec %></td>\n        <td><%= notifier.enabled %></td>\n        <td><%= link_to 'Show', notifier %></td>\n        <td><%= link_to 'Edit', edit_notifier_path(notifier) %></td>\n        <td><%= link_to 'Destroy', notifier, method: :delete, data: { confirm: 'Are you sure?' } %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n\n<%= link_to 'New Notifier', new_notifier_path %>\n"
  },
  {
    "path": "app/views/notifiers/index.json.jbuilder",
    "content": "json.array!(@notifiers) do |notifier|\n  json.extract! notifier, :id, :settings, :provider_id, :provider, :topic_id, :user_id, :notify_after_sec, :created_at, :updated_at\n  json.url notifier_url(notifier, format: :json)\nend\n"
  },
  {
    "path": "app/views/notifiers/new.html.erb",
    "content": "<h1>New Notifier</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', notifiers_path %>\n"
  },
  {
    "path": "app/views/notifiers/show.html.erb",
    "content": "\n<p>\n  <strong>Provider:</strong>\n  <%= @notifier.provider.name %>\n</p>\n\n<p>\n  <strong>User:</strong>\n  <%= @notifier.user && @notifier.user.name %>\n</p>\n\n<p>\n  <strong>Topic:</strong>\n  <%= @notifier.topic && @notifier.topic.name %>\n</p>\n\n<p>\n  <strong>Settings:</strong>\n  <%= @notifier.settings %>\n</p>\n\n<p>\n  <strong>Notify after sec:</strong>\n  <%= @notifier.notify_after_sec %>\n</p>\n\n<p>\n  <strong>Enabled:</strong>\n  <%= @notifier.enabled %>\n</p>\n\n<%= link_to 'Edit', edit_notifier_path(@notifier) %> |\n<%= link_to 'Back', notifiers_path %>\n"
  },
  {
    "path": "app/views/notifiers/show.json.jbuilder",
    "content": "json.extract! @notifier, :id, :settings, :provider_id, :provider, :topic_id, :user_id, :notify_after_sec, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/sessions/create.html.erb",
    "content": "<h1>Sessions#create</h1>\n<p>Find me in app/views/sessions/create.html.erb</p>\n"
  },
  {
    "path": "app/views/slack/interactive.html.erb",
    "content": "<h1>Slack#interactive</h1>\n<p>Find me in app/views/slack/interactive.html.erb</p>\n"
  },
  {
    "path": "app/views/topics/_form.html.erb",
    "content": "<%= form_for(@topic) do |f| %>\n  <% if @topic.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@topic.errors.count, \"error\") %> prohibited this topic from being saved:</h2>\n\n      <ul>\n      <% @topic.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :name %>\n    <%= f.text_field :name, required: true, class: 'form-control' %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :kind %>\n    <%= f.select :kind, nil, {}, class: 'form-control' do %>\n      <% Topic.kinds.each do |kind, _| %>\n        <%= content_tag(:option, kind.to_s.split('_').map {|s| s.capitalize }.join(' '), value: kind) %>\n      <% end %>\n    <% end %>\n  </div>\n  <div class=\"form-group\">\n    <%= f.label :escalation_series_id %>\n    <%= f.collection_select(:escalation_series_id, EscalationSeries.all, :id, :name, {}, class: 'form-control') %>\n  </div>\n  <div class=\"checkbox\">\n    <%= f.label :enabled do %>\n      <%= f.check_box :enabled %>\n      Enabled\n    <% end %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/topics/edit.html.erb",
    "content": "<h1>Editing Topic</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @topic %> |\n<%= link_to 'Back', topics_path %>\n"
  },
  {
    "path": "app/views/topics/index.html.erb",
    "content": "\n<h1>Listing Topics</h1>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Kind</th>\n      <th>Escalation Series</th>\n      <th>Enabled</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @topics.each do |topic| %>\n      <tr>\n        <td><%= topic.name %></td>\n        <td><%= topic.kind %></td>\n        <td><%= topic.escalation_series.name %></td>\n        <td><%= topic.enabled ? 'Yes' : 'No' %></td>\n        <td><%= link_to 'Show', topic %></td>\n        <td><%= link_to 'Edit', edit_topic_path(topic) %></td>\n        <td><%= link_to 'Destroy', topic, method: :delete, data: { confirm: 'Are you sure?' } %></td>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n\n<%= link_to 'New Topic', new_topic_path %>\n"
  },
  {
    "path": "app/views/topics/index.json.jbuilder",
    "content": "json.array!(@topics) do |topic|\n  json.extract! topic, :id, :name, :type\n  json.url topic_url(topic, format: :json)\nend\n"
  },
  {
    "path": "app/views/topics/new.html.erb",
    "content": "<h1>New Topic</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', topics_path %>\n"
  },
  {
    "path": "app/views/topics/show.html.erb",
    "content": "\n<p>\n  <strong>Name:</strong>\n  <%= @topic.name %>\n</p>\n\n<p>\n  <strong>Kind:</strong>\n  <%= @topic.kind %>\n</p>\n\n<p>\n  <strong>Escalation Series:</strong>\n  <%= @topic.escalation_series.name %>\n</p>\n\n<p>\n  <strong>Enabled:</strong>\n  <%= @topic.enabled ? 'Yes' : 'No' %>\n</p>\n\n<p>\n  <strong>Mailgun Endpoint:</strong>\n  <pre><%= mailgun_topic_url(@topic, format: :json) %></pre>\n</p>\n\n<p>\n  <strong>Mackerel Endpoint:</strong>\n  <pre><%= mackerel_topic_url(@topic, format: :json) %></pre>\n</p>\n\n<p>\n  <strong>AlertManagerEndpoint:</strong>\n  <pre><%= alertmanager_topic_url(@topic, format: :json) %></pre>\n</p>\n\n<p>\n  <strong>SlackEndpoint:</strong>\n  <pre><%= slack_topic_url(@topic, format: :json) %></pre>\n</p>\n\n<%= link_to 'Edit', edit_topic_path(@topic) %> |\n<%= link_to 'Back', topics_path %>\n"
  },
  {
    "path": "app/views/topics/show.json.jbuilder",
    "content": "json.extract! @topic, :id, :name, :type, :created_at, :updated_at\n"
  },
  {
    "path": "app/views/users/_form.html.erb",
    "content": "<%= form_for(@user) do |f| %>\n  <% if @user.errors.any? %>\n    <div class=\"alert alert-danger\">\n      <h2><%= pluralize(@user.errors.count, \"error\") %> prohibited this user from being saved:</h2>\n\n      <ul>\n      <% @user.errors.full_messages.each do |message| %>\n        <li><%= message %></li>\n      <% end %>\n      </ul>\n    </div>\n  <% end %>\n\n  <div class=\"form-group\">\n    <%= f.label :name %>\n    <%= f.text_field :name, required: true, class: 'form-control' %>\n  </div>\n  <%= f.submit(class: 'btn btn-default') %>\n<% end %>\n"
  },
  {
    "path": "app/views/users/edit.html.erb",
    "content": "<h1>Editing User</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Show', @user %> |\n<%= link_to 'Back', users_path %>\n"
  },
  {
    "path": "app/views/users/index.html.erb",
    "content": "\n<h1>Listing Users</h1>\n\n<table class=\"table\">\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Status</th>\n      <th colspan=\"3\"></th>\n    </tr>\n  </thead>\n\n  <tbody>\n    <% @users.each do |user| %>\n      <tr>\n        <td>\n          <%= user.name %>\n        </td>\n        <td>\n          <%- unless user.active -%>\n            <span class=\"label label-default\">Deactivated</span>\n          <%- end -%>\n        </td>\n        <td><%= link_to 'Show', user %></td>\n        <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>\n        <%- if user.active -%>\n          <td><%= link_to 'Deactivate', deactivation_user_path(user), method: :patch, data: { confirm: 'Are you sure?' } %></td>\n        <%- else -%>\n          <td><%= link_to 'Activate', activation_user_path(user), method: :patch, data: { confirm: 'Are you sure?' } %></td>\n        <%- end -%>\n      </tr>\n    <% end %>\n  </tbody>\n</table>\n\n<br>\n"
  },
  {
    "path": "app/views/users/index.json.jbuilder",
    "content": "json.array!(@users) do |user|\n  json.extract! user, :id, :name\n  json.url user_url(user, format: :json)\nend\n"
  },
  {
    "path": "app/views/users/new.html.erb",
    "content": "<h1>New User</h1>\n\n<%= render 'form' %>\n\n<%= link_to 'Back', users_path %>\n"
  },
  {
    "path": "app/views/users/show.html.erb",
    "content": "\n<p>\n  <strong>Name:</strong>\n  <%= @user.name %>\n</p>\n\n<p>\n  <strong>Provider:</strong>\n  <%= @user.provider %>\n</p>\n\n<p>\n  <strong>UID:</strong>\n  <%= @user.uid %>\n</p>\n\n<%= link_to 'Back', users_path %>\n"
  },
  {
    "path": "app/views/users/show.json.jbuilder",
    "content": "json.extract! @user, :id, :name, :created_at, :updated_at\n"
  },
  {
    "path": "bin/bundle",
    "content": "#!/usr/bin/env ruby\nENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)\nload Gem.bin_path('bundler', 'bundle')\n"
  },
  {
    "path": "bin/rails",
    "content": "#!/usr/bin/env ruby\nbegin\n  load File.expand_path(\"../spring\", __FILE__)\nrescue LoadError\nend\nAPP_PATH = File.expand_path('../../config/application', __FILE__)\nrequire_relative '../config/boot'\nrequire 'rails/commands'\n"
  },
  {
    "path": "bin/rake",
    "content": "#!/usr/bin/env ruby\nbegin\n  load File.expand_path(\"../spring\", __FILE__)\nrescue LoadError\nend\nrequire_relative '../config/boot'\nrequire 'rake'\nRake.application.run\n"
  },
  {
    "path": "bin/setup",
    "content": "#!/usr/bin/env ruby\nrequire 'pathname'\n\n# path to your application root.\nAPP_ROOT = Pathname.new File.expand_path('../../',  __FILE__)\n\nDir.chdir APP_ROOT do\n  # This script is a starting point to setup your application.\n  # Add necessary setup steps to this file:\n\n  puts \"== Installing dependencies ==\"\n  system \"gem install bundler --conservative\"\n  system \"bundle check || bundle install\"\n\n  # puts \"\\n== Copying sample files ==\"\n  # unless File.exist?(\"config/database.yml\")\n  #   system \"cp config/database.yml.sample config/database.yml\"\n  # end\n\n  puts \"\\n== Preparing database ==\"\n  system \"bin/rake db:setup\"\n\n  puts \"\\n== Removing old logs and tempfiles ==\"\n  system \"rm -f log/*\"\n  system \"rm -rf tmp/cache\"\n\n  puts \"\\n== Restarting application server ==\"\n  system \"touch tmp/restart.txt\"\nend\n"
  },
  {
    "path": "bin/spring",
    "content": "#!/usr/bin/env ruby\n\n# This file loads spring without using Bundler, in order to be fast\n# It gets overwritten when you run the `spring binstub` command\n\nunless defined?(Spring)\n  require \"rubygems\"\n  require \"bundler\"\n\n  if match = Bundler.default_lockfile.read.match(/^GEM$.*?^    (?:  )*spring \\((.*?)\\)$.*?^$/m)\n    ENV[\"GEM_PATH\"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)\n    ENV[\"GEM_HOME\"] = \"\"\n    Gem.paths = ENV\n\n    gem \"spring\", match[1]\n    require \"spring/binstub\"\n  end\nend\n"
  },
  {
    "path": "config/application.rb",
    "content": "require File.expand_path('../boot', __FILE__)\n\n# Pick the frameworks you want:\nrequire \"active_model/railtie\"\nrequire \"active_job/railtie\"\nrequire \"active_record/railtie\"\nrequire \"action_controller/railtie\"\nrequire \"action_mailer/railtie\"\nrequire \"action_view/railtie\"\nrequire \"sprockets/railtie\"\n# require \"rails/test_unit/railtie\"\n\n# Require the gems listed in Gemfile, including any gems\n# you've limited to :test, :development, or :production.\nBundler.require(*Rails.groups)\n\nmodule Waker\n  class Application < Rails::Application\n    # Settings in config/environments/* take precedence over those specified here.\n    # Application configuration should go into files in config/initializers\n    # -- all .rb files in that directory are automatically loaded.\n\n    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.\n    # Run \"rake -D time\" for a list of tasks for finding time zone names. Default is UTC.\n    if time_zone = ENV['TIME_ZONE']\n      config.time_zone = time_zone\n    end\n\n    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.\n    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]\n    # config.i18n.default_locale = :de\n\n    # Do not swallow errors in after_commit/after_rollback callbacks.\n    config.middleware.use Rack::Health\n    config.middleware.use OmniAuth::Builder do\n      config = {}\n      config[:hd] = ENV['GOOGLE_DOMAIN'] if ENV['GOOGLE_DOMAIN']\n\n      provider :google_oauth2, ENV[\"GOOGLE_CLIENT_ID\"], ENV[\"GOOGLE_CLIENT_SECRET\"],\n      config.merge(scope: 'userinfo.profile,userinfo.email,calendar',\n                   name: 'google_oauth2_with_calendar',\n                   access_type: 'offline', approval_prompt: 'force', prompt: 'consent')\n    end\n  end\nend\n\n"
  },
  {
    "path": "config/boot.rb",
    "content": "ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)\n\nrequire 'bundler/setup' # Set up gems listed in the Gemfile.\n"
  },
  {
    "path": "config/database.yml",
    "content": "production:\n  adapter: mysql2\n  database: waker\n  encoding: utf8mb4\n  username : <%= ENV['MYSQL_USER'] || 'root' %>\n  password: <%= ENV['MYSQL_PASSWORD'] %>\n  host: <%= ENV['MYSQL_HOST'] || 'localhost' %>\n\ndevelopment:\n  adapter: mysql2\n  database: waker_development\n  encoding: utf8mb4\n  username : <%= ENV['MYSQL_USER'] || 'root' %>\n  password: <%= ENV['MYSQL_PASSWORD'] %>\n  host: <%= ENV['MYSQL_HOST'] || 'localhost' %>\n\ntest:\n  adapter: mysql2\n  database: waker_test\n  encoding: utf8mb4\n  username : <%= ENV['MYSQL_USER'] || 'root' %>\n  password: <%= ENV['MYSQL_PASSWORD'] %>\n  host: <%= ENV['MYSQL_HOST'] || 'localhost' %>\n"
  },
  {
    "path": "config/environment.rb",
    "content": "# Load the Rails application.\nrequire File.expand_path('../application', __FILE__)\n\n# Initialize the Rails application.\nRails.application.initialize!\n"
  },
  {
    "path": "config/environments/development.rb",
    "content": "Rails.application.configure do\n  # Settings specified here will take precedence over those in config/application.rb.\n\n  # In the development environment your application's code is reloaded on\n  # every request. This slows down response time but is perfect for development\n  # since you don't have to restart the web server when you make code changes.\n  config.cache_classes = false\n\n  # Do not eager load code on boot.\n  config.eager_load = false\n\n  # Show full error reports and disable caching.\n  config.consider_all_requests_local       = true\n  config.action_controller.perform_caching = false\n\n  # Don't care if the mailer can't send.\n  config.action_mailer.raise_delivery_errors = false\n\n  # Print deprecation notices to the Rails logger.\n  config.active_support.deprecation = :log\n\n  # Raise an error on page load if there are pending migrations.\n  config.active_record.migration_error = :page_load\n\n  # Debug mode disables concatenation and preprocessing of assets.\n  # This option may cause significant delays in view rendering with a large\n  # number of complex assets.\n  config.assets.debug = true\n\n  # Asset digests allow you to set far-future HTTP expiration dates on all assets,\n  # yet still be able to expire them through the digest params.\n  config.assets.digest = true\n\n  # Adds additional error checking when serving assets at runtime.\n  # Checks for improperly declared sprockets dependencies.\n  # Raises helpful error messages.\n  config.assets.raise_runtime_errors = true\n\n  # Raises error for missing translations\n  # config.action_view.raise_on_missing_translations = true\n\nend\n\nRails.application.routes.default_url_options[:host] = 'localhost:3000'\n"
  },
  {
    "path": "config/environments/production.rb",
    "content": "Rails.application.configure do\n  # Settings specified here will take precedence over those in config/application.rb.\n\n  # Code is not reloaded between requests.\n  config.cache_classes = true\n\n  # Eager load code on boot. This eager loads most of Rails and\n  # your application in memory, allowing both threaded web servers\n  # and those relying on copy on write to perform better.\n  # Rake tasks automatically ignore this option for performance.\n  config.eager_load = true\n\n  # Full error reports are disabled and caching is turned on.\n  config.consider_all_requests_local       = false\n  config.action_controller.perform_caching = true\n\n  # Enable Rack::Cache to put a simple HTTP cache in front of your application\n  # Add `rack-cache` to your Gemfile before enabling this.\n  # For large-scale production use, consider using a caching reverse proxy like\n  # NGINX, varnish or squid.\n  # config.action_dispatch.rack_cache = true\n\n  # Disable serving static files from the `/public` folder by default since\n  # Apache or NGINX already handles this.\n  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n\n  # Compress JavaScripts and CSS.\n  config.assets.js_compressor = :uglifier\n  # config.assets.css_compressor = :sass\n\n  # Do not fallback to assets pipeline if a precompiled asset is missed.\n  config.assets.compile = false\n\n  # Asset digests allow you to set far-future HTTP expiration dates on all assets,\n  # yet still be able to expire them through the digest params.\n  config.assets.digest = true\n\n  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb\n\n  # Specifies the header that your server uses for sending files.\n  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache\n  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX\n\n  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.\n  # config.force_ssl = true\n\n  # Use the lowest log level to ensure availability of diagnostic information\n  # when problems arise.\n  config.log_level = :debug\n\n  # Prepend all log lines with the following tags.\n  # config.log_tags = [ :subdomain, :uuid ]\n\n  # Use a different logger for distributed setups.\n  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)\n\n  if log_dir = ENV['LOG_DIR']\n    config.logger = ::Logger.new(File.expand_path('production.log', log_dir))\n  end\n\n  # Use a different cache store in production.\n  # config.cache_store = :mem_cache_store\n\n  # Enable serving of images, stylesheets, and JavaScripts from an asset server.\n  # config.action_controller.asset_host = 'http://assets.example.com'\n\n  # Ignore bad email addresses and do not raise email delivery errors.\n  # Set this to true and configure the email server for immediate delivery to raise delivery errors.\n  # config.action_mailer.raise_delivery_errors = false\n\n  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to\n  # the I18n.default_locale when a translation cannot be found).\n  config.i18n.fallbacks = true\n\n  # Send deprecation notices to registered listeners.\n  config.active_support.deprecation = :notify\n\n  # Use default logging formatter so that PID and timestamp are not suppressed.\n  config.log_formatter = ::Logger::Formatter.new\n\n  if ENV[\"RAILS_LOG_TO_STDOUT\"].present?\n    logger           = ActiveSupport::Logger.new(STDOUT)\n    logger.formatter = config.log_formatter\n    config.logger = ActiveSupport::TaggedLogging.new(logger)\n  end\n\n  # Do not dump schema after migrations.\n  config.active_record.dump_schema_after_migration = false\nend\n"
  },
  {
    "path": "config/environments/test.rb",
    "content": "Rails.application.configure do\n  # Settings specified here will take precedence over those in config/application.rb.\n\n  # The test environment is used exclusively to run your application's\n  # test suite. You never need to work with it otherwise. Remember that\n  # your test database is \"scratch space\" for the test suite and is wiped\n  # and recreated between test runs. Don't rely on the data there!\n  config.cache_classes = true\n\n  # Do not eager load code on boot. This avoids loading your whole application\n  # just for the purpose of running a single test. If you are using a tool that\n  # preloads Rails for running tests, you may have to set it to true.\n  config.eager_load = false\n\n  # Configure static file server for tests with Cache-Control for performance.\n  config.serve_static_files   = true\n  config.static_cache_control = 'public, max-age=3600'\n\n  # Show full error reports and disable caching.\n  config.consider_all_requests_local       = true\n  config.action_controller.perform_caching = false\n\n  # Raise exceptions instead of rendering exception templates.\n  config.action_dispatch.show_exceptions = false\n\n  # Disable request forgery protection in test environment.\n  config.action_controller.allow_forgery_protection = false\n\n  # Tell Action Mailer not to deliver emails to the real world.\n  # The :test delivery method accumulates sent emails in the\n  # ActionMailer::Base.deliveries array.\n  config.action_mailer.delivery_method = :test\n\n  # Randomize the order test cases are executed.\n  config.active_support.test_order = :random\n\n  # Print deprecation notices to the stderr.\n  config.active_support.deprecation = :stderr\n\n  # Raises error for missing translations\n  # config.action_view.raise_on_missing_translations = true\nend\n"
  },
  {
    "path": "config/initializers/assets.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Version of your assets, change this if you want to expire all your assets.\nRails.application.config.assets.version = '1.0'\n\n# Add additional assets to the asset load path\n# Rails.application.config.assets.paths << Emoji.images_path\n\n# Precompile additional assets.\n# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.\n# Rails.application.config.assets.precompile += %w( search.js )\n"
  },
  {
    "path": "config/initializers/backtrace_silencers.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.\n# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }\n\n# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.\n# Rails.backtrace_cleaner.remove_silencers!\n"
  },
  {
    "path": "config/initializers/cookies_serializer.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\nRails.application.config.action_dispatch.cookies_serializer = :json\n"
  },
  {
    "path": "config/initializers/field_with_errors.rb",
    "content": "Rails.application.configure do\n  config.action_view.field_error_proc = lambda do |html_tag, instance|\n    %Q{<div class=\"has-error\">#{html_tag}</div>}.html_safe\n  end\nend\n"
  },
  {
    "path": "config/initializers/filter_parameter_logging.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Configure sensitive parameters which will be filtered from the log file.\nRails.application.config.filter_parameters += [:password]\n"
  },
  {
    "path": "config/initializers/inflections.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Add new inflection rules using the following format. Inflections\n# are locale specific, and you may define rules for as many different\n# locales as you wish. All of these examples are active by default:\n# ActiveSupport::Inflector.inflections(:en) do |inflect|\n#   inflect.plural /^(ox)$/i, '\\1en'\n#   inflect.singular /^(ox)en/i, '\\1'\n#   inflect.irregular 'person', 'people'\n#   inflect.uncountable %w( fish sheep )\n# end\n\n# These inflection rules are supported but not enabled by default:\n# ActiveSupport::Inflector.inflections(:en) do |inflect|\n#   inflect.acronym 'RESTful'\n# end\n"
  },
  {
    "path": "config/initializers/mime_types.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Add new mime types for use in respond_to blocks:\n# Mime::Type.register \"text/richtext\", :rtf\n"
  },
  {
    "path": "config/initializers/omniauth.rb",
    "content": "OmniAuth.config.logger = Rails.logger\n"
  },
  {
    "path": "config/initializers/session_store.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\nRails.application.config.session_store :cookie_store, key: '_waker_session'\n"
  },
  {
    "path": "config/initializers/sidekiq.rb",
    "content": "namespace = ENV['REDIS_NAMESPACE'] || \"waker-#{Rails.env}\"\nhost = ENV['REDIS_HOST'] || 'localhost'\nport = ENV['REDIS_PORT'] || 6379\n\nSidekiq.configure_server do |config|\n  config.poll_interval = 5\n  config.redis = {url: \"redis://#{host}:#{port}\", namespace: namespace}\nend\n\nSidekiq.configure_client do |config|\n  config.redis = {url: \"redis://#{host}:#{port}\", namespace: namespace}\nend\n\nSidekiq::Logging.logger = Rails.logger\n"
  },
  {
    "path": "config/initializers/url_options.rb",
    "content": "if default_host = ENV['DEFAULT_HOST']\n  Rails.application.routes.default_url_options[:host] = default_host\nend\n\nif default_protocol = ENV['DEFAULT_PROTOCOL']\n  Rails.application.routes.default_url_options[:protocol] = default_protocol\nend\n"
  },
  {
    "path": "config/initializers/wrap_parameters.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# This file contains settings for ActionController::ParamsWrapper which\n# is enabled by default.\n\n# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.\nActiveSupport.on_load(:action_controller) do\n  wrap_parameters format: [:json] if respond_to?(:wrap_parameters)\nend\n\n# To enable root element in JSON for ActiveRecord objects.\n# ActiveSupport.on_load(:active_record) do\n#  self.include_root_in_json = true\n# end\n"
  },
  {
    "path": "config/locales/en.yml",
    "content": "# Files in the config/locales directory are used for internationalization\n# and are automatically loaded by Rails. If you want to use locales other\n# than English, add the necessary files in this directory.\n#\n# To use the locales, use `I18n.t`:\n#\n#     I18n.t 'hello'\n#\n# In views, this is aliased to just `t`:\n#\n#     <%= t('hello') %>\n#\n# To use a different locale, set it with `I18n.locale`:\n#\n#     I18n.locale = :es\n#\n# This would use the information in config/locales/es.yml.\n#\n# To learn more, please read the Rails Internationalization guide\n# available at http://guides.rubyonrails.org/i18n.html.\n\nen:\n  hello: \"Hello world\"\n"
  },
  {
    "path": "config/routes.rb",
    "content": "Rails.application.routes.draw do\n  post 'slack/interactive'\n\n  get '/auth/:provider/callback', to: 'sessions#create'\n\n  resources :incident_events, only: [] do\n    member do\n      post 'twilio'\n      get 'twilio'\n    end\n  end\n\n  resources :incidents do\n    member do\n      get 'acknowledge'\n      get 'resolve'\n    end\n\n    collection do\n      patch 'acknowledge', to: \"incidents#bulk_acknowledge\"\n      patch 'resolve', to: \"incidents#bulk_resolve\"\n    end\n\n    resources :comments\n  end\n\n  resources :escalation_series do\n    member do\n      get 'update_escalations'\n    end\n  end\n\n  resources :escalations\n\n  resources :shifts\n\n  resources :notifiers\n\n  resources :notifier_providers\n\n  resources :maintenances\n\n  resources :users, only: [:index, :show, :destroy] do\n    member do\n      patch 'activation'\n      patch 'deactivation'\n    end\n  end\n\n  resources :topics do\n    member do\n      post 'mailgun'\n      post 'mackerel'\n      post 'alertmanager'\n      post 'slack'\n    end\n  end\n\n  require 'sidekiq/web'\n  mount Sidekiq::Web => '/sidekiq'\n\n  root 'home#index'\n\n  # The priority is based upon order of creation: first created -> highest priority.\n  # See how all your routes lay out with \"rake routes\".\n\n  # You can have the root of your site routed with \"root\"\n  # root 'welcome#index'\n\n  # Example of regular route:\n  #   get 'products/:id' => 'catalog#view'\n\n  # Example of named route that can be invoked with purchase_url(id: product.id)\n  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase\n\n  # Example resource route (maps HTTP verbs to controller actions automatically):\n  #   resources :products\n\n  # Example resource route with options:\n  #   resources :products do\n  #     member do\n  #       get 'short'\n  #       post 'toggle'\n  #     end\n  #\n  #     collection do\n  #       get 'sold'\n  #     end\n  #   end\n\n  # Example resource route with sub-resources:\n  #   resources :products do\n  #     resources :comments, :sales\n  #     resource :seller\n  #   end\n\n  # Example resource route with more complex sub-resources:\n  #   resources :products do\n  #     resources :comments\n  #     resources :sales do\n  #       get 'recent', on: :collection\n  #     end\n  #   end\n\n  # Example resource route with concerns:\n  #   concern :toggleable do\n  #     post 'toggle'\n  #   end\n  #   resources :posts, concerns: :toggleable\n  #   resources :photos, concerns: :toggleable\n\n  # Example resource route within a namespace:\n  #   namespace :admin do\n  #     # Directs /admin/products/* to Admin::ProductsController\n  #     # (app/controllers/admin/products_controller.rb)\n  #     resources :products\n  #   end\nend\n"
  },
  {
    "path": "config/secrets.yml",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Your secret key is used for verifying the integrity of signed cookies.\n# If you change this key, all old signed cookies will become invalid!\n\n# Make sure the secret is at least 30 characters and all random,\n# no regular words or you'll be exposed to dictionary attacks.\n# You can use `rake secret` to generate a secure secret key.\n\n# Make sure the secrets in this file are kept private\n# if you're sharing your code publicly.\n\ndevelopment:\n  secret_key_base: d50e30eb49152fcfff420c795f7d0f559934a6497808d4c8a34e83f1ec4807f7c36b4ca47af41bdb4d5a757e9a756f4425c748defb4054f89e63cea1788eb2d3\n\ntest:\n  secret_key_base: 5206b6e3c7cd04a83e4743c3f0d631e025f196223d8d13742f0bd71c6e1c5d0b0a443398a4536f503d8399c8c7e58e20dadc3553e64bcdb1f4cb7dbc95a7fe0c\n\n# Do not keep production secrets in the repository,\n# instead read values from the environment.\nproduction:\n  secret_key_base: <%= ENV[\"SECRET_KEY_BASE\"] %>\n"
  },
  {
    "path": "config.ru",
    "content": "# This file is used by Rack-based servers to start the application.\n\nrequire ::File.expand_path('../config/environment', __FILE__)\nrun Rails.application\n"
  },
  {
    "path": "db/migrate/20150120134616_create_topics.rb",
    "content": "class CreateTopics < ActiveRecord::Migration\n  def change\n    create_table :topics do |t|\n      t.string :name\n      t.integer :type\n\n      t.timestamps null: false\n    end\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120134747_create_users.rb",
    "content": "class CreateUsers < ActiveRecord::Migration\n  def change\n    create_table :users do |t|\n      t.string :name\n\n      t.timestamps null: false\n    end\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120134905_create_notifiers.rb",
    "content": "class CreateNotifiers < ActiveRecord::Migration\n  def change\n    create_table :notifiers do |t|\n      t.integer :type\n      t.text :settings\n      t.integer :notify_after_sec\n\n      t.timestamps null: false\n    end\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120135017_create_shifts.rb",
    "content": "class CreateShifts < ActiveRecord::Migration\n  def change\n    create_table :shifts do |t|\n      t.references :user, index: true\n\n      t.timestamps null: false\n    end\n    add_foreign_key :shifts, :users\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120135123_create_escalations.rb",
    "content": "class CreateEscalations < ActiveRecord::Migration\n  def change\n    create_table :escalations do |t|\n      t.references :escalate_to, index: true\n      t.integer :escalate_after_sec\n\n      t.timestamps null: false\n    end\n    add_foreign_key :escalations, :users, column: 'escalate_to_id'\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120135244_create_escalation_series.rb",
    "content": "class CreateEscalationSeries < ActiveRecord::Migration\n  def change\n    create_table :escalation_series do |t|\n      t.string :name\n\n      t.timestamps null: false\n    end\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120135351_add_escalation_series_to_escalation.rb",
    "content": "class AddEscalationSeriesToEscalation < ActiveRecord::Migration\n  def change\n    add_reference :escalations, :escalation_series, index: true\n    add_foreign_key :escalations, :escalation_series\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120141627_rename_type_with_kind_of_topic.rb",
    "content": "class RenameTypeWithKindOfTopic < ActiveRecord::Migration\n  def change\n    rename_column :topics, :type, :kind\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120142452_create_incidents.rb",
    "content": "class CreateIncidents < ActiveRecord::Migration\n  def change\n    create_table :incidents do |t|\n      t.string :subject\n      t.text :description\n      t.references :topic, index: true\n      t.datetime :occured_at\n\n      t.timestamps null: false\n    end\n    add_foreign_key :incidents, :topics\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120151642_add_escalation_series_to_topic.rb",
    "content": "class AddEscalationSeriesToTopic < ActiveRecord::Migration\n  def change\n    add_reference :topics, :escalation_series, index: true\n    add_foreign_key :topics, :escalation_series\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150120154438_add_name_to_shift.rb",
    "content": "class AddNameToShift < ActiveRecord::Migration\n  def change\n    add_column :shifts, :name, :string\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150121150043_add_user_to_notifier.rb",
    "content": "class AddUserToNotifier < ActiveRecord::Migration\n  def change\n    add_reference :notifiers, :user, index: true\n    add_foreign_key :notifiers, :users\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150121150857_rename_type_with_kind_of_notifier.rb",
    "content": "class RenameTypeWithKindOfNotifier < ActiveRecord::Migration\n  def change\n    rename_column :notifiers, :type, :kind\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150123132415_remove_shift.rb",
    "content": "class RemoveShift < ActiveRecord::Migration\n  def change\n    drop_table :shifts\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150123150518_add_status_to_incident.rb",
    "content": "class AddStatusToIncident < ActiveRecord::Migration\n  def change\n    add_column :incidents, :status, :integer\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150123150947_create_incident_events.rb",
    "content": "class CreateIncidentEvents < ActiveRecord::Migration\n  def change\n    create_table :incident_events do |t|\n      t.references :incident, index: true\n      t.integer :kind\n      t.text :text\n      t.references :user_by, index: true\n\n      t.timestamps null: false\n    end\n    add_foreign_key :incident_events, :incidents\n    add_foreign_key :incident_events, :users, column: 'user_by_id'\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150125050529_create_notifier_providers.rb",
    "content": "class CreateNotifierProviders < ActiveRecord::Migration\n  def change\n    create_table :notifier_providers do |t|\n      t.string :name\n      t.integer :kind\n      t.text :settings\n\n      t.timestamps null: false\n    end\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150125050556_add_provider_to_notifier.rb",
    "content": "class AddProviderToNotifier < ActiveRecord::Migration\n  def change\n    add_reference :notifiers, :provider, index: true\n    add_foreign_key :notifiers, :notifier_providers, column: 'provider_id'\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150125101901_remove_kind_from_notifier.rb",
    "content": "class RemoveKindFromNotifier < ActiveRecord::Migration\n  def change\n    remove_column :notifiers, :kind\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150127142530_remove_user_by_from_incident_event.rb",
    "content": "class RemoveUserByFromIncidentEvent < ActiveRecord::Migration\n  def change\n    remove_foreign_key :incident_events, column: \"user_by_id\"\n    remove_index  :incident_events, :user_by_id\n    remove_column :incident_events, :user_by_id\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150127152127_add_info_to_incident_event.rb",
    "content": "class AddInfoToIncidentEvent < ActiveRecord::Migration\n  def change\n    add_column :incident_events, :info, :text\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150128064248_add_email_to_user.rb",
    "content": "class AddEmailToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :email, :string\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150131120557_add_enable_to_topic.rb",
    "content": "class AddEnableToTopic < ActiveRecord::Migration\n  def change\n    add_column :topics, :enable, :boolean\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150131121143_set_default_of_enable_of_topic_true.rb",
    "content": "class SetDefaultOfEnableOfTopicTrue < ActiveRecord::Migration\n  def change\n    change_column :topics, :enable, :boolean, default: true\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150131122151_rename_enable_with_enabled_of_topic.rb",
    "content": "class RenameEnableWithEnabledOfTopic < ActiveRecord::Migration\n  def change\n    rename_column :topics, :enable, :enabled\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150201033946_add_login_token_to_user.rb",
    "content": "class AddLoginTokenToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :login_token, :string\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150202144538_add_token_to_user.rb",
    "content": "class AddTokenToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :token, :string\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150202151740_add_refresh_token_to_user.rb",
    "content": "class AddRefreshTokenToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :refresh_token, :string\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150202152015_add_settings_to_escalation_series.rb",
    "content": "class AddSettingsToEscalationSeries < ActiveRecord::Migration\n  def change\n    add_column :escalation_series, :escalation_series, :text\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150202155726_add_token_expires_at_to_user.rb",
    "content": "class AddTokenExpiresAtToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :token_expires_at, :datetime\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150203010332_remove_escalation_series_from_escalation_series.rb",
    "content": "class RemoveEscalationSeriesFromEscalationSeries < ActiveRecord::Migration\n  def change\n    remove_column :escalation_series, :escalation_series\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150203010417_add_settings_to_escalation_series_again.rb",
    "content": "class AddSettingsToEscalationSeriesAgain < ActiveRecord::Migration\n  def change\n    add_column :escalation_series, :settings, :text\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150207164010_add_topic_to_notifier.rb",
    "content": "class AddTopicToNotifier < ActiveRecord::Migration\n  def change\n    add_reference :notifiers, :topic, index: true\n    add_foreign_key :notifiers, :topics\n  end\nend\n"
  },
  {
    "path": "db/migrate/20150218071007_add_enable_to_notifier.rb",
    "content": "class AddEnableToNotifier < ActiveRecord::Migration\n  def change\n    add_column :notifiers, :enabled, :boolean, default: true\n  end\nend\n"
  },
  {
    "path": "db/migrate/20151117011141_add_active_to_user.rb",
    "content": "class AddActiveToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :active, :boolean, default: false\n  end\nend\n"
  },
  {
    "path": "db/migrate/20151117013824_add_provider_and_uid_to_user.rb",
    "content": "class AddProviderAndUidToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :provider, :string\n    add_column :users, :uid, :string\n  end\nend\n"
  },
  {
    "path": "db/migrate/20151118061253_add_credentials_to_user.rb",
    "content": "class AddCredentialsToUser < ActiveRecord::Migration\n  def change\n    add_column :users, :credentials, :text\n  end\nend\n"
  },
  {
    "path": "db/migrate/20151118061938_delete_token_from_user.rb",
    "content": "class DeleteTokenFromUser < ActiveRecord::Migration\n  def change\n    User.all.each do |u|\n      if u.token\n        u.update!(credentials: {\n          token: u.token,\n          refresh_token: u.refresh_token,\n          expires_at: u.token_expires_at.to_i,\n          expires: true,\n        })\n      end\n    end\n\n    remove_column :users, :token\n    remove_column :users, :token_expires_at\n    remove_column :users, :refresh_token\n  end\nend\n"
  },
  {
    "path": "db/migrate/20160210010310_create_maintenances.rb",
    "content": "class CreateMaintenances < ActiveRecord::Migration\n  def change\n    create_table :maintenances do |t|\n      t.references :topic, index: true\n      t.datetime :start_time\n      t.datetime :end_time\n\n      t.timestamps null: false\n    end\n    add_foreign_key :maintenances, :topics\n  end\nend\n"
  },
  {
    "path": "db/migrate/20160907123728_create_comments.rb",
    "content": "class CreateComments < ActiveRecord::Migration\n  def change\n    create_table \"comments\", force: :cascade do |t|\n      t.integer  \"incident_id\", limit: 4,   null: false\n      t.integer  \"user_id\",     limit: 4,   null: false\n      t.text     \"comment\",                 null: false\n      t.datetime \"created_at\",              null: false\n      t.datetime \"updated_at\",              null: false\n    end\n  end\nend\n"
  },
  {
    "path": "db/migrate/20160914063913_add_comment_index.rb",
    "content": "class AddCommentIndex < ActiveRecord::Migration\n  def change\n    add_index :comments, :incident_id\n  end\nend\n"
  },
  {
    "path": "db/migrate/20161207045554_add_filter_to_maintenance.rb",
    "content": "class AddFilterToMaintenance < ActiveRecord::Migration\n  def change\n    add_column :maintenances, :filter, :string\n  end\nend\n"
  },
  {
    "path": "db/schema.rb",
    "content": "# encoding: UTF-8\n# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 20161207045554) do\n\n  create_table \"comments\", force: :cascade do |t|\n    t.integer  \"incident_id\", limit: 4,     null: false\n    t.integer  \"user_id\",     limit: 4,     null: false\n    t.text     \"comment\",     limit: 65535, null: false\n    t.datetime \"created_at\",                null: false\n    t.datetime \"updated_at\",                null: false\n  end\n\n  add_index \"comments\", [\"incident_id\"], name: \"index_comments_on_incident_id\", using: :btree\n\n  create_table \"escalation_series\", force: :cascade do |t|\n    t.string   \"name\",       limit: 255\n    t.datetime \"created_at\",               null: false\n    t.datetime \"updated_at\",               null: false\n    t.text     \"settings\",   limit: 65535\n  end\n\n  create_table \"escalations\", force: :cascade do |t|\n    t.bigint \"escalate_to_id\",       limit: 4\n    t.integer  \"escalate_after_sec\",   limit: 4\n    t.datetime \"created_at\",                     null: false\n    t.datetime \"updated_at\",                     null: false\n    t.bigint \"escalation_series_id\", limit: 4\n  end\n\n  add_index \"escalations\", [\"escalate_to_id\"], name: \"index_escalations_on_escalate_to_id\", using: :btree\n  add_index \"escalations\", [\"escalation_series_id\"], name: \"index_escalations_on_escalation_series_id\", using: :btree\n\n  create_table \"incident_events\", force: :cascade do |t|\n    t.bigint \"incident_id\", limit: 4\n    t.integer  \"kind\",        limit: 4\n    t.text     \"text\",        limit: 65535\n    t.datetime \"created_at\",                null: false\n    t.datetime \"updated_at\",                null: false\n    t.text     \"info\",        limit: 65535\n  end\n\n  add_index \"incident_events\", [\"incident_id\"], name: \"index_incident_events_on_incident_id\", using: :btree\n\n  create_table \"incidents\", force: :cascade do |t|\n    t.string   \"subject\",     limit: 255\n    t.text     \"description\", limit: 65535\n    t.bigint \"topic_id\",    limit: 4\n    t.datetime \"occured_at\"\n    t.datetime \"created_at\",                null: false\n    t.datetime \"updated_at\",                null: false\n    t.integer  \"status\",      limit: 4\n  end\n\n  add_index \"incidents\", [\"topic_id\"], name: \"index_incidents_on_topic_id\", using: :btree\n\n  create_table \"maintenances\", force: :cascade do |t|\n    t.bigint \"topic_id\",   limit: 4\n    t.datetime \"start_time\"\n    t.datetime \"end_time\"\n    t.datetime \"created_at\",             null: false\n    t.datetime \"updated_at\",             null: false\n    t.string   \"filter\",     limit: 255\n  end\n\n  add_index \"maintenances\", [\"topic_id\"], name: \"index_maintenances_on_topic_id\", using: :btree\n\n  create_table \"notifier_providers\", force: :cascade do |t|\n    t.string   \"name\",       limit: 255\n    t.integer  \"kind\",       limit: 4\n    t.text     \"settings\",   limit: 65535\n    t.datetime \"created_at\",               null: false\n    t.datetime \"updated_at\",               null: false\n  end\n\n  create_table \"notifiers\", force: :cascade do |t|\n    t.text     \"settings\",         limit: 65535\n    t.integer  \"notify_after_sec\", limit: 4\n    t.datetime \"created_at\",                                    null: false\n    t.datetime \"updated_at\",                                    null: false\n    t.bigint \"user_id\",          limit: 4\n    t.bigint \"provider_id\",      limit: 4\n    t.bigint \"topic_id\",         limit: 4\n    t.boolean  \"enabled\",                        default: true\n  end\n\n  add_index \"notifiers\", [\"provider_id\"], name: \"index_notifiers_on_provider_id\", using: :btree\n  add_index \"notifiers\", [\"topic_id\"], name: \"index_notifiers_on_topic_id\", using: :btree\n  add_index \"notifiers\", [\"user_id\"], name: \"index_notifiers_on_user_id\", using: :btree\n\n  create_table \"topics\", force: :cascade do |t|\n    t.string   \"name\",                 limit: 255\n    t.integer  \"kind\",                 limit: 4\n    t.datetime \"created_at\",                                      null: false\n    t.datetime \"updated_at\",                                      null: false\n    t.bigint \"escalation_series_id\", limit: 4\n    t.boolean  \"enabled\",                          default: true\n  end\n\n  add_index \"topics\", [\"escalation_series_id\"], name: \"index_topics_on_escalation_series_id\", using: :btree\n\n  create_table \"users\", force: :cascade do |t|\n    t.string   \"name\",        limit: 255\n    t.datetime \"created_at\",                                null: false\n    t.datetime \"updated_at\",                                null: false\n    t.string   \"email\",       limit: 255\n    t.string   \"login_token\", limit: 255\n    t.boolean  \"active\",                    default: false\n    t.string   \"provider\",    limit: 255\n    t.string   \"uid\",         limit: 255\n    t.text     \"credentials\", limit: 65535\n  end\n\n  add_foreign_key \"escalations\", \"escalation_series\"\n  add_foreign_key \"escalations\", \"users\", column: \"escalate_to_id\"\n  add_foreign_key \"incident_events\", \"incidents\"\n  add_foreign_key \"incidents\", \"topics\"\n  add_foreign_key \"maintenances\", \"topics\"\n  add_foreign_key \"notifiers\", \"notifier_providers\", column: \"provider_id\"\n  add_foreign_key \"notifiers\", \"topics\"\n  add_foreign_key \"notifiers\", \"users\"\n  add_foreign_key \"topics\", \"escalation_series\"\nend\n"
  },
  {
    "path": "db/seeds.rb",
    "content": "# This file should contain all the record creation needed to seed the database with its default values.\n# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).\n#\n# Examples:\n#\n#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])\n#   Mayor.create(name: 'Emanuel', city: cities.first)\n"
  },
  {
    "path": "docker/puma.rb",
    "content": "require 'fileutils'\n\nlisten_unix = ENV['LISTEN_UNIX']\n\nif listen_unix\n  bind \"unix://#{listen_unix}\"\nend\nenvironment ENV['RAILS_ENV']\nport = ENV['PORT'] || 8080\nbind \"tcp://0.0.0.0:#{port}\"\n"
  },
  {
    "path": "docker-compose.yml",
    "content": "version: '3'\nservices:\n  app:\n    build: .\n    ports:\n      - 5000:5000\n    environment:\n      DATABASE_URL: 'mysql2://database/waker_development?encoding=utf8mb4&collation=utf8mb4_unicode_ci'\n      REDIS_HOST: cache\n    depends_on:\n      - database\n      - cache\n  database:\n    image: mysql:5\n    environment:\n      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'\n      MYSQL_DATABASE: waker_development\n  cache:\n    image: redis\n"
  },
  {
    "path": "lib/assets/.keep",
    "content": ""
  },
  {
    "path": "lib/tasks/.keep",
    "content": ""
  },
  {
    "path": "log/.keep",
    "content": ""
  },
  {
    "path": "public/404.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>The page you were looking for doesn't exist (404)</title>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <style>\n  body {\n    background-color: #EFEFEF;\n    color: #2E2F30;\n    text-align: center;\n    font-family: arial, sans-serif;\n    margin: 0;\n  }\n\n  div.dialog {\n    width: 95%;\n    max-width: 33em;\n    margin: 4em auto 0;\n  }\n\n  div.dialog > div {\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #BBB;\n    border-top: #B00100 solid 4px;\n    border-top-left-radius: 9px;\n    border-top-right-radius: 9px;\n    background-color: white;\n    padding: 7px 12% 0;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n\n  h1 {\n    font-size: 100%;\n    color: #730E15;\n    line-height: 1.5em;\n  }\n\n  div.dialog > p {\n    margin: 0 0 1em;\n    padding: 1em;\n    background-color: #F7F7F7;\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #999;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    border-top-color: #DADADA;\n    color: #666;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/404.html -->\n  <div class=\"dialog\">\n    <div>\n      <h1>The page you were looking for doesn't exist.</h1>\n      <p>You may have mistyped the address or the page may have moved.</p>\n    </div>\n    <p>If you are the application owner check the logs for more information.</p>\n  </div>\n</body>\n</html>\n"
  },
  {
    "path": "public/422.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>The change you wanted was rejected (422)</title>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <style>\n  body {\n    background-color: #EFEFEF;\n    color: #2E2F30;\n    text-align: center;\n    font-family: arial, sans-serif;\n    margin: 0;\n  }\n\n  div.dialog {\n    width: 95%;\n    max-width: 33em;\n    margin: 4em auto 0;\n  }\n\n  div.dialog > div {\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #BBB;\n    border-top: #B00100 solid 4px;\n    border-top-left-radius: 9px;\n    border-top-right-radius: 9px;\n    background-color: white;\n    padding: 7px 12% 0;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n\n  h1 {\n    font-size: 100%;\n    color: #730E15;\n    line-height: 1.5em;\n  }\n\n  div.dialog > p {\n    margin: 0 0 1em;\n    padding: 1em;\n    background-color: #F7F7F7;\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #999;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    border-top-color: #DADADA;\n    color: #666;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/422.html -->\n  <div class=\"dialog\">\n    <div>\n      <h1>The change you wanted was rejected.</h1>\n      <p>Maybe you tried to change something you didn't have access to.</p>\n    </div>\n    <p>If you are the application owner check the logs for more information.</p>\n  </div>\n</body>\n</html>\n"
  },
  {
    "path": "public/500.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>We're sorry, but something went wrong (500)</title>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <style>\n  body {\n    background-color: #EFEFEF;\n    color: #2E2F30;\n    text-align: center;\n    font-family: arial, sans-serif;\n    margin: 0;\n  }\n\n  div.dialog {\n    width: 95%;\n    max-width: 33em;\n    margin: 4em auto 0;\n  }\n\n  div.dialog > div {\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #BBB;\n    border-top: #B00100 solid 4px;\n    border-top-left-radius: 9px;\n    border-top-right-radius: 9px;\n    background-color: white;\n    padding: 7px 12% 0;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n\n  h1 {\n    font-size: 100%;\n    color: #730E15;\n    line-height: 1.5em;\n  }\n\n  div.dialog > p {\n    margin: 0 0 1em;\n    padding: 1em;\n    background-color: #F7F7F7;\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #999;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    border-top-color: #DADADA;\n    color: #666;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/500.html -->\n  <div class=\"dialog\">\n    <div>\n      <h1>We're sorry, but something went wrong.</h1>\n    </div>\n    <p>If you are the application owner check the logs for more information.</p>\n  </div>\n</body>\n</html>\n"
  },
  {
    "path": "public/robots.txt",
    "content": "# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file\n#\n# To ban all spiders from the entire site uncomment the next two lines:\nUser-agent: *\nDisallow: /\n"
  },
  {
    "path": "script/update-escalations-from-google-calendar",
    "content": "#!/usr/bin/env ruby\n\nrequire 'optparse'\nrequire 'json'\nrequire 'faraday'\nrequire 'google/api_client'\nrequire 'google/api_client/client_secrets'\nrequire 'google/api_client/auth/file_storage'\nrequire 'google/api_client/auth/installed_app'\n\nclass Configuration < Struct.new(:client_secret_file, :credential_store_file, :calendar_name, :delimiter, :url, :escalation_series, :login_token)\n  def self.from_command_line_options\n    self.new.tap do |config|\n      opt = OptionParser.new\n      opt.on('--client-secret-file VAL') {|v| config.client_secret_file = v }\n      opt.on('--credential-store-file VAL') {|v| config.credential_store_file = v }\n      opt.on('--calendar-name VAL') {|v| config.calendar_name = v }\n      opt.on('--delimiter VAL') {|v| config.delimiter = v }\n      opt.on('--url VAL') {|v| config.url = v }\n      opt.on('--escalation-series VAL') {|v| config.escalation_series = v }\n      opt.on('--login-token VAL') {|v| config.login_token = v }\n      opt.parse!(ARGV)\n\n      config.validate!\n    end\n  end\n\n  def validate!\n    members.each do |member|\n      unless self[member]\n        raise \"#{member} is required.\"\n      end\n    end\n  end\nend\n\nclass WakerClient\n  InvalidResponseError = Class.new(StandardError)\n\n  def initialize(url:, token:)\n    @url = url\n    @token = token\n  end\n\n  def users\n    get('/users.json')\n  end\n\n  def escalation_series\n    get('/escalation_series.json')\n  end\n\n  def escalations\n    get('/escalations.json')\n  end\n\n  def update_escalation(escalation, escalate_to: nil)\n    params = {}\n    params['escalation[escalate_to_id]'] = escalate_to.id if escalate_to\n    update(\"/escalations/#{escalation.id}.json\", params)\n  end\n\n  private\n\n  def conn\n    @conn ||= Faraday.new(url: @url) do |faraday|\n      faraday.request  :url_encoded\n      faraday.response :logger if ENV['DEBUG']\n      faraday.adapter  Faraday.default_adapter\n    end\n  end\n\n  def get(path)\n    res = conn.get do |req|\n      req.url path\n      req.headers['X-Login-Token'] = @token\n    end\n\n    parse_response(res)\n  end\n\n  def update(path, params = {})\n    res = conn.put do |req|\n      req.url path\n      req.params = params\n      req.headers['X-Login-Token'] = @token\n    end\n\n    parse_response(res)\n  end\n\n  def parse_response(res)\n    unless 200 <= res.status && res.status < 300\n      raise InvalidResponseError, \"status #{res.status}\\nbody: #{res.body}\"\n    end\n\n    body = JSON.parse(res.body)\n    if body.is_a?(Array)\n      body.map {|v| OpenStruct.new(v) }\n    elsif body.is_a?(Hash)\n      OpenStruct.new(body)\n    end\n  end\nend\n\ndef setup_google_client\n  client = Google::APIClient.new(application_name: 'Waker',\n                                 application_version: '1.0.0')\n\n  file_storage = Google::APIClient::FileStorage.new($config.credential_store_file)\n  if file_storage.authorization.nil?\n    client_secrets = Google::APIClient::ClientSecrets.load($config.client_secret_file)\n    flow = Google::APIClient::InstalledAppFlow.new(\n      client_id: client_secrets.client_id,\n      client_secret: client_secrets.client_secret,\n      scope: ['https://www.googleapis.com/auth/calendar.readonly']\n    )\n    client.authorization = flow.authorize(file_storage)\n  else\n    client.authorization = file_storage.authorization\n  end\n\n  return client\nend\n\n$config = Configuration.from_command_line_options\n\nclient = setup_google_client\ncalendar_api = client.discovered_api('calendar', 'v3')\n\ncalendar = client.execute(\n  api_method: calendar_api.calendar_list.list,\n  parameters: {},\n).data.items.find do |cal|\n  cal['summary'] == $config.calendar_name\nend\n\nevents = client.execute(\n  api_method: calendar_api.events.list,\n  parameters: {\n    'calendarId' => calendar['id'],\n    'timeMax' => (Time.now + 1).strftime('%FT%T%:z'),\n    'timeMin' => (Time.now).strftime('%FT%T%:z'),\n    'singleEvents' => true,\n  },\n).data.items\n\nevents.each do |event|\n  unless event['end']['dateTime'] && event['start']['dateTime']\n    raise \"dateTime field is not found (The event may be all-day event)\\n#{event}\"\n  end\nend\n\nevents.sort! do |a, b|\n  a['end']['dateTime'] - a['start']['dateTime'] <=>\n    b['end']['dateTime'] - b['start']['dateTime']\nend\n\n# shortest event\nevent = events.first\n\npersons = event['summary'].split($config.delimiter).map(&:strip)\n\nclient = WakerClient.new(url: $config.url, token: $config.login_token)\n\nescalation_series = client.escalation_series.find do |series|\n  [series.id, series.name].include?($config.escalation_series)\nend\n\nescalations = client.escalations.select do |escalation|\n  escalation.escalation_series_id == escalation_series.id\nend.sort_by do |escalation|\n  escalation.escalate_after_sec\nend\n\nusers = client.users\n\npersons.each_with_index do |name, i|\n  user = users.find {|u| u.name == name }\n  raise \"#{name} user is not found.\" unless user\n  escalation = escalations[i]\n  client.update_escalation(escalation, escalate_to: user)\nend\n"
  },
  {
    "path": "spec/controllers/slack_controller_spec.rb",
    "content": "require 'rails_helper'\n\nRSpec.describe SlackController, type: :controller do\n\n  describe \"GET interactive\" do\n    it \"raises token verification failed error\" do\n      expect(get: 'slack/interactive').not_to be_routable\n      expect{get :interactive}.to raise_error(RuntimeError, /token verification failed/)\n    end\n  end\n\nend\n"
  },
  {
    "path": "spec/factories/escalation.rb",
    "content": "FactoryBot.define do\n  factory :escalation do\n    association :escalate_to, factory: :user\n    escalate_after_sec { 60 }\n    escalation_series\n  end\nend\n"
  },
  {
    "path": "spec/factories/escalation_series.rb",
    "content": "FactoryBot.define do\n  factory :escalation_series do\n    name { \"Infra\" }\n  end\nend\n"
  },
  {
    "path": "spec/factories/incident.rb",
    "content": "FactoryBot.define do\n  factory :incident do\n    id { 1 }\n    topic\n    subject { \"mysql-01 is down\" }\n    description { \"alert\" }\n  end\nend\n"
  },
  {
    "path": "spec/factories/incident_events.rb",
    "content": "FactoryBot.define do\n  factory :incident_event do\n    incident_id { 1 }\n    kind { :opened }\n  end\nend\n"
  },
  {
    "path": "spec/factories/maintenances.rb",
    "content": "FactoryBot.define do\n  factory :maintenance do\n    topic nil\n    start_time { \"2016-02-10 10:03:10\" }\n    end_time { \"2016-02-10 10:03:10\" }\n  end\n\nend\n"
  },
  {
    "path": "spec/factories/notifier.rb",
    "content": "FactoryBot.define do\n  factory :notifier do\n    user\n    association :provider, factory: :notifier_provider\n    notify_after_sec { 60 }\n  end\nend\n"
  },
  {
    "path": "spec/factories/notifier_provider.rb",
    "content": "FactoryBot.define do\n  factory :notifier_provider do\n    name { \"Logger\" }\n    kind { :rails_logger }\n  end\nend\n"
  },
  {
    "path": "spec/factories/topic.rb",
    "content": "FactoryBot.define do\n  factory :topic do\n    name { \"Infra\" }\n    kind { \"api\" }\n    escalation_series\n  end\nend\n"
  },
  {
    "path": "spec/factories/user.rb",
    "content": "FactoryBot.define do\n  factory :user do\n    name { \"Ryota Arai\" }\n  end\nend\n"
  },
  {
    "path": "spec/helpers/slack_helper_spec.rb",
    "content": "require 'rails_helper'\n\n# Specs in this file have access to a helper object that includes\n# the SlackHelper. For example:\n#\n# describe SlackHelper do\n#   describe \"string concat\" do\n#     it \"concats two strings with spaces\" do\n#       expect(helper.concat_strings(\"this\",\"that\")).to eq(\"this that\")\n#     end\n#   end\n# end\nRSpec.describe SlackHelper, type: :helper do\n  pending \"add some examples to (or delete) #{__FILE__}\"\nend\n"
  },
  {
    "path": "spec/models/comment_spec.rb",
    "content": "require 'rails_helper'\n\nRSpec.describe Comment, type: :model do\n  let(:incident) { create(:incident) }\n  let(:user) { create(:user) }\n\n  it 'should be valid' do\n    comment = Comment.new(\n      incident: incident,\n      user: user,\n      comment: 'Help Me',\n    )\n    expect(comment).to be_valid\n  end\n\n  it 'should be invalid without incident' do\n    comment = Comment.new(\n      incident: nil,\n      user: user,\n      comment: 'Help Me',\n    )\n    expect(comment).not_to be_valid\n  end\n\n  it 'should be invalid without user' do\n    comment = Comment.new(\n      incident: incident,\n      user: nil,\n      comment: 'Help Me',\n    )\n    expect(comment).not_to be_valid\n  end\n\n  it 'should be invalid without comment' do\n    comment = Comment.new(\n      incident: incident,\n      user: user,\n      comment: '',\n    )\n    expect(comment).not_to be_valid\n  end\nend\n"
  },
  {
    "path": "spec/models/escalation_series_spec.rb",
    "content": "require 'rails_helper'\nrequire 'ostruct'\nrequire 'google/api_client'\nrequire 'json'\n\nRSpec.describe EscalationSeries, type: :model do\n  describe \"after_create enqueue\" do\n    before do\n      # I understand that this is not the recommended method, but it is enough.\n      allow_any_instance_of(Google::APIClient).to receive(:execute).and_return(\n        OpenStruct.new(\n          {\n            data: OpenStruct.new({\n              items: [{\n                'id' => 1,\n                'summary' => 'test_calendar'\n              }]\n            })\n          }\n        ),\n        OpenStruct.new(\n          {\n              data: OpenStruct.new({\n                items: [{\n                  'summary' => 'c,b,a',\n                  'start' => { 'dateTime' => Time.now },\n                  'end' => { 'dateTime' => Time.now + 300 },\n                }]\n              })\n          }\n        ),\n      )\n    end\n\n    it \"#update_escalations\" do\n      users = %w(a b c).map { |n| create(:user, name: n, credentials: { expires_at: Time.now.to_i + 300, token: \"dummy\", expires: nil, }) }\n      series = create(:escalation_series, settings: {\n        update_by: 'google_calendar',\n        user_as_id: users.first.id,\n        calendar: 'test_calendar',\n        event_delimiter: ',',\n      })\n      escalations = users.map { |u| create(:escalation, escalation_series: series, escalate_to: u ) }\n\n      expect(series.update_escalations!).to be_truthy\n\n      users.reverse.each_with_index do |u,i|\n        expect(Escalation.find(escalations[i].id).escalate_to.id).to eq(u.id)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "spec/models/incident_spec.rb",
    "content": "require 'rails_helper'\n\nRSpec.describe Incident, type: :model do\n  describe \"after_create enqueue\" do\n    it \"creates escalation jobs\" do\n      series = create(:escalation_series)\n      escalation = create(:escalation, escalation_series: series)\n      notifier = create(:notifier, user: escalation.escalate_to)\n      topic = create(:topic, escalation_series: series)\n\n      incident = nil\n      expect {\n        incident = create(:incident, topic: topic)\n      }.to change(EscalationWorker.jobs, :size).by(1).and change(NotificationWorker.jobs, :size).by(1)\n\n      expect {\n        EscalationWorker.drain\n      }.to change(incident.events, :count).by(1)\n\n      event = incident.events.last\n      expect(event.kind).to eq('escalated')\n      expect(event.escalation).to eq(escalation)\n\n      expect(NotificationWorker.jobs.size).to eq(2)\n    end\n  end\nend\n"
  },
  {
    "path": "spec/models/maintenance_spec.rb",
    "content": "require 'rails_helper'\n\nRSpec.describe Maintenance, type: :model do\n  pending \"add some examples to (or delete) #{__FILE__}\"\nend\n"
  },
  {
    "path": "spec/rails_helper.rb",
    "content": "# This file is copied to spec/ when you run 'rails generate rspec:install'\nENV[\"RAILS_ENV\"] ||= 'test'\nrequire 'spec_helper'\nrequire File.expand_path(\"../../config/environment\", __FILE__)\nrequire 'rspec/rails'\n# Add additional requires below this line. Rails is not loaded until this point!\n\n# Requires supporting ruby files with custom matchers and macros, etc, in\n# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are\n# run as spec files by default. This means that files in spec/support that end\n# in _spec.rb will both be required and run as specs, causing the specs to be\n# run twice. It is recommended that you do not name files matching this glob to\n# end with _spec.rb. You can configure this pattern with the --pattern\n# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.\n#\n# The following line is provided for convenience purposes. It has the downside\n# of increasing the boot-up time by auto-requiring all files in the support\n# directory. Alternatively, in the individual `*_spec.rb` files, manually\n# require only the support files necessary.\n#\nDir[Rails.root.join(\"spec/support/**/*.rb\")].each { |f| require f }\n\n# Checks for pending migrations before tests are run.\n# If you are not using ActiveRecord, you can remove this line.\nActiveRecord::Migration.maintain_test_schema!\n\nRSpec.configure do |config|\n  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures\n  config.fixture_path = \"#{::Rails.root}/spec/fixtures\"\n\n  # If you're not using ActiveRecord, or you'd prefer not to run each of your\n  # examples within a transaction, remove the following line or assign false\n  # instead of true.\n  config.use_transactional_fixtures = true\n\n  # RSpec Rails can automatically mix in different behaviours to your tests\n  # based on their file location, for example enabling you to call `get` and\n  # `post` in specs under `spec/controllers`.\n  #\n  # You can disable this behaviour by removing the line below, and instead\n  # explicitly tag your specs with their type, e.g.:\n  #\n  #     RSpec.describe UsersController, :type => :controller do\n  #       # ...\n  #     end\n  #\n  # The different available types are documented in the features, such as in\n  # https://relishapp.com/rspec/rspec-rails/docs\n  config.infer_spec_type_from_file_location!\nend\n"
  },
  {
    "path": "spec/requests/incident_envets_spec.rb",
    "content": "require 'rails_helper'\n\nRSpec.describe \"IncidentEvent\", type: :request do\n  describe \"POST /incident_events/:id/twilio\" do\n    let(:incident) { create(:incident) }\n    let(:event) { create(:incident_event, incident_id: incident.id) }\n\n    describe 'without params[:Digits]' do\n      it \"works!\" do\n        post \"/incident_events/#{event.id}/twilio\"\n        expect(response).to have_http_status(200)\n      end\n    end\n\n    describe 'with params[:Digits]' do\n      before do\n        post \"/incident_events/#{event.id}/twilio\", params: { Digits: digit}\n        incident.reload\n      end\n\n      context '1' do\n        let(:digit) { 1 }\n        it \"acknowledged\" do\n          expect(response).to have_http_status(200)\n          expect(incident.status).to eq 'acknowledged'\n        end\n      end\n\n      context '2' do\n        let(:digit) { 2 }\n        it \"resolved\" do\n          expect(response).to have_http_status(200)\n          expect(incident.status).to eq 'resolved'\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "spec/requests/maintenances_spec.rb",
    "content": "require 'rails_helper'\n\nRSpec.describe \"Maintenances\", type: :request do\n  describe \"GET /maintenances\" do\n    it \"works! (now write some real specs)\" do\n      get maintenances_path\n      expect(response).to have_http_status(200)\n    end\n  end\nend\n"
  },
  {
    "path": "spec/requests/topics_spec.rb",
    "content": "require \"rails_helper\"\n\nRSpec.describe \"Topics\", type: :request do\n  describe \"POST /topics/1/mailgun\" do\n    let(:subject) { 'New Alert' }\n    let(:body) { \"Your server is on fire\" }\n    it \"creates a new incident\" do\n      topic = create(:topic)\n      post mailgun_topic_path(topic, format: :json), params: {\n        'subject' => subject,\n        'body-plain' => body,\n      }\n      expect(response).to have_http_status(200)\n\n      incident = Incident.last\n      expect(incident.subject).to eq(subject)\n      expect(incident.description).to eq(body)\n    end\n  end\n\n  describe \"POST /topics/1/slack\" do\n    it \"creates a new incident\" do\n      topic = create(:topic)\n      post slack_topic_path(topic, format: :json), params: {\n        'channel_name' => 'test_channel',\n        'user_name' => 'test_user',\n        'text' => 'help me',\n      }\n      expect(response).to have_http_status(200)\n\n      incident = Incident.last\n      expect(incident.subject).to eq(\"escalation from slack,channel name:test_channel help me\")\n      expect(incident.description).to eq(\"channel:test_channel user:test_user help me\")\n    end\n  end\nend\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "require 'simplecov'\nSimpleCov.start 'rails' do\n  add_filter '/vendor/'\n  add_filter '/.bundle/'\nend\n\n# This file was generated by the `rails generate rspec:install` command. Conventionally, all\n# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.\n# The generated `.rspec` file contains `--require spec_helper` which will cause this\n# file to always be loaded, without a need to explicitly require it in any files.\n#\n# Given that it is always loaded, you are encouraged to keep this file as\n# light-weight as possible. Requiring heavyweight dependencies from this file\n# will add to the boot time of your test suite on EVERY test run, even for an\n# individual file that may not need all of that loaded. Instead, consider making\n# a separate helper file that requires the additional dependencies and performs\n# the additional setup, and require it from the spec files that actually need it.\n#\n# The `.rspec` file also contains a few flags that are not defaults but that\n# users commonly want.\n#\n# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration\nRSpec.configure do |config|\n  config.before :suite do\n    DatabaseRewinder.clean_all\n  end\n\n  config.after :each do\n    DatabaseRewinder.clean\n  end\n\n  # rspec-expectations config goes here. You can use an alternate\n  # assertion/expectation library such as wrong or the stdlib/minitest\n  # assertions if you prefer.\n  config.expect_with :rspec do |expectations|\n    # This option will default to `true` in RSpec 4. It makes the `description`\n    # and `failure_message` of custom matchers include text for helper methods\n    # defined using `chain`, e.g.:\n    # be_bigger_than(2).and_smaller_than(4).description\n    #   # => \"be bigger than 2 and smaller than 4\"\n    # ...rather than:\n    #   # => \"be bigger than 2\"\n    expectations.include_chain_clauses_in_custom_matcher_descriptions = true\n  end\n\n  # rspec-mocks config goes here. You can use an alternate test double\n  # library (such as bogus or mocha) by changing the `mock_with` option here.\n  config.mock_with :rspec do |mocks|\n    # Prevents you from mocking or stubbing a method that does not exist on\n    # a real object. This is generally recommended, and will default to\n    # `true` in RSpec 4.\n    mocks.verify_partial_doubles = true\n  end\n\n  # Run specs in random order to surface order dependencies. If you find an\n  # order dependency and want to debug it, you can fix the order by providing\n  # the seed, which is printed after each run.\n  #     --seed 1234\n  config.order = :random\n\n  # Seed global randomization in this process using the `--seed` CLI option.\n  # Setting this allows you to use `--seed` to deterministically reproduce\n  # test failures related to randomization by passing the same `--seed` value\n  # as the one that triggered the failure.\n  Kernel.srand config.seed\n\n# The settings below are suggested to provide a good initial experience\n# with RSpec, but feel free to customize to your heart's content.\n=begin\n  # These two settings work together to allow you to limit a spec run\n  # to individual examples or groups you care about by tagging them with\n  # `:focus` metadata. When nothing is tagged with `:focus`, all examples\n  # get run.\n  config.filter_run :focus\n  config.run_all_when_everything_filtered = true\n\n  # Limits the available syntax to the non-monkey patched syntax that is recommended.\n  # For more details, see:\n  #   - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax\n  #   - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/\n  #   - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching\n  config.disable_monkey_patching!\n\n  # Many RSpec users commonly either run the entire suite or an individual\n  # file, and it's useful to allow more verbose output when running an\n  # individual spec file.\n  if config.files_to_run.one?\n    # Use the documentation formatter for detailed output,\n    # unless a formatter has already been configured\n    # (e.g. via a command-line flag).\n    config.default_formatter = 'doc'\n  end\n\n  # Print the 10 slowest examples and example groups at the\n  # end of the spec run, to help surface which specs are running\n  # particularly slow.\n  config.profile_examples = 10\n=end\nend\n"
  },
  {
    "path": "spec/support/factory_girl.rb",
    "content": "RSpec.configure do |config|\n  config.include FactoryBot::Syntax::Methods\n\n  config.before(:suite) do\n    begin\n      FactoryBot.lint\n    ensure\n      DatabaseRewinder.clean_all\n    end\n  end\nend\n"
  },
  {
    "path": "spec/support/sidekiq.rb",
    "content": "require 'sidekiq/testing'\n\nRSpec.configure do |config|\n  config.before(:each) do\n    Sidekiq::Worker.clear_all\n  end\nend\n"
  },
  {
    "path": "spec/views/slack/interactive.html.erb_spec.rb",
    "content": "require 'rails_helper'\n\nRSpec.describe \"slack/interactive.html.erb\", type: :view do\n  pending \"add some examples to (or delete) #{__FILE__}\"\nend\n"
  },
  {
    "path": "vendor/assets/javascripts/.keep",
    "content": ""
  },
  {
    "path": "vendor/assets/stylesheets/.keep",
    "content": ""
  }
]