xml-mixup 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5d422e3cab772172b48772aa775c71c7362f3459c4315b28a48180832160dca
4
- data.tar.gz: 12d50f74beb943f993fbd52b89913e9696c9240893fb14bcca81a434bc569d0c
3
+ metadata.gz: d4939bcfe6e304b5b71251451f59982f747f43b6e31cdd5337d95ed30dfa37d3
4
+ data.tar.gz: e97756ea84870da09ac8fbc82d35b74d0a856eb74ed0fe826d4153d520f16398
5
5
  SHA512:
6
- metadata.gz: 1896aa7cec980baf9779ca87aaad386de815879406f24ca04cc92d9a5b00b995e4a785edbd7d625b4954435f3b248b69f997f429eb55d76d1dbef4538f38f0da
7
- data.tar.gz: 1648c19729fcd0a56504c046d11e4c2def65c2cc287ee371fbb24e837c8fe499991ad763c51ec9abaa060d3e34718c8db69d74bb16c3299c6da8c5266532eee0
6
+ metadata.gz: bed9c8b8a0f064d533192bee3f883f9b19c00e45dfb4e569c0b34fbfa7622124087a8fb39c5a36aefdbafab2e5c3d412af0d8911262111f89893c110354cd737
7
+ data.tar.gz: 870ebed923f4b9a6fb5c83924115ad598a4b1293ed03a481ef9cd5a3409e53bca68609e61baa23f4549f92f5f7d4a7551dc375b27d769007d2f59df9c48e64e9
data/README.md CHANGED
@@ -44,20 +44,20 @@ Ruby, and found a lot of the same things:
44
44
 
45
45
  Granted it's a lot nicer to do this sort of thing in Ruby, but at the
46
46
  end of the day, the thing generating the XML is a nested list of
47
- method calls---_not_ a declarative data structure.
47
+ method calls_not_ a declarative data structure.
48
48
 
49
49
  ### Document has to be generated all in one shot
50
50
 
51
51
  It's not super-easy to generate a piece of the target document and
52
52
  then go back and generate some more (although
53
- {Nokogiri::XML::Builder.with} is a nice start). This plus the last
53
+ `Nokogiri::XML::Builder.with` is a nice start). This plus the last
54
54
  point leads to all sorts of cockamamy constructs which are almost as
55
55
  life-sucking as writing raw DOM routines.
56
56
 
57
57
  ### Hard to do surgery on existing documents
58
58
 
59
59
  This comes up a lot: you have an existing document and you want to add
60
- even just a single node to it---say, in between two nodes just for
60
+ even just a single node to itsay, in between two nodes just for
61
61
  fun. Good luck with that.
62
62
 
63
63
  ### Enter `XML::Mixup`
@@ -77,7 +77,7 @@ among other things, takes a `:spec`. The spec can be any composite
77
77
 
78
78
  ### Hashes
79
79
 
80
- The principal construct in `XML::Mixup` is the {Hash}. You can
80
+ The principal construct in `XML::Mixup` is the `Hash`. You can
81
81
  generate pretty much any node with it:
82
82
 
83
83
  #### Elements
@@ -115,7 +115,7 @@ Attributes are sorted lexically. Composite attribute values get
115
115
  flattened like this:
116
116
 
117
117
  ```ruby
118
- { nil => :foo, array: [:a :b], hash: { e: :f, c: :d } }
118
+ { nil => :foo, array: [:a, :b], hash: { e: :f, c: :d } }
119
119
  # => <foo array="a b" hash="c: d e: f"/>
120
120
  ```
121
121
 
@@ -1,5 +1,5 @@
1
1
  module XML
2
2
  module Mixup
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data/lib/xml/mixup.rb CHANGED
@@ -112,10 +112,10 @@ module XML::Mixup
112
112
  ADJACENT.keys do |k|
113
113
  if nodes[k]
114
114
  if adj
115
- raise
115
+ raise "Cannot bind to #{k}: #{adj} is already present"
116
116
  end
117
117
  unless nodes[k].is_a? Nokogiri::XML::Node
118
- raise
118
+ raise "#{k} must be an XML node"
119
119
  end
120
120
  adj = k
121
121
  end
@@ -126,7 +126,7 @@ module XML::Mixup
126
126
  doc ||= nodes[adj].document
127
127
  unless adj == 'parent'
128
128
  unless (nodes[:parent] = nodes[adj].parent)
129
- raise
129
+ raise "#{adj} node must have a parent node!"
130
130
  end
131
131
  end
132
132
  else
@@ -222,7 +222,7 @@ module XML::Mixup
222
222
  elsif name == '#pi' or name == '#processing-instruction'
223
223
  # now processing instructions
224
224
  if children.empty?
225
- raise
225
+ raise "Processing instruction must have at least a target"
226
226
  end
227
227
  target = children[0]
228
228
  content = ''
@@ -245,7 +245,7 @@ module XML::Mixup
245
245
  elsif name == '#dtd' or name == '#doctype'
246
246
  # now doctype declarations
247
247
  if children.empty?
248
- raise
248
+ raise "DTD node must have a root element declaration"
249
249
  end
250
250
 
251
251
  # assign as if these are args
@@ -255,7 +255,7 @@ module XML::Mixup
255
255
  sys ||= attr[:system] if attr[:system]
256
256
 
257
257
  # XXX for some reason this is an *internal* subset?
258
- node = doc.create_internal_subset(root, pub, sys)
258
+ node = doc.create_internal_subset(root, pub.to_s, sys.to_s)
259
259
 
260
260
  # at any rate it doesn't have to be explicitly attached
261
261
 
@@ -319,7 +319,7 @@ module XML::Mixup
319
319
 
320
320
  # there should be no nil namespace declarations now
321
321
  if ns.has_value? nil
322
- raise
322
+ raise 'INTERNAL ERROR: nil namespace declaration'
323
323
  end
324
324
 
325
325
  # generate the node
@@ -466,7 +466,7 @@ module XML::Mixup
466
466
  private
467
467
 
468
468
  def element tag, doc: nil, ns: {}, attr: {}, args: []
469
- raise unless doc
469
+ raise 'Document node must be present' unless doc
470
470
  prefix = local = nil
471
471
  if tag.respond_to? :to_a
472
472
  prefix, local = tag
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-mixup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Taylor