vipnet_parser 0.2.1 → 0.3
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/lib/vipnet_parser.rb +13 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da32dfbdad3c1bf685d6d99bcc67df17bdcc9a22
|
4
|
+
data.tar.gz: 1b591f46815a89fe55e4aec8899ede46f4173fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f251255ad22e639a70e3ee7b385b55e07f4f352afdc535612919c0b648f89c07cb25753735d1ef1b0c789507262a49831169bf3c5933096a694116f14ef737
|
7
|
+
data.tar.gz: c965f7256f8e527abd02db7f962a443835456a70cf27dd8a72691d5d77266f8dd4352c6152185ca099353e2777f0732901d190fba83dbf45f81296360f033061
|
data/lib/vipnet_parser.rb
CHANGED
@@ -91,7 +91,12 @@ module VipnetParser
|
|
91
91
|
unless args.size == 1
|
92
92
|
return false
|
93
93
|
end
|
94
|
-
|
94
|
+
args = args[0]
|
95
|
+
if args.class == String
|
96
|
+
@content = args
|
97
|
+
elsif args.class == Hash
|
98
|
+
@content = args[:content]
|
99
|
+
end
|
95
100
|
# remove comments
|
96
101
|
content_nc = @content.gsub(/^#.*\n/, "")
|
97
102
|
# remove ending
|
@@ -116,7 +121,7 @@ module VipnetParser
|
|
116
121
|
}
|
117
122
|
props.each do |type, props|
|
118
123
|
props.each do |prop|
|
119
|
-
get_section_param({ prop: prop, section: tmp_section, content: section_content, type: type })
|
124
|
+
get_section_param({ prop: prop, section: tmp_section, content: section_content, type: type, opts: args })
|
120
125
|
end
|
121
126
|
end
|
122
127
|
# self section id
|
@@ -127,6 +132,8 @@ module VipnetParser
|
|
127
132
|
end
|
128
133
|
|
129
134
|
def get_section_param(args)
|
135
|
+
opts = {} if args[:opts].class == String
|
136
|
+
opts = args[:opts] if args[:opts].class == Hash
|
130
137
|
value_regexp = Regexp.new("^#{args[:prop].to_s}=\s(.*)$")
|
131
138
|
if args[:type] == :multi
|
132
139
|
tmp_array = Array.new
|
@@ -134,7 +141,10 @@ module VipnetParser
|
|
134
141
|
value = line[value_regexp, 1]
|
135
142
|
tmp_array.push(value) if value
|
136
143
|
end
|
137
|
-
|
144
|
+
unless tmp_array.empty?
|
145
|
+
tmp_array = tmp_array.to_s if opts[:arrays_to_s]
|
146
|
+
args[:section][args[:prop]] = tmp_array
|
147
|
+
end
|
138
148
|
elsif args[:type] == :single
|
139
149
|
value = args[:content][value_regexp, 1]
|
140
150
|
args[:section][args[:prop]] = value if value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vipnet_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Morozov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parses ViPNet strings like 'something 1A0EABCD something', iplir.conf
|
14
14
|
and other files.
|