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.
@@ -0,0 +1 @@
1
+ 'lib/**/*.rb' - '*.md'
@@ -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.
@@ -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
@@ -1,6 +1,7 @@
1
1
  #require "xml-fu/version"
2
2
  require "xml-fu/hash"
3
3
  require "xml-fu/array"
4
+ require "xml-fu/markup"
4
5
 
5
6
  module XmlFu
6
7
  class << self
@@ -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 = Builder::XmlMarkup.new
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, "")
@@ -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 = Builder::XmlMarkup.new
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
@@ -1,3 +1,3 @@
1
1
  module XmlFu
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe XmlFu::Markup do
4
+
5
+ it "should return a Builder::XmlMarkup object when instantiated" do
6
+ Builder::XmlMarkup.should === XmlFu::Markup.new
7
+ end
8
+ end
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
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: