i18n-airbrake 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@i18n-airbrake
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in i18n-airbrake.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 iain
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,36 @@
1
+ # I18n::Airbrake
2
+
3
+ * translates known keys normally
4
+ * translates defaults normally
5
+ * notifies airbrake in production environment
6
+ * titleizes the key in production environment
7
+ * raises the error in development environment
8
+ * raises the error in test environment
9
+
10
+ (straight from the specs)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ``` ruby
17
+ gem 'i18n-airbrake'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ``` shell
23
+ $ bundle
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ That should be it. There is no configuration (yet).
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/i18n-airbrake/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["iain"]
6
+ gem.email = ["iain@iain.nl"]
7
+ gem.description = %q{Notifies Airbrake when you miss a translation}
8
+ gem.summary = gem.description
9
+ gem.homepage = "https://github.com/iain/i18n-airbrake"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "i18n-airbrake"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = I18n::Airbrake::VERSION
17
+
18
+ gem.add_dependency "i18n", "~> 0.6.0"
19
+ gem.add_dependency "airbrake", "~> 3.0.9"
20
+
21
+ gem.add_development_dependency "rspec", "~> 2.9"
22
+
23
+ end
@@ -0,0 +1,15 @@
1
+ require "i18n"
2
+ require "i18n-airbrake/version"
3
+ require "i18n-airbrake/handler"
4
+
5
+ module I18n
6
+ module Airbrake
7
+
8
+ def self.call(*args)
9
+ Handler.new(*args).call
10
+ end
11
+
12
+ end
13
+ end
14
+
15
+ I18n.exception_handler = I18n::Airbrake
@@ -0,0 +1,31 @@
1
+ module I18n
2
+ module Airbrake
3
+ class Handler
4
+
5
+ def initialize(exception, locale, key, options)
6
+ @exception, @locale, @key, @options = exception, locale, key, options
7
+ end
8
+
9
+ def call
10
+ if Rails.env.development? or Rails.env.test?
11
+ fail exception
12
+ else
13
+ notify
14
+ @key.to_s.titleize
15
+ end
16
+ end
17
+
18
+ def exception
19
+ if @exception.respond_to?(:to_exception)
20
+ @exception.to_exception
21
+ else
22
+ @exception
23
+ end
24
+ end
25
+
26
+ def notify
27
+ ::Airbrake.notify exception
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module I18n
2
+ module Airbrake
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,48 @@
1
+ require 'i18n-airbrake'
2
+ require 'airbrake'
3
+
4
+
5
+ describe I18n::Airbrake do
6
+
7
+ let(:env) { stub "env", :development? => false, :test? => false }
8
+ let(:translation) { "This is a known value" }
9
+
10
+ module Rails
11
+ end
12
+
13
+ before do
14
+ I18n.backend.store_translations :en, :known => translation
15
+ Rails.stub(:env) { env }
16
+ end
17
+
18
+ it "translates known keys normally" do
19
+ I18n.t(:known).should == translation
20
+ end
21
+
22
+ it "translates defaults normally" do
23
+ I18n.t(:unknown, :default => "With Default").should == "With Default"
24
+ end
25
+
26
+ it "notifies airbrake in production environment" do
27
+ ::Airbrake.should_receive(:notify).with(an_instance_of(I18n::MissingTranslationData))
28
+ I18n.t(:unknown)
29
+ end
30
+
31
+ it "titleizes the key in production environment" do
32
+ ::Airbrake.stub(:notify)
33
+ I18n.t(:unknown).should == "Unknown"
34
+ end
35
+
36
+ it "raises the error in development environment" do
37
+ Rails.env.stub(:development?) { true }
38
+ ::Airbrake.should_not_receive(:notify)
39
+ expect { I18n.t(:unknown) }.to raise_error I18n::MissingTranslationData
40
+ end
41
+
42
+ it "raises the error in test environment" do
43
+ Rails.env.stub(:test?) { true }
44
+ ::Airbrake.should_not_receive(:notify)
45
+ expect { I18n.t(:unknown) }.to raise_error I18n::MissingTranslationData
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n-airbrake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - iain
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: i18n
16
+ requirement: &70268164432240 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70268164432240
25
+ - !ruby/object:Gem::Dependency
26
+ name: airbrake
27
+ requirement: &70268164448100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.9
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70268164448100
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70268164447640 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.9'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70268164447640
47
+ description: Notifies Airbrake when you miss a translation
48
+ email:
49
+ - iain@iain.nl
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rspec
56
+ - .rvmrc
57
+ - Gemfile
58
+ - MIT-LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - i18n-airbrake.gemspec
62
+ - lib/i18n-airbrake.rb
63
+ - lib/i18n-airbrake/handler.rb
64
+ - lib/i18n-airbrake/version.rb
65
+ - spec/i18n-airbrake_spec.rb
66
+ homepage: https://github.com/iain/i18n-airbrake
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.15
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Notifies Airbrake when you miss a translation
90
+ test_files:
91
+ - spec/i18n-airbrake_spec.rb