bragi-validates_xml 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +14 -0
- data/lib/validates_xml.rb +20 -0
- data/rails/init.rb +2 -0
- metadata +67 -0
data/README.textile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
ValidatesXml
|
2
|
+
============
|
3
|
+
|
4
|
+
Provides validates_xml method allowing to validate xml correctness of ActiveRecord attributes.
|
5
|
+
|
6
|
+
Acknowledgment
|
7
|
+
--------------
|
8
|
+
|
9
|
+
It's just a repacking as gem of plugin published on http://code.google.com/p/validates-xml/ by johnwulff
|
10
|
+
|
11
|
+
License
|
12
|
+
-------
|
13
|
+
|
14
|
+
MIT License
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Validations
|
3
|
+
module ClassMethods
|
4
|
+
def validates_xml(*attr_names)
|
5
|
+
configuration = { :message => ActiveRecord::Errors.default_error_messages[:invalid],
|
6
|
+
:on => :save,
|
7
|
+
:with => nil }
|
8
|
+
configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
|
9
|
+
validates_each(attr_names, configuration) do |record, attr_name, value|
|
10
|
+
begin
|
11
|
+
REXML::Document.new("<base>#{value}</base>")
|
12
|
+
rescue REXML::ParseException => ex
|
13
|
+
record.errors.add(attr_name,
|
14
|
+
"is not valid xml. #{ex.continued_exception}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/rails/init.rb
ADDED
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bragi-validates_xml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lukasz Piestrzeniewicz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-29 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.0
|
24
|
+
version:
|
25
|
+
description: Provides validates_xml method allowing to validate xml correctness of ActiveRecord attributes.
|
26
|
+
email:
|
27
|
+
- bragi@ragnarson.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.textile
|
34
|
+
files:
|
35
|
+
- lib/validates_xml.rb
|
36
|
+
- rails/init.rb
|
37
|
+
- README.textile
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/bragi/validates_xml
|
40
|
+
licenses:
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --main
|
44
|
+
- README.textile
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project: validates_xml
|
62
|
+
rubygems_version: 1.3.5
|
63
|
+
signing_key:
|
64
|
+
specification_version: 2
|
65
|
+
summary: Rails helper for validating xml attributes.
|
66
|
+
test_files: []
|
67
|
+
|