Commit d008855b authored by Marco Metz's avatar Marco Metz
Browse files

Pushes a Notification to the DashboardApp to notify that a chronjob occured

CronjobService::Notifier.push("project_id", "cronjob_tilte“, options_hash)
parents
source 'https://rubygems.org'
# Specify your gem's dependencies in cronjob_service.gemspec
gemspec
PATH
remote: .
specs:
cronjob_service (1.0.0)
GEM
remote: https://rubygems.org/
specs:
rake (10.5.0)
PLATFORMS
ruby
DEPENDENCIES
bundler (~> 1.7)
cronjob_service!
rake (~> 10.0)
BUNDLED WITH
1.14.6
Copyright (c) 2014 Marco Metz
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# CronjobService
Pushes a Notification to the DashboardApp to notify that a chronjob occured
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'cronjob_service', git: "ssh://git@git.ikusei.de:7999/ik/cronjobnotificationtodashboard.git"
```
And then execute:
$ bundle
## Usage
```ruby
CronjobService::Notifier.push("project_id", "cronjob_tilte")
```
```ruby
CronjobService::Notifier.push("project_id", "cronjob_tilte", description: "My Description", foo: "bar")
```
## Develop
```ruby
rake console
```
\ No newline at end of file
require "bundler/gem_tasks"
task :console do
exec "irb -r cronjob_service -I ./lib"
end
# encoding: utf-8
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cronjob_service/version'
Gem::Specification.new do |spec|
spec.name = "cronjob_service"
spec.version = CronjobService::VERSION
spec.authors = ["Marco Metz"]
spec.email = ["marco.metz@gmail.com"]
spec.summary = %q{Push a Notification to dashboard app}
spec.description = %q{Push a Notification to dashboard app at https://dashboard.dev-ikusei.de/cronjobs}
spec.homepage = "https://git.ikusei.de/projects/IK/repos/cronjobnotificationtodashboard/browse"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
end
# encoding: utf-8
require 'open-uri'
require "cronjob_service/version"
module CronjobService
class Notifier
def self.push(project_id, cron_identifier, options = {})
raise "project_id missing" if project_id.nil?
raise "cron_identifier missing" if cron_identifier.nil?
base_url = "https://dashboard.dev-ikusei.de/api/v1/cronjob"
parameterized_options = options.map { |key, value| "&#{key}=#{value}"}.join
post_url = ["#{base_url}/#{project_id}?title=#{cron_identifier}", parameterized_options].join("&")
begin
open(post_url).read
rescue
puts "https://dashboard.dev-ikusei.de ist nicht erreichbar"
end
end
end
end
# encoding: utf-8
module CronjobService
VERSION = "1.0.0"
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment