easydom 0.2.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 +7 -0
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/lib/easydom.rb +86 -0
- metadata +90 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1951ef02d5b66164f15ff58f2b39b2caac0510488f5175beb988c7e26f75cc54
|
4
|
+
data.tar.gz: d96df18c8fb245ff11db24d2a868915407c479c0350dfde9bcefd8ddbd8a8d5b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 130c61f94d311fef3ebded8da81922f724d8d20572b799e95796c67d0522fda559910a0e39aafc6919c7a2da5dd8303cb611c4af36cdb77b31df41c318bea8b3
|
7
|
+
data.tar.gz: 4295cb71d89579f8f4110f45d484cd57a30d5760e8e22055eab181766c53a3766faf7b4666f7b5d5d4d232bef582d6d2502f12728260b9b9bab88a3768f4a401
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/lib/easydom.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: easydom.rb
|
4
|
+
|
5
|
+
require 'free_dom'
|
6
|
+
|
7
|
+
|
8
|
+
class EasyDom
|
9
|
+
|
10
|
+
attr_reader :e
|
11
|
+
|
12
|
+
def initialize(obj=nil, debug: false, root: 'root')
|
13
|
+
|
14
|
+
@debug = debug
|
15
|
+
|
16
|
+
obj ||= "<#{root}/>"
|
17
|
+
|
18
|
+
@e = obj.is_a?(String) ? FreeDom.new(obj).root : obj
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def ==(v)
|
23
|
+
@e.attributes.values.first.to_s == v
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s()
|
27
|
+
@e.attributes.values.first.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_sliml()
|
31
|
+
@e.to_sliml()
|
32
|
+
end
|
33
|
+
|
34
|
+
def method_missing(sym, *args, &block)
|
35
|
+
|
36
|
+
puts "name: %s; args: %s" % [sym, args.inspect] if @debug
|
37
|
+
|
38
|
+
if @e.respond_to? sym then
|
39
|
+
|
40
|
+
puts 'attribute found' if @debug
|
41
|
+
@e.method(sym).call(*args)
|
42
|
+
|
43
|
+
elsif sym.to_s[-1] == '='
|
44
|
+
|
45
|
+
# assumes the 1st attribute it finds is the attribute to be set
|
46
|
+
|
47
|
+
puts '==' if @debug
|
48
|
+
e = @e.element(sym.to_s[0..-2])
|
49
|
+
|
50
|
+
if e.nil? then
|
51
|
+
|
52
|
+
attribute = sym[0..-2]
|
53
|
+
|
54
|
+
@e.instance_eval("def #{attribute}()
|
55
|
+
attributes[:#{attribute}]
|
56
|
+
end")
|
57
|
+
|
58
|
+
@e.instance_eval("def #{sym}(val)
|
59
|
+
attributes[:#{attribute}] = val
|
60
|
+
val
|
61
|
+
end")
|
62
|
+
|
63
|
+
return @e.method(sym).call(args.first)
|
64
|
+
end
|
65
|
+
|
66
|
+
attr = e.attributes.keys.first.to_s
|
67
|
+
|
68
|
+
puts 'attribute: ' + attr.inspect if @debug
|
69
|
+
|
70
|
+
e.method((attr + '=').to_sym).call(*args)
|
71
|
+
|
72
|
+
else
|
73
|
+
|
74
|
+
puts 'query element: ' + sym.to_s if @debug
|
75
|
+
e = @e.element(sym.to_s)
|
76
|
+
|
77
|
+
# if the element doesn't exist, create it
|
78
|
+
e = @e.add FreeDom::Element.new(sym, attributes: {}) unless e
|
79
|
+
|
80
|
+
EasyDom.new(e, debug: @debug) if e
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easydom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNDI5MDkzMzA1WhcN
|
15
|
+
MjEwNDI5MDkzMzA1WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCgqMzh
|
17
|
+
/aDgLvsJk+ai2X2dH2xkkXKSiNev3R7w8k5EiymYbAXKgS8r0Os38f+IGGBekxMf
|
18
|
+
wxjSbCqfgj7IFEJHoDBaRmoihNeye523oNP+B89qvZg5T2nOWNcBqjZZ/w4cd868
|
19
|
+
IfjJk1CGzAqCwI8s817ct8dS+nIaO0UCKL5ku0t3M+LsqLvjN5StkCxxNGxPvyNM
|
20
|
+
9d9s50o+YLKLFGpHyWUBa20UWPZP9W4qME0Cx7DqZMrJOQwd9bFNA0N8wi+kel7z
|
21
|
+
Dp1YziayUWmw8hrfwggQaQ3Gft/U9Cb5uZp4U29zgnQ7Mxr61yJaU3B1TFF5fMqN
|
22
|
+
Y27YxEMTVtP3JusHZqO02iTs9nbhH7pSAzBYsV5WhuT7x6KQ82CG9ArBc0caE0dL
|
23
|
+
RMwHC0yDuzG2RXEdC6s8yGfEshQ3aa2wGmvddYh4Ta7gS7QDnjHNsLSefoMiiwwg
|
24
|
+
XHnMui3AcyWNc2na7n4lOdxCiEakQqSP/WuOigXWhXLvr8gqAZUdBeGoFoUCAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUPx9uUlJw
|
26
|
+
lFynbLocHwQ/Czdod9IwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAjQ5x92t6rp7SGy2tiSolihcvFX5yjORXnx5zoyld
|
29
|
+
yWiLUg1ozX5bkszPXUPONMSnIa2QejVvtVUogBY/T0ta5p7XXmnJvGiNn0sKRCxn
|
30
|
+
woTPakZdW2OskL4JpzsjSI2N49hyrEQySO/uCbbzR9LPJUfnxpwGOHwYGM5KdA8R
|
31
|
+
8B/XY2YYYZAjiTXG13vGdu/fdGr/eU91/4nlcnyEJdGJSII+ecZHkZduvDbOlUcT
|
32
|
+
URxDUMxXZIYdKaCCpCEVU7M4lQ6ob93wR1jwxxF4u3MrW6K96WoX8xNJTYZKXUJq
|
33
|
+
b0jNqTEz3EYeRNBy87zsjVc+YKF5uH1KZw26e5URwQWvQPslgB8Nue0/yaDBTxHA
|
34
|
+
KDlUvUPutF/hRhGM+QNkK6+YNOljwtJTzN9VZAP8vRa4Lhv4ZgiogInc5lw3o4AF
|
35
|
+
GqWzjdQ5Dfb1ydCV6UC9Lu1hzIoAQVrkWlRlbX15SCvwTM+CbAAPFg3vwmKNi5T1
|
36
|
+
u695LgOX0KlDJi1766NJIYv8
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2020-05-02 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: free_dom
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.3'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.3.1
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.3'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.3.1
|
60
|
+
description:
|
61
|
+
email: james@jamesrobertson.eu
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- lib/easydom.rb
|
67
|
+
homepage: https://github.com/jrobertson/easydom
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.0.3
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Experimental gem to access XML elements from simple dot notation (e.g. person.name).
|
90
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|