pagerduty_cli 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +14 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +53 -0
 - data/Rakefile +2 -0
 - data/bin/pagerduty-resolve +8 -0
 - data/bin/pagerduty-trigger +8 -0
 - data/lib/pagerduty_cli.rb +7 -0
 - data/lib/pagerduty_cli/common.rb +61 -0
 - data/lib/pagerduty_cli/resolve.rb +37 -0
 - data/lib/pagerduty_cli/trigger.rb +82 -0
 - data/lib/pagerduty_cli/version.rb +4 -0
 - data/pagerduty_cli.gemspec +27 -0
 - data/spec/pagerduty_cli_spec.rb +174 -0
 - data/spec/spec_helper.rb +14 -0
 - metadata +106 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0d4f3f309ba8e989ee26ce922e3a4fd79f6836fc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 6ad7430c264960dd7f97079ef352dc85b0f47405
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: daff2bce60dfda39f8557ccc209ed98ba29c2c8675c7f41aea1e426fd2a0c63bbddcdadf2ee85ff251da9fd71cf4c4b91068dfd2ebad26bc9fa4476d5b9f020b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8093c58396762102b66f3a56862f48f7a838dccd40d2c2996cd18a5ffcb3700f9dd2a0d14bce003fa511c796f9cab03585ec714e246b65a8c927ed080afd889a
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2014 Justin Dossey
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,53 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # PagerdutyCli
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            A Ruby-based CLI to PagerDuty. Supports triggers and resolves.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Inspired by Pinterest's Python implementation:
         
     | 
| 
      
 6 
     | 
    
         
            +
            https://github.com/pinterest/pagerduty-monit
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Requires Ruby >= 1.9.3.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Add to your Gemfile:
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 15 
     | 
    
         
            +
            gem 'pagerduty_cli'
         
     | 
| 
      
 16 
     | 
    
         
            +
            ```
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                $ gem install pagerduty_cli
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            Trigger an event with
         
     | 
| 
      
 29 
     | 
    
         
            +
            ```
         
     | 
| 
      
 30 
     | 
    
         
            +
            pagerduty-trigger -e EVENT_NAME
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            See all options with:
         
     | 
| 
      
 34 
     | 
    
         
            +
            ```
         
     | 
| 
      
 35 
     | 
    
         
            +
            pagerduty-trigger -h
         
     | 
| 
      
 36 
     | 
    
         
            +
            ```
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            Resolve an event with
         
     | 
| 
      
 39 
     | 
    
         
            +
            ```
         
     | 
| 
      
 40 
     | 
    
         
            +
            pagerduty-resolve -e EVENT_NAME
         
     | 
| 
      
 41 
     | 
    
         
            +
            ```
         
     | 
| 
      
 42 
     | 
    
         
            +
            See all options with:
         
     | 
| 
      
 43 
     | 
    
         
            +
            ```
         
     | 
| 
      
 44 
     | 
    
         
            +
            pagerduty-resolve -h
         
     | 
| 
      
 45 
     | 
    
         
            +
            ```
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            1. Fork it ( https://github.com/[my-github-username]/pagerduty_cli/fork )
         
     | 
| 
      
 50 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 51 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 52 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 53 
     | 
    
         
            +
            5. Create a new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Module for common functionality to pagerduty CLI classes
         
     | 
| 
      
 2 
     | 
    
         
            +
            module PagerdutyCli
         
     | 
| 
      
 3 
     | 
    
         
            +
              # Common functionality to pagerduty interaction
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Common
         
     | 
| 
      
 5 
     | 
    
         
            +
                API_KEY_FILE = '/etc/pagerduty_api.key'
         
     | 
| 
      
 6 
     | 
    
         
            +
                def load_data
         
     | 
| 
      
 7 
     | 
    
         
            +
                  @api_key = File.open(@options[:api_key_file]).read.chomp
         
     | 
| 
      
 8 
     | 
    
         
            +
                rescue Errno::ENOENT, Errno::EPERM
         
     | 
| 
      
 9 
     | 
    
         
            +
                  croak("Could not open PD API key file at #{@options[:api_key_file]}.")
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def croak(message)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  $stderr.puts "#{@me} Error: #{message} Exiting."
         
     | 
| 
      
 14 
     | 
    
         
            +
                  exit 1
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def warn(message)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  $stderr.puts "#{@me} Warning: #{message}"
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def incident_key
         
     | 
| 
      
 22 
     | 
    
         
            +
                  event_key = "#{@options[:host]}:#{@options[:event]}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                  Digest::SHA1.hexdigest(event_key)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # return the name for our incident state file.
         
     | 
| 
      
 27 
     | 
    
         
            +
                def incident_file
         
     | 
| 
      
 28 
     | 
    
         
            +
                  File.join(@options[:tmpdir], "pagerduty-#{incident_key}")
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                # Disabling the MethodLength cop here because any reduction would reduce
         
     | 
| 
      
 32 
     | 
    
         
            +
                # readability.
         
     | 
| 
      
 33 
     | 
    
         
            +
                # rubocop:disable MethodLength
         
     | 
| 
      
 34 
     | 
    
         
            +
                def parse_common_options(opts)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  opts.banner = "Usage: #{@me} [options]"
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @options ||= {}
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @options.merge!(host: ENV['HOSTNAME'],
         
     | 
| 
      
 38 
     | 
    
         
            +
                                  api_key_file: API_KEY_FILE,
         
     | 
| 
      
 39 
     | 
    
         
            +
                                  tmpdir: '/tmp')
         
     | 
| 
      
 40 
     | 
    
         
            +
                  opts.on('-H', '--host HOST', 'Report from the hostname given') do |h|
         
     | 
| 
      
 41 
     | 
    
         
            +
                    @options[:host] = h
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                  opts.on('-k', '--keyfile KEYFILE',
         
     | 
| 
      
 44 
     | 
    
         
            +
                          'Use the key specified in file KEYFILE') do |kf|
         
     | 
| 
      
 45 
     | 
    
         
            +
                    @options[:api_key_file] = kf
         
     | 
| 
      
 46 
     | 
    
         
            +
                          end
         
     | 
| 
      
 47 
     | 
    
         
            +
                  opts.on('-e', '--event EVENT', 'Report the event given') do |e|
         
     | 
| 
      
 48 
     | 
    
         
            +
                    @options[:event] = e
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
                  opts.on('-t', '--tmpdir PATH',
         
     | 
| 
      
 51 
     | 
    
         
            +
                          'location for incident files') do |tmp|
         
     | 
| 
      
 52 
     | 
    
         
            +
                    @options[:tmpdir] = tmp
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
                  opts.on_tail('-h', '--help', 'Show this message') do
         
     | 
| 
      
 55 
     | 
    
         
            +
                    $stderr.puts opts
         
     | 
| 
      
 56 
     | 
    
         
            +
                    exit
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
                # rubocop:enable MethodLength
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Class to send resolutions to PagerDuty.
         
     | 
| 
      
 2 
     | 
    
         
            +
            module PagerdutyCli
         
     | 
| 
      
 3 
     | 
    
         
            +
              # Send a resolve to PagerDuty.
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Resolve
         
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize(args)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @me = 'pagerduty_resolve'
         
     | 
| 
      
 7 
     | 
    
         
            +
                  parse_opts(args)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  load_data
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def self.resolve(args)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  new(args).send_resolve
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def send_resolve
         
     | 
| 
      
 16 
     | 
    
         
            +
                  Pagerduty.new(@api_key).get_incident(incident_key).resolve
         
     | 
| 
      
 17 
     | 
    
         
            +
                  remove_incident_file
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                private
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                include PagerdutyCli::Common
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def parse_opts(args)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  opt_parser = OptionParser.new do |opts|
         
     | 
| 
      
 26 
     | 
    
         
            +
                    parse_common_options(opts)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                  opt_parser.parse! args
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def remove_incident_file
         
     | 
| 
      
 32 
     | 
    
         
            +
                  File.delete(incident_file)
         
     | 
| 
      
 33 
     | 
    
         
            +
                rescue Errno::ENOENT
         
     | 
| 
      
 34 
     | 
    
         
            +
                  warn("No incident file found at #{incident_file}")
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,82 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'optparse'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'pagerduty'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'digest/sha1'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require_relative 'common'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # Send a PagerDuty alert.
         
     | 
| 
      
 10 
     | 
    
         
            +
            module PagerdutyCli
         
     | 
| 
      
 11 
     | 
    
         
            +
              # Send a trigger to PagerDuty
         
     | 
| 
      
 12 
     | 
    
         
            +
              class Trigger
         
     | 
| 
      
 13 
     | 
    
         
            +
                def initialize(args)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @me = 'pagerduty_trigger'
         
     | 
| 
      
 15 
     | 
    
         
            +
                  parse_opts(args)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  load_data
         
     | 
| 
      
 17 
     | 
    
         
            +
                  return unless @options[:force] || !incident_is_too_fresh?
         
     | 
| 
      
 18 
     | 
    
         
            +
                  touch_incident_file unless @options[:no_touch]
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 22 
     | 
    
         
            +
                  def trigger(args)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    new(args).send_trigger
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                def send_trigger
         
     | 
| 
      
 28 
     | 
    
         
            +
                  Pagerduty.new(@api_key).trigger(incident_description,
         
     | 
| 
      
 29 
     | 
    
         
            +
                                                  incident_key: incident_key,
         
     | 
| 
      
 30 
     | 
    
         
            +
                                                  client: @options[:host])
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                private
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                include PagerdutyCli::Common
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                # Disabling the MethodLength cop here because any reduction would reduce
         
     | 
| 
      
 38 
     | 
    
         
            +
                # readability.
         
     | 
| 
      
 39 
     | 
    
         
            +
                # rubocop:disable MethodLength
         
     | 
| 
      
 40 
     | 
    
         
            +
                def parse_opts(args)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  # default options
         
     | 
| 
      
 42 
     | 
    
         
            +
                  @options = {}
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @options[:interval] = (4 * 60 * 60 + 1)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  opt_parser = OptionParser.new do |opts|
         
     | 
| 
      
 46 
     | 
    
         
            +
                    parse_common_options(opts)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    opts.on('-f', '--force',
         
     | 
| 
      
 48 
     | 
    
         
            +
                            'Force the event to process, even if not fresh') do
         
     | 
| 
      
 49 
     | 
    
         
            +
                      @options[:force] = true
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                    opts.on('-n', '--no-incident',
         
     | 
| 
      
 52 
     | 
    
         
            +
                            'Do not record sending this incident') do
         
     | 
| 
      
 53 
     | 
    
         
            +
                      @options[:no_touch] = true
         
     | 
| 
      
 54 
     | 
    
         
            +
                    end
         
     | 
| 
      
 55 
     | 
    
         
            +
                    opts.on('-i', '--touch-interval INTERVAL',
         
     | 
| 
      
 56 
     | 
    
         
            +
                            'Specify freshness interval in seconds') do |interval|
         
     | 
| 
      
 57 
     | 
    
         
            +
                      @options[:interval] = interval.to_i
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                  opt_parser.parse! args
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
                # rubocop:enable MethodLength
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                # return true if this incident has been reported in the past 4 hrs 1 min
         
     | 
| 
      
 65 
     | 
    
         
            +
                def incident_is_too_fresh?
         
     | 
| 
      
 66 
     | 
    
         
            +
                  cutoff = Time.now - @options[:interval]
         
     | 
| 
      
 67 
     | 
    
         
            +
                  File.exist?(incident_file) && File.mtime(incident_file) > cutoff
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                def incident_description
         
     | 
| 
      
 71 
     | 
    
         
            +
                  "#{@options[:event]} failed on #{@options[:host]}"
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                def touch_incident_file
         
     | 
| 
      
 75 
     | 
    
         
            +
                  File.open(incident_file, 'a') do |f|
         
     | 
| 
      
 76 
     | 
    
         
            +
                    f.puts "#{Time.now}: #{incident_description}"
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
                rescue Errno::EPERM
         
     | 
| 
      
 79 
     | 
    
         
            +
                  croak("Could not write incident file #{incident_file.inspect}")
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'pagerduty_cli/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = 'pagerduty_cli'
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = PagerdutyCli::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ['Justin Dossey']
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ['justin.dossey@newcontext.com']
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = 'ruby CLI for PagerDuty API'
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = 'ruby CLI for PagerDuty API. '\
         
     | 
| 
      
 13 
     | 
    
         
            +
                'Supports sending triggers and resolves.'
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage      = 'https://github.com/justindossey/pagerduty_cli'
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.license       = 'MIT'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              spec.bindir        = 'bin'
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.executables   = spec.files.grep(/^bin\//) { |f| File.basename(f) }
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(/^(test|spec|features)\//)
         
     | 
| 
      
 21 
     | 
    
         
            +
              spec.require_paths = ['lib']
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_runtime_dependency 'pagerduty', '~> 2.0.0'
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency 'bundler', '~> 1.7'
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_development_dependency 'rake', '~> 10.0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,174 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe PagerdutyCli do
         
     | 
| 
      
 5 
     | 
    
         
            +
              it 'defines the PagerdutyCli module' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                expect(PagerdutyCli).to be_a(Module)
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              it 'defines the PagerdutyCli::Common module' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                expect(PagerdutyCli::Common).to be_a(Module)
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
              it 'croaks properly' do
         
     | 
| 
      
 12 
     | 
    
         
            +
                # stub for testing the cli
         
     | 
| 
      
 13 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 14 
     | 
    
         
            +
                out = 'Stub Actor Error: hi Exiting.'
         
     | 
| 
      
 15 
     | 
    
         
            +
                allow($stderr).to receive(:puts).with(out).and_return(out)
         
     | 
| 
      
 16 
     | 
    
         
            +
                expect { stub_actor.croak('hi') }.to raise_error(SystemExit)
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect($stderr).to have_received(:puts).with(out)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it 'warns properly' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 22 
     | 
    
         
            +
                out = 'Stub Actor Warning: hi'
         
     | 
| 
      
 23 
     | 
    
         
            +
                allow($stderr).to receive(:puts).with(out).and_return(out)
         
     | 
| 
      
 24 
     | 
    
         
            +
                stub_actor.warn('hi')
         
     | 
| 
      
 25 
     | 
    
         
            +
                expect($stderr).to have_received(:puts).with(out)
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              it 'generates the same key for triggers and resolves' do
         
     | 
| 
      
 29 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 30 
     | 
    
         
            +
                stub_actor.options[:host] = 'foo'
         
     | 
| 
      
 31 
     | 
    
         
            +
                stub_actor.options[:event] = 'bar'
         
     | 
| 
      
 32 
     | 
    
         
            +
                allow(Digest::SHA1).to receive(:hexdigest).with('foo:bar')
         
     | 
| 
      
 33 
     | 
    
         
            +
                stub_actor.incident_key
         
     | 
| 
      
 34 
     | 
    
         
            +
                expect(Digest::SHA1).to have_received(:hexdigest).with('foo:bar')
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              it 'generates a valid incident filename' do
         
     | 
| 
      
 38 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 39 
     | 
    
         
            +
                stub_actor.options[:host] = 'foo'
         
     | 
| 
      
 40 
     | 
    
         
            +
                stub_actor.options[:event] = 'bar'
         
     | 
| 
      
 41 
     | 
    
         
            +
                stub_actor.options[:tmpdir] = '/FAKETEMP'
         
     | 
| 
      
 42 
     | 
    
         
            +
                allow(stub_actor).to receive(:incident_key).and_return('x')
         
     | 
| 
      
 43 
     | 
    
         
            +
                expect(stub_actor.incident_file).to eq('/FAKETEMP/pagerduty-x')
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              it 'bails when no API key is loaded' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 48 
     | 
    
         
            +
                stub_actor.options[:api_key_file] = 'nonexistent_file'
         
     | 
| 
      
 49 
     | 
    
         
            +
                allow(stub_actor).to receive(:croak)
         
     | 
| 
      
 50 
     | 
    
         
            +
                stub_actor.load_data
         
     | 
| 
      
 51 
     | 
    
         
            +
                expect(stub_actor).to have_received(:croak)
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              it 'defines the PagerdutyCli::Trigger class' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                expect(PagerdutyCli::Trigger).to be_a(Class)
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
              it 'processes common PagerdutyCli options' do
         
     | 
| 
      
 59 
     | 
    
         
            +
                args = %w(-H foo -k bar -e baz -t /var/tmp)
         
     | 
| 
      
 60 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 61 
     | 
    
         
            +
                stub_optionparser = OptionParser.new
         
     | 
| 
      
 62 
     | 
    
         
            +
                stub_actor.parse_common_options(stub_optionparser)
         
     | 
| 
      
 63 
     | 
    
         
            +
                stub_optionparser.parse!(args)
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                expect(stub_actor.options[:host]).to eq('foo')
         
     | 
| 
      
 66 
     | 
    
         
            +
                expect(stub_actor.options[:api_key_file]).to eq('bar')
         
     | 
| 
      
 67 
     | 
    
         
            +
                expect(stub_actor.options[:tmpdir]).to eq('/var/tmp')
         
     | 
| 
      
 68 
     | 
    
         
            +
                expect(stub_actor.options[:event]).to eq('baz')
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              it 'supports correct defaults' do
         
     | 
| 
      
 72 
     | 
    
         
            +
                args = %w(-e foo)
         
     | 
| 
      
 73 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 74 
     | 
    
         
            +
                stub_optionparser = OptionParser.new
         
     | 
| 
      
 75 
     | 
    
         
            +
                stub_actor.parse_common_options(stub_optionparser)
         
     | 
| 
      
 76 
     | 
    
         
            +
                stub_optionparser.parse!(args)
         
     | 
| 
      
 77 
     | 
    
         
            +
                expect(stub_actor.options[:host]).to eq(ENV['HOSTNAME'])
         
     | 
| 
      
 78 
     | 
    
         
            +
                expect(stub_actor.options[:api_key_file])
         
     | 
| 
      
 79 
     | 
    
         
            +
                  .to eq(PagerdutyCli::Common::API_KEY_FILE)
         
     | 
| 
      
 80 
     | 
    
         
            +
                expect(stub_actor.options[:tmpdir]).to eq('/tmp')
         
     | 
| 
      
 81 
     | 
    
         
            +
                expect(stub_actor.options[:event]).to eq('foo')
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              it 'prints help and exits with -h' do
         
     | 
| 
      
 85 
     | 
    
         
            +
                args = %w(-h)
         
     | 
| 
      
 86 
     | 
    
         
            +
                stub_actor = StubPagerdutyCliActor.new
         
     | 
| 
      
 87 
     | 
    
         
            +
                stub_optionparser = OptionParser.new
         
     | 
| 
      
 88 
     | 
    
         
            +
                stub_actor.parse_common_options(stub_optionparser)
         
     | 
| 
      
 89 
     | 
    
         
            +
                allow($stderr).to receive(:puts)
         
     | 
| 
      
 90 
     | 
    
         
            +
                expect { stub_optionparser.parse!(args) }.to raise_error(SystemExit)
         
     | 
| 
      
 91 
     | 
    
         
            +
                expect($stderr).to have_received(:puts)
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              it 'processes trigger options' do
         
     | 
| 
      
 95 
     | 
    
         
            +
                args = %w(-f -n -i 600 -e foo)
         
     | 
| 
      
 96 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Trigger).to receive(:load_data)
         
     | 
| 
      
 97 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Trigger)
         
     | 
| 
      
 98 
     | 
    
         
            +
                  .to receive(:touch_incident_file)
         
     | 
| 
      
 99 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Trigger)
         
     | 
| 
      
 100 
     | 
    
         
            +
                  .to receive(:incident_is_too_fresh?).and_return(true)
         
     | 
| 
      
 101 
     | 
    
         
            +
                PagerdutyCli::Trigger.class_eval('attr_reader :options')
         
     | 
| 
      
 102 
     | 
    
         
            +
                trigger = PagerdutyCli::Trigger.new(args)
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                expect(trigger.options).to be_a(Hash)
         
     | 
| 
      
 105 
     | 
    
         
            +
                expect(trigger.options[:force]).to be_truthy
         
     | 
| 
      
 106 
     | 
    
         
            +
                expect(trigger.options[:no_touch]).to be_truthy
         
     | 
| 
      
 107 
     | 
    
         
            +
                expect(trigger.options[:interval]).to eq(600)
         
     | 
| 
      
 108 
     | 
    
         
            +
                expect(trigger.options[:event]).to eq('foo')
         
     | 
| 
      
 109 
     | 
    
         
            +
              end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
              it 'places tmp files in the right location' do
         
     | 
| 
      
 112 
     | 
    
         
            +
                args = %w(-e foo)
         
     | 
| 
      
 113 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Trigger)
         
     | 
| 
      
 114 
     | 
    
         
            +
                  .to receive(:incident_is_too_fresh?).and_return(false)
         
     | 
| 
      
 115 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Trigger).to receive(:load_data)
         
     | 
| 
      
 116 
     | 
    
         
            +
                trigger = PagerdutyCli::Trigger.new(args)
         
     | 
| 
      
 117 
     | 
    
         
            +
                string_buffer = StringIO.new
         
     | 
| 
      
 118 
     | 
    
         
            +
                allow(File).to receive(:open).and_return(string_buffer)
         
     | 
| 
      
 119 
     | 
    
         
            +
                allow(trigger).to receive(:incident_key).and_return('abc')
         
     | 
| 
      
 120 
     | 
    
         
            +
                trigger.send(:touch_incident_file)
         
     | 
| 
      
 121 
     | 
    
         
            +
                expect(File).to have_received(:open).with('/tmp/pagerduty-abc', 'a')
         
     | 
| 
      
 122 
     | 
    
         
            +
              end
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
              it 'allows triggers to be sent via class method' do
         
     | 
| 
      
 125 
     | 
    
         
            +
                args = %w(-e foo)
         
     | 
| 
      
 126 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Trigger).to receive(:load_data)
         
     | 
| 
      
 127 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Trigger)
         
     | 
| 
      
 128 
     | 
    
         
            +
                  .to receive(:send_trigger).and_return('bar')
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                expect(PagerdutyCli::Trigger.trigger(args)).to eq('bar')
         
     | 
| 
      
 131 
     | 
    
         
            +
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
              it 'defines the PagerdutyCli::Resolve class' do
         
     | 
| 
      
 134 
     | 
    
         
            +
                expect(PagerdutyCli::Resolve).to be_a(Class)
         
     | 
| 
      
 135 
     | 
    
         
            +
              end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              it 'processes all options to resolve' do
         
     | 
| 
      
 138 
     | 
    
         
            +
                args = %w(-H foo -k bar -e baz -t /var/tmp)
         
     | 
| 
      
 139 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Resolve).to receive(:load_data)
         
     | 
| 
      
 140 
     | 
    
         
            +
                PagerdutyCli::Resolve.class_eval('attr_reader :options')
         
     | 
| 
      
 141 
     | 
    
         
            +
                resolver = PagerdutyCli::Resolve.new(args)
         
     | 
| 
      
 142 
     | 
    
         
            +
                expect(resolver.options[:host]).to eq('foo')
         
     | 
| 
      
 143 
     | 
    
         
            +
                expect(resolver.options[:api_key_file]).to eq('bar')
         
     | 
| 
      
 144 
     | 
    
         
            +
                expect(resolver.options[:event]).to eq('baz')
         
     | 
| 
      
 145 
     | 
    
         
            +
                expect(resolver.options[:tmpdir]).to eq('/var/tmp')
         
     | 
| 
      
 146 
     | 
    
         
            +
              end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
              it 'removes tmp files in the right location' do
         
     | 
| 
      
 149 
     | 
    
         
            +
                # stub pagerduty API so we can resolve without getting too deep
         
     | 
| 
      
 150 
     | 
    
         
            +
                class FakePagerDuty
         
     | 
| 
      
 151 
     | 
    
         
            +
                end
         
     | 
| 
      
 152 
     | 
    
         
            +
                my_fake_pagerduty = FakePagerDuty.new
         
     | 
| 
      
 153 
     | 
    
         
            +
                allow(my_fake_pagerduty).to receive(:resolve).and_return(true)
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                allow_any_instance_of(Pagerduty)
         
     | 
| 
      
 156 
     | 
    
         
            +
                  .to receive(:get_incident).and_return(my_fake_pagerduty)
         
     | 
| 
      
 157 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Resolve)
         
     | 
| 
      
 158 
     | 
    
         
            +
                  .to receive(:incident_file).and_return('foo')
         
     | 
| 
      
 159 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Resolve).to receive(:load_data)
         
     | 
| 
      
 160 
     | 
    
         
            +
                allow(File).to receive(:delete).with('foo').and_return(true)
         
     | 
| 
      
 161 
     | 
    
         
            +
                PagerdutyCli::Resolve.resolve(%w(-e abc))
         
     | 
| 
      
 162 
     | 
    
         
            +
                expect(File).to have_received(:delete).with('foo')
         
     | 
| 
      
 163 
     | 
    
         
            +
                expect(my_fake_pagerduty).to have_received(:resolve)
         
     | 
| 
      
 164 
     | 
    
         
            +
              end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
              it 'allows resolves to be sent via class method' do
         
     | 
| 
      
 167 
     | 
    
         
            +
                args = %w(-e foo)
         
     | 
| 
      
 168 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Resolve).to receive(:load_data)
         
     | 
| 
      
 169 
     | 
    
         
            +
                allow_any_instance_of(PagerdutyCli::Resolve)
         
     | 
| 
      
 170 
     | 
    
         
            +
                  .to receive(:send_resolve).and_return('bar')
         
     | 
| 
      
 171 
     | 
    
         
            +
                expect(PagerdutyCli::Resolve.resolve(args)).to eq('bar')
         
     | 
| 
      
 172 
     | 
    
         
            +
              end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,106 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: pagerduty_cli
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Justin Dossey
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-12-06 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: pagerduty
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1.7'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '1.7'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            description: ruby CLI for PagerDuty API. Supports sending triggers and resolves.
         
     | 
| 
      
 56 
     | 
    
         
            +
            email:
         
     | 
| 
      
 57 
     | 
    
         
            +
            - justin.dossey@newcontext.com
         
     | 
| 
      
 58 
     | 
    
         
            +
            executables:
         
     | 
| 
      
 59 
     | 
    
         
            +
            - pagerduty-resolve
         
     | 
| 
      
 60 
     | 
    
         
            +
            - pagerduty-trigger
         
     | 
| 
      
 61 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 62 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 63 
     | 
    
         
            +
            files:
         
     | 
| 
      
 64 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 65 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 66 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 67 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 68 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 69 
     | 
    
         
            +
            - bin/pagerduty-resolve
         
     | 
| 
      
 70 
     | 
    
         
            +
            - bin/pagerduty-trigger
         
     | 
| 
      
 71 
     | 
    
         
            +
            - lib/pagerduty_cli.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - lib/pagerduty_cli/common.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/pagerduty_cli/resolve.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - lib/pagerduty_cli/trigger.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/pagerduty_cli/version.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - pagerduty_cli.gemspec
         
     | 
| 
      
 77 
     | 
    
         
            +
            - spec/pagerduty_cli_spec.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 79 
     | 
    
         
            +
            homepage: https://github.com/justindossey/pagerduty_cli
         
     | 
| 
      
 80 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 81 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 82 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 83 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 84 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 85 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 86 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 87 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 88 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 89 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 90 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 91 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 92 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 93 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 94 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 95 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 96 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 97 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 98 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 99 
     | 
    
         
            +
            rubygems_version: 2.4.1
         
     | 
| 
      
 100 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 101 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 102 
     | 
    
         
            +
            summary: ruby CLI for PagerDuty API
         
     | 
| 
      
 103 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 104 
     | 
    
         
            +
            - spec/pagerduty_cli_spec.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
            has_rdoc: 
         
     |