kvx 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +3 -2
  3. data.tar.gz.sig +0 -0
  4. data/lib/kvx.rb +25 -2
  5. metadata +3 -3
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d243a687afd8e0ad9bf8c4e7a38a6eedd02a9ef4
4
- data.tar.gz: 90cba2e99e6138b1dd2932d265f1fd1c5fb972af
3
+ metadata.gz: 8dda0bccf32b792dfdb62f62645b1f0e71d1d313
4
+ data.tar.gz: bfe3aa2f41aeb8a050bb8558ebf4e6fa0f6a02e3
5
5
  SHA512:
6
- metadata.gz: cc950bc81d044d2d616733f3e95207dfc72b9236a1a411f5b41adaa5c0e0b64274fb064cb4e342b6b4704d1d5115eac58400b889d79d27843510b717a9acb0a9
7
- data.tar.gz: ebdb9f57945a969d2a3a63a6b360608fb3922b4b9febbb6721811699a2822dd9cec0283e2aae59e4a451fc85bf9d621851d02b30687da1a99eb980c86fa92696
6
+ metadata.gz: 02b2d88b029cf1bc1ee942f3397d554f851abe6272c3c73b458896522dbe895b1e9ae80e5e7100a06dc7a9d0d7030d5030ae9368cfa6da08070c12aa167a4446
7
+ data.tar.gz: 224d86a8a16b33a0bf89c7d87cda6c3ee281c5565ca64f8ea7d7d3bff5f3cb11af4df38a6edbda823c6d07ac0c31968c92abe794ee55b6f933e459e5b599291e
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- !��gHp��_��c�/�ð�u�gp02Տ��4� �A�V�,NS�8��>�v4�
2
- u�h>�D~���m��̑��E t��049�֒qv�'f�w��q�����xΣ��&O�>�u����#�j��w�A+�@2o���7:��GDٍj�j�X��u,�C;OM��R[b��ӧ�f=Da�؊�,��׌��nRu2sS �oŭ]Dz�mv��D\)b��=��)����냰}b�h�ѡQT+
1
+ �7����a9�݈��������u���rFSs�/��Wv��G>��E!h�/��xF N*�e|^�Go\�
2
+ R���=��W#�$W�Ⱦ�g��wL�#m�-��˜(yj3ƙ.���'���r�l`��TQ�V��`Yؽ7��� 7dh��iӉ����#�L��_������d>��!w,��k uJyP����mD��ܜJ�;�7Q��Ѓ'��!>��:xiX�ꩍ���Q
3
+ �P�=�o�Q?�#����V
data.tar.gz.sig CHANGED
Binary file
data/lib/kvx.rb CHANGED
@@ -23,14 +23,22 @@ class Kvx
23
23
  @identifier = 'kvx'
24
24
  @attributes = attributes
25
25
  h = {hash: :passthru, :'rexle::element' => :hashify, string: :parse_to_h}
26
- @to_h = method(h[x.class.to_s.downcase.to_sym]).call x
26
+ @h = method(h[x.class.to_s.downcase.to_sym]).call x
27
27
 
28
28
  end
29
+
30
+ def item()
31
+ @h
32
+ end
29
33
 
30
34
  def parse(t=nil)
31
35
  parse_to_h(t || @to_s)
32
36
  end
33
37
 
38
+ def to_h()
39
+ deep_clone @h
40
+ end
41
+
34
42
  def to_s()
35
43
 
36
44
  header = ''
@@ -39,8 +47,9 @@ class Kvx
39
47
 
40
48
  header = '<?' + @identifier
41
49
  header += ' ' + @attributes.map {|x| "%s='%s'" % x }.join(' ')
42
- header += "?>\n\n"
50
+ header += "?>\n"
43
51
  end
52
+ h = @to_h
44
53
 
45
54
  header + scan_to_s(@to_h)
46
55
 
@@ -56,6 +65,20 @@ class Kvx
56
65
  end
57
66
 
58
67
  private
68
+
69
+ def deep_clone(h)
70
+
71
+ h.inject({}) do |r, x|
72
+
73
+ h2 = if x.last.is_a? Hash then
74
+ [x.first, deep_clone(x.last)]
75
+ else
76
+ x
77
+ end
78
+ r.merge h2[0] => h2[1]
79
+ end
80
+
81
+ end
59
82
 
60
83
  def get_attributes(raw_attributes)
61
84
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kvx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -103,6 +103,6 @@ rubyforge_project:
103
103
  rubygems_version: 2.4.6
104
104
  signing_key:
105
105
  specification_version: 4
106
- summary: Kvx (Keys, Attributes, and XML) makes it convenient to store and retrieve
107
- the simplest of data as plain text using a hash-like format or as XML.
106
+ summary: Kvx (Keys, Values, and XML) makes it convenient to store and retrieve the
107
+ simplest of data as plain text using a hash-like format or as XML.
108
108
  test_files: []
metadata.gz.sig CHANGED
Binary file