warnr 1.0.0

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.
data/rdoc/index.html ADDED
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ Warnr
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>Warnr</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/README.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
@@ -0,0 +1,31 @@
1
+ require 'lib/warnr'
2
+
3
+ ActiveRecord::Base.establish_connection('adapter' => 'sqlite3', 'database' => ':memory:')
4
+
5
+ ActiveRecord::Schema.define do
6
+ create_table :users do |table|
7
+ table.column :email, :string
8
+ end
9
+
10
+ create_table :clients do |table|
11
+ table.column :manager_id, :integer
12
+ table.column :abn, :string
13
+ end
14
+ end
15
+
16
+ class User < ActiveRecord::Base; end;
17
+ class Client < ActiveRecord::Base
18
+ # Notify the client manager that the ABN has not been set
19
+ belongs_to :manager, :class_name => "User"
20
+ validates_presence_of :abn, :manager_id
21
+
22
+ treat_validation_errors_as_warnings_on :abn
23
+
24
+ on_save_with_warnings :handle_warnings
25
+
26
+ def handle_warnings
27
+ # Stub, just here for the specs
28
+ end
29
+
30
+ end
31
+
@@ -0,0 +1,76 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Client do
4
+
5
+ before do
6
+ @client = Client.new
7
+ @user = User.create
8
+ end
9
+
10
+ it "should return true from save when valid and warning free" do
11
+ @client.manager = @user
12
+ @client.abn = '123'
13
+ Client.should_not_receive(:callback)
14
+ @client.save.should eql(true)
15
+ end
16
+
17
+ describe "when the record is invalid" do
18
+ def self.no_callback_save_false
19
+ it "should not recieve a callback when saved" do
20
+ Client.should_not_receive(:callback)
21
+ @client.save
22
+ end
23
+ it "should return false from save" do
24
+ @client.save.should eql(false)
25
+ end
26
+ end
27
+ describe "when the record has warnings" do
28
+ no_callback_save_false
29
+ end
30
+ describe "when the record has no warnings" do
31
+ before do
32
+ @client.abn = '1234'
33
+ end
34
+ no_callback_save_false
35
+ end
36
+ end
37
+
38
+ it "should be marked to only warn when errors exist on 'abn'" do
39
+ Client.warnr_warning_fields.should eql([:abn])
40
+ end
41
+
42
+ it "should have a callback recorded" do
43
+ Client._on_save_with_warnings_callbacks.length.should eql(1)
44
+ end
45
+
46
+ describe "when only warnings have been violated" do
47
+ before do
48
+ @client.manager = @user
49
+ end
50
+ it "should return true for valid?" do
51
+ @client.valid?.should eql(true)
52
+ end
53
+ describe "after calling valid?" do
54
+ before do
55
+ @client.valid?
56
+ end
57
+ it "should contain a warning" do
58
+ @client.warnings.empty?.should eql(false)
59
+ end
60
+ it "should not contain an error" do
61
+ @client.errors.empty?.should eql(true)
62
+ end
63
+ end
64
+ it "should be valid" do
65
+ @client.valid?.should eql(true)
66
+ end
67
+ it "should return true when saved" do
68
+ @client.save.should eql(true)
69
+ end
70
+ it "should run a callback when you save it" do
71
+ @client.should_receive(:handle_warnings).once
72
+ @client.save
73
+ end
74
+ end
75
+ end
76
+
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
data/warnr.gemspec ADDED
@@ -0,0 +1,68 @@
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{warnr}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Daniel Heath"]
12
+ s.date = %q{2010-04-24}
13
+ s.description = %q{Ernr builds on the power of Rails 3 validations.
14
+ It lets you use validations to identify situations which are warnings rather than errors.
15
+ It also lets you define a callback on the model which is executed after save if there are any warnings.
16
+ }
17
+ s.email = %q{daniel.heath@gmail.com}
18
+ s.extra_rdoc_files = [
19
+ "README"
20
+ ]
21
+ s.files = [
22
+ ".gitignore",
23
+ "MIT-LICENSE",
24
+ "README",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "init.rb",
28
+ "install.rb",
29
+ "lib/warnr.rb",
30
+ "rdoc/classes/ActiveRecord.html",
31
+ "rdoc/classes/ActiveRecord/Validations.html",
32
+ "rdoc/classes/ActiveRecord/Validations/InstanceMethods.html",
33
+ "rdoc/classes/Warnr.html",
34
+ "rdoc/classes/Warnr/ClassMethods.html",
35
+ "rdoc/created.rid",
36
+ "rdoc/files/README.html",
37
+ "rdoc/files/lib/warnr_rb.html",
38
+ "rdoc/fr_class_index.html",
39
+ "rdoc/fr_file_index.html",
40
+ "rdoc/fr_method_index.html",
41
+ "rdoc/index.html",
42
+ "rdoc/rdoc-style.css",
43
+ "spec/spec_helper.rb",
44
+ "spec/warnr_spec.rb",
45
+ "uninstall.rb",
46
+ "warnr.gemspec"
47
+ ]
48
+ s.homepage = %q{http://github.com/DanielHeath/warnr}
49
+ s.rdoc_options = ["--charset=UTF-8"]
50
+ s.require_paths = ["lib"]
51
+ s.rubygems_version = %q{1.3.6}
52
+ s.summary = %q{Non-fatal rails 3 validations (ie, warnings rather than errors)}
53
+ s.test_files = [
54
+ "spec/warnr_spec.rb",
55
+ "spec/spec_helper.rb"
56
+ ]
57
+
58
+ if s.respond_to? :specification_version then
59
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
63
+ else
64
+ end
65
+ else
66
+ end
67
+ end
68
+
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: warnr
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Daniel Heath
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-24 00:00:00 +10:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: |
22
+ Ernr builds on the power of Rails 3 validations.
23
+ It lets you use validations to identify situations which are warnings rather than errors.
24
+ It also lets you define a callback on the model which is executed after save if there are any warnings.
25
+
26
+ email: daniel.heath@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ files:
34
+ - .gitignore
35
+ - MIT-LICENSE
36
+ - README
37
+ - Rakefile
38
+ - VERSION
39
+ - init.rb
40
+ - install.rb
41
+ - lib/warnr.rb
42
+ - rdoc/classes/ActiveRecord.html
43
+ - rdoc/classes/ActiveRecord/Validations.html
44
+ - rdoc/classes/ActiveRecord/Validations/InstanceMethods.html
45
+ - rdoc/classes/Warnr.html
46
+ - rdoc/classes/Warnr/ClassMethods.html
47
+ - rdoc/created.rid
48
+ - rdoc/files/README.html
49
+ - rdoc/files/lib/warnr_rb.html
50
+ - rdoc/fr_class_index.html
51
+ - rdoc/fr_file_index.html
52
+ - rdoc/fr_method_index.html
53
+ - rdoc/index.html
54
+ - rdoc/rdoc-style.css
55
+ - spec/spec_helper.rb
56
+ - spec/warnr_spec.rb
57
+ - uninstall.rb
58
+ - warnr.gemspec
59
+ has_rdoc: true
60
+ homepage: http://github.com/DanielHeath/warnr
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.3.6
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Non-fatal rails 3 validations (ie, warnings rather than errors)
89
+ test_files:
90
+ - spec/warnr_spec.rb
91
+ - spec/spec_helper.rb