glimmer-dsl-xml 1.3.0 → 1.3.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: b7531b79c996e380ee9e921e33240bb043db4e5e194f6cd2d3582fd45f6a316e
4
- data.tar.gz: b65de2fe406335a7ea4190943cce76736867f4e74507d42d938ab754a8ccbfd2
3
+ metadata.gz: 1366050ddcebd522d82ae386b6048b5c0c8e5f32944588c71dc8020996acb595
4
+ data.tar.gz: 808f0b774ac0ce0860f46de890afd1e7215821a83b1008233c75f2ef260ef578
5
5
  SHA512:
6
- metadata.gz: 6f5182930e5e4067e91affa54be7353de536a22bc7619ffda01951231f8d4b4bebeedc7c1293966889704e924384cab16bd1443ddb6ebc257e5f108398cc79f5
7
- data.tar.gz: 5b3c56a03f721ec475ad45ab0ef0321a8626c3e8efe6b6ce207dcaab35b3ce63a64db040bf837f45749f33c7f19a2511f6d977f325fde9b84112e0b16f78bbb7
6
+ metadata.gz: 783c1848a2cee2b53117c4a74bc25ad3d6cb636f37ccf84525105d149c606c9f3c47ff8e1a5228e2662b439002af7195ce4f2509fa55a9672954045d98f31de7
7
+ data.tar.gz: a67e7ee09c14a084dce073c4da380d4f5e7283825e82a6bbf8d8a75d3ee4dd28810d321fbac0d279cc94e831ab84f6bacf449e1269c589c885bc3aa913a89715
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.3.1
4
+
5
+ - Support `Glimmer::Config.xml_attribute_underscore = '-'` to auto convert xml attribute underscores to dashes (or any character) only in symbols, but not strings
6
+
3
7
  ## 1.3.0
4
8
 
5
9
  - Upgrade to Glimmer 2.4.1 (automatically gets rid of `invalid log level:` output without needing v1.2.1's fix)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for XML & HTML 1.3.0
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for XML & HTML 1.3.1
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-xml.svg)](http://badge.fury.io/rb/glimmer-dsl-xml)
3
3
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-xml.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-xml)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-xml/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-xml?branch=master)
@@ -25,7 +25,7 @@ Please follow these instructions to make the `glimmer` command available on your
25
25
 
26
26
  Run this command to install directly:
27
27
  ```
28
- gem install glimmer-dsl-xml -v 1.3.0
28
+ gem install glimmer-dsl-xml -v 1.3.1
29
29
  ```
30
30
 
31
31
  Note: When using JRuby, `jgem` is JRuby's version of `gem` command. RVM allows running `gem` as an alias in JRuby. Otherwise, you may also run `jruby -S gem install ...`
@@ -40,7 +40,7 @@ That's it! Requiring the gem activates the Glimmer XML DSL automatically.
40
40
 
41
41
  Add the following to `Gemfile` (after `glimmer-dsl-swt` and/or `glimmer-dsl-opal` if included too):
42
42
  ```
43
- gem 'glimmer-dsl-xml', '~> 1.3.0'
43
+ gem 'glimmer-dsl-xml', '~> 1.3.1'
44
44
  ```
45
45
 
46
46
  And, then run:
@@ -180,6 +180,65 @@ Output:
180
180
  <p>p is a reserved keyword in Ruby</p>
181
181
  ```
182
182
 
183
+ ## Glimmer Config
184
+
185
+ ### `xml_attribute_underscore`
186
+
187
+ (default value: `'_'`)
188
+
189
+ Calling the following code enables auto-conversion of xml attribute underscores into dashes in `Symbol` attribute names (but not `String` attribute names):
190
+
191
+ ```ruby
192
+ Glimmer::Config.xml_attribute_underscore = '-'
193
+ ```
194
+
195
+ Example:
196
+
197
+ ```ruby
198
+ require 'glimmer-dsl-xml'
199
+
200
+ Glimmer::Config.xml_attribute_underscore = '-'
201
+
202
+ include Glimmer
203
+
204
+ document = html {
205
+ body {
206
+ video(:data_loop, data_src: "http://videos.org/1.mp4")
207
+ }
208
+ }
209
+
210
+ puts document
211
+ ```
212
+
213
+ ```
214
+ <!DOCTYPE html><html><body><video data-src="http://videos.org/1.mp4" data-loop /></body></html>
215
+ ```
216
+
217
+ Note that strings are intentionally ignored to enable using underscores when needed.
218
+
219
+ Example:
220
+
221
+ ```ruby
222
+ require 'glimmer-dsl-xml'
223
+
224
+ Glimmer::Config.xml_attribute_underscore = '-'
225
+
226
+ include Glimmer
227
+
228
+ document = html {
229
+ body {
230
+ video('data_loop', 'data_src' => "http://videos.org/1.mp4")
231
+ }
232
+ }
233
+
234
+ puts document
235
+ ```
236
+
237
+ ```
238
+ <!DOCTYPE html><html><body><video data_src="http://videos.org/1.mp4" data_loop /></body></html>
239
+ ```
240
+
241
+
183
242
  ## Multi-DSL Support
184
243
 
185
244
  Learn more about how to use this DSL alongside other Glimmer DSLs:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/config'
23
+
24
+ module Glimmer
25
+ module Config
26
+ class << self
27
+ # Tells Glimmer to automatically convert underscores in xml attribute names into dashes only when passed in as symbols (not strings)
28
+ def xml_attribute_underscore=(value)
29
+ @@xml_attribute_underscore = value
30
+ end
31
+
32
+ def xml_attribute_underscore
33
+ if defined?(@@xml_attribute_underscore) && @@xml_attribute_underscore
34
+ @@xml_attribute_underscore
35
+ else
36
+ @@xml_attribute_underscore = '_'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -51,9 +51,9 @@ module Glimmer
51
51
  unless node.is_a?(String)
52
52
  name_space_visitor = Glimmer::XML::NameSpaceVisitor.new(parent.name)
53
53
  Glimmer::XML::DepthFirstSearchIterator.new(node, name_space_visitor).iterate
54
- def node.process_block(block)
55
- Glimmer::Config.logger&.debug 'block'
56
- end
54
+ # def node.process_block(block)
55
+ # Glimmer::Config.logger&.debug 'block'
56
+ # end
57
57
  end
58
58
  parent.children << node if parent and !parent.children.include?(node)
59
59
  node
@@ -59,7 +59,7 @@ module Glimmer
59
59
  attribute.parent = nil #attributes do not usually have parents
60
60
  end
61
61
  end
62
- Glimmer::Config.logger&.debug(attributes)
62
+ # Glimmer::Config.logger&.debug(attributes)
63
63
  end
64
64
  end
65
65
 
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2020 - Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -33,7 +33,7 @@ module Glimmer
33
33
  end
34
34
 
35
35
  def process_before_children(node)
36
- if (!node.is_a?(Glimmer::XML::Node))
36
+ if (!node.is_a?(Glimmer::XML::Node))
37
37
  @document += node.to_s
38
38
  return
39
39
  end
@@ -75,11 +75,12 @@ module Glimmer
75
75
 
76
76
  def append_attributes(node)
77
77
  return if node.name == 'xml' || node.name_space_context?
78
- Glimmer::Config.logger&.debug "Take 3"
79
- Glimmer::Config.logger&.debug(node.attributes)
78
+ # Glimmer::Config.logger&.debug "Append Attributes"
79
+ # Glimmer::Config.logger&.debug(node.attributes)
80
80
  node.attributes.each do |attribute, value|
81
81
  attribute_name = attribute
82
82
  attribute_name = "#{attribute.name_space.name}:#{attribute.name}" if attribute.is_a?(Node)
83
+ attribute_name = attribute_name.to_s.gsub('_', Glimmer::Config.xml_attribute_underscore) if attribute_name.is_a?(Symbol)
83
84
  @document += " #{attribute_name}"
84
85
  @document += "=\"#{value}\"" unless value.nil?
85
86
  end
@@ -19,7 +19,9 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
+
22
23
  $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
23
24
 
24
25
  require 'glimmer'
26
+ require 'ext/glimmer/config'
25
27
  require 'glimmer/dsl/xml/dsl'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-10 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -182,7 +182,7 @@ dependencies:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
- description: Glimmer DSL for XML (& HTML)
185
+ description: Glimmer DSL for XML & HTML
186
186
  email: andy.am@gmail.com
187
187
  executables: []
188
188
  extensions: []
@@ -196,6 +196,7 @@ files:
196
196
  - LICENSE.txt
197
197
  - README.md
198
198
  - VERSION
199
+ - lib/ext/glimmer/config.rb
199
200
  - lib/glimmer-dsl-xml.rb
200
201
  - lib/glimmer/dsl/xml/dsl.rb
201
202
  - lib/glimmer/dsl/xml/html_expression.rb