cocoapods-replace 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: 5d514a9ab6189b8f0d4e16787e80431c88011aed5500eceb8e0b49381cac1995
4
+ data.tar.gz: 1db20023ea363131fc1f602efd2ac8fd954442582caff2ba18ed168dae63dba3
5
+ SHA512:
6
+ metadata.gz: 9e8120d8f2404f369de465224ef7b3bac4384e841fd80b534c87e132aa1006932fe5cef3054fc922c591743d5846f2d37459a0020b082d63c05f2f7335ccbaa4
7
+ data.tar.gz: 9b64981130f290997eec5a30aabeffc4e5b336d5c839bf58c5d08972c200d74e3d25fb1c17f2b4edf96bfd20f2c2d551e7670678f84be613c10e68dadd4cbedd
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-replace.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) 2022 jinqiucheng <jinqiucheng@foryou56.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-replace
2
+
3
+ A description of cocoapods-replace.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-replace
8
+
9
+ ## Usage
10
+
11
+ $ pod spec replace 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-replace/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-replace'
8
+ spec.version = CocoapodsReplace::VERSION
9
+ spec.authors = ['jinqiucheng']
10
+ spec.email = ['jinqiucheng@foryou56.com']
11
+ spec.description = %q{A short description of cocoapods-replace.}
12
+ spec.summary = %q{A longer description of cocoapods-replace.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-replace'
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,28 @@
1
+ module Pod
2
+ class Command
3
+
4
+ # class Replace < Command
5
+ # self.summary = '宏替换'
6
+ #
7
+ # self.description = <<-DESC
8
+ # 可宏替换三方库中的简单代码,例如NSLog
9
+ # DESC
10
+ #
11
+ # # self.arguments = 'NAME'
12
+ #
13
+ # def initialize(argv)
14
+ # @name = argv.shift_argument
15
+ # super
16
+ # end
17
+ #
18
+ # def validate!
19
+ # super
20
+ # help! 'A Pod name is required.' unless @name
21
+ # end
22
+ #
23
+ # def run
24
+ # UI.puts "Add your implementation for the cocoapods-replace plugin in #{__FILE__}"
25
+ # end
26
+ # end
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-replace/command/replace'
@@ -0,0 +1,3 @@
1
+ module CocoapodsReplace
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,62 @@
1
+
2
+ module CococapodsReplacement
3
+ class Replacement
4
+ attr_reader :origin
5
+ attr_reader :to
6
+ attr_reader :configurations
7
+ def initialize(origin, to, configurations)
8
+ @origin = origin
9
+ @to = to
10
+ @configurations = configurations
11
+ end
12
+ end
13
+ end
14
+
15
+
16
+ module Pod
17
+ class Podfile
18
+ module DSL
19
+
20
+ def fy_replace(origin, to, *requirements)
21
+ configurations = r_parse_key(:configurations, requirements)
22
+ replacementEntity = CococapodsReplacement::Replacement.new origin, to, configurations
23
+
24
+ replacementEntities = r_get_internal_hash_value 'replacement'
25
+
26
+ r_set_internal_hash_value 'replacement', [] unless replacementEntities != nil
27
+
28
+ replacementEntities = r_get_internal_hash_value 'replacement'
29
+
30
+ replacementEntities.append replacementEntity
31
+
32
+ end
33
+
34
+ private
35
+
36
+ def r_parse_key(key, requirements)
37
+ result = nil
38
+ requirements.each do |obj|
39
+ if obj.is_a?(Hash) && obj.has_key?(key)
40
+ result = obj[key]
41
+ end
42
+ end
43
+ result
44
+ end
45
+
46
+
47
+ def r_valid_bin_plugin
48
+ raise Pod::Informative, 'You should add `plugin \'cocoapods-replace\'` before using its DSL' unless plugins.keys.include?('cocoapods-replace')
49
+ end
50
+
51
+ def r_set_internal_hash_value(key, value)
52
+ r_valid_bin_plugin
53
+
54
+ internal_hash[key] = value
55
+ end
56
+
57
+ def r_get_internal_hash_value(key, default = nil)
58
+ internal_hash.fetch(key, default)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-replace/gem_version'
@@ -0,0 +1,36 @@
1
+ require 'cocoapods-replace/command'
2
+
3
+
4
+ module CococapodsReplacement
5
+ Pod::HooksManager.register 'cocoapods-replace', :post_install do | installer |
6
+ # Pod::UserInterface.info "Start remove 'NSLog' ..."
7
+ # Pod::UserInterface.info "SandBox #{installer.sandbox.root}"
8
+ dir = installer.sandbox.root.join("Target Support Files")
9
+ Pod::UserInterface.title "Start remove 'NSLog' by 'cocoapods-replace' ..."
10
+ # Pod::UserInterface.info "Target Support Files #{dir}"
11
+ #installer.podfile.to_hash["replacement"]
12
+ installer.pods_project.targets.each do |target|
13
+ target.build_configurations.each do |config|
14
+ prefix_file_name = dir.join("#{target.name}/#{target.name}-prefix.pch")
15
+ if File.exist? prefix_file_name
16
+ Pod::UserInterface.message "[#{target.name}-#{config.name}]"
17
+ # Pod::UserInterface.info "Set GCC_PRECOMPILE_PREFIX_HEADER true"
18
+ config.build_settings['GCC_PRECOMPILE_PREFIX_HEADER'] = 'YES'
19
+ # Pod::UserInterface.info "Fix #{target.name} at #{prefix_file_name}"
20
+ file = File.open(prefix_file_name, "a+")
21
+ ruby_code = <<-CODE
22
+ #ifdef DEBUG
23
+ #define NSLog(...) NSLog(__VA_ARGS__)
24
+ #else
25
+ #define NSLog(...)
26
+ #endif
27
+ CODE
28
+ file.puts ruby_code unless file.read.include? ruby_code
29
+ file.close
30
+ # Pod::UserInterface.info "=============================[#{target.name}]============================="
31
+ end
32
+ end
33
+ end
34
+ Pod::UserInterface.title "End remove 'NSLog' by 'cocoapods-replace' ..."
35
+ end
36
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Replace do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ replace }).should.be.instance_of Command::Replace
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,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-replace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - "\bjinqiucheng"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-07-26 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-replace.
42
+ email:
43
+ - jinqiucheng@foryou56.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - cocoapods-replace.gemspec
54
+ - lib/cocoapods-replace.rb
55
+ - lib/cocoapods-replace/command.rb
56
+ - lib/cocoapods-replace/command/replace.rb
57
+ - lib/cocoapods-replace/gem_version.rb
58
+ - lib/cocoapods-replace/native/podfile.rb
59
+ - lib/cocoapods_plugin.rb
60
+ - spec/command/replace_spec.rb
61
+ - spec/spec_helper.rb
62
+ homepage: https://github.com/EXAMPLE/cocoapods-replace
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubygems_version: 3.0.6
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: A longer description of cocoapods-replace.
85
+ test_files:
86
+ - spec/command/replace_spec.rb
87
+ - spec/spec_helper.rb