cocoapods-bb-PodAssistant 0.3.12.1 → 0.3.12.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f24cb36efee097e747c10f4f2d4f7746bc48711818b02c13db8748dde4b3eec6
4
- data.tar.gz: 7a2c0fbc83879774f5bef6b4b4162ded38076953e378d76394c2f441dbc0a170
3
+ metadata.gz: 3440bb4946cc5950fd81fabdcf604815b467a441986b0eddf3787e1226bd5f93
4
+ data.tar.gz: e0d1b5979fe4243979a02265acf29c8e42caf0bca355793c6f8193a78d7e4d31
5
5
  SHA512:
6
- metadata.gz: 5b72cb59afd1d49622913c3b65040e93f93331f12a1f7c20c9b35cd8a88d182bdaa81c2507d752d8a76bd804c1d20f6bf64094a63b13470e934352d99f337cac
7
- data.tar.gz: 7151e24ab59a31c0d631937257a9901d9c2a10736b093190eca261bbef24714ff7d23f197270133b0f650b7b292ac8873f608067e3aac6be0572f77ef6ae2a06
6
+ metadata.gz: b60b8c8959c7be1563c500ea37d754ffc7acab0e3354e34756914932a0c66ce6d5b7165d443d94446e1c1b520b0753e3967f99224bfb800c0a44c8ceac3db6ad
7
+ data.tar.gz: 89e48f338eae8cde2bbf46c4a1cdc214868734a592e8a841cea54656d6372e5a09aebfafc64c2af7cc12df24b732ccde56c583ab275773d28fdb78c16cae1a53
@@ -0,0 +1,40 @@
1
+ require 'json'
2
+
3
+ module BB
4
+ class JsonParser
5
+ attr_reader :data
6
+
7
+ def initialize(file_path)
8
+ begin
9
+ json_str = File.read(file_path)
10
+ @data = JSON.parse(json_str)
11
+ rescue JSON::ParserError => e
12
+ puts "JSON解析失败: #{e.message} file_path:#{file_path} json_str:#{json_str}".red
13
+ @data = {}
14
+ end
15
+ end
16
+
17
+ # 获取指定 key 的值(支持嵌套)
18
+ def get(*keys)
19
+ keys.reduce(@data) do |current, key|
20
+ return nil unless current.is_a?(Hash) && current.key?(key)
21
+ current[key]
22
+ end
23
+ end
24
+
25
+ # 设置指定 key 的值(仅一级 key)
26
+ def set(key, value)
27
+ @data[key] = value
28
+ end
29
+
30
+ # 返回内部完整的 JSON 数据(作为 Hash)
31
+ def get_json_data
32
+ @data
33
+ end
34
+
35
+ # 将内部数据重新转为 JSON 字符串
36
+ def to_json(pretty: false)
37
+ pretty ? JSON.pretty_generate(@data) : @data.to_json
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBbPodassistant
2
- VERSION = "0.3.12.1"
2
+ VERSION = "0.3.12.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-bb-PodAssistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12.1
4
+ version: 0.3.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - humin
@@ -169,6 +169,7 @@ files:
169
169
  - lib/cocoapods-bb-PodAssistant/command/stable/update.rb
170
170
  - lib/cocoapods-bb-PodAssistant/config/cache_path.rb
171
171
  - lib/cocoapods-bb-PodAssistant/config/data_config.rb
172
+ - lib/cocoapods-bb-PodAssistant/config/json_parser.rb
172
173
  - lib/cocoapods-bb-PodAssistant/config/source_manager.rb
173
174
  - lib/cocoapods-bb-PodAssistant/config/stable_source.rb
174
175
  - lib/cocoapods-bb-PodAssistant/config/stable_specs.rb