exception_notification-ikachan 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d36d1fcfabd7fab2c2fd82a5ac0bcf93bc9ac8f7
4
+ data.tar.gz: 322666c6c4a3b7c7ab4e2d2938a38163ab1a2719
5
+ SHA512:
6
+ metadata.gz: 207b882420e3f7562c28a98cb464b1e6fba2b69342f4cab8ea60b6c91545572d66c7e7a04e4163ddc0bd4ba162a007c639a035e58e44c23cf6d6b207dd16a524
7
+ data.tar.gz: ea8f7a77c755159f3a13f3d34c355db759cfd618855e3f03ed75e799fdfaa0ae8021d5bf8946e003f1da15db41d6d54d053461456b24428f7fea0192d080c80f
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exception_notification-ikachan.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Uchio KONDO
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,39 @@
1
+ # ExceptionNotification::Ikachan
2
+
3
+ ExceptionNotification plugin for Ikachan!!!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'exception_notification-ikachan'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install exception_notification-ikachan
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ FooBar::Application.configure do
23
+ config.middleware.use ExceptionNotification::Rack,
24
+ ikachan: {
25
+ channel: '#udzura',
26
+ base_url: 'ikachan.example.com:8080'
27
+ }
28
+ end
29
+ ```
30
+
31
+ `:message_format` like `"%{class}: %{message}"` also available.
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
@@ -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 'exception_notification/ikachan/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "exception_notification-ikachan"
8
+ spec.version = ExceptionNotification::Ikachan::VERSION
9
+ spec.authors = ["Uchio KONDO"]
10
+ spec.email = ["udzura@paperboy.co.jp"]
11
+ spec.description = %q{ExceptionNotification ikachan plugin}
12
+ spec.summary = %q{ExceptionNotification ikachan plugin}
13
+ spec.homepage = "https://github.com/udzura/exception_notification-ikachan"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "exception_notification", ">= 3.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "webmock"
27
+ end
@@ -0,0 +1,5 @@
1
+ module ExceptionNotification
2
+ class Ikachan
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'exception_notifier/ikachan_notifier'
@@ -0,0 +1,68 @@
1
+ require "exception_notification/ikachan/version"
2
+ require 'net/http'
3
+
4
+ module ExceptionNotifier
5
+ class IkachanNotifier
6
+ class Client
7
+ def initialize(base_url)
8
+ @base_url = base_url.match(/^https?:\/\/[^\/]+\//) ? base_url : "http://#{base_url}/"
9
+ end
10
+ attr_reader :base_url
11
+
12
+ def notice_all(channels, message)
13
+ channels.each do |channel|
14
+ join(channel)
15
+ notice(channel, message)
16
+ end
17
+ end
18
+
19
+ private
20
+ def join(channel)
21
+ dispatch :join, 'channel' => channel
22
+ end
23
+
24
+ def notice(channel, message)
25
+ dispatch :notice, 'channel' => channel, 'message' => message
26
+ end
27
+
28
+ def dispatch(type, params = {})
29
+ uri = URI.parse "#{base_url}#{type.to_s}"
30
+ Net::HTTP.post_form uri, params
31
+ end
32
+ end
33
+
34
+ def initialize(options)
35
+ channel = options[:channels] || options[:channel]
36
+ if !channel or !options[:base_url]
37
+ raise "Some of option is missing: %s" % options
38
+ end
39
+
40
+ @channels = channel.is_a?(Array) ? channel : [channel]
41
+ @client = Client.new(options[:base_url])
42
+ @message_format = build_message_format(options)
43
+ end
44
+ attr_reader :client, :channels, :message_format
45
+
46
+ def call(exception, options = {})
47
+ client.notice_all(channels, build_message(exception))
48
+ end
49
+
50
+ private
51
+ def build_message_format(options)
52
+ return options[:message_format] if options[:message_format]
53
+ "\x02\x0315,4[ERROR]\x03 \x0313%{class}\x03 - \x038%{message}\x03, %{occurred}\x0f"
54
+ end
55
+
56
+ def build_message(exception)
57
+ params = {
58
+ class: exception.class,
59
+ message: exception.message,
60
+ occurred: (exception.backtrace.first rescue nil),
61
+ }
62
+ return message_format % params
63
+ end
64
+
65
+ # alias
66
+ VERSION = ExceptionNotification::Ikachan::VERSION
67
+ end
68
+ end
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ describe ExceptionNotifier::IkachanNotifier do
4
+ let(:notifier) { ExceptionNotifier::IkachanNotifier.new(options) }
5
+
6
+ describe "initial options" do
7
+ let(:options) do
8
+ {
9
+ base_url: 'ikachan.udzura.jp',
10
+ channel: '#udzura',
11
+ message_format: '%{class}: %{message}'
12
+ }
13
+ end
14
+
15
+ describe ":base_url" do
16
+ it "should set client's base_url" do
17
+ expect(notifier.client.base_url).to eq("http://ikachan.udzura.jp/")
18
+ end
19
+ end
20
+ end
21
+
22
+ describe "#call" do
23
+ let(:options) do
24
+ {
25
+ base_url: 'ikachan.udzura.jp',
26
+ channel: '#udzura',
27
+ message_format: '%{class}: %{message}'
28
+ }
29
+ end
30
+ let(:exception) { StandardError.new("Hello, exception!")}
31
+
32
+ it "should notice message to ikachan" do
33
+ stub_join = stub_request(:post, "http://ikachan.udzura.jp/join").
34
+ with(body: {"channel" => "#udzura"})
35
+ stub_notice = stub_request(:post, "http://ikachan.udzura.jp/notice").
36
+ with(body: {"channel" => "#udzura", "message" => "StandardError: Hello, exception!"})
37
+
38
+ notifier.call(exception, {})
39
+ stub_join.should have_been_requested.once
40
+ stub_notice.should have_been_requested.once
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require 'webmock/rspec'
9
+ require 'exception_notification-ikachan'
10
+
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+
22
+ config.before do
23
+ WebMock.disable_net_connect!
24
+ end
25
+ end
data/wercker.yml ADDED
@@ -0,0 +1,8 @@
1
+ box: wercker/ruby
2
+ # http://devcenter.wercker.com/articles/languages/ruby.html
3
+ build:
4
+ steps:
5
+ - bundle-install
6
+ - script:
7
+ name: Running rake spec
8
+ code: bundle exec rake spec
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exception_notification-ikachan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Uchio KONDO
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: exception_notification
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.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.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ExceptionNotification ikachan plugin
84
+ email:
85
+ - udzura@paperboy.co.jp
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - exception_notification-ikachan.gemspec
97
+ - lib/exception_notification-ikachan.rb
98
+ - lib/exception_notification/ikachan/version.rb
99
+ - lib/exception_notifier/ikachan_notifier.rb
100
+ - spec/exception_notification/ikachan_spec.rb
101
+ - spec/spec_helper.rb
102
+ - wercker.yml
103
+ homepage: https://github.com/udzura/exception_notification-ikachan
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.14
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: ExceptionNotification ikachan plugin
127
+ test_files:
128
+ - spec/exception_notification/ikachan_spec.rb
129
+ - spec/spec_helper.rb