xml-fu 0.1.6 → 0.1.7
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/.yardopts +1 -0
- data/CHANGELOG.md +13 -0
- data/{LICENSE → LICENSE.md} +2 -1
- data/lib/xml-fu.rb +1 -0
- data/lib/xml-fu/array.rb +1 -4
- data/lib/xml-fu/hash.rb +2 -4
- data/lib/xml-fu/markup.rb +21 -0
- data/lib/xml-fu/version.rb +1 -1
- data/spec/lib/xml_spec.rb +8 -0
- metadata +8 -4
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
'lib/**/*.rb' - '*.md'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## Changes by Version
|
2
|
+
|
3
|
+
### 0.1.7
|
4
|
+
|
5
|
+
* Added pass through for Builder::XmlMarkup options via XmlFu.xml
|
6
|
+
* :indent
|
7
|
+
* :margin
|
8
|
+
* Refactored Builder::XmlMarkup creation logic into separate class
|
9
|
+
|
10
|
+
### 0.1.6
|
11
|
+
|
12
|
+
* Added :instruct option for adding XML doctype instruction to generated XML
|
13
|
+
|
1
14
|
### 0.1.5
|
2
15
|
|
3
16
|
* Fix false positive for Node value responding to "to_datetime" by checking explicitly for String values before hand.
|
data/{LICENSE → LICENSE.md}
RENAMED
@@ -1,7 +1,8 @@
|
|
1
1
|
Copyright (c) 2012 Ryan Johnson
|
2
|
+
|
2
3
|
Copyright (c) 2010 Daniel Harrington (for logic inspired by Gyoku)
|
3
4
|
|
4
|
-
MIT License
|
5
|
+
## MIT License
|
5
6
|
|
6
7
|
Permission is hereby granted, free of charge, to any person obtaining
|
7
8
|
a copy of this software and associated documentation files (the
|
data/lib/xml-fu.rb
CHANGED
data/lib/xml-fu/array.rb
CHANGED
@@ -68,10 +68,7 @@ module XmlFu
|
|
68
68
|
# @param [Array] arr Array to iterate over
|
69
69
|
# @param [Hash] opts Hash of options to pass to the iteration
|
70
70
|
def self.each_with_xml(arr, opts={})
|
71
|
-
xml =
|
72
|
-
xml.instruct! if opts[:instruct] == true
|
73
|
-
opts.delete(:instruct)
|
74
|
-
|
71
|
+
xml = XmlFu::Markup.new(opts)
|
75
72
|
|
76
73
|
arr.each do |item|
|
77
74
|
key = opts.fetch(:key, "")
|
data/lib/xml-fu/hash.rb
CHANGED
@@ -37,10 +37,8 @@ module XmlFu
|
|
37
37
|
|
38
38
|
# Provides a convenience function to iterate over the hash
|
39
39
|
# Logic will filter out attribute and content keys from hash values
|
40
|
-
def self.each_with_xml(hash, opts)
|
41
|
-
xml =
|
42
|
-
xml.instruct! if opts[:instruct] == true
|
43
|
-
opts.delete(:instruct)
|
40
|
+
def self.each_with_xml(hash, opts={})
|
41
|
+
xml = XmlFu::Markup.new(opts)
|
44
42
|
|
45
43
|
hash.each do |key,value|
|
46
44
|
node_value = value
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module XmlFu
|
2
|
+
require 'builder'
|
3
|
+
|
4
|
+
# Pseudo class for holding logic for creating the XmlMarkup object.
|
5
|
+
class Markup
|
6
|
+
|
7
|
+
# @return [Builder::XmlMarkup]
|
8
|
+
def self.new(options={})
|
9
|
+
indent = (options.delete(:indent) || 0).to_i
|
10
|
+
margin = (options.delete(:margin) || 0).to_i
|
11
|
+
instruct = options.delete(:instruct) || false
|
12
|
+
|
13
|
+
xml = Builder::XmlMarkup.new(:indent => indent, :margin => margin)
|
14
|
+
xml.instruct! if instruct == true
|
15
|
+
|
16
|
+
return xml
|
17
|
+
end#self.new
|
18
|
+
|
19
|
+
end#Markup
|
20
|
+
|
21
|
+
end#XmlFu
|
data/lib/xml-fu/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xml-fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Johnson
|
@@ -75,20 +75,23 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
77
|
- .travis-yml
|
78
|
+
- .yardopts
|
78
79
|
- CHANGELOG.md
|
79
80
|
- Gemfile
|
80
|
-
- LICENSE
|
81
|
+
- LICENSE.md
|
81
82
|
- README.md
|
82
83
|
- Rakefile
|
83
84
|
- lib/xml-fu.rb
|
84
85
|
- lib/xml-fu/array.rb
|
85
86
|
- lib/xml-fu/core_ext/string.rb
|
86
87
|
- lib/xml-fu/hash.rb
|
88
|
+
- lib/xml-fu/markup.rb
|
87
89
|
- lib/xml-fu/node.rb
|
88
90
|
- lib/xml-fu/version.rb
|
89
91
|
- spec/lib/array_spec.rb
|
90
92
|
- spec/lib/hash_spec.rb
|
91
93
|
- spec/lib/node_spec.rb
|
94
|
+
- spec/lib/xml_spec.rb
|
92
95
|
- spec/spec_helper.rb
|
93
96
|
- spec/xmlfu_spec.rb
|
94
97
|
- xml-fu.gemspec
|
@@ -129,6 +132,7 @@ test_files:
|
|
129
132
|
- spec/lib/array_spec.rb
|
130
133
|
- spec/lib/hash_spec.rb
|
131
134
|
- spec/lib/node_spec.rb
|
135
|
+
- spec/lib/xml_spec.rb
|
132
136
|
- spec/spec_helper.rb
|
133
137
|
- spec/xmlfu_spec.rb
|
134
138
|
has_rdoc:
|