YKBIU 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 22686cb12ff96ca787f81b9a12f6170f4b455434cdee94c6b67e9385733877f4
4
+ data.tar.gz: 9eee8ca4eaa9d511b1d3cd22485b2a1e3ead8fce4bedc8dfd377f54551e771dc
5
+ SHA512:
6
+ metadata.gz: 22c2e3533f6b859c301f0254d12078371ed427be410b4a8be39c484522a5131ebe5d07a528aa9afc7fafe71824ea5c64fb91abdff78ac28d756fbca2adbdcf6f
7
+ data.tar.gz: ccde7885def6c82442e1c5550478d0cf649cf97057f2d949edf2a52e40d55d98b6e28c41a4600d0dc42bae8519bc82db1ff663d205fd019916e748844012c82e
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in YKBIU.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 wanyakun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,176 @@
1
+ ### 项目简介
2
+
3
+ YKBIU 是一个使用 Ruby 编写的iOS远程依赖配置安装工具,用来获取服务端配置的CocoaPods依赖,并自动安装。 从而解决Podfile中频繁修改依赖组件,或者组件的版本。 特别适合项目发展到一定程度形成组件化,Podfile中依赖的组件越多,越适合使用YKBIU。
4
+
5
+ ### 为什么有这个项目
6
+
7
+ 拍拍贷财富App经过几年的迭代发展,目前已经完全进入组件化开发的方式,项目中已经有将近上百个组件,如果这些组件的依赖都写到Podfile中,里面将有将近上百条类似`Pod 'xxxx'`的内容存在,而且在多人同时修改的情况也容易形成冲突。为此我们开发了移动应用管理系统,用来线上管理应用、管理组件、管理应用版本对组件的依赖。线上系统中配置的依赖需要能够在执行`pod install`的时候自动被安装,此项目就是为了解决这个问题而产生的,它是整个移动应用管理系统中很重要的一部分。
8
+
9
+ ### 安装
10
+
11
+ 将下面这行代码添加到您应用目录下的Gemfile中
12
+
13
+ ```ruby
14
+ gem 'YKBIU'
15
+ ```
16
+
17
+ 然后执行:
18
+
19
+ $ bundle
20
+
21
+ 或者用下面的命令进行安装:
22
+
23
+ $ gem install YKBIU
24
+
25
+ ### 使用
26
+
27
+ 1. 在Podfile中引入依赖 `require 'YKBIU'`
28
+
29
+ 2. 删除所有可以通过服务端配置的依赖代码如: pod 'xxxxx'
30
+
31
+ 3. 添加`makeup_pods(url, params, method, ignores)`来获取依赖并进行依赖安装, 参数中含义解释如下:
32
+
33
+ - url: 为获取json依赖内容的地址,通过url接口请求得到Podfile中的依赖,来安装依赖内容
34
+
35
+ - params为url的请求参数
36
+
37
+ - method为网络请求的方式,支持GET和POST
38
+
39
+ - ignores为忽略依赖的数组,在执行依赖安装的过程中会判断依赖名称是否在忽略的数组中,忽略数组一般用来调试本地组件或者指定git地址使用,放弃从配置中安装依赖,再在Podfile中添加本地组件或者git地址。
40
+
41
+ 4. 服务端配置返回的json内容格式如下:
42
+
43
+ ```json
44
+ {
45
+ "result": 0,
46
+ "codeMsg": "",
47
+ "resultMessage": "响应成功",
48
+ "content": [
49
+ {
50
+ "dependencyName": "AFNetworking",
51
+ "componentVersion": "~> 3.2.0"
52
+ },
53
+ {
54
+ "dependencyName": "YYModel",
55
+ "componentVersion": "1.0.4"
56
+ },
57
+ {
58
+ "dependencyName": "YYText",
59
+ "componentVersion": "1.0.5"
60
+ },
61
+ {
62
+ "dependencyName": "Masonry",
63
+ "gitUrl": "https://github.com/SnapKit/Masonry.git"
64
+ },
65
+ {
66
+ "dependencyName": "MBProgressHUD",
67
+ "gitUrl": "https://github.com/jdg/MBProgressHUD.git",
68
+ "componentBranch": "master"
69
+ },
70
+ {
71
+ "dependencyName": "UICKeyChainStore",
72
+ "gitUrl": "https://github.com/kishikawakatsumi/UICKeyChainStore.git",
73
+ "tag": "v2.1.1"
74
+ }
75
+ ]
76
+ }
77
+ ```
78
+
79
+ 5. 依赖安装过程优先安装指定`componentVersion`的版本,如果返回的有`componentVersion`字段,会安装此字段设置的版本进行安装,否则安装giturl、tag,componentBranch等信息进行依赖安装
80
+
81
+ 实例:
82
+
83
+ ```ruby
84
+ source 'http://github.com/CocoaPods/Specs.git'
85
+
86
+ platform :ios, "8.0"
87
+ inhibit_all_warnings!
88
+ workspace 'Demo.xcworkspace'
89
+
90
+ target 'Demo' do
91
+ project 'Demo/Demo.xcodeproj'
92
+
93
+ require 'YKBIU'
94
+
95
+ # 包含忽略依赖数组,如['YYText']
96
+ makeup_pods('https://raw.githubusercontent.com/wanyakun/resources/master/dependency.json', {'applicationVersionId' => '4', 'pageSize' => '99999'}, 'GET', ['YYText'])
97
+ pod 'YYText', :git => 'https://github.com/ibireme/YYText.git'
98
+
99
+ # 不包含忽略数字键
100
+ # makeup_pods('https://raw.githubusercontent.com/wanyakun/resources/master/dependency.json', {'applicationVersionId' => '4', 'pageSize' => '99999'}, 'GET')
101
+ end
102
+ ```
103
+
104
+ ### 项目结构
105
+
106
+ 整个项目结构如下:
107
+
108
+ ```
109
+ YKBIU/
110
+ ├── Gemfile
111
+ ├── Gemfile.lock
112
+ ├── LICENSE
113
+ ├── README.md
114
+ ├── Rakefile
115
+ ├── bin
116
+ │   ├── console
117
+ │   └── setup
118
+ ├── lib
119
+ │   ├── YKBIU
120
+ │   │   └── version.rb
121
+ │   └── YKBIU.rb
122
+ ├── YKBIU.gemspec
123
+ └── test
124
+ ├── Demo
125
+ │   ├── Demo
126
+ │   │   ├── AppDelegate.h
127
+ │   │   ├── AppDelegate.m
128
+ │   │   ├── Assets.xcassets
129
+ │   │   │   ├── AppIcon.appiconset
130
+ │   │   │   │   └── Contents.json
131
+ │   │   │   └── Contents.json
132
+ │   │   ├── Base.lproj
133
+ │   │   │   ├── LaunchScreen.storyboard
134
+ │   │   │   └── Main.storyboard
135
+ │   │   ├── Info.plist
136
+ │   │   ├── ViewController.h
137
+ │   │   ├── ViewController.m
138
+ │   │   └── main.m
139
+ │   ├── Demo.xcodeproj
140
+ │   │   ├── project.pbxproj
141
+ │   │   └── xcuserdata
142
+ │   │   └── wanyakun.xcuserdatad
143
+ │   │   └── xcschemes
144
+ │   │   └── xcschememanagement.plist
145
+ │   └── DemoTests
146
+ │   ├── DemoTests.m
147
+ │   └── Info.plist
148
+ ├── Demo.xcworkspace
149
+ │   ├── contents.xcworkspacedata
150
+ │   ├── xcshareddata
151
+ │   │   └── IDEWorkspaceChecks.plist
152
+ │   └── xcuserdata
153
+ │   └── wanyakun.xcuserdatad
154
+ │   └── UserInterfaceState.xcuserstate
155
+ ├── Gemfile
156
+ ├── Gemfile.lock
157
+ ├── Podfile
158
+ ├── Podfile.lock
159
+ └── dependency.json
160
+ ```
161
+
162
+ 项目编译使用到Ruby 2.3.0, 并使用Rake进行构建、打包和发布。
163
+
164
+ ### 开发
165
+
166
+ 克隆代码后进入项目目录,执行`bin/setup`来安装依赖。
167
+
168
+ 想要在本机安装此gem,可以执行`bundle exec rake install`。如果想要发布一个新版本,先更新`version.rb`里的版本号,然后执行`bundle exec rake release`,这个操作将为这个版本创建一个git tag,并且推送git提交和tags,而且会推送`.gem`文件到[rubygems.org](https://rubygems.org)。
169
+
170
+ ### 联系
171
+
172
+ 我们的邮箱地址: wanyakun@ppdai.com, 欢迎来信联系。
173
+
174
+ ### 开源许可协议
175
+
176
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/YKBIU.gemspec ADDED
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "YKBIU/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "YKBIU"
8
+ spec.version = YKBIU::VERSION
9
+ spec.authors = ["wanyakun"]
10
+ spec.email = ["wanyakun@vip.qq.com"]
11
+
12
+ spec.summary = %q{iOS应用依赖管理gem.}
13
+ spec.description = %q{用来处理iOS应用的CocoaPods依赖关系,根据远程依赖配置数据自动安装配置.}
14
+ spec.homepage = "http://github.com/wanyakun/YKBIU"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.15"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "cocoapods"
27
+ spec.add_development_dependency "fastlane"
28
+ spec.add_development_dependency "dotenv"
29
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "YKBIU"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module YKBIU
2
+ VERSION = "0.1.0"
3
+ end
data/lib/YKBIU.rb ADDED
@@ -0,0 +1,144 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2020 wanyakun
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require "YKBIU/version"
24
+
25
+ module Pod
26
+ class Podfile
27
+
28
+ # 从url获取依赖并进行依赖安装
29
+ #
30
+ # @param url 获取依赖配置的请求url
31
+ # @param params 获取依赖配置的请求参数
32
+ # @param method 获取依赖配置的请求方式
33
+ # @param ignores 依赖安装忽略列表,默认为空
34
+ #
35
+ def makeup_pods(url, params, method, ignores = [])
36
+ UI.title "makeup pods dependency from #{url}"
37
+ file = "dependency.json"
38
+ dependencies = peform_request(url, params, method)
39
+ if dependencies
40
+ #1.保存json
41
+ File.delete(file) if File.exist?(file)
42
+ File.open(file, "w") { |io| io.syswrite(JSON.generate(dependencies))}
43
+ #2.安装依赖
44
+ yk_pod(dependencies, ignores)
45
+ else
46
+ #1.读取本地保存的json
47
+ json = File.read(file) if File.exist?(file)
48
+ dependencies = JSON.parse(json)
49
+ #2.安装依赖
50
+ yk_pod(dependencies, ignores) if dependencies
51
+ end
52
+ end
53
+
54
+ # 安装依赖,在安装依赖的过程中判断是否在ignores中,
55
+ # 如果在ignores中则忽略不进行依赖安装,
56
+ # 如果不在ignores,判断是否有componentVersion,优先是用版本进行安装,否则进行url、tag、commit等配置进行安装依赖
57
+ #
58
+ # @param dependencies 依赖列表
59
+ # @param ignores 忽略列表
60
+ #
61
+ def yk_pod(dependencies, ignores)
62
+ dependencies.each { |value|
63
+ componentName = value.fetch("dependencyName", nil)
64
+ # 忽略组件名称不存的依赖
65
+ return unless componentName
66
+ # 跳过在ignores列表中的依赖
67
+ next if ignores.include? componentName
68
+
69
+ version = value.fetch("componentVersion", nil)
70
+ if version
71
+ pod(componentName, version)
72
+ else
73
+ hash = {}
74
+ value.each{ |rKey, rValue|
75
+ hash[:git] = rValue if rKey == "gitUrl"
76
+ hash[:branch] = rValue if rKey == "componentBranch"
77
+ hash[:tag] = rValue if rKey == "tag"
78
+ hash[:commit] = rValue if rKey == "commit"
79
+ hash[:configuration] = rValue if rKey == "configuration"
80
+ hash[:path] = rValue if rKey == "path"
81
+ hash[:podspec] = rValue if rKey == "podspec"
82
+ hash[:subspecs] = rValue if rKey == "subspecs"
83
+ }
84
+ pod(componentName, hash)
85
+ end
86
+ }
87
+ end
88
+
89
+ # 处理获取依赖的网络请求
90
+ #
91
+ # @param url 请求的url
92
+ # @param paras 请求的参数
93
+ # @param method 请求的方式
94
+ #
95
+ def peform_request(url, params, method)
96
+ require 'rest'
97
+ require 'json'
98
+
99
+ headers = {'Accept' => 'application/json, */*', 'Content-Type' => 'application/json; charset=utf-8'}
100
+ if 'GET' == method || 'get' == method
101
+ response = REST.get(url, headers, params)
102
+ handleResponse(url, response)
103
+ elsif 'POST' == method || 'post' == method
104
+ response = REST.post(url, params.to_json, headers)
105
+ handleResponse(url, response)
106
+ end
107
+ end
108
+
109
+ # 处理网络请求返回来的内容
110
+ #
111
+ # @param response 应返回json数据结构,如下:
112
+ #
113
+ # {
114
+ # "result": 0,
115
+ # "codeMsg": "",
116
+ # "resultMessage": "响应成功",
117
+ # "content": [
118
+ # {
119
+ # "dependencyName": "AFNetworking",
120
+ # "componentVersion": "~> 3.2.0"
121
+ # }
122
+ # ]
123
+ # }
124
+ #
125
+ def handleResponse(url, response)
126
+ if response.ok?
127
+ body = JSON.parse(response.body)
128
+ result = body["result"]
129
+ if result == 0
130
+ content = body["content"]
131
+ UI.title content
132
+ content
133
+ else
134
+ resultMessage = body["resultMessage"]
135
+ CoreUI.warn "Request to #{url} has error - #{resultMessage}"
136
+ nil
137
+ end
138
+ else
139
+ CoreUI.warn "Request to #{url} failed - #{response.status_code}"
140
+ nil
141
+ end
142
+ end
143
+ end
144
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: YKBIU
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - wanyakun
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cocoapods
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fastlane
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: 用来处理iOS应用的CocoaPods依赖关系,根据远程依赖配置数据自动安装配置.
84
+ email:
85
+ - wanyakun@vip.qq.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - YKBIU.gemspec
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/YKBIU.rb
99
+ - lib/YKBIU/version.rb
100
+ homepage: http://github.com/wanyakun/YKBIU
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.7.10
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: iOS应用依赖管理gem.
124
+ test_files: []