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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3440bb4946cc5950fd81fabdcf604815b467a441986b0eddf3787e1226bd5f93
|
4
|
+
data.tar.gz: e0d1b5979fe4243979a02265acf29c8e42caf0bca355793c6f8193a78d7e4d31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|