glimmer-dsl-xml 1.1.0 → 1.2.0
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 +4 -4
- data/README.md +18 -27
- data/VERSION +1 -1
- data/lib/glimmer/dsl/xml/name_space_expression.rb +4 -4
- data/lib/glimmer/dsl/xml/node_parent_expression.rb +5 -5
- data/lib/glimmer/xml/node.rb +4 -4
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b685c6e5771e631dde5326ebcaf4687aa92c7d89e6cf39df8b74eb95e99b4348
|
4
|
+
data.tar.gz: 9392982b3c7c3e3709dcf89793c0f85793dff98f953906e545a9f176e9438e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e4b76284985f4db72cbcbbf621eece60e17c9a640eb61caec19d74f1d47b3f64ac8bf92de084fe15da7f58cba37dd9dea3c45cd4e93924178a1bb6163546c4
|
7
|
+
data.tar.gz: a42597d205467c6e63830ec4cc831747116571adb0d37fd5918ea597ad8f64222cc8a3fa126c1c67a62b959eb1eafbfffc63d0589495257a82952111c1cfd628
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
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 1.
|
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 1.2.0 (& HTML)
|
2
2
|
[](http://badge.fury.io/rb/glimmer-dsl-xml)
|
3
3
|
[](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-xml)
|
4
4
|
[](https://coveralls.io/github/AndyObtiva/glimmer-dsl-xml?branch=master)
|
5
5
|
[](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-xml/maintainability)
|
6
6
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
7
|
|
8
|
-
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for XML provides Ruby syntax for building XML (eXtensible Markup Language) documents.
|
8
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for XML provides Ruby syntax for building XML (eXtensible Markup Language) and HTML documents.
|
9
9
|
|
10
10
|
Within the context of desktop development, Glimmer DSL for XML is useful in providing XML data for the [SWT Browser widget](https://github.com/AndyObtiva/glimmer-dsl-swt/tree/master#browser-widget).
|
11
11
|
|
@@ -23,7 +23,7 @@ Please follow these instructions to make the `glimmer` command available on your
|
|
23
23
|
|
24
24
|
Run this command to install directly:
|
25
25
|
```
|
26
|
-
gem install glimmer-dsl-xml -v 1.
|
26
|
+
gem install glimmer-dsl-xml -v 1.2.0
|
27
27
|
```
|
28
28
|
|
29
29
|
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 ...`
|
@@ -38,7 +38,7 @@ That's it! Requiring the gem activates the Glimmer XML DSL automatically.
|
|
38
38
|
|
39
39
|
Add the following to `Gemfile` (after `glimmer-dsl-swt` and/or `glimmer-dsl-opal` if included too):
|
40
40
|
```
|
41
|
-
gem 'glimmer-dsl-xml', '~> 1.
|
41
|
+
gem 'glimmer-dsl-xml', '~> 1.2.0'
|
42
42
|
```
|
43
43
|
|
44
44
|
And, then run:
|
@@ -67,13 +67,19 @@ Here are all the Glimmer XML DSL top-level keywords:
|
|
67
67
|
|
68
68
|
Element properties are typically passed as a key/value hash (e.g. `section(id: 'main', class: 'accordion')`) . However, for properties like "selected" or "checked", you must leave value `nil` or otherwise pass in front of the hash (e.g. `input(:checked, type: 'checkbox')` )
|
69
69
|
|
70
|
-
|
70
|
+
You may try the following examples in IRB after installing the [glimmer-dsl-xml](https://rubygems.org/gems/glimmer-dsl-xml) gem.
|
71
|
+
|
72
|
+
Just make sure to require the library and include Glimmer first:
|
71
73
|
|
72
74
|
```ruby
|
73
75
|
require 'glimmer-dsl-xml'
|
74
76
|
|
75
77
|
include Glimmer
|
78
|
+
```
|
79
|
+
|
80
|
+
Example (full HTML document):
|
76
81
|
|
82
|
+
```ruby
|
77
83
|
@html = html {
|
78
84
|
head {
|
79
85
|
meta(name: "viewport", content: "width=device-width, initial-scale=2.0")
|
@@ -82,6 +88,7 @@ include Glimmer
|
|
82
88
|
h1 { "Hello, World!" }
|
83
89
|
}
|
84
90
|
}
|
91
|
+
|
85
92
|
puts @html
|
86
93
|
```
|
87
94
|
|
@@ -94,13 +101,10 @@ Output:
|
|
94
101
|
Example (partial HTML fragment):
|
95
102
|
|
96
103
|
```ruby
|
97
|
-
require 'glimmer-dsl-xml'
|
98
|
-
|
99
|
-
include Glimmer
|
100
|
-
|
101
104
|
@html = html {
|
102
105
|
h1 { "Hello, World!" }
|
103
106
|
}
|
107
|
+
|
104
108
|
puts @html
|
105
109
|
```
|
106
110
|
|
@@ -113,35 +117,29 @@ Output:
|
|
113
117
|
Example (basic XML):
|
114
118
|
|
115
119
|
```ruby
|
116
|
-
require 'glimmer-dsl-xml'
|
117
|
-
|
118
|
-
include Glimmer
|
119
|
-
|
120
120
|
@xml = xml {
|
121
|
-
|
121
|
+
greeting { "Hello, World!" }
|
122
122
|
}
|
123
|
+
|
123
124
|
puts @xml
|
124
125
|
```
|
125
126
|
|
126
127
|
Output:
|
127
128
|
|
128
129
|
```
|
129
|
-
<
|
130
|
+
<greeting>Hello, World!</greeting>
|
130
131
|
```
|
131
132
|
|
132
133
|
Example (XML namespaces using `name_space` keyword):
|
133
134
|
|
134
135
|
```ruby
|
135
|
-
require 'glimmer-dsl-xml'
|
136
|
-
|
137
|
-
include Glimmer
|
138
|
-
|
139
136
|
@xml = name_space(:acme) {
|
140
137
|
product(:id => "thesis", :class => "document") {
|
141
138
|
component(:id => "main") {
|
142
139
|
}
|
143
140
|
}
|
144
141
|
}
|
142
|
+
|
145
143
|
puts @xml
|
146
144
|
```
|
147
145
|
|
@@ -154,14 +152,11 @@ Output:
|
|
154
152
|
Example (XML namespaces using dot operator):
|
155
153
|
|
156
154
|
```ruby
|
157
|
-
require 'glimmer-dsl-xml'
|
158
|
-
|
159
|
-
include Glimmer
|
160
|
-
|
161
155
|
@xml = xml {
|
162
156
|
document.body(document.id => "main") {
|
163
157
|
}
|
164
158
|
}
|
159
|
+
|
165
160
|
puts @xml
|
166
161
|
```
|
167
162
|
|
@@ -174,10 +169,6 @@ Output:
|
|
174
169
|
Example (custom tag):
|
175
170
|
|
176
171
|
```ruby
|
177
|
-
require 'glimmer-dsl-xml'
|
178
|
-
|
179
|
-
include Glimmer
|
180
|
-
|
181
172
|
puts tag(:_name => "p") {"p is a reserved keyword in Ruby"}
|
182
173
|
```
|
183
174
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -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
|
@@ -46,7 +46,7 @@ module Glimmer
|
|
46
46
|
Glimmer::XML::Node.new(parent, args[0].to_s, :_name_space_context => true)
|
47
47
|
end
|
48
48
|
|
49
|
-
def add_content(parent, &block)
|
49
|
+
def add_content(parent, keyword, *args, &block)
|
50
50
|
node = block.call(parent)
|
51
51
|
unless node.is_a?(String)
|
52
52
|
name_space_visitor = Glimmer::XML::NameSpaceVisitor.new(parent.name)
|
@@ -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
|
@@ -30,8 +30,8 @@ module Glimmer
|
|
30
30
|
include ParentExpression
|
31
31
|
include Glimmer
|
32
32
|
|
33
|
-
def add_content(parent, &block)
|
34
|
-
return_value = block.call(parent)
|
33
|
+
def add_content(parent, keyword, *args, &block)
|
34
|
+
return_value = block.call(parent)
|
35
35
|
if !return_value.is_a?(Glimmer::XML::Node) and !parent.children.include?(return_value)
|
36
36
|
text = return_value.to_s
|
37
37
|
first_match = text.match(/[#][^{]+[{][^}]+[}]/)
|
data/lib/glimmer/xml/node.rb
CHANGED
@@ -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
|
@@ -66,7 +66,7 @@ module Glimmer
|
|
66
66
|
def method_missing(symbol, *args, &block)
|
67
67
|
@is_name_space = true
|
68
68
|
parent.children.delete(self) if parent
|
69
|
-
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::XML::XmlExpression.new) {@tag = super}
|
69
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::XML::XmlExpression.new, name, attributes) {@tag = super}
|
70
70
|
@tag
|
71
71
|
end
|
72
72
|
|
metadata
CHANGED
@@ -1,33 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.1
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 2.0.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.0.1
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: 2.0.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
@@ -238,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
232
|
- !ruby/object:Gem::Version
|
239
233
|
version: '0'
|
240
234
|
requirements: []
|
241
|
-
rubygems_version: 3.
|
235
|
+
rubygems_version: 3.2.22
|
242
236
|
signing_key:
|
243
237
|
specification_version: 4
|
244
238
|
summary: Glimmer DSL for XML
|