simple-config 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6f580398dfac278daa0ae860c7a0374e15a24b6
4
- data.tar.gz: 200900916214c116d4e874f91d1d3b59d400bc97
3
+ metadata.gz: 55c903999f63fda86117d56cde5c29b21602a2ae
4
+ data.tar.gz: 8cdc62b5eba092b4db60ab1c359c874c6f9b211a
5
5
  SHA512:
6
- metadata.gz: 4c89a8140bfa7776b0c058980e61dd8c5f86e9d3a71b35c52857e1b0c1dd9ff547ef18e46e78774335e8c4b274ba9cd7181a45a3bdb4b07eeca4c81c5afcda90
7
- data.tar.gz: 4eec4f72ed2fa715bd3523349cbf7befa30facedbc5f189d90c49c210da433ca72b3c2359aa1351aa0e44f5dc2d9c2e1b215f22e77160f4f096905853e66287f
6
+ metadata.gz: 756bdf86272c60c1caf23c76559db8f8d3217b3ac66ce7c0cb5e1b2057414efe436466a2a3a5f3a542518354d075bf5a47e97c6ca0a7c0e13b0be49553c7e894
7
+ data.tar.gz: ef7914457cdcaf8f12e2bc8fd48f51f5dfd0185daafe19ce7bfc71e34c9e748c6e3b7d1709eaf9af292ebac53a010e7facc56736ee0e9ad966d2fdfa8d68d7b5
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/simple-config.rb CHANGED
@@ -10,10 +10,12 @@ class SimpleConfig
10
10
 
11
11
  attr_reader :to_h, :to_s
12
12
 
13
- def initialize(x=nil)
13
+ def initialize(x=nil, attributes: {})
14
14
 
15
15
  @header = false
16
+ @attributes = attributes
16
17
  m = {:String => :parse_to_h, :Hash => :write, :SimpleConfig => :passthru}
18
+
17
19
  method(m[x.class.to_s.to_sym]).call(x) if x
18
20
  end
19
21
 
@@ -30,7 +32,7 @@ class SimpleConfig
30
32
  if @header then
31
33
 
32
34
  header = '<?simple-config'
33
- header += ' ' + @type if @type
35
+ header += ' ' + @attributes.map {|x| "%s='%s'" % x }.join(' ')
34
36
  header += "?>\n"
35
37
  end
36
38
 
@@ -42,8 +44,7 @@ class SimpleConfig
42
44
 
43
45
  make_xml(@to_h)
44
46
 
45
- attributes = @type ? {type: @type} : {}
46
- a = ['simpleconfig', attributes, '', *make_xml(@to_h)]
47
+ a = ['simpleconfig', @attributes, '', *make_xml(@to_h)]
47
48
  Rexle.new(a).xml(options)
48
49
 
49
50
  end
@@ -69,7 +70,7 @@ class SimpleConfig
69
70
 
70
71
  txt = if a[0][/^<\?simple-?config /] then
71
72
  raw_header = a.shift
72
- @type = raw_header[/type=["']([^"']+)/,1]
73
+ @attributes.merge! type: raw_header[/type=["']([^"']+)/,1]
73
74
  @header = true
74
75
  a.join
75
76
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  GOyi72Dr1XTvfW8Vje543EzUeJP4EjrtsoS0tbx5hs2J8Ey8zv39aU4aNyM1h0Fv
32
32
  1BzvTQ2PY7IAEQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-04-21 00:00:00.000000000 Z
34
+ date: 2015-04-23 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: line-tree
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- Mz��������!���քu��Ng{Z���q�ҙ&��Ai[|kE=��Ih��~2�����h�К37�������3~��Er�,�^7��?�7�Nh�-&�L�oy`���V�S�� 7�v
1
+ ����O+1{/Ƣ��=jQ��IcD�(����~rtтѺ �;�;ޖ�h̄GFxR��[η��25/�X��C��%��Ӓ�<���f) wBo~�&S�/W*����/h6�.!�Q6/��Kz��"c���E2��(���9.�ZI��|/I�\�M���k4Ne�~���,��yw��c~