cocoapods-cafswitcher 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 54a736cff9760f59099f7cd9e00de5f04ca7d2d4e4d23c3c243bd395c82560e0
4
+ data.tar.gz: 42d52fc682bddeedef53b731f1704a8b0d1451edbecda27aef8cc686ed5033bc
5
+ SHA512:
6
+ metadata.gz: d4acb5b8fdc0609355a5b74d87776632cb0a366eabfd1375dc19e94415076142f1ed19b654b0ab0b96af6863ca8406c236249e0f042d26b151d49e9162d1521e
7
+ data.tar.gz: 655783e68aa66669e00fa206108c79bc22589c43d1a83fb4cf75591b3c7e8625d043596b624b2e9ed53b97f3c75b13dbd4eb9127709c471f6ac5c61dce606db9
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ Example/
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-cafswitcher.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+ gem 'cocoapods-plugins'
9
+ gem 'cocoapods-packager'
10
+ gem 'mocha'
11
+ gem 'bacon'
12
+ gem 'mocha-on-bacon'
13
+ gem 'prettybacon'
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,101 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-cafswitcher (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (3.0.0)
10
+ activesupport (4.2.10)
11
+ i18n (~> 0.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ atomos (0.1.3)
16
+ bacon (1.2.0)
17
+ claide (1.0.2)
18
+ cocoapods (1.5.3)
19
+ activesupport (>= 4.0.2, < 5)
20
+ claide (>= 1.0.2, < 2.0)
21
+ cocoapods-core (= 1.5.3)
22
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
23
+ cocoapods-downloader (>= 1.2.0, < 2.0)
24
+ cocoapods-plugins (>= 1.0.0, < 2.0)
25
+ cocoapods-search (>= 1.0.0, < 2.0)
26
+ cocoapods-stats (>= 1.0.0, < 2.0)
27
+ cocoapods-trunk (>= 1.3.0, < 2.0)
28
+ cocoapods-try (>= 1.1.0, < 2.0)
29
+ colored2 (~> 3.1)
30
+ escape (~> 0.0.4)
31
+ fourflusher (~> 2.0.1)
32
+ gh_inspector (~> 1.0)
33
+ molinillo (~> 0.6.5)
34
+ nap (~> 1.0)
35
+ ruby-macho (~> 1.1)
36
+ xcodeproj (>= 1.5.7, < 2.0)
37
+ cocoapods-core (1.5.3)
38
+ activesupport (>= 4.0.2, < 6)
39
+ fuzzy_match (~> 2.0.4)
40
+ nap (~> 1.0)
41
+ cocoapods-deintegrate (1.0.2)
42
+ cocoapods-downloader (1.2.1)
43
+ cocoapods-packager (1.5.0)
44
+ cocoapods (>= 1.1.1, < 2.0)
45
+ cocoapods-plugins (1.0.0)
46
+ nap
47
+ cocoapods-search (1.0.0)
48
+ cocoapods-stats (1.0.0)
49
+ cocoapods-trunk (1.3.1)
50
+ nap (>= 0.8, < 2.0)
51
+ netrc (~> 0.11)
52
+ cocoapods-try (1.1.0)
53
+ colored2 (3.1.2)
54
+ concurrent-ruby (1.0.5)
55
+ escape (0.0.4)
56
+ fourflusher (2.0.1)
57
+ fuzzy_match (2.0.4)
58
+ gh_inspector (1.1.3)
59
+ i18n (0.9.5)
60
+ concurrent-ruby (~> 1.0)
61
+ metaclass (0.0.4)
62
+ minitest (5.11.3)
63
+ mocha (1.7.0)
64
+ metaclass (~> 0.0.1)
65
+ mocha-on-bacon (0.2.3)
66
+ mocha (>= 0.13.0)
67
+ molinillo (0.6.6)
68
+ nanaimo (0.2.6)
69
+ nap (1.1.0)
70
+ netrc (0.11.0)
71
+ prettybacon (0.0.2)
72
+ bacon (~> 1.2)
73
+ rake (12.3.1)
74
+ ruby-macho (1.2.0)
75
+ thread_safe (0.3.6)
76
+ tzinfo (1.2.5)
77
+ thread_safe (~> 0.1)
78
+ xcodeproj (1.6.0)
79
+ CFPropertyList (>= 2.3.3, < 4.0)
80
+ atomos (~> 0.1.3)
81
+ claide (>= 1.0.2, < 2.0)
82
+ colored2 (~> 3.1)
83
+ nanaimo (~> 0.2.6)
84
+
85
+ PLATFORMS
86
+ ruby
87
+
88
+ DEPENDENCIES
89
+ bacon
90
+ bundler (~> 1.3)
91
+ cocoapods
92
+ cocoapods-cafswitcher!
93
+ cocoapods-packager
94
+ cocoapods-plugins
95
+ mocha
96
+ mocha-on-bacon
97
+ prettybacon
98
+ rake
99
+
100
+ BUNDLED WITH
101
+ 1.16.3
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 handa <handa@ke.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cocoapods-cafswitcher
2
+
3
+ A description of cocoapods-cafswitcher.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-cafswitcher
8
+
9
+ ## Usage
10
+
11
+ $ pod spec cafswitcher POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-cafswitcher/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-cafswitcher'
8
+ spec.version = CocoapodsCafswitcher::VERSION
9
+ spec.authors = ['handa']
10
+ spec.email = ['794363716@qq.com']
11
+ spec.description = %q{A short description of cocoapods-cafswitcher.}
12
+ spec.summary = %q{A longer description of cocoapods-cafswitcher.}
13
+ spec.homepage = 'https://github.com/piaoying/cocoapods-cafswitcher.git'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-cafswitcher/gem_version'
@@ -0,0 +1,201 @@
1
+ # encoding: UTF-8
2
+ require 'fileutils'
3
+ require 'yaml'
4
+ require 'pathname'
5
+
6
+ require_relative('podfile_switch')
7
+
8
+ # noinspection RubyInterpreter
9
+ Pod::HooksManager.register('cocoapods-cafswitcher', :pre_install) do |installer_content|
10
+ ## 处理所有命令的优先级关系
11
+ #
12
+ # 对于全局变量
13
+ # all_framework! > all_archive! > all_source!
14
+ # 如果不指定,默认是framwork的形式
15
+ #
16
+ #
17
+ # 对与有针对特定的pod库的局部变量
18
+ # isFramework > isArchive > isSource
19
+ #
20
+ #
21
+ # 如果全局变量和局部变量同时出现
22
+ # 全部变量统领全局
23
+ # 布局变量针对特殊pod库
24
+ #
25
+ # 如果对两个相同的库。如:
26
+ # LJCache/Foundation 和 LJCache/UIKit 算两个库,可以分别进行控制
27
+ # 如果出现:
28
+ # all_archive!
29
+ # pod 'LJCache/Foundation', isFramework => true
30
+ # pod 'LJCache/UIKit'
31
+ #
32
+ # 则 LJCache/Foundation 安装为framework
33
+ # LJCache/UIKit 安装为archive
34
+ #
35
+ #
36
+ allNames = Pod::Podfile.allPodName.uniq
37
+
38
+ if ENV['IS_ARCHIVE']
39
+ ENV.delete('IS_ARCHIVE')
40
+ for name in allNames
41
+ setEnv(name, "_ARCHIVE")
42
+ # ENV["#{name}_ARCHIVE"] = '1'
43
+ end
44
+ elsif ENV['IS_SOURCE']
45
+ ENV.delete('IS_SOURCE')
46
+ for name in allNames
47
+ setEnv(name, "_SOURCE")
48
+ # ENV["#{name}_SOURCE"] = '1'
49
+ end
50
+ end
51
+
52
+ if ENV['IS_DEBUG']
53
+ ENV.delete('IS_DEBUG')
54
+ for name in allNames
55
+ setEnv(name, "_DEBUG")
56
+ # ENV["#{name}_DEBUG"] = '1'
57
+ end
58
+ end
59
+
60
+ # 对debug和release切换,release级别高
61
+ for debugName in Pod::Podfile.debugPackageList.uniq
62
+ cleanDebugENV(debugName)
63
+ setEnv(debugName, "_DEBUG")
64
+ # ENV["#{debugName}_DEBUG"] = '1'
65
+ end
66
+
67
+ for releaseName in Pod::Podfile.releasePackageList.uniq
68
+ cleanDebugENV(releaseName)
69
+ setEnv(releaseName, "_RELEASE")
70
+ # ENV["#{releaseName}_RELEASE"] = '1'
71
+ end
72
+
73
+ # 二进制切换
74
+ for sourceName in Pod::Podfile.sourceList.uniq
75
+ cleanENV(sourceName)
76
+ setEnv(sourceName, "_SOURCE")
77
+ # ENV["#{sourceName}_SOURCE"] = '1'
78
+ end
79
+
80
+ for archiveName in Pod::Podfile.archiveList.uniq
81
+ cleanENV(archiveName)
82
+ setEnv(archiveName, "_ARCHIVE")
83
+ # ENV["#{archiveName}_ARCHIVE"] = '1'
84
+ end
85
+
86
+ for frameworkName in Pod::Podfile.frameworkList.uniq
87
+ cleanENV(frameworkName)
88
+ setEnv(frameworkName, "_FRAMEWORK")
89
+ # ENV["#{frameworkName}_FRAMEWORK"] = '1'
90
+ end
91
+
92
+ sourceList = Array.new
93
+ archiveList = Array.new
94
+ frameworkList = Array.new
95
+ debugPackageList = Array.new
96
+ releasePackageList = Array.new
97
+
98
+ for name in allNames
99
+ if ENV["#{name}_DEBUG"] == '1'
100
+ debugPackageList << name
101
+ else
102
+ releasePackageList << name
103
+ end
104
+
105
+ if ENV["#{name}_SOURCE"] == '1'
106
+ sourceList << name
107
+ elsif ENV["#{name}_ARCHIVE"] == '1'
108
+ archiveList << name
109
+ else
110
+ frameworkList << name
111
+ end
112
+ end
113
+ Pod::UI.puts "\n"
114
+ Pod::UI.puts "is Source :\n #{sourceList}"
115
+ Pod::UI.puts "is Archive :\n #{archiveList}"
116
+ Pod::UI.puts "is Framework :\n #{frameworkList}"
117
+ Pod::UI.puts "is debugPackage :\n #{debugPackageList}"
118
+ Pod::UI.puts "is releasePackage :\n #{releasePackageList}"
119
+
120
+ # 如果某一个Pod和上一次比发生变化,需要清除缓存
121
+ # 1. 清除pod缓存
122
+ # pod cache clean LJCache --all
123
+ # 2. 清除壳工程的pod文件夹下的缓存(如果指向的是path,即本地,不做处理)
124
+ # rm -r -f Pod/LJCache
125
+ # 3. 保存本次配置
126
+ #
127
+
128
+ caf_hash = Hash["sourceList" => sourceList, "archiveList" => archiveList, "frameworkList" => frameworkList,
129
+ "debugPackageList" => debugPackageList, "releasePackageList" => releasePackageList]
130
+
131
+ config = Pod::Config.instance
132
+
133
+ require_relative('cafswitcher_config')
134
+
135
+ configPath = config.cafConfigPath
136
+ FileUtils.mkdir_p(configPath) if !configPath.exist?
137
+ configFile = config.cafConfigFile
138
+ cafConfig = Hash.new
139
+ if configFile.exist?
140
+ cafConfig = YAML.load(File.open(configFile))
141
+ else
142
+ FileUtils.touch configFile
143
+ end
144
+ # 比较不同
145
+ changedSubPods = Array.new
146
+ cafConfig.each do |key, value|
147
+ if key == "debugPackageList"
148
+ changedSubPods |= (value | debugPackageList) - (value & debugPackageList)
149
+ elsif key == "releasePackageList"
150
+ changedSubPods |= (value | releasePackageList) - (value & releasePackageList)
151
+ elsif key == "sourceList"
152
+ changedSubPods |= (value | sourceList) - (value & sourceList)
153
+ elsif key == "archiveList"
154
+ changedSubPods |= (value | archiveList) - (value & archiveList)
155
+ elsif key == "frameworkList"
156
+ changedSubPods |= (value | frameworkList) - (value & frameworkList)
157
+ end
158
+ end
159
+ Pod::UI.puts "\nchanged sub Pod is:\n " + changedSubPods.to_s if changedSubPods.length > 0
160
+ # changedPod 里是根据subspec来存的,需要进行合并,找到pod库而不是含有subspec的库
161
+ changedPods = Array.new
162
+ changedSubPods.each {|subPod| changedPods << subPod.split("_")[0]}
163
+ changedPods.uniq!
164
+ Pod::UI.puts "\nchanged Pod is:\n " + changedPods.to_s if changedPods.length > 0
165
+
166
+ # 根据不同删除cache
167
+ podRoot = config.project_pods_root
168
+ changedPods.each do |changedPod|
169
+ # TODO如果pod 里没有用到preserve_paths,需要清除 pod cache clean
170
+
171
+ # 清除目录 pods 文件夹下的缓存
172
+ changedPodPath = podRoot + changedPod
173
+ FileUtils.rm_r(changedPodPath) if changedPodPath.exist?
174
+ end
175
+
176
+ # 把新的配置写入file
177
+ File.open(configFile, "wb") {|f| YAML.dump(caf_hash, f) }
178
+ end
179
+
180
+
181
+ def setEnv(name, suffix)
182
+ ENV["#{name}#{suffix}"] = '1'
183
+ podName = name.split("_")[0]
184
+ ENV["#{podName}#{suffix}"] = '1'
185
+ end
186
+
187
+
188
+
189
+ def cleanENV(name)
190
+ ENV.delete("#{name}_SOURCE")
191
+ ENV.delete("#{name}_ARCHIVE")
192
+ ENV.delete("#{name}_FRAMEWORK")
193
+ ENV.delete('IS_SOURCE')
194
+ ENV.delete('IS_ARCHIVE')
195
+ end
196
+
197
+ def cleanDebugENV(name)
198
+ ENV.delete("#{name}_DEBUG")
199
+ ENV.delete("#{name}_RELEASE")
200
+ ENV.delete('IS_DEBUG')
201
+ end
@@ -0,0 +1,19 @@
1
+ module Pod
2
+ # Stores the global configuration of CocoaPods.
3
+ #
4
+ class Config
5
+
6
+ attr_accessor :caf_config_path
7
+
8
+ def cafConfigPath
9
+ @caf_config_path = project_root + ".config/"
10
+ end
11
+
12
+ attr_accessor :caf_config_file
13
+
14
+ def cafConfigFile
15
+ @caf_config_file = caf_config_path + "cafswitcher_config.yml"
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-cafswitcher/command/cafswitcher'
@@ -0,0 +1,44 @@
1
+ module Pod
2
+ class Command
3
+ # This is an example of a cocoapods plugin adding a top-level subcommand
4
+ # to the 'pod' command.
5
+ #
6
+ # You can also create subcommands of existing or new commands. Say you
7
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
8
+ # (e.g. `pod list deprecated`), there are a few things that would need
9
+ # to change.
10
+ #
11
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
12
+ # the class to exist in the the Pod::Command::List namespace
13
+ # - change this class to extend from `List` instead of `Command`. This
14
+ # tells the plugin system that it is a subcommand of `list`.
15
+ # - edit `lib/cocoapods_plugins.rb` to require this file
16
+ #
17
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
18
+ # in the `plugins.json` file, once your plugin is released.
19
+ #
20
+ class Cafswitcher < Command
21
+ self.summary = 'Short description of cocoapods-cafswitcher.'
22
+
23
+ self.description = <<-DESC
24
+ Longer description of cocoapods-cafswitcher.
25
+ DESC
26
+
27
+ self.arguments = 'NAME'
28
+
29
+ def initialize(argv)
30
+ @name = argv.shift_argument
31
+ super
32
+ end
33
+
34
+ def validate!
35
+ super
36
+ help! 'A Pod name is required.' unless @name
37
+ end
38
+
39
+ def run
40
+ UI.puts "Add your implementation for the cocoapods-cafswitcher plugin in #{__FILE__}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsCafswitcher
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,211 @@
1
+ module Pod
2
+
3
+ class Podfile
4
+
5
+ # add flag
6
+ # :isSource => true
7
+ def self.isSource
8
+ :isSource
9
+ end
10
+
11
+ # add flag
12
+ # :isArchive => true
13
+ def self.isArchive
14
+ :isArchive
15
+ end
16
+ # add flag
17
+ # :isFramework
18
+ def self.isFramework
19
+ :isFramework
20
+ end
21
+
22
+ # add flag
23
+ # :isDebugPackage
24
+ def self.isDebugPackage
25
+ :isDebugPackage
26
+ end
27
+
28
+ # add flag
29
+ # :isReleasePackage
30
+ def self.isReleasePackage
31
+ :isReleasePackage
32
+ end
33
+
34
+ @@sourceList = Array.new
35
+
36
+ def Podfile.sourceList
37
+ @@sourceList
38
+ end
39
+
40
+ @@archiveList = Array.new
41
+
42
+ def Podfile.archiveList
43
+ @@archiveList
44
+ end
45
+
46
+ @@frameworkList = Array.new
47
+
48
+ def Podfile.frameworkList
49
+ @@frameworkList
50
+ end
51
+
52
+ @@debugPackageList = Array.new
53
+
54
+ def Podfile.debugPackageList
55
+ @@debugPackageList
56
+ end
57
+
58
+ @@releasePackageList = Array.new
59
+
60
+ def Podfile.releasePackageList
61
+ @@releasePackageList
62
+ end
63
+
64
+ # all the name of Pod
65
+ @@allPodName = Array.new
66
+
67
+ def Podfile.allPodName
68
+ @@allPodName
69
+ end
70
+
71
+ module DSL
72
+ # Enable code for all pods
73
+ # it has a lower priority to other binary settings
74
+ def all_source!
75
+ ENV['IS_SOURCE'] = '1'
76
+ end
77
+
78
+ # Enable archive for all pods
79
+ # it has a lower priority to other binary settings
80
+ def all_archive!
81
+ ENV['IS_ARCHIVE'] = '1'
82
+ end
83
+
84
+ # Enable debug package for all pods
85
+ # it has a lower priority to other binary settings
86
+ def all_debug_package!
87
+ ENV['IS_DEBUG'] = '1'
88
+ end
89
+
90
+ end
91
+
92
+ class TargetDefinition
93
+
94
+
95
+ def parse_isFramework(name, requirements)
96
+ options = requirements.last
97
+ return requirements unless options.is_a?(Hash)
98
+ isFramework = options.has_key?(Pod::Podfile.isFramework)
99
+ # pod_name = Specification.root_name(name)
100
+ if isFramework
101
+ Pod::Podfile.frameworkList << name.gsub(/[\/]/, '_')
102
+ end
103
+ requirements.pop if options.empty?
104
+ end
105
+
106
+ def parse_isSource(name, requirements)
107
+ options = requirements.last
108
+ return requirements unless options.is_a?(Hash)
109
+
110
+ isSource = options.has_key?(Pod::Podfile.isSource)
111
+ # pod_name = Specification.root_name(name)
112
+ if isSource
113
+ Pod::Podfile.sourceList << name.gsub(/[\/]/, '_')
114
+ end
115
+ requirements.pop if options.empty?
116
+ end
117
+
118
+ def parse_isArchive(name, requirements)
119
+ options = requirements.last
120
+ return requirements unless options.is_a?(Hash)
121
+
122
+ isArchive = options.has_key?(Pod::Podfile.isArchive)
123
+ # pod_name = Specification.root_name(name)
124
+ if isArchive
125
+ Pod::Podfile.archiveList << name.gsub(/[\/]/, '_')
126
+ end
127
+
128
+ requirements.pop if options.empty?
129
+ end
130
+
131
+ def parse_debug_package(name, requirements)
132
+ options = requirements.last
133
+ return requirements unless options.is_a?(Hash)
134
+
135
+ isDebugPackage = options.has_key?(Pod::Podfile.isDebugPackage)
136
+ # pod_name = Specification.root_name(name)
137
+ if isDebugPackage
138
+ Pod::Podfile.debugPackageList << name.gsub(/[\/]/, '_')
139
+ end
140
+ requirements.pop if options.empty?
141
+ end
142
+
143
+ def parse_release_package(name, requirements)
144
+ options = requirements.last
145
+ return requirements unless options.is_a?(Hash)
146
+
147
+ isReleasePackage = options.has_key?(Pod::Podfile.isReleasePackage)
148
+ # pod_name = Specification.root_name(name)
149
+ if isReleasePackage
150
+ Pod::Podfile.releasePackageList << name.gsub(/[\/]/, '_')
151
+ end
152
+ requirements.pop if options.empty?
153
+ end
154
+
155
+ # ---- patch method ----
156
+ # We want modify `store_pod` method, but it's hard to insert a line in the
157
+ # implementation. So we patch a method called in `store_pod`.
158
+ old_method = instance_method(:parse_inhibit_warnings)
159
+
160
+ define_method(:parse_inhibit_warnings) do |name, requirements|
161
+ parse_isFramework(name, requirements)
162
+ parse_isSource(name, requirements)
163
+ parse_isArchive(name, requirements)
164
+ parse_debug_package(name, requirements)
165
+ parse_release_package(name, requirements)
166
+ # pod_name = Specification.root_name(name)
167
+ Pod::Podfile.allPodName << name.gsub(/[\/]/, '_')
168
+ old_method.bind(self).(name, requirements)
169
+ end
170
+
171
+ def deep_copy(o)
172
+ Marshal.load(Marshal.dump(o))
173
+ end
174
+
175
+ def clean(name, requirements)
176
+ tmp_hash = deep_copy(requirements)
177
+ options = tmp_hash.last
178
+ return tmp_hash unless options.is_a?(Hash)
179
+
180
+ isFramework = options.delete(Pod::Podfile.isFramework)
181
+ isSource = options.delete(Pod::Podfile.isSource)
182
+ isArchive = options.delete(Pod::Podfile.isArchive)
183
+ isDebugPackage = options.delete(Pod::Podfile.isDebugPackage)
184
+ isReleasePackage = options.delete(Pod::Podfile.isReleasePackage)
185
+ tmp_hash.pop if options.empty?
186
+ tmp_hash
187
+ end
188
+
189
+
190
+ define_method(:store_pod) do |name, *requirements|
191
+ return if parse_subspecs(name, requirements) # This parse method must be called first
192
+ parse_inhibit_warnings(name, requirements)
193
+ parse_configuration_whitelist(name, requirements)
194
+
195
+ # 去掉添加的字段
196
+ tmp_hash = clean(name, requirements)
197
+ if tmp_hash && !tmp_hash.empty?
198
+ pod = { name => tmp_hash }
199
+ else
200
+ pod = name
201
+ end
202
+
203
+ get_hash_value('dependencies', []) << pod
204
+ nil
205
+ end
206
+
207
+
208
+ end
209
+
210
+ end
211
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-cafswitcher/Main'
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-cafswitcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - handa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-28 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A short description of cocoapods-cafswitcher.
42
+ email:
43
+ - 794363716@qq.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-cafswitcher.gemspec
55
+ - lib/cocoapods-cafswitcher.rb
56
+ - lib/cocoapods-cafswitcher/Main.rb
57
+ - lib/cocoapods-cafswitcher/cafswitcher_config.rb
58
+ - lib/cocoapods-cafswitcher/command.rb
59
+ - lib/cocoapods-cafswitcher/command/cafswitcher.rb
60
+ - lib/cocoapods-cafswitcher/gem_version.rb
61
+ - lib/cocoapods-cafswitcher/podfile_switch.rb
62
+ - lib/cocoapods_plugin.rb
63
+ - spec/spec_helper.rb
64
+ homepage: https://github.com/piaoying/cocoapods-cafswitcher.git
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.7.7
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: A longer description of cocoapods-cafswitcher.
88
+ test_files:
89
+ - spec/spec_helper.rb