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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b93dfc26dda0ff4068e3fc7b3d95c3cd1aff7eb74ff624ca891b8372546d488
4
- data.tar.gz: 03a8b5f40491616094293620e4660de4dfd98939029a93944987443cdaebe96d
3
+ metadata.gz: 7f9feb20497624eb84294e67ed3035e76f2b705e473fd666fb0d5a5e1da7b969
4
+ data.tar.gz: 9bb503495e23f83642f8e0d16973698980b64cb795ba053ae42e343a76b8360c
5
5
  SHA512:
6
- metadata.gz: f15b0f9e178f081426f6d6d907fa17612ffed8e4485710b3220b4ea03353f3bbe3632cea3ee142bef2ff18feff4c719a340a76573c6fa6af97302d4fe084c160
7
- data.tar.gz: 1e7b6f889c3fdb3787e9b0ede998ebed0834b26f9f00ff6e2ecd16dbc5fc2fa1bd0304b0363ebca85f886c1d5ae22d0306ee2d11407472d67b0ef4a67897f929
6
+ metadata.gz: f71ef3c450010528839e2b28a6c6ed9719f0e902b5dab9b59a2ac957752f356106c2848d8d5a60128241eb6f02d86bc32a04ef7c35a4308215b4b26c3db4f5fa
7
+ data.tar.gz: 8f33fbaa323ed22129f58bbca2371f8bc95c5be372eaa9c16bd3da3e86f12e58e4102b796b33148e0128a3a154832f35cc0ca095833ae6e140d04a8fc1ec854c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pb_json_parser (0.2.0)
4
+ pb_json_parser (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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) == @package
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
@@ -1,3 +1,3 @@
1
1
  module PbJsonParser
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.2.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-10-30 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler