rails_errors2html 1.3.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +1 -1
- data/Rakefile +90 -148
- data/lib/rails_errors2html.rb +20 -28
- data/lib/rails_errors2html/_lib.rb +53 -0
- data/rails_errors2html.gemspec +8 -6
- data/test/rails_errors2html_test.rb +27 -0
- metadata +23 -30
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6a752066c937770f23db95be0f5af353995abf0a3f3917e16bf48f8d19faa88a
|
4
|
+
data.tar.gz: e72f5abf737685fca876b26666feed8ec9d3047d552b0a54dfb2693759fd2b0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5da4e1e5bede59344147b9d396808127f458e8be7d1bb8cb76fa30d47164c4dc6c60a6d12b4f1ae3b80f8502d019edd371c2b1a295527527849cba55fc5ace86
|
7
|
+
data.tar.gz: 0fc1dc42b4e5e09f0e3adcc03b5d4de60a7ce522390ab4a4e5f343cc64d6886c27e308c9a2a83e4b8345cdaea4696a810743e245d455c3653738591f365d9f9c
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,33 +1,26 @@
|
|
1
|
-
This.
|
2
|
-
|
3
|
-
|
4
|
-
This.synopsis =
|
5
|
-
"<%= form_for @post do %> <%= @post.errors.to_html %>"
|
6
|
-
|
7
|
-
This.rubyforge_project = 'codeforpeople'
|
8
|
-
This.author = "Ara T. Howard"
|
9
|
-
This.email = "ara.t.howard@gmail.com"
|
10
|
-
This.homepage = "https://github.com/ahoward/#{ This.lib }"
|
11
|
-
|
12
|
-
This.setup!
|
13
|
-
|
1
|
+
This.author = "Ara T. Howard"
|
2
|
+
This.email = "ara.t.howard@gmail.com"
|
3
|
+
This.homepage = "https://github.com/ahoward/#{ This.lib }"
|
14
4
|
|
5
|
+
task :license do
|
6
|
+
open('LICENSE', 'w'){|fd| fd.puts "Ruby"}
|
7
|
+
end
|
15
8
|
|
16
9
|
task :default do
|
17
10
|
puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
|
18
11
|
end
|
19
12
|
|
20
13
|
task :test do
|
21
|
-
|
14
|
+
run_tests!
|
22
15
|
end
|
23
16
|
|
24
17
|
namespace :test do
|
25
|
-
task(:unit){
|
26
|
-
task(:functional){
|
27
|
-
task(:integration){
|
18
|
+
task(:unit){ run_tests!(:unit) }
|
19
|
+
task(:functional){ run_tests!(:functional) }
|
20
|
+
task(:integration){ run_tests!(:integration) }
|
28
21
|
end
|
29
22
|
|
30
|
-
def
|
23
|
+
def run_tests!(which = nil)
|
31
24
|
which ||= '**'
|
32
25
|
test_dir = File.join(This.dir, "test")
|
33
26
|
test_glob ||= File.join(test_dir, "#{ which }/**_test.rb")
|
@@ -38,28 +31,28 @@ def This.run_tests!(which = nil)
|
|
38
31
|
|
39
32
|
test_rbs.each_with_index do |test_rb, index|
|
40
33
|
testno = index + 1
|
41
|
-
command = "#{
|
34
|
+
command = "#{ This.ruby } -w -I ./lib -I ./test/lib #{ test_rb }"
|
42
35
|
|
43
36
|
puts
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
say(div, :color => :cyan, :bold => true)
|
38
|
+
say("@#{ testno } => ", :bold => true, :method => :print)
|
39
|
+
say(command, :color => :cyan, :bold => true)
|
40
|
+
say(line, :color => :cyan, :bold => true)
|
48
41
|
|
49
42
|
system(command)
|
50
43
|
|
51
|
-
|
44
|
+
say(line, :color => :cyan, :bold => true)
|
52
45
|
|
53
46
|
status = $?.exitstatus
|
54
47
|
|
55
48
|
if status.zero?
|
56
|
-
|
57
|
-
|
49
|
+
say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
|
50
|
+
say("SUCCESS", :color => :green, :bold => true)
|
58
51
|
else
|
59
|
-
|
60
|
-
|
52
|
+
say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
|
53
|
+
say("FAILURE", :color => :red, :bold => true)
|
61
54
|
end
|
62
|
-
|
55
|
+
say(line, :color => :cyan, :bold => true)
|
63
56
|
|
64
57
|
exit(status) unless status.zero?
|
65
58
|
end
|
@@ -68,8 +61,8 @@ end
|
|
68
61
|
|
69
62
|
task :gemspec do
|
70
63
|
ignore_extensions = ['git', 'svn', 'tmp', /sw./, 'bak', 'gem']
|
71
|
-
ignore_directories = ['pkg'
|
72
|
-
ignore_files = ['test/log'
|
64
|
+
ignore_directories = ['pkg']
|
65
|
+
ignore_files = ['test/log']
|
73
66
|
|
74
67
|
shiteless =
|
75
68
|
lambda do |list|
|
@@ -96,9 +89,10 @@ task :gemspec do
|
|
96
89
|
files = shiteless[Dir::glob("**/**")]
|
97
90
|
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
|
98
91
|
#has_rdoc = true #File.exist?('doc')
|
99
|
-
test_files =
|
100
|
-
summary =
|
101
|
-
description =
|
92
|
+
test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
|
93
|
+
summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
|
94
|
+
description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
|
95
|
+
license = object.respond_to?(:license) ? object.license : "Ruby"
|
102
96
|
|
103
97
|
if This.extensions.nil?
|
104
98
|
This.extensions = []
|
@@ -109,7 +103,6 @@ task :gemspec do
|
|
109
103
|
end
|
110
104
|
extensions = [extensions].flatten.compact
|
111
105
|
|
112
|
-
# TODO
|
113
106
|
if This.dependencies.nil?
|
114
107
|
dependencies = []
|
115
108
|
else
|
@@ -123,9 +116,9 @@ task :gemspec do
|
|
123
116
|
|
124
117
|
template =
|
125
118
|
if test(?e, 'gemspec.erb')
|
126
|
-
|
119
|
+
Template{ IO.read('gemspec.erb') }
|
127
120
|
else
|
128
|
-
|
121
|
+
Template {
|
129
122
|
<<-__
|
130
123
|
## <%= lib %>.gemspec
|
131
124
|
#
|
@@ -136,6 +129,7 @@ task :gemspec do
|
|
136
129
|
spec.platform = Gem::Platform::RUBY
|
137
130
|
spec.summary = <%= lib.inspect %>
|
138
131
|
spec.description = <%= description.inspect %>
|
132
|
+
spec.license = <%= license.inspect %>
|
139
133
|
|
140
134
|
spec.files =\n<%= files.sort.pretty_inspect %>
|
141
135
|
spec.executables = <%= executables.inspect %>
|
@@ -150,7 +144,6 @@ task :gemspec do
|
|
150
144
|
|
151
145
|
spec.extensions.push(*<%= extensions.inspect %>)
|
152
146
|
|
153
|
-
spec.rubyforge_project = <%= This.rubyforge_project.inspect %>
|
154
147
|
spec.author = <%= This.author.inspect %>
|
155
148
|
spec.email = <%= This.email.inspect %>
|
156
149
|
spec.homepage = <%= This.homepage.inspect %>
|
@@ -159,20 +152,20 @@ task :gemspec do
|
|
159
152
|
}
|
160
153
|
end
|
161
154
|
|
162
|
-
|
155
|
+
Fu.mkdir_p(This.pkgdir)
|
163
156
|
gemspec = "#{ lib }.gemspec"
|
164
157
|
open(gemspec, "w"){|fd| fd.puts(template)}
|
165
158
|
This.gemspec = gemspec
|
166
159
|
end
|
167
160
|
|
168
161
|
task :gem => [:clean, :gemspec] do
|
169
|
-
|
162
|
+
Fu.mkdir_p(This.pkgdir)
|
170
163
|
before = Dir['*.gem']
|
171
164
|
cmd = "gem build #{ This.gemspec }"
|
172
165
|
`#{ cmd }`
|
173
166
|
after = Dir['*.gem']
|
174
167
|
gem = ((after - before).first || after.first) or abort('no gem!')
|
175
|
-
|
168
|
+
Fu.mv(gem, This.pkgdir)
|
176
169
|
This.gem = File.join(This.pkgdir, File.basename(gem))
|
177
170
|
end
|
178
171
|
|
@@ -186,21 +179,21 @@ task :readme do
|
|
186
179
|
samples << "\n" << " <========< #{ sample } >========>" << "\n\n"
|
187
180
|
|
188
181
|
cmd = "cat #{ sample }"
|
189
|
-
samples <<
|
190
|
-
samples <<
|
182
|
+
samples << Util.indent(prompt + cmd, 2) << "\n\n"
|
183
|
+
samples << Util.indent(`#{ cmd }`, 4) << "\n"
|
191
184
|
|
192
185
|
cmd = "ruby #{ sample }"
|
193
|
-
samples <<
|
186
|
+
samples << Util.indent(prompt + cmd, 2) << "\n\n"
|
194
187
|
|
195
188
|
cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -I ./lib #{ sample })'"
|
196
|
-
samples <<
|
189
|
+
samples << Util.indent(`#{ cmd } 2>&1`, 4) << "\n"
|
197
190
|
end
|
198
191
|
|
199
192
|
template =
|
200
|
-
if test(?e, '
|
201
|
-
|
193
|
+
if test(?e, 'README.erb')
|
194
|
+
Template{ IO.read('README.erb') }
|
202
195
|
else
|
203
|
-
|
196
|
+
Template {
|
204
197
|
<<-__
|
205
198
|
NAME
|
206
199
|
#{ lib }
|
@@ -219,12 +212,10 @@ task :readme do
|
|
219
212
|
open("README", "w"){|fd| fd.puts template}
|
220
213
|
end
|
221
214
|
|
222
|
-
|
223
215
|
task :clean do
|
224
|
-
Dir[File.join(This.pkgdir, '**/**')].each{|entry|
|
216
|
+
Dir[File.join(This.pkgdir, '**/**')].each{|entry| Fu.rm_rf(entry)}
|
225
217
|
end
|
226
218
|
|
227
|
-
|
228
219
|
task :release => [:clean, :gemspec, :gem] do
|
229
220
|
gems = Dir[File.join(This.pkgdir, '*.gem')].flatten
|
230
221
|
raise "which one? : #{ gems.inspect }" if gems.size > 1
|
@@ -235,12 +226,6 @@ task :release => [:clean, :gemspec, :gem] do
|
|
235
226
|
puts
|
236
227
|
system(cmd)
|
237
228
|
abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
|
238
|
-
|
239
|
-
#cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.gem }"
|
240
|
-
#puts cmd
|
241
|
-
#puts
|
242
|
-
#system(cmd)
|
243
|
-
#abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
|
244
229
|
end
|
245
230
|
|
246
231
|
|
@@ -252,106 +237,70 @@ BEGIN {
|
|
252
237
|
#
|
253
238
|
$VERBOSE = nil
|
254
239
|
|
240
|
+
require 'ostruct'
|
255
241
|
require 'erb'
|
256
242
|
require 'fileutils'
|
257
243
|
require 'rbconfig'
|
258
244
|
require 'pp'
|
259
245
|
|
260
|
-
#
|
246
|
+
# fu shortcut
|
261
247
|
#
|
248
|
+
Fu = FileUtils
|
262
249
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
def method_missing(method, *args, &block)
|
267
|
-
if method.to_s =~ /=/
|
268
|
-
key = method.to_s.chomp('=')
|
269
|
-
value = block ? block : args.shift
|
270
|
-
self[key] = value
|
271
|
-
else
|
272
|
-
key = method.to_s
|
273
|
-
if block
|
274
|
-
value = block
|
275
|
-
self[key] = value
|
276
|
-
else
|
277
|
-
value = self[key]
|
278
|
-
|
279
|
-
if value.respond_to?(:call)
|
280
|
-
self[key] = value.call()
|
281
|
-
else
|
282
|
-
value
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
def inspect
|
289
|
-
expand!
|
290
|
-
PP.pp(self, '')
|
291
|
-
end
|
292
|
-
|
293
|
-
def expand!
|
294
|
-
keys.each do |key|
|
295
|
-
value = self[key]
|
296
|
-
if value.respond_to?(:call)
|
297
|
-
self[key] = value.call()
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
end.new()
|
250
|
+
# cache a bunch of stuff about this rakefile/environment
|
251
|
+
#
|
252
|
+
This = OpenStruct.new
|
303
253
|
|
304
254
|
This.file = File.expand_path(__FILE__)
|
305
255
|
This.dir = File.dirname(This.file)
|
306
256
|
This.pkgdir = File.join(This.dir, 'pkg')
|
257
|
+
This.lib = File.basename(Dir.pwd).sub(/[-].*$/, '')
|
307
258
|
|
308
|
-
#
|
259
|
+
# load _lib
|
309
260
|
#
|
310
|
-
This.lib
|
311
|
-
|
312
|
-
end
|
261
|
+
This._lib = "./lib/#{ This.lib }/_lib.rb"
|
262
|
+
require This._lib
|
313
263
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
264
|
+
# extract name from _lib
|
265
|
+
#
|
266
|
+
lines = IO.binread(This._lib).split("\n")
|
267
|
+
re = %r`\A \s* (module|class) \s+ ([^\s]+) \s* \z`iomx
|
268
|
+
name = nil
|
269
|
+
lines.each do |line|
|
270
|
+
match = line.match(re)
|
271
|
+
if match
|
272
|
+
name = match.to_a.last
|
273
|
+
break
|
319
274
|
end
|
320
275
|
end
|
321
|
-
|
322
|
-
|
323
|
-
This.name = This.lib.capitalize
|
276
|
+
unless name
|
277
|
+
abort "could not extract `name` from #{ This._lib }"
|
324
278
|
end
|
279
|
+
This.name = name
|
325
280
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
rescue Object
|
330
|
-
abort("could not determine object from #{ This.name }")
|
331
|
-
end
|
332
|
-
end
|
281
|
+
# now, fully grok This
|
282
|
+
#
|
283
|
+
This.object = eval(This.name)
|
333
284
|
|
334
|
-
This.version
|
335
|
-
|
336
|
-
end
|
285
|
+
version = This.object.send(:version)
|
286
|
+
This.version = version
|
337
287
|
|
338
|
-
This.dependencies
|
339
|
-
|
340
|
-
This.object.dependencies
|
341
|
-
end
|
288
|
+
if This.object.respond_to?(:dependencies)
|
289
|
+
This.dependencies = This.object.dependencies
|
342
290
|
end
|
343
291
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
292
|
+
# discover full path to this ruby executable
|
293
|
+
#
|
294
|
+
c = RbConfig::CONFIG
|
295
|
+
bindir = c["bindir"] || c['BINDIR']
|
296
|
+
ruby_install_name = c['ruby_install_name'] || c['RUBY_INSTALL_NAME'] || 'ruby'
|
297
|
+
ruby_ext = c['EXEEXT'] || ''
|
298
|
+
ruby = File.join(bindir, (ruby_install_name + ruby_ext))
|
299
|
+
This.ruby = ruby
|
351
300
|
|
352
301
|
# some utils
|
353
302
|
#
|
354
|
-
|
303
|
+
module Util
|
355
304
|
def indent(s, n = 2)
|
356
305
|
s = unindent(s)
|
357
306
|
ws = ' ' * n
|
@@ -361,33 +310,27 @@ BEGIN {
|
|
361
310
|
def unindent(s)
|
362
311
|
indent = nil
|
363
312
|
s.each_line do |line|
|
364
|
-
|
365
|
-
|
366
|
-
end
|
367
|
-
indent ? s.gsub(%r/^#{ indent }/, "") : s
|
313
|
+
next if line =~ %r/^\s*$/
|
314
|
+
indent = line[%r/^\s*/] and break
|
368
315
|
end
|
369
|
-
|
316
|
+
indent ? s.gsub(%r/^#{ indent }/, "") : s
|
317
|
+
end
|
370
318
|
extend self
|
371
319
|
end
|
372
320
|
|
373
321
|
# template support
|
374
322
|
#
|
375
|
-
|
323
|
+
class Template
|
376
324
|
def initialize(&block)
|
377
325
|
@block = block
|
378
326
|
@template = block.call.to_s
|
379
327
|
end
|
380
|
-
|
381
328
|
def expand(b=nil)
|
382
|
-
ERB.new(
|
329
|
+
ERB.new(Util.unindent(@template)).result((b||@block).binding)
|
383
330
|
end
|
384
|
-
|
385
331
|
alias_method 'to_s', 'expand'
|
386
332
|
end
|
387
|
-
|
388
|
-
def This.template_for(*args, &block)
|
389
|
-
This.template.new(*args, &block)
|
390
|
-
end
|
333
|
+
def Template(*args, &block) Template.new(*args, &block) end
|
391
334
|
|
392
335
|
# colored console output support
|
393
336
|
#
|
@@ -420,8 +363,7 @@ BEGIN {
|
|
420
363
|
:on_cyan => "\e[46m",
|
421
364
|
:on_white => "\e[47m"
|
422
365
|
}
|
423
|
-
|
424
|
-
def This.say(something, *args)
|
366
|
+
def say(phrase, *args)
|
425
367
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
426
368
|
options[:color] = args.shift.to_s.to_sym unless args.empty?
|
427
369
|
keys = options.keys
|
@@ -430,7 +372,7 @@ BEGIN {
|
|
430
372
|
color = options[:color]
|
431
373
|
bold = options.has_key?(:bold)
|
432
374
|
|
433
|
-
parts = [
|
375
|
+
parts = [phrase]
|
434
376
|
parts.unshift(This.ansi[color]) if color
|
435
377
|
parts.unshift(This.ansi[:bold]) if bold
|
436
378
|
parts.push(This.ansi[:clear]) if parts.size > 1
|
data/lib/rails_errors2html.rb
CHANGED
@@ -1,30 +1,16 @@
|
|
1
1
|
module Errors2Html
|
2
|
-
|
3
|
-
|
4
|
-
def Errors2Html.version
|
5
|
-
Errors2Html::VERSION
|
6
|
-
end
|
7
|
-
|
8
|
-
def Errors2Html.dependencies
|
9
|
-
{
|
10
|
-
'fattr' => [ 'fattr' , ' >= 2.2.1' ],
|
11
|
-
'map' => [ 'map' , ' >= 6.2.0' ],
|
12
|
-
'rails_view' => [ 'rails_view' , ' >= 1.0.1' ]
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
begin
|
17
|
-
require 'rubygems'
|
18
|
-
rescue LoadError
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
|
22
|
-
Errors2Html.dependencies.each do |lib, dependency|
|
23
|
-
gem(*dependency) if defined?(gem)
|
24
|
-
require(lib)
|
25
|
-
end
|
2
|
+
require_relative './lib/errors2html/_lib.rb'
|
3
|
+
Errors2Html.load_dependencies!
|
26
4
|
|
27
5
|
def Errors2Html.to_html(*args)
|
6
|
+
if args.size == 1
|
7
|
+
case args.first
|
8
|
+
when Array, String, Symbol
|
9
|
+
messages = Array(args.first)
|
10
|
+
args = [{:base => messages}]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
28
14
|
args.flatten!
|
29
15
|
args.compact!
|
30
16
|
|
@@ -38,11 +24,12 @@ module Errors2Html
|
|
38
24
|
flatten(e).each do |key, messages|
|
39
25
|
Array(messages).each do |message|
|
40
26
|
at_least_one_error = true
|
27
|
+
message = message.to_s.html_safe
|
41
28
|
|
42
29
|
if Array(key).join =~ /\A(?:[*]|base)\Z/iomx
|
43
|
-
errors.global.push(message
|
30
|
+
errors.global.push(message).uniq!
|
44
31
|
else
|
45
|
-
(errors.fields[key] ||= []).push(message
|
32
|
+
(errors.fields[key] ||= []).push(message).uniq!
|
46
33
|
end
|
47
34
|
end
|
48
35
|
end
|
@@ -57,9 +44,9 @@ module Errors2Html
|
|
57
44
|
}
|
58
45
|
|
59
46
|
if template
|
60
|
-
View.render(:template => template, :locals => locals)
|
47
|
+
View.render(:template => template, :locals => locals, :layout => false)
|
61
48
|
else
|
62
|
-
View.render(:inline => inline, :locals => locals)
|
49
|
+
View.render(:inline => inline, :locals => locals, :layout => false)
|
63
50
|
end
|
64
51
|
end
|
65
52
|
|
@@ -129,6 +116,10 @@ module Errors2Html
|
|
129
116
|
end
|
130
117
|
end
|
131
118
|
|
119
|
+
##
|
120
|
+
#
|
121
|
+
Errors2HTML = Errors2Html
|
122
|
+
|
132
123
|
##
|
133
124
|
#
|
134
125
|
require 'active_model' unless defined?(ActiveModel)
|
@@ -140,3 +131,4 @@ end
|
|
140
131
|
to_hash.inspect(*args, &block)
|
141
132
|
end
|
142
133
|
end
|
134
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Errors2Html
|
2
|
+
Version = '1.5.1' unless defined?(Version)
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def version
|
6
|
+
Version
|
7
|
+
end
|
8
|
+
|
9
|
+
def summary
|
10
|
+
"tiny, KISS html rendering of active_model errors"
|
11
|
+
end
|
12
|
+
|
13
|
+
def dependencies
|
14
|
+
{
|
15
|
+
'fattr' => [ 'fattr' , ' ~> 2' ],
|
16
|
+
'map' => [ 'map' , ' ~> 6' ],
|
17
|
+
'rails_view' => [ 'rails_view' , ' ~> 1' ]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def load_dependencies!
|
22
|
+
begin
|
23
|
+
require 'rubygems'
|
24
|
+
rescue LoadError
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
dependencies.each do |lib, dependency|
|
29
|
+
gem(*dependency) if defined?(gem)
|
30
|
+
require(lib)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def libdir(*args, &block)
|
35
|
+
@libdir ||= File.dirname(File.expand_path(__FILE__).sub(/\.rb$/,''))
|
36
|
+
args.empty? ? @libdir : File.join(@libdir, *args)
|
37
|
+
ensure
|
38
|
+
if block
|
39
|
+
begin
|
40
|
+
$LOAD_PATH.unshift(@libdir)
|
41
|
+
block.call()
|
42
|
+
ensure
|
43
|
+
$LOAD_PATH.shift()
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def load(*libs)
|
49
|
+
libs = libs.join(' ').scan(/[^\s+]+/)
|
50
|
+
libdir{ libs.each{|lib| Kernel.load(lib) } }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/rails_errors2html.gemspec
CHANGED
@@ -3,16 +3,19 @@
|
|
3
3
|
|
4
4
|
Gem::Specification::new do |spec|
|
5
5
|
spec.name = "rails_errors2html"
|
6
|
-
spec.version = "1.
|
6
|
+
spec.version = "1.5.1"
|
7
7
|
spec.platform = Gem::Platform::RUBY
|
8
8
|
spec.summary = "rails_errors2html"
|
9
|
-
spec.description = "
|
9
|
+
spec.description = "description: rails_errors2html kicks the ass"
|
10
|
+
spec.license = "Ruby"
|
10
11
|
|
11
12
|
spec.files =
|
12
13
|
["README.md",
|
13
14
|
"Rakefile",
|
14
15
|
"lib",
|
16
|
+
"lib/rails_errors2html",
|
15
17
|
"lib/rails_errors2html.rb",
|
18
|
+
"lib/rails_errors2html/_lib.rb",
|
16
19
|
"rails_errors2html.gemspec",
|
17
20
|
"test",
|
18
21
|
"test/rails_errors2html_test.rb",
|
@@ -25,16 +28,15 @@ Gem::Specification::new do |spec|
|
|
25
28
|
spec.test_files = nil
|
26
29
|
|
27
30
|
|
28
|
-
spec.add_dependency(*["fattr", "
|
31
|
+
spec.add_dependency(*["fattr", " ~> 2"])
|
29
32
|
|
30
|
-
spec.add_dependency(*["map", "
|
33
|
+
spec.add_dependency(*["map", " ~> 6"])
|
31
34
|
|
32
|
-
spec.add_dependency(*["rails_view", "
|
35
|
+
spec.add_dependency(*["rails_view", " ~> 1"])
|
33
36
|
|
34
37
|
|
35
38
|
spec.extensions.push(*[])
|
36
39
|
|
37
|
-
spec.rubyforge_project = "codeforpeople"
|
38
40
|
spec.author = "Ara T. Howard"
|
39
41
|
spec.email = "ara.t.howard@gmail.com"
|
40
42
|
spec.homepage = "https://github.com/ahoward/rails_errors2html"
|
@@ -88,6 +88,33 @@ Testing Errors2Html do
|
|
88
88
|
assert{ compress(errors) == compress(expected) }
|
89
89
|
end
|
90
90
|
|
91
|
+
##
|
92
|
+
#
|
93
|
+
testing 'array-y errors' do
|
94
|
+
errors = %w( fu bar )
|
95
|
+
|
96
|
+
expected = <<-__
|
97
|
+
<div class="errors2html errors-summary">
|
98
|
+
<h4 class="errors-caption">Sorry, we encountered some errors:</h4>
|
99
|
+
|
100
|
+
|
101
|
+
<ul class="errors-global-list">
|
102
|
+
<li class="errors-message">
|
103
|
+
fu
|
104
|
+
</li>
|
105
|
+
<li class="errors-message">
|
106
|
+
bar
|
107
|
+
</li>
|
108
|
+
</ul>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
__
|
112
|
+
|
113
|
+
actual = Errors2Html.to_html(errors)
|
114
|
+
|
115
|
+
assert{ compress(actual) == compress(expected) }
|
116
|
+
end
|
117
|
+
|
91
118
|
protected
|
92
119
|
def compress(*strings)
|
93
120
|
strings.flatten.compact.join.gsub(/\s+/, '')
|
metadata
CHANGED
@@ -1,65 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_errors2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.5.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ara T. Howard
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-10-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: fattr
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2
|
19
|
+
version: '2'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2
|
26
|
+
version: '2'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: map
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 6
|
33
|
+
version: '6'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 6
|
40
|
+
version: '6'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rails_view
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1
|
47
|
+
version: '1'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1
|
62
|
-
description:
|
54
|
+
version: '1'
|
55
|
+
description: 'description: rails_errors2html kicks the ass'
|
63
56
|
email: ara.t.howard@gmail.com
|
64
57
|
executables: []
|
65
58
|
extensions: []
|
@@ -68,31 +61,31 @@ files:
|
|
68
61
|
- README.md
|
69
62
|
- Rakefile
|
70
63
|
- lib/rails_errors2html.rb
|
64
|
+
- lib/rails_errors2html/_lib.rb
|
71
65
|
- rails_errors2html.gemspec
|
72
66
|
- test/rails_errors2html_test.rb
|
73
67
|
- test/testing.rb
|
74
68
|
homepage: https://github.com/ahoward/rails_errors2html
|
75
|
-
licenses:
|
69
|
+
licenses:
|
70
|
+
- Ruby
|
71
|
+
metadata: {}
|
76
72
|
post_install_message:
|
77
73
|
rdoc_options: []
|
78
74
|
require_paths:
|
79
75
|
- lib
|
80
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
77
|
requirements:
|
83
|
-
- -
|
78
|
+
- - ">="
|
84
79
|
- !ruby/object:Gem::Version
|
85
80
|
version: '0'
|
86
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
82
|
requirements:
|
89
|
-
- -
|
83
|
+
- - ">="
|
90
84
|
- !ruby/object:Gem::Version
|
91
85
|
version: '0'
|
92
86
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 1.8.24
|
87
|
+
rubygems_version: 3.0.3
|
95
88
|
signing_key:
|
96
|
-
specification_version:
|
89
|
+
specification_version: 4
|
97
90
|
summary: rails_errors2html
|
98
91
|
test_files: []
|