cocoapods-prefer 1.0.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: 2eaa54ad6402036db653bcfb83dad676a669d82ca6b8ac1a83c23f1d2f0d46ba
4
+ data.tar.gz: 487da7d570c90b6207535dec57b9dab7743e255e12e62ad66d337c51117c21bc
5
+ SHA512:
6
+ metadata.gz: 92f602b01312d621bd038ac9adb5e1852ff2128679b8a64de258455785f7ed47a322d5540975e00546999de42e341b5c99e9dac4fbe159b6841167155371c163
7
+ data.tar.gz: e89448b4178c92cf7814ddcd393cc278b04f3732f3e70f10f469e811b3c8acedb0ffbb37b03a90a9665d4043ede0711713853f2f16d2b3d3adc57efd1f475381
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-prefer.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020 bob <bob170731@gmail.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,78 @@
1
+ # cocoapods-prefer
2
+
3
+ A cocoapods plugin to work with pod sources
4
+
5
+ ## Installation
6
+
7
+ Just install it
8
+
9
+ ```
10
+ gem install cocoapods-prefer
11
+ ```
12
+
13
+ or use Gemfile with `bundle install`
14
+
15
+ ```
16
+ source 'https://rubygems.org/'
17
+
18
+ gem 'cocoapods', '>= 1.8.4'
19
+ gem 'colored2','~> 3.1'
20
+ gem 'neatjson','~> 0.9'
21
+ gem 'cocoapods-prefer','~ 1.0'
22
+
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ - only work with git ssh url
28
+
29
+ ### in Podfile
30
+
31
+
32
+ ```ruby
33
+
34
+ require "cocoapods-prefer"
35
+
36
+ # only source it
37
+ source "git@github.com:DanboDuan/Test_Dislike_Specs.git"
38
+ source "git@github.com:DanboDuan/Test_Prefer_Specs.git"
39
+
40
+
41
+
42
+ plugin 'cocoapods-prefer'
43
+
44
+ prefer_source("Test_Prefer","git@github.com:DanboDuan/Test_Prefer_Specs.git")
45
+
46
+ target 'Example' do
47
+
48
+ lock_source_with_url("git@github.com:DanboDuan/Test_Prefer_Specs.git") do
49
+ prefer_source_pod 'AFNetworking'
50
+ end
51
+
52
+ lock_source_with_url("git@github.com:DanboDuan/Test_Dislike_Specs.git") do
53
+ dislike_source_pod 'FMDB'
54
+ end
55
+
56
+ pod 'Godzippa'
57
+ pod 'XcodeCoverage'
58
+
59
+ end
60
+ ```
61
+
62
+ ### rules
63
+
64
+ - AFNetworking then will prefer the source if it meets requirement
65
+ - if it does not meet requirement, the preferred source does not work
66
+ - FMDB then will prefer other sources unless only the source meets requirement
67
+ - `prefer_source` work for all the pods if it meets requirement
68
+ - `Godzippa` is not in the preferred source, so it does not work
69
+
70
+ ## Example
71
+
72
+ see [TestExample](https://github.com/DanboDuan/TestExample)
73
+
74
+ ## Contribute
75
+
76
+ if you like
77
+
78
+ ![like it](https://raw.githubusercontent.com/DanboDuan/cocoapods-unit-test/master/like_it.jpg)
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,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-prefer/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-prefer'
8
+ spec.version = CocoapodsPrefer::VERSION
9
+ spec.authors = ['bob']
10
+ spec.email = ['bob170731@gmail.com']
11
+ spec.description = %q{A short description of cocoapods-prefer.}
12
+ spec.summary = %q{A longer description of cocoapods-prefer.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-prefer'
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_dependency 'xcodeproj','~> 1.10'
22
+ spec.add_dependency 'cocoapods-core','~> 1.8'
23
+ spec.add_dependency 'cocoapods','~> 1.8'
24
+ spec.add_dependency 'neatjson','~> 0.9'
25
+ spec.add_dependency 'colored2','~> 3.0'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 2.1'
28
+ spec.add_development_dependency 'rake',"~> 12.3"
29
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-prefer/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-prefer/gem_version'
@@ -0,0 +1,207 @@
1
+ require 'cocoapods-core'
2
+ require 'cocoapods'
3
+ require 'singleton'
4
+ require 'colored2'
5
+ require 'neatjson'
6
+ require 'cocoapods-prefer/lock'
7
+ require 'cocoapods-prefer/lockfile'
8
+ module Pod
9
+ class PreferConfig
10
+ include Singleton
11
+ include PreferLock
12
+ include PreferLockFile
13
+ attr_accessor :prefer_sources
14
+ attr_accessor :prefer_source_urls
15
+ attr_accessor :dislike_source_urls
16
+ attr_accessor :dislike_sources
17
+
18
+ def installed?
19
+ !prefer_source_urls.empty? || !dislike_source_urls.empty?
20
+ end
21
+
22
+ def prefer_sources
23
+ @prefer_sources ||= {}
24
+ end
25
+
26
+ def prefer_source_urls
27
+ @prefer_source_urls ||= {}
28
+ end
29
+
30
+ def dislike_sources
31
+ @dislike_sources ||= {}
32
+ end
33
+
34
+ def dislike_source_urls
35
+ @dislike_source_urls ||= {}
36
+ end
37
+
38
+
39
+ def prefer_source_options(user_options)
40
+ dislike = user_options[:dislike_sources]
41
+ unless dislike.nil? || dislike.empty? || !dislike.is_a?(Hash)
42
+ dislike.each { |source_name, url|
43
+ dislike_source(source_name, url)
44
+ }
45
+ end
46
+
47
+ sources = user_options[:prefer_sources]
48
+ unless sources.nil? || sources.empty? || !sources.is_a?(Hash)
49
+ sources.each { |source_name, url|
50
+ prefer_source(source_name, url)
51
+ }
52
+ end
53
+ end
54
+
55
+ def dislike_source(source_name, url)
56
+ preferred = prefer_source_urls.select { |e, u|
57
+ e == source_name || u == url
58
+ }
59
+
60
+ unless preferred.empty?
61
+ UI.puts "#{source_name} or #{url} is preferred. Ignored!".red
62
+ return
63
+ end
64
+
65
+ UI.puts "dislike #{source_name} with #{url}".green
66
+ add_dislike_source(source_name, url)
67
+ end
68
+
69
+ def add_dislike_source(source_name, url)
70
+ unless validate_name_and_url?(source_name, url)
71
+ return
72
+ end
73
+
74
+ old = dislike_source_urls.fetch(source_name, nil)
75
+
76
+ raise Informative, "#{source_name} already exist and url = #{old}" if !old.nil? && old != url
77
+
78
+ return if url == old
79
+
80
+ dislike_source_urls[source_name] = url
81
+ dislike_sources[source_name] = source_with_name_and_url(source_name, url)
82
+ end
83
+
84
+ def prefer_source(source_name, url)
85
+ disliked = dislike_source_urls.select { |e, u|
86
+ e == source_name || u == url
87
+ }
88
+
89
+ unless disliked.empty?
90
+ UI.puts "#{source_name} or #{url} is disliked. Ignored!".red
91
+ return
92
+ end
93
+
94
+ UI.puts "prefer #{source_name} with #{url}".green
95
+ add_prefer_source(source_name, url)
96
+ end
97
+
98
+ def add_prefer_source(source_name, url)
99
+ unless validate_name_and_url?(source_name, url)
100
+ return
101
+ end
102
+
103
+ old = prefer_source_urls.fetch(source_name, nil)
104
+
105
+ raise Informative, "#{source_name} already exist and url = #{old}" if !old.nil? && old != url
106
+
107
+ return if url == old
108
+
109
+ prefer_source_urls[source_name] = url
110
+ prefer_sources[source_name] = source_with_name_and_url(source_name, url)
111
+ end
112
+
113
+ def validate_name_and_url?(source_name, url)
114
+ if source_name.nil? || source_name.empty?
115
+ UI.puts "name for the source is needed".red
116
+ return false
117
+ end
118
+
119
+ if url.nil? || url.empty?
120
+ UI.puts "url for the source #{source_name} is needed".red
121
+ return false
122
+ end
123
+
124
+ unless url =~ /git@([A-Za-z0-9_\.]+)(:|\/)([A-Za-z0-9_\/]+)(\.git)/
125
+ UI.puts "#{url} is not a git ssh like 'git@github.com:DanboDuan/cocoapods-prefer.git' ".red
126
+ return false
127
+ end
128
+
129
+ return true
130
+ end
131
+
132
+ def source_with_name_and_url(source_name, url)
133
+ path = File.expand_path(source_name, '~/.cocoapods/repos')
134
+ unless File.directory?(path)
135
+ UI.puts "Adding source repo..."
136
+ File.delete(path) if File.file?(path)
137
+ Pod::Command::Repo::Add.parse([source_name, url]).run
138
+ UI.puts "finish add source repo #{source_name}"
139
+ end
140
+ source = Pod::Source.new(path)
141
+ UI.puts "updating source repo"
142
+ source.update(true)
143
+ source
144
+ end
145
+
146
+ def prefer_pods
147
+ return [] if prefer_sources.empty?
148
+
149
+ pods = prefer_sources.map { |source_name, source|
150
+ source.pods
151
+ }.flatten.uniq
152
+
153
+ # pod_versions = pods.map { |pod|
154
+ # {pod => prefer_sources.map { |source_name, source|
155
+ # source.versions(pod).map(&:to_s)
156
+ # }.flatten.uniq}
157
+ # }.reduce({}) { |h, v| h.merge v }
158
+ # UI.puts JSON.neat_generate(pod_versions, sort:true, wrap:true, after_colon:1)
159
+
160
+ return pods
161
+ end
162
+
163
+ def dislike_pods
164
+ return [] if dislike_sources.empty?
165
+
166
+ return dislike_sources.map { |source_name, source|
167
+ source.pods
168
+ }.flatten.uniq
169
+ end
170
+
171
+ def report
172
+ report_lock_result()
173
+ if installed?
174
+ locked_result_pods = locked_pods()
175
+ result = lock_file_result().reject { |pod_name, url|
176
+ locked_result_pods.include?(pod_name)
177
+ }
178
+
179
+ prefer_urls = prefer_source_urls.values
180
+ prefer_pod_names = prefer_pods()
181
+
182
+ result.select { |pod_name, url|
183
+ prefer_pod_names.include?(pod_name) && !prefer_urls.include?(url)
184
+ }.each do |pod_name, url|
185
+ UI.puts "#{pod_name} using #{url} not in preferred sources".yellow
186
+ end
187
+
188
+ dislike_urls = dislike_source_urls.values
189
+ dislike_pod_names = dislike_pods()
190
+
191
+ result.select { |pod_name, url|
192
+ dislike_pod_names.include?(pod_name) && dislike_urls.include?(url)
193
+ }.each do |pod_name, url|
194
+ UI.puts "#{pod_name} using #{url} in disliked sources".yellow
195
+ end
196
+ end
197
+ end
198
+
199
+ module Mixin
200
+ def perfer_config
201
+ PreferConfig.instance
202
+ end
203
+ end
204
+
205
+ end
206
+
207
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsPrefer
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'cocoapods-prefer/hook/podfile'
2
+ require 'cocoapods-prefer/hook/installer'
3
+ require 'cocoapods-prefer/hook/resolver'
4
+ require 'cocoapods-prefer/hook/project'
5
+
@@ -0,0 +1,21 @@
1
+ require 'cocoapods-core'
2
+ require 'cocoapods'
3
+ # require 'cocoapods-prefer/config'
4
+
5
+ module Pod
6
+ # class Installer
7
+ ## record final result
8
+ # alias_method :cocoapods_prefer_specs, :root_specs
9
+ # def root_specs
10
+ # cocoapods_analysis_result = cocoapods_prefer_specs
11
+ # if PreferConfig.instance.installed?
12
+ # PreferConfig.instance.installed_specs = cocoapods_analysis_result.map { |result|
13
+ # {result.name.to_s => result.version.to_s}
14
+ # }.each_with_object({}){ |i, v|
15
+ # v.merge!(i)
16
+ # }
17
+ # end
18
+ # cocoapods_analysis_result
19
+ # end
20
+ # end
21
+ end
@@ -0,0 +1,43 @@
1
+ require 'colored2'
2
+ require 'cocoapods-core'
3
+ require 'cocoapods'
4
+ require 'cocoapods-prefer/config'
5
+
6
+ module Pod
7
+ class Podfile
8
+ module DSL
9
+
10
+ def prefer_source(source_name, url)
11
+ Pod::PreferConfig.instance.prefer_source(source_name, url)
12
+ source(url)
13
+ end
14
+
15
+ def dislike_source(source_name, url)
16
+ Pod::PreferConfig.instance.dislike_source(source_name, url)
17
+ end
18
+
19
+ def lock_source_with_url(url)
20
+ Pod::PreferConfig.instance.lock_url(url)
21
+ source(url)
22
+
23
+ yield if block_given?
24
+
25
+ Pod::PreferConfig.instance.unlock_url()
26
+ end
27
+
28
+ def prefer_source_pod(name = nil, *requirements)
29
+ pod(name, *requirements)
30
+
31
+ Pod::PreferConfig.instance.prefer_pod(name)
32
+ end
33
+
34
+ def dislike_source_pod(name = nil, *requirements)
35
+ pod(name, *requirements)
36
+
37
+ Pod::PreferConfig.instance.dislike_pod(name)
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,13 @@
1
+ module Pod
2
+ # class Project
3
+ # alias prefer_add_podfile add_podfile
4
+ # def add_podfile(podfile_path)
5
+ # prefer_file_path = File.expand_path("Podfile_prefer", File.dirname(podfile_path))
6
+ # if File.file?(prefer_file_path) && File.basename(podfile_path) == "Podfile"
7
+ # prefer_add_podfile(prefer_file_path)
8
+ # end
9
+ # prefer_add_podfile(podfile_path)
10
+ # end
11
+ # end
12
+ end
13
+
@@ -0,0 +1,96 @@
1
+ require 'cocoapods-core'
2
+ require 'cocoapods'
3
+ require 'cocoapods-prefer/config'
4
+
5
+ module Pod
6
+ class Resolver
7
+ include PreferConfig::Mixin
8
+ attr_accessor :prefer_pods
9
+ attr_accessor :prefer_source_urls
10
+ attr_accessor :dislike_pods
11
+ attr_accessor :dislike_source_urls
12
+
13
+ def prefer_source_urls
14
+ @prefer_source_urls ||= perfer_config.prefer_source_urls.values
15
+ end
16
+
17
+ def prefer_pods
18
+ @prefer_pods ||= perfer_config.prefer_pods()
19
+ end
20
+
21
+ def dislike_source_urls
22
+ @dislike_source_urls ||= perfer_config.dislike_source_urls.values
23
+ end
24
+
25
+ def dislike_pods
26
+ @dislike_pods ||= perfer_config.dislike_pods()
27
+ end
28
+
29
+ def prefer_specifications_filter(pod_name, specifications)
30
+ if perfer_config.installed? && prefer_pods.include?(pod_name)
31
+ filter = specifications.select { |s|
32
+ s.respond_to?('spec_source') && prefer_source_urls.include?(s.spec_source.url)
33
+ }
34
+
35
+ return filter unless filter.empty?
36
+ end
37
+
38
+ specifications
39
+ end
40
+
41
+ def dislike_specifications_filter(pod_name, specifications)
42
+ if perfer_config.installed? && dislike_pods.include?(pod_name)
43
+ filter = specifications.reject { |s|
44
+ s.respond_to?('spec_source') && dislike_source_urls.include?(s.spec_source.url)
45
+ }
46
+
47
+ return filter unless filter.empty?
48
+ end
49
+
50
+ specifications
51
+ end
52
+
53
+ def prefer_lock_specifications_filter(pod_name, specifications)
54
+ lock_url = perfer_config.lock_url_for_prefer_pod(pod_name)
55
+ unless lock_url.nil?
56
+ filter = specifications.select { |s|
57
+ s.respond_to?('spec_source') && lock_url == s.spec_source.url
58
+ }
59
+ return filter unless filter.empty?
60
+ end
61
+
62
+ specifications
63
+ end
64
+
65
+ def dislike_lock_specifications_filter(pod_name, specifications)
66
+ lock_url = perfer_config.lock_url_for_dislike_pod(pod_name)
67
+
68
+ unless lock_url.nil?
69
+ filter = specifications.reject { |s|
70
+ s.respond_to?('spec_source') && lock_url == s.spec_source.url
71
+ }
72
+
73
+ return filter unless filter.empty?
74
+ end
75
+
76
+ specifications
77
+ end
78
+
79
+ alias perfer_search_for search_for
80
+ ## Specification
81
+ ## return preferred source if meet requirement
82
+ def search_for(dependency)
83
+ # install_script_phases_for_dependency(dependency.root_name)
84
+ specifications = perfer_search_for(dependency)
85
+
86
+ pod_name = dependency.root_name
87
+ specifications = dislike_lock_specifications_filter(pod_name, specifications)
88
+ specifications = dislike_specifications_filter(pod_name, specifications)
89
+ specifications = prefer_lock_specifications_filter(pod_name, specifications)
90
+ specifications = prefer_specifications_filter(pod_name, specifications)
91
+ specifications
92
+ end
93
+ end
94
+ end
95
+
96
+
@@ -0,0 +1,95 @@
1
+ require 'cocoapods-core'
2
+ require 'cocoapods'
3
+ require 'singleton'
4
+ require 'colored2'
5
+ require 'neatjson'
6
+ require 'cocoapods-prefer/lock'
7
+
8
+ module Pod
9
+ module PreferLock
10
+
11
+ attr_accessor :lock_prefer_pods
12
+ attr_accessor :lock_dislike_pods
13
+
14
+ attr_accessor :current_locked_url
15
+
16
+ def current_locked_url
17
+ @current_locked_url ||= ""
18
+ end
19
+
20
+ def lock_prefer_pods
21
+ @lock_prefer_pods ||= {}
22
+ end
23
+
24
+ def lock_dislike_pods
25
+ @lock_dislike_pods ||= {}
26
+ end
27
+
28
+ def lock_url(url)
29
+ unless current_locked_url.empty?
30
+ UI.puts "current locked with url = #{current_locked_url}".yellow
31
+ return
32
+ end
33
+
34
+ @current_locked_url = url
35
+ UI.puts "locking source with #{url}".green
36
+ end
37
+
38
+ def unlock_url
39
+ @current_locked_url = ""
40
+ end
41
+
42
+ def prefer_pod(pod)
43
+ if current_locked_url.empty?
44
+ UI.puts "current locked url is empty ".red
45
+ return
46
+ end
47
+
48
+ lock_prefer_pods[pod] = current_locked_url
49
+ UI.puts "#{pod} prefer locked source ".green
50
+ end
51
+
52
+ def dislike_pod(pod)
53
+ if current_locked_url.empty?
54
+ UI.puts "current locked url is empty".red
55
+ return
56
+ end
57
+
58
+ lock_dislike_pods[pod] = current_locked_url
59
+ UI.puts "#{pod} dislike locked source ".green
60
+ end
61
+
62
+ def lock_url_for_prefer_pod(pod)
63
+ return lock_prefer_pods.fetch(pod, nil)
64
+ end
65
+
66
+ def lock_url_for_dislike_pod(pod)
67
+ return lock_dislike_pods.fetch(pod, nil)
68
+ end
69
+
70
+ def locked_pods
71
+ return lock_prefer_pods.keys + lock_dislike_pods.keys
72
+ end
73
+
74
+ def report_lock_result
75
+ result = lock_file_result()
76
+
77
+ result.select { |pod_name, url|
78
+ lock_prefer_pods.key?(pod_name) && lock_prefer_pods[pod_name] != url
79
+ }.each do |pod_name, url|
80
+ UI.puts "#{pod_name} using #{url} is not locked preferred source".yellow
81
+ end
82
+
83
+ result.select { |pod_name, url|
84
+ lock_dislike_pods.key?(pod_name) && lock_dislike_pods[pod_name] == url
85
+ }.each do |pod_name, url|
86
+ UI.puts "#{pod_name} using #{url} is locked disliked source".yellow
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+ end
93
+
94
+
95
+
@@ -0,0 +1,24 @@
1
+ require 'cocoapods-core'
2
+ require 'cocoapods'
3
+ require 'singleton'
4
+ require 'colored2'
5
+ require 'neatjson'
6
+
7
+ module Pod
8
+ module PreferLockFile
9
+ def lock_file_result
10
+ lock_file = Pod::Lockfile.from_file(Pathname.new('Podfile.lock'))
11
+ result = lock_file.pod_names.map { |pod_name|
12
+ pod_name.split("/")[0]
13
+ }.map { |pod_name|
14
+ {pod_name => lock_file.spec_repo(pod_name)}
15
+ }.each_with_object({}){ |i, v|
16
+ v.merge!(i)
17
+ }.reject { |pod_name, url| url.nil? }
18
+
19
+ # UI.puts JSON.neat_generate(result, sort:true, wrap:true, after_colon:1)
20
+ result
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,25 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods-core'
3
+ require 'cocoapods-prefer/command'
4
+ require 'cocoapods-prefer/config'
5
+ require 'cocoapods-prefer/hook'
6
+
7
+ module CocoapodsPrefer
8
+ Pod::HooksManager.register('cocoapods-prefer', :source_provider) do |context, user_options|
9
+ Pod::PreferConfig.instance.prefer_sources().each { |e, source|
10
+ context.add_source(source)
11
+ }
12
+ end
13
+
14
+ Pod::HooksManager.register('cocoapods-prefer', :pre_install) do |context, user_options|
15
+ Pod::PreferConfig.instance.prefer_source_options(user_options)
16
+ # targets = context.podfile.target_definition_list.reject { |e| e.name.include?("Pods") }
17
+ # targets.each{ |e| puts e.name }
18
+ end
19
+
20
+ Pod::HooksManager.register('cocoapods-prefer', :post_install) do |context, user_options|
21
+ Pod::PreferConfig.instance.report()
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Prefer do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ prefer }).should.be.instance_of Command::Prefer
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -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,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-prefer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - bob
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcodeproj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cocoapods-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cocoapods
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: neatjson
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colored2
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '12.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '12.3'
111
+ description: A short description of cocoapods-prefer.
112
+ email:
113
+ - bob170731@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - cocoapods-prefer.gemspec
124
+ - lib/cocoapods-prefer.rb
125
+ - lib/cocoapods-prefer/command.rb
126
+ - lib/cocoapods-prefer/config.rb
127
+ - lib/cocoapods-prefer/gem_version.rb
128
+ - lib/cocoapods-prefer/hook.rb
129
+ - lib/cocoapods-prefer/hook/installer.rb
130
+ - lib/cocoapods-prefer/hook/podfile.rb
131
+ - lib/cocoapods-prefer/hook/project.rb
132
+ - lib/cocoapods-prefer/hook/resolver.rb
133
+ - lib/cocoapods-prefer/lock.rb
134
+ - lib/cocoapods-prefer/lockfile.rb
135
+ - lib/cocoapods_plugin.rb
136
+ - spec/command/prefer_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: https://github.com/EXAMPLE/cocoapods-prefer
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubygems_version: 3.0.3
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: A longer description of cocoapods-prefer.
161
+ test_files:
162
+ - spec/command/prefer_spec.rb
163
+ - spec/spec_helper.rb