pb_json_parser 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pb_json_parser.rb +2 -1
- data/lib/pb_json_parser/config.rb +10 -1
- data/lib/pb_json_parser/parser.rb +4 -1
- data/lib/pb_json_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f9feb20497624eb84294e67ed3035e76f2b705e473fd666fb0d5a5e1da7b969
|
4
|
+
data.tar.gz: 9bb503495e23f83642f8e0d16973698980b64cb795ba053ae42e343a76b8360c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f71ef3c450010528839e2b28a6c6ed9719f0e902b5dab9b59a2ac957752f356106c2848d8d5a60128241eb6f02d86bc32a04ef7c35a4308215b4b26c3db4f5fa
|
7
|
+
data.tar.gz: 8f33fbaa323ed22129f58bbca2371f8bc95c5be372eaa9c16bd3da3e86f12e58e4102b796b33148e0128a3a154832f35cc0ca095833ae6e140d04a8fc1ec854c
|
data/Gemfile.lock
CHANGED
data/lib/pb_json_parser.rb
CHANGED
@@ -8,10 +8,11 @@ module PbJsonParser
|
|
8
8
|
# @param [String] json
|
9
9
|
# @param [String] filename
|
10
10
|
# @return [<AST::Message>]
|
11
|
-
def parse(json:, filename:, skip_fields: [])
|
11
|
+
def parse(json:, filename:, skip_fields: [], field_types: [])
|
12
12
|
parser = Parser.new(json: json, filename: filename)
|
13
13
|
parser.configure do |c|
|
14
14
|
c.skip_fields = skip_fields
|
15
|
+
c.field_types = field_types
|
15
16
|
end
|
16
17
|
parser.parse
|
17
18
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module PbJsonParser
|
2
2
|
class Config
|
3
|
-
attr_reader :skip_fields
|
3
|
+
attr_reader :skip_fields, :field_types
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@skip_fields = []
|
7
|
+
@field_types = []
|
7
8
|
end
|
8
9
|
|
9
10
|
# @param [<String>] fields
|
@@ -13,5 +14,13 @@ module PbJsonParser
|
|
13
14
|
end
|
14
15
|
@skip_fields = fields
|
15
16
|
end
|
17
|
+
|
18
|
+
# @param [<String>] types
|
19
|
+
def field_types=(types)
|
20
|
+
if !types.is_a?(Array)
|
21
|
+
raise "invalid field_types: #{types}"
|
22
|
+
end
|
23
|
+
@field_types = types
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
@@ -15,6 +15,7 @@ module PbJsonParser
|
|
15
15
|
def parse
|
16
16
|
r = []
|
17
17
|
@data["message_type"].each do |m_type|
|
18
|
+
next if @config.field_types.include?(m_type["name"])
|
18
19
|
m = parse_message(m_type)
|
19
20
|
r.push m
|
20
21
|
end
|
@@ -74,7 +75,9 @@ module PbJsonParser
|
|
74
75
|
# @param [{ string => Any }] field
|
75
76
|
# @return [bool]
|
76
77
|
def is_assoc?(field)
|
77
|
-
field_package(field)
|
78
|
+
return false if field_package(field) != @package
|
79
|
+
return false if @config.field_types.include?(field_message_type(field))
|
80
|
+
true
|
78
81
|
end
|
79
82
|
|
80
83
|
# @param [Hash] field
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pb_json_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nao Minami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|