kintone_notifier 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64163e607f9eb5d52d30c36d2f38f5ab690e8438
4
- data.tar.gz: 16d4fcbad35139928640e6b2afcb83be9d1f6e5f
3
+ metadata.gz: 61c98bdf21480d4f8a6a593caa4d4e8f892656df
4
+ data.tar.gz: ffe7a13037b6ffe0c5aa2f51ade83a9cf3da9415
5
5
  SHA512:
6
- metadata.gz: cf1a6a62d59ef0a72848939d6c0f1c96f5d94633dc7cf94e0b162acccd12289d03beaef0496a616c3341068e26ed9d4c2535195c6da24b7bb970ab77e9d1c7b7
7
- data.tar.gz: e8b2e7568b31e5457de6ff547c26ddd217e4c70f883d9d12bd7db74ad85cda9d9400c5a126a2524f22cb4f777a1195dd4669abf2ab7f39f8e7ea692e6308d2db
6
+ metadata.gz: ce48cc29023468fd1775180cbd7366891d2f7b549028e36e20b50c02d533eee026b6f7f32fc4ba8c4b0d1982d18bc7bb72c881f93f21a911828078d6af9a09dd
7
+ data.tar.gz: dd08fef6cab6a6cf45211ccd7bac2e596c64c5ac4ebdfe14c9413db77a2ec67e167c7e05b044f69a7acbc6c9030d3aa89ce7c455faff5f72ca8d94c34ea96256
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["fujimoto"]
10
10
  spec.email = ["fujimoto@team-heartbeat.com"]
11
11
  spec.summary = %q{tweeting exception or error to Kintone App}
12
- spec.description = %q{}
12
+ spec.description = %q{You have to use as local gem}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -0,0 +1,48 @@
1
+ module KintoneNotifier
2
+ class Bot
3
+
4
+ def initialize(options={})
5
+ raise ArgumentError, "invalid argument. class configuration haven't been given." if @@config.blank?
6
+ @options = default_options.reverse_merge(default_options)
7
+ @api = Kintone::Api.new(@options["url"],@options["user"],@options["password"])
8
+ end
9
+ def tweet(values={})
10
+ @api.record.create(@options["app_id"],convert_hash(values.reverse_merge(default_values)))
11
+ end
12
+
13
+ def self.config=(h)
14
+ @@config = h
15
+ end
16
+
17
+ private
18
+ def convert_hash(h)
19
+ val = {}.tap do |_val|
20
+ h.each do |k,v|
21
+ _val.merge!(k => {"value" => v})
22
+ end
23
+ end
24
+ end
25
+
26
+ def default_options
27
+ @@config.stringify_keys
28
+ end
29
+
30
+ def default_values
31
+ {
32
+ "app_name" => app_name,
33
+ "server" => Socket.gethostname ,
34
+ "rails_root" => Rails.root,
35
+ "svn_version" => %x[ svnversion ],
36
+ "pid" => $$
37
+ }
38
+ end
39
+
40
+ def app_name
41
+ if Rails.respond_to?(:application)
42
+ Rails.application.class.name.split("::").shift
43
+ else
44
+ Rails.root.to_s.split("/")[-2]
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module KintoneNotifier
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require "kintone_notifier/version"
2
+ require 'kintone_notifier/bot'
3
+ require 'kintone'
2
4
 
3
5
  module KintoneNotifier
4
6
 
@@ -6,11 +8,12 @@ module KintoneNotifier
6
8
  base.extend(ClassMethods)
7
9
  base.class_eval do
8
10
  include KintoneNotifier::InstanceMethods
9
- # if Rails.env.production?
11
+ if Rails.env.production?
10
12
  rescue_from Exception, :with => :render_500
11
13
  rescue_from ActiveRecord::RecordNotFound, :with => :render_404
12
14
  rescue_from ActionController::RoutingError, :with => :render_404
13
- # end
15
+ rescue_from ActionView::MissingTemplate, :with => :render_404
16
+ end
14
17
  helper_method :request_env_string
15
18
 
16
19
  end
@@ -30,53 +33,6 @@ module KintoneNotifier
30
33
  # :app_id => 1
31
34
  # }
32
35
 
33
- class Bot
34
-
35
- def initialize(options={})
36
- raise ArgumentError, "invalid argument. class configuration haven't been given." if @@config.blank?
37
- @options = default_options.reverse_merge(default_options)
38
- @api = Kintone::Api.new(@options["url"],@options["user"],@options["password"])
39
- end
40
- def tweet(values={})
41
- @api.record.create(@options["app_id"],convert_hash(values.reverse_merge(default_values)))
42
- end
43
-
44
- def self.config=(h)
45
- @@config = h
46
- end
47
-
48
- private
49
- def convert_hash(h)
50
- val = {}.tap do |_val|
51
- h.each do |k,v|
52
- _val.merge!(k => {"value" => v})
53
- end
54
- end
55
- end
56
-
57
- def default_options
58
- @@config.stringify_keys
59
- end
60
-
61
- def default_values
62
- {
63
- "app_name" => app_name,
64
- "server" => Socket.gethostname ,
65
- "rails_root" => Rails.root,
66
- "svn_version" => %x[ svnversion ],
67
- "pid" => $$
68
- }
69
- end
70
-
71
- def app_name
72
- if Rails.respond_to?(:application)
73
- Rails.application.class.name.split("::").shift
74
- else
75
- Rails.root.to_s.split("/")[-2]
76
- end
77
- end
78
- end
79
-
80
36
  module ClassMethods
81
37
 
82
38
  end
@@ -98,9 +54,11 @@ module KintoneNotifier
98
54
  "remote_ip" => request.remote_ip,
99
55
  "parameters" => request.filtered_parameters.inspect,
100
56
  "exception_class_name" => exception.class.name,
101
- "description" => compose_exception_description(exception),
57
+ "description" => exception.message,
58
+ "backtrace" => exception.backtrace.join("\r\n"),
102
59
  "session" => session.inspect,
103
- "environment" => request_env_string
60
+ "environment" => request_env_string,
61
+ "user_agent" => request.headers["HTTP_USER_AGENT"]
104
62
  }
105
63
  bot.tweet(notice)
106
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kintone_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fujimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-09 00:00:00.000000000 Z
11
+ date: 2014-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: ''
55
+ description: You have to use as local gem
56
56
  email:
57
57
  - fujimoto@team-heartbeat.com
58
58
  executables: []
@@ -66,6 +66,7 @@ files:
66
66
  - Rakefile
67
67
  - kintone_notifier.gemspec
68
68
  - lib/kintone_notifier.rb
69
+ - lib/kintone_notifier/bot.rb
69
70
  - lib/kintone_notifier/version.rb
70
71
  homepage: ''
71
72
  licenses: