vipnet_parser 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vipnet_parser/iplirconf.rb +6 -8
- data/lib/vipnet_parser/nodename.rb +1 -3
- data/lib/vipnet_parser/strings.rb +8 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7970f04e800c4708b908008d233b801145a23ba6
|
4
|
+
data.tar.gz: ade58764a0627fbee189144d7891824b1394d447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db265c3b81ebfbfa511b289be370d6aa2e439e51042335495ca957b8dab16bee2a79581ac849da15753fe7070113668acb9265fbcae142fd5e8106f216d19be1
|
7
|
+
data.tar.gz: 6fda0aa8af392f7a76d430fe0e29b744bd013ba9fff680f65ce43232e95dc1587c3b900f1363f27082c06151ca092f9e19988c9e69eb3044dcba05dd925fd0e7
|
@@ -12,9 +12,7 @@ module VipnetParser
|
|
12
12
|
|
13
13
|
def parse(args = DEFAULT_PARSE_ARGS)
|
14
14
|
args = DEFAULT_PARSE_ARGS.merge(args)
|
15
|
-
format = args
|
16
|
-
encoding = args[:encoding]
|
17
|
-
normalize_names = args[:normalize_names]
|
15
|
+
format, encoding, normalize_names = args.values_at(:format, :encoding, :normalize_names)
|
18
16
|
|
19
17
|
# change encoding to utf8 and remove comments
|
20
18
|
string = self.string
|
@@ -35,8 +33,8 @@ module VipnetParser
|
|
35
33
|
sections = string.map do |section|
|
36
34
|
section =~ /\[(?<section_name>.+)\]\n(?<section_content>.*)/m
|
37
35
|
{
|
38
|
-
name: Regexp.last_match
|
39
|
-
content: Regexp.last_match
|
36
|
+
name: Regexp.last_match(:section_name).to_sym,
|
37
|
+
content: Regexp.last_match(:section_content),
|
40
38
|
}
|
41
39
|
end
|
42
40
|
|
@@ -80,11 +78,11 @@ module VipnetParser
|
|
80
78
|
|
81
79
|
section_content.split("\n").each do |line|
|
82
80
|
if line =~ /(?<prop>.*)=\s(?<value>.*)/
|
83
|
-
prop = Regexp.last_match
|
84
|
-
value = Regexp.last_match
|
81
|
+
prop = Regexp.last_match(:prop).to_sym
|
82
|
+
value = Regexp.last_match(:value)
|
85
83
|
|
86
84
|
# array-type props
|
87
|
-
if [
|
85
|
+
if %i[ip filterudp filtertcp server].include?(prop)
|
88
86
|
if hash[prop]
|
89
87
|
hash[prop].push(value)
|
90
88
|
else
|
@@ -12,9 +12,7 @@ module VipnetParser
|
|
12
12
|
|
13
13
|
def parse(args = DEFAULT_PARSE_ARGS)
|
14
14
|
args = DEFAULT_PARSE_ARGS.merge(args)
|
15
|
-
format = args
|
16
|
-
encoding = args[:encoding]
|
17
|
-
normalize_names = args[:normalize_names]
|
15
|
+
format, encoding, normalize_names = args.values_at(:format, :encoding, :normalize_names)
|
18
16
|
|
19
17
|
# change encoding to utf8
|
20
18
|
string = self.string
|
@@ -2,16 +2,14 @@ module VipnetParser
|
|
2
2
|
def id(args)
|
3
3
|
if args.class == String
|
4
4
|
string = args
|
5
|
-
array =
|
5
|
+
array = []
|
6
6
|
elsif args.class == Hash
|
7
|
-
string = args
|
8
|
-
array = args[:array]
|
9
|
-
threshold = args[:threshold]
|
7
|
+
string, array, threshold = args.values_at(:string, :array, :threshold)
|
10
8
|
end
|
11
9
|
string = string.downcase
|
12
10
|
cyrillic_sub = {
|
13
|
-
"а" => "a", "б" => "b", "с" => "c", "д" => "d", "е" => "e", "ф" => "f",
|
14
|
-
"А" => "a", "Б" => "b", "С" => "c", "Д" => "d", "Е" => "e", "Ф" => "f",
|
11
|
+
"а" => "a", "б" => "b", "В" => "b", "с" => "c", "д" => "d", "е" => "e", "ф" => "f",
|
12
|
+
"А" => "a", "Б" => "b", "в" => "b", "С" => "c", "Д" => "d", "Е" => "e", "Ф" => "f",
|
15
13
|
}
|
16
14
|
cyrillic_sub.each do |cyr, lat|
|
17
15
|
string = string.gsub(cyr, lat)
|
@@ -27,10 +25,10 @@ module VipnetParser
|
|
27
25
|
regexps.each do |regexp, callback|
|
28
26
|
if string =~ regexp && !string_matches_anything
|
29
27
|
string_matches_anything = true
|
30
|
-
array += callback.call(
|
28
|
+
array += callback.call(string: Regexp.last_match(2), threshold: threshold)
|
31
29
|
[Regexp.last_match(1), Regexp.last_match(3)].each do |side_match|
|
32
30
|
unless side_match.empty?
|
33
|
-
array += id(
|
31
|
+
array += id(string: side_match, array: array, threshold: threshold)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
@@ -53,7 +51,7 @@ module VipnetParser
|
|
53
51
|
if threshold
|
54
52
|
return [] if interval_end - interval_begin + 1 > threshold
|
55
53
|
end
|
56
|
-
array =
|
54
|
+
array = []
|
57
55
|
(interval_end - interval_begin + 1).times do |n|
|
58
56
|
array.push("0x#{(interval_begin + n).to_s(16).rjust(8, '0')}")
|
59
57
|
end
|
@@ -74,7 +72,7 @@ module VipnetParser
|
|
74
72
|
def network(id)
|
75
73
|
normal_ids = id(id)
|
76
74
|
if normal_ids
|
77
|
-
normal_id = normal_ids
|
75
|
+
normal_id = normal_ids.first
|
78
76
|
return id[2..5].to_i(16).to_s(10)
|
79
77
|
end
|
80
78
|
|
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: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Morozov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parses ViPNet™ IDs, iplir.conf and other files
|
14
14
|
email: ntcomp12@gmail.com
|
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
43
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.
|
44
|
+
rubygems_version: 2.6.6
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: ViPNet™ strings parser
|