notify_if_invalid 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ryan Sonnek
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,26 @@
1
+ = notify_if_invalid
2
+
3
+ Record an exception in HopToad if your model object is invalid.
4
+
5
+ == Usage
6
+
7
+ class User < ActiveRecord::Base
8
+ notify_if_invalid
9
+
10
+ #validations for the object
11
+ validates_precense_of :name
12
+ end
13
+
14
+ = Installation
15
+
16
+ Command line installation
17
+
18
+ sudo gem install wireframe-notify_if_invalid
19
+
20
+ Rails environment.rb configuration
21
+
22
+ config.gem 'wireframe-notify_if_invalid', :source => 'http://gems.github.com', :lib => 'notify_if_invalid'
23
+
24
+ == Copyright
25
+
26
+ Copyright (c) 2009 Ryan Sonnek. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "notify_if_invalid"
8
+ gem.summary = %Q{ notify exception monitoring system when model object is invalid }
9
+ gem.email = "ryan@socialcast.com"
10
+ gem.homepage = "http://github.com/wireframe/notify_if_invalid"
11
+ gem.authors = ["Ryan Sonnek"]
12
+ gem.add_runtime_dependency "hoptoad_notifier", ">= 2.3"
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/*_test.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/*_test.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ if File.exist?('VERSION.yml')
47
+ config = YAML.load(File.read('VERSION.yml'))
48
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
49
+ else
50
+ version = ""
51
+ end
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "notify_if_invalid #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
58
+
data/VERSION.yml ADDED
@@ -0,0 +1,3 @@
1
+ major: 0
2
+ minor: 1
3
+ patch: 0
@@ -0,0 +1,29 @@
1
+ class ValidationError < StandardError
2
+ end
3
+
4
+ module NotifyIfInvalid
5
+ def self.included(base)
6
+ base.extend ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def notify_if_invalid
11
+ after_validation :check_if_invalid
12
+
13
+ include InstanceMethods
14
+ extend SingletonMethods
15
+ end
16
+ end
17
+
18
+ module SingletonMethods
19
+ end
20
+
21
+ module InstanceMethods
22
+ def check_if_invalid
23
+ return if self.errors.empty?
24
+ message = "#{self.class.to_s} #{self.errors.full_messages.to_sentence}: #{self.inspect}"
25
+ error = ValidationError.new message
26
+ HoptoadNotifier.notify error
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{notify_if_invalid}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Sonnek"]
12
+ s.date = %q{2010-09-01}
13
+ s.email = %q{ryan@socialcast.com}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "LICENSE",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "VERSION.yml",
23
+ "lib/notify_if_invalid.rb",
24
+ "notify_if_invalid.gemspec",
25
+ "test/notify_if_invalid_test.rb",
26
+ "test/test_helper.rb"
27
+ ]
28
+ s.homepage = %q{http://github.com/wireframe/notify_if_invalid}
29
+ s.rdoc_options = ["--charset=UTF-8"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = %q{1.3.7}
32
+ s.summary = %q{notify exception monitoring system when model object is invalid}
33
+ s.test_files = [
34
+ "test/notify_if_invalid_test.rb",
35
+ "test/test_helper.rb"
36
+ ]
37
+
38
+ if s.respond_to? :specification_version then
39
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<hoptoad_notifier>, [">= 2.3"])
44
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
45
+ else
46
+ s.add_dependency(%q<hoptoad_notifier>, [">= 2.3"])
47
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<hoptoad_notifier>, [">= 2.3"])
51
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
52
+ end
53
+ end
54
+
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class NotifyIfInvalidTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'notify_if_invalid'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: notify_if_invalid
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Ryan Sonnek
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-01 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hoptoad_notifier
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 2
32
+ - 3
33
+ version: "2.3"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: thoughtbot-shoulda
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id002
50
+ description:
51
+ email: ryan@socialcast.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files:
57
+ - LICENSE
58
+ - README.rdoc
59
+ files:
60
+ - LICENSE
61
+ - README.rdoc
62
+ - Rakefile
63
+ - VERSION.yml
64
+ - lib/notify_if_invalid.rb
65
+ - notify_if_invalid.gemspec
66
+ - test/notify_if_invalid_test.rb
67
+ - test/test_helper.rb
68
+ has_rdoc: true
69
+ homepage: http://github.com/wireframe/notify_if_invalid
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --charset=UTF-8
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.3.7
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: notify exception monitoring system when model object is invalid
102
+ test_files:
103
+ - test/notify_if_invalid_test.rb
104
+ - test/test_helper.rb