yeller_ruby 0.1.0 → 0.1.1

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: 9be335c24f5bc5cc32739b5dd1e213ab257b0ee8
4
- data.tar.gz: 6fe8f356c2bd651b6da8a99c68cf8709b38e1f96
3
+ metadata.gz: f832aa0453b7e200b482d80f2c58b46203f5851d
4
+ data.tar.gz: e9a80a30239b0fc19b112ef4c2fee626ddceb4a3
5
5
  SHA512:
6
- metadata.gz: a31b8067de2352ece465297e840212a8975bde91fc3a0c5846b53bc6e5f4be2e09f02cffa8153b00271f7929b8d7177893fd30b39af82f6049910bcb21836679
7
- data.tar.gz: 0d26f185687705c49af4dba7536cc44c2bbeffe116a9ef9d3092ac0971a8c9d5f576e95c0af09d4fda51ed65335abf46983ad6b8651e922a587c7fb306e90668
6
+ metadata.gz: 40d168e4f251a688b184d720ebdbd1dcd3161ebf241b67ac1da694792698fde59e919caf633a26aab2c96849aee4cc527bed9cfcc53e9a1cd25358d96eafe6ba
7
+ data.tar.gz: ca0131c62419252dd141914dd24c78218c60bb479eb4c427917465ab896513da2511b9de45b7d69d8f2189eae9e324c7877e6f378b76cf92da42f1b9fdb97729
data/lib/yeller.rb CHANGED
@@ -11,16 +11,29 @@ require_relative 'yeller/version'
11
11
  require_relative 'yeller/startup_params'
12
12
  require_relative 'yeller/log_error_handler'
13
13
 
14
+ if defined?(::Rails)
15
+ require 'yeller/rails'
16
+ end
17
+
18
+ if defined?(::Rails) && defined?(::Rake)
19
+ require 'yeller/rails/tasks'
20
+ end
21
+
14
22
  module Yeller
15
- def self.client(&block)
23
+ def self.client(*blocks, &block)
16
24
  config = Yeller::Configuration.new
17
- block.call(config)
25
+ if block_given?
26
+ block.call(config)
27
+ end
28
+ blocks.each do |b|
29
+ b.call(config)
30
+ end
18
31
  build_client(config)
19
32
  end
20
33
 
21
34
  def self.build_client(config)
22
35
  if config.ignore_exceptions?
23
- Yeller::IgnoringClient.new
36
+ Yeller::IgnoringClient.new(config.token)
24
37
  else
25
38
  Yeller::Client.new(
26
39
  config.servers,
data/lib/yeller/client.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Yeller
2
2
  class Client
3
- attr_reader :backtrace_filter
3
+ attr_reader :backtrace_filter, :token
4
4
 
5
5
  def initialize(servers, token, startup_params, backtrace_filter, error_handler)
6
6
  @servers = servers
@@ -9,6 +9,7 @@ module Yeller
9
9
  @token = token
10
10
  @error_handler = error_handler
11
11
  @backtrace_filter = backtrace_filter
12
+ @reported_error = false
12
13
  end
13
14
 
14
15
  def report(exception, options={})
@@ -19,6 +20,7 @@ module Yeller
19
20
 
20
21
  def report_with_roundtrip(serialized, error_count)
21
22
  next_server.client.post("/#{@token}", serialized, {"Content-Type" => "application/json"})
23
+ @reported_error ||= true
22
24
  rescue StandardError => e
23
25
  if error_count <= (@servers.size * 2)
24
26
  report_with_roundtrip(serialized, error_count + 1)
@@ -39,6 +41,14 @@ module Yeller
39
41
  true
40
42
  end
41
43
 
44
+ def reported_error?
45
+ @reported_error
46
+ end
47
+
48
+ def inspect
49
+ "#<Yeller::Client enabled=true token=#{@token.inspect}>"
50
+ end
51
+
42
52
  private
43
53
 
44
54
  def next_server
@@ -1,10 +1,19 @@
1
1
  module Yeller
2
2
  class IgnoringClient
3
+ attr_reader :token
4
+ def initialize(token)
5
+ @token = token
6
+ end
7
+
3
8
  def report(*_)
4
9
  end
5
10
 
6
11
  def enabled?
7
12
  false
8
13
  end
14
+
15
+ def reported_error?
16
+ false
17
+ end
9
18
  end
10
19
  end
data/lib/yeller/rack.rb CHANGED
@@ -4,7 +4,9 @@ require_relative '../yeller'
4
4
  module Yeller
5
5
  class Rack
6
6
  def self.configure(&block)
7
- @client = Yeller.client(&block)
7
+ @config_blocks ||= []
8
+ @config_blocks << block
9
+ @client = Yeller.client(*@config_blocks)
8
10
  end
9
11
 
10
12
  def self.report(exception, options={})
@@ -0,0 +1,70 @@
1
+ require 'action_controller/test_case'
2
+ namespace :yeller do
3
+ desc "verify your yeller gem installation by sending a test exception to yeller's servers"
4
+ task :verify => [:environment] do
5
+ Dir["app/controllers/application*.rb"].each { |file| require(File.expand_path(file)) }
6
+
7
+ catcher = Yeller::Rails::ActionControllerCatchingHooks
8
+
9
+ if !([ActionController::Base, ActionDispatch::DebugExceptions, ActionDispatch::ShowExceptions, ApplicationController].any? {|x| x.included_modules.include?(catcher) })
10
+ puts "YELLER: NO RAILS INITIALIZATION DETECTED"
11
+ puts "this is likely our problem, email tcrayford@yellerapp.com"
12
+ exit 126
13
+ end
14
+
15
+ client = Yeller::Rack.instance_variable_get('@client')
16
+ if client.token.nil? || client.token == 'YOUR_API_TOKEN_HERE'
17
+ puts "NO YELLER API TOKEN DETECTED: your api token was set to #{client.token.inspect}"
18
+ puts "Yeller needs an api key configured. Check the README: https://github.com/tcrayford/yeller_ruby to find out how to do that"
19
+ exit 126
20
+ end
21
+
22
+ class YellerVerifyException < RuntimeError; end
23
+
24
+ Yeller::Rails.configure do |config|
25
+ config.development_environments = []
26
+ end
27
+
28
+ class ApplicationController
29
+ prepend_before_filter :verify_yeller
30
+
31
+ def verify_yeller
32
+ raise YellerVerifyException.new("verifying that yeller works")
33
+ end
34
+
35
+ def verify
36
+ end
37
+
38
+ def consider_all_requests_local
39
+ false
40
+ end
41
+
42
+ def local_request?
43
+ false
44
+ end
45
+ end
46
+
47
+ class YellerVerificationController < ApplicationController; end
48
+
49
+
50
+ Rails.application.routes.draw do
51
+ root 'yeller_verification#verify'
52
+ end
53
+
54
+ env = Rack::MockRequest.env_for('http://example.com')
55
+ Rails.application.call(env)
56
+
57
+ client = Yeller::Rack.instance_variable_get('@client')
58
+ if client.reported_error?
59
+ Kernel.puts "SUCCESS yeller-verified token=\"#{client.token}\""
60
+ else
61
+ if client.enabled?
62
+ Kernel.puts "ERROR: CLIENT NOT ENABLED yeller-verification-failed enabled=#{client.enabled?} token=\"#{client.token}\""
63
+ Kernel.puts "Yeller rails client not enabled, check development_environments setting"
64
+ else
65
+ Kernel.puts "ERROR yeller-verification-failed enabled=#{client.enabled?} token=\"#{client.token}\""
66
+ end
67
+ exit 126
68
+ end
69
+ end
70
+ end
@@ -1,3 +1,3 @@
1
1
  module Yeller
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1 @@
1
+ require_relative 'yeller'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeller_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Crayford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-01 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,9 +68,11 @@ files:
68
68
  - lib/yeller/log_error_handler.rb
69
69
  - lib/yeller/rack.rb
70
70
  - lib/yeller/rails.rb
71
+ - lib/yeller/rails/tasks.rb
71
72
  - lib/yeller/server.rb
72
73
  - lib/yeller/startup_params.rb
73
74
  - lib/yeller/version.rb
75
+ - lib/yeller_ruby.rb
74
76
  homepage: https://github.com/tcrayford/yeller_rubby
75
77
  licenses:
76
78
  - MIT
@@ -91,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
93
  version: '0'
92
94
  requirements: []
93
95
  rubyforge_project:
94
- rubygems_version: 2.2.0
96
+ rubygems_version: 2.2.2
95
97
  signing_key:
96
98
  specification_version: 4
97
99
  summary: A Ruby/Rack/Rails client for yellerapp.com