cocoapods-dongjia 1.0.6 → 1.0.7
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 +4 -4
- data/lib/cocoapods-dongjia/gem_version.rb +2 -2
- data/lib/cocoapods_plugin.rb +5 -0
- data/lib/dongjia_router.rb +150 -0
- data/lib/helper/dongjia_version_checker.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f3344d6aa8a82093be25e107fae8fdbc85978f62c37de24716bbc52f6e8adf9
|
4
|
+
data.tar.gz: 373230993613ea7c542a748b1047f54dc1d00b79b8f5d6738971b42b38036937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c9404e7d325cf8dfaddad1ccaa28ddba2ff76b8165a1831282299f0243ec7ae9f583d865d92d56024f04ca7592673be8ba9e7f169ec995639a8ed3350e5efe8
|
7
|
+
data.tar.gz: 3b07c1adfeb8df3c8b975586b6474a0053c0c2a8d2e317fbcb216942cc788b65afa16ece34d8d41972d0e8402f697aaecb1382b06e85e67bb9b612b70a39c616
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'dongjia_source'
|
|
3
3
|
require_relative 'dongjia_branch_inspector'
|
4
4
|
require_relative 'dongjia_enterprise_inspector'
|
5
5
|
require_relative 'dongjia_warning_manager'
|
6
|
+
require_relative 'dongjia_router'
|
6
7
|
|
7
8
|
require_relative 'helper/podfile_local_importer'
|
8
9
|
require_relative 'helper/podfile_options'
|
@@ -37,6 +38,10 @@ module Dongjia
|
|
37
38
|
files = EnterpriseInspector.inspect()
|
38
39
|
Pod::UI.warn "文件未加入企业版:#{files}" if files.count > 0
|
39
40
|
|
41
|
+
# 抓取所有路由汇总至
|
42
|
+
router = Router.new
|
43
|
+
router.scrape_routers(ctx.sandbox_root, params[:scrap_routers])
|
44
|
+
|
40
45
|
end
|
41
46
|
|
42
47
|
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Dongjia
|
5
|
+
|
6
|
+
HEADER_CONTENT = <<-EOS
|
7
|
+
/**
|
8
|
+
|
9
|
+
这里汇总了项目中所有的路由定义,方便日常开发中进行检索、版本比对等操作
|
10
|
+
|
11
|
+
该文件会在每次 pod install 后,由 cocoapods-dongjia 插件自动生成,所以无需手动修改
|
12
|
+
|
13
|
+
注意:此处的实现仅供查看,如需修改,请点击对应的 _redirect{type} 方法跳转至对应的实现
|
14
|
+
|
15
|
+
*/
|
16
|
+
|
17
|
+
|
18
|
+
EOS
|
19
|
+
|
20
|
+
class RouterItem
|
21
|
+
|
22
|
+
attr_accessor :body
|
23
|
+
attr_accessor :redirect_type
|
24
|
+
attr_accessor :pre_line
|
25
|
+
|
26
|
+
def initialize(defining_line)
|
27
|
+
@defining_line = defining_line.strip
|
28
|
+
@body = ''
|
29
|
+
@prefix = nil
|
30
|
+
prefix_len = 0
|
31
|
+
if @defining_line.start_with?('@redirectObj(')
|
32
|
+
@prefix = 'redirectObj'
|
33
|
+
prefix_len = @prefix.length + 2
|
34
|
+
elsif @defining_line.start_with?('@redirect(')
|
35
|
+
@prefix = 'redirect'
|
36
|
+
prefix_len = @prefix.length + 2
|
37
|
+
end
|
38
|
+
|
39
|
+
if @prefix != nil
|
40
|
+
@redirect_type = @defining_line[prefix_len, @defining_line.index(',') - prefix_len]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def output
|
45
|
+
del_count = @defining_line.end_with?('{') ? 1 : 0
|
46
|
+
result = "#pregma mark - "
|
47
|
+
result << @defining_line[0, @defining_line.length - del_count].strip
|
48
|
+
|
49
|
+
if @pre_line && @pre_line.start_with?('/')
|
50
|
+
result << " " << @pre_line.gsub(/^\/+/, '').strip
|
51
|
+
end
|
52
|
+
|
53
|
+
result << "\n"
|
54
|
+
result << "_" << @prefix << @redirect_type << "\n"
|
55
|
+
result << (del_count == 1 ? "{\n" : "")
|
56
|
+
result << @body << "\n\n"
|
57
|
+
result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Router
|
62
|
+
|
63
|
+
def route_items_from_file(path)
|
64
|
+
route_items = []
|
65
|
+
item = nil
|
66
|
+
File.open(path, 'r') do |file|
|
67
|
+
pre_line = nil
|
68
|
+
file.each_line do |line|
|
69
|
+
is_start = false
|
70
|
+
if line.start_with?('@redirect')
|
71
|
+
item = RouterItem.new(line)
|
72
|
+
item.pre_line = pre_line
|
73
|
+
is_start = true
|
74
|
+
elsif item != nil && line.start_with?('}')
|
75
|
+
item.body << line
|
76
|
+
route_items << item
|
77
|
+
item = nil
|
78
|
+
pre_line = nil
|
79
|
+
end
|
80
|
+
if item != nil
|
81
|
+
if !is_start
|
82
|
+
item.body << line
|
83
|
+
end
|
84
|
+
end
|
85
|
+
pre_line = line
|
86
|
+
end
|
87
|
+
end
|
88
|
+
route_items
|
89
|
+
end
|
90
|
+
|
91
|
+
def scrape_routers(sandbox_root, config)
|
92
|
+
|
93
|
+
if config == nil
|
94
|
+
return
|
95
|
+
end
|
96
|
+
|
97
|
+
result_file_path = ''
|
98
|
+
path = config[:path]
|
99
|
+
if path && path.length > 0
|
100
|
+
result_file_path = File.expand_path(File.join(sandbox_root, '..', path))
|
101
|
+
end
|
102
|
+
if !File.exist?(result_file_path)
|
103
|
+
Pod::UI.warn("Router scrapy: path not found.")
|
104
|
+
return
|
105
|
+
end
|
106
|
+
|
107
|
+
route_items = []
|
108
|
+
|
109
|
+
Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
|
110
|
+
proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
|
111
|
+
if name != 'Pods.xcodeproj'
|
112
|
+
proj.targets.each do |target|
|
113
|
+
next unless target.name.start_with?('DJ')
|
114
|
+
next unless target.is_a?(Xcodeproj::Project::Object::PBXNativeTarget)
|
115
|
+
target.source_build_phase.files_references.each do |file|
|
116
|
+
next if file.path.end_with?('Api.m')
|
117
|
+
next if file.path.end_with?('Model.m')
|
118
|
+
next if file.path.end_with?('-dummy.m')
|
119
|
+
next if file.path.end_with?('Log.m')
|
120
|
+
route_items += route_items_from_file(file.real_path)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# 排序
|
127
|
+
route_items.sort! do |a, b|
|
128
|
+
a.redirect_type.to_i <=> b.redirect_type.to_i
|
129
|
+
end
|
130
|
+
|
131
|
+
# 输出所有结果
|
132
|
+
result = HEADER_CONTENT
|
133
|
+
route_items.each do |item|
|
134
|
+
result += item.output
|
135
|
+
end
|
136
|
+
|
137
|
+
FileUtils.chmod('u+w', result_file_path)
|
138
|
+
|
139
|
+
File.open(result_file_path, 'w') do |f|
|
140
|
+
f.write(result)
|
141
|
+
end
|
142
|
+
|
143
|
+
# 将文件只读
|
144
|
+
FileUtils.chmod('ugo-w', result_file_path)
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -17,7 +17,7 @@ module Dongjia
|
|
17
17
|
if v < latest_version
|
18
18
|
update_desc = info['metadata']['update_desc']
|
19
19
|
warnings = "cocoapods-dongjia #{latest_version} is available.\n\n"
|
20
|
-
warnings << update_desc
|
20
|
+
warnings << update_desc
|
21
21
|
warnings << "To upgrade: [sudo] gem install cocoapods-dongjia\n"
|
22
22
|
Pod::UI.warn warnings
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-dongjia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiangzhuoyi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/cocoapods_plugin.rb
|
67
67
|
- lib/dongjia_branch_inspector.rb
|
68
68
|
- lib/dongjia_enterprise_inspector.rb
|
69
|
+
- lib/dongjia_router.rb
|
69
70
|
- lib/dongjia_source.rb
|
70
71
|
- lib/dongjia_warning_manager.rb
|
71
72
|
- lib/helper/dongjia_version_checker.rb
|
@@ -77,7 +78,7 @@ homepage: https://github.com/EXAMPLE/cocoapods-dongjia
|
|
77
78
|
licenses:
|
78
79
|
- MIT
|
79
80
|
metadata:
|
80
|
-
update_desc: " -
|
81
|
+
update_desc: " - 添加路由信息汇总\n"
|
81
82
|
post_install_message:
|
82
83
|
rdoc_options: []
|
83
84
|
require_paths:
|