diff --git a/Gemfile b/Gemfile index 0f00e09..3d9ff26 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source "https://rubygems.org" gem 'blasphemy' +gem 'faker' gem 'httparty' gem 'slop' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 6f0a2f3..2d07d81 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,9 +2,12 @@ GEM remote: https://rubygems.org/ specs: blasphemy (0.2.0) + faker (1.4.3) + i18n (~> 0.5) httparty (0.9.0) multi_json (~> 1.0) multi_xml + i18n (0.7.0) multi_json (1.3.5) multi_xml (0.5.1) slop (3.5.0) @@ -14,5 +17,6 @@ PLATFORMS DEPENDENCIES blasphemy + faker httparty slop diff --git a/bin/samuel-incident b/bin/samuel-incident index 26cb6ca..f2421d6 100755 --- a/bin/samuel-incident +++ b/bin/samuel-incident @@ -10,6 +10,7 @@ opts = Slop.parse(help: true) do on :s, :service=, 'service guid' on :d, :domain=, 'host' on :n, :number=, 'number of incidents', as: Integer + on :safe=, 'safe for work', as: Integer end if opts[:service].nil? @@ -19,8 +20,9 @@ end options_hash = opts.to_hash number_of_times = options_hash[:number] || 1 +safe_for_work = options_hash[:safe] == 1 || true -event_creator = EventCreator.new(options_hash[:host] || 'https://events.pagerduty.com/', options_hash[:service]) +event_creator = EventCreator.new(options_hash[:host] || 'https://events.pagerduty.com/', options_hash[:service], safe_for_work) puts "Creating #{number_of_times} incident(s)..." for i in 0...number_of_times puts event_creator.post diff --git a/lib/generator.rb b/lib/generator.rb index cf74c46..ef4d499 100644 --- a/lib/generator.rb +++ b/lib/generator.rb @@ -1,6 +1,7 @@ require 'blasphemy' require 'httparty' require 'json' +require 'faker' class EventCreator include HTTParty @@ -10,26 +11,30 @@ class EventCreator attr_accessor :service_key, :base_uri - def initialize(host, service) + def initialize(host, service, safe_for_work) @service_key = service @base_uri = host + @sfw = safe_for_work end def generate_event bacon = Faker::BaconIpsum.new + hacker = Faker::Hacker sam = Faker::SamuelLIpsum.new { :service_key => @service_key, :event_type => 'trigger', - :description => bacon.sentence, + :description => hacker.say_something_smart, :contexts => [ { - 'href' => 'https://www.youtube.com/watch?v=oUltheRpJNw', - 'type' => 'image', - 'src' => 'http://www.placecage.com/gif/300/180' + 'href' => 'http://www.pagerduty.com', + 'type' => 'link', + 'text' => 'Incident Report' } ], :details => { - :quote => sam.paragraph + :mac_address => Faker::Internet.mac_address, + :ip_addr => Faker::Internet.ip_v4_address, + :quote => @sfw ? bacon.paragraph : sam.paragraph } }.to_json end