cocoapods-resource 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 500da21e33fb217f4f9417ac2989effc25a79f4def6e0199659492cc4f79ba73
4
+ data.tar.gz: '058923025600c68944e3ded591ae3baefe20dac4afa17ed48485c84b963bef9b'
5
+ SHA512:
6
+ metadata.gz: acefb90882da58bb5bc15f8e5eb49786eb08b7485c8d9f86c3e048478e90c467c30b34a85be756b69a2dc3c6a1a779f1147b3814bb7fcbc949857f24abfe31ec
7
+ data.tar.gz: bfee8c1c92a5e93cbc13115ae5b8d841dc451283969948372ea59802ec27750f601e0007106d49764a5576f39f16c7f371caa15328d00809f5024ea59f511d41
@@ -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-resource.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
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020 gonghonglou <gonghonglou@icloud.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.
@@ -0,0 +1,23 @@
1
+ # cocoapods-resource
2
+
3
+ Resource file management configuration tool for Pod.
4
+
5
+ Configure the pod with Preprocessor Macros to get the name of the current Pod at the line of code execution.
6
+
7
+ Also for [HoloResource](https://github.com/HoloFoundation/HoloResource)
8
+
9
+ ## Installation
10
+
11
+ $ gem install cocoapods-resource
12
+
13
+ ## Usage
14
+
15
+ By default, add configuration to all current Pods.
16
+
17
+ $ pod resource MACRO_NAME
18
+
19
+ Pass in the Pod name array, and configure the Preprocessor Macros for these specified Pods.
20
+
21
+ $ pod resource MACRO_NAME --pod=POD_NAME
22
+
23
+
@@ -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-resource/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-resource'
8
+ spec.version = CocoapodsResource::VERSION
9
+ spec.authors = ['gonghonglou']
10
+ spec.email = ['gonghonglou@icloud.com']
11
+ spec.description = %q{Resource file management configuration tool for Pod.}
12
+ spec.summary = %q{Configure the pod with Preprocessor Macros to get the name of the current Pod at the line of code execution. By default, add configuration to all current Pods.}
13
+ spec.homepage = 'https://github.com/HoloFoundation/cocoapods-resource'
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-resource/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-resource/command/resource'
@@ -0,0 +1,121 @@
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 Resource < Command
21
+ self.summary = 'Resource file management configuration tool for Pod.'
22
+
23
+ self.description = <<-DESC
24
+ Configure the pod with Preprocessor Macros to get the name of the current Pod at the line of code execution. By default, add configuration to all current Pods.
25
+ DESC
26
+
27
+ self.arguments = [
28
+ CLAide::Argument.new('MACRO_NAME', true)
29
+ ]
30
+
31
+ def self.options
32
+ [
33
+ ['--pods=POD_NAME', 'Pass in the Pod name array, and configure the Preprocessor Macros for these specified Pods.']
34
+ ]
35
+ end
36
+
37
+
38
+ def initialize(argv)
39
+ @macro_name = argv.shift_argument
40
+ @target_pods = argv.option('pods', '')
41
+ super
42
+ end
43
+
44
+ def validate!
45
+ super
46
+ help! 'A macro name for Pod is required.' unless @macro_name
47
+ end
48
+
49
+ def run
50
+
51
+ raise Informative, "No 'Pods' folder found in the project directory." unless Dir.exists? "Pods"
52
+
53
+ macro_name = @macro_name
54
+
55
+ completed_pods = Array.new
56
+ already_pods = Array.new
57
+ target_pods = Array.new
58
+ @target_pods.split(',').each do |pod|
59
+ target_pods.push(pod.gsub(' ',''))
60
+ end
61
+
62
+
63
+ xcconfig_paths = File.expand_path('Pods/**/*.*.xcconfig')
64
+ Dir.glob(xcconfig_paths) do |xcconfig|
65
+
66
+ pod_name = File.basename(xcconfig, ".*")
67
+ pod_name = File.basename(pod_name, ".*")
68
+
69
+ # Pods- start, next
70
+ next if /^Pods-/ =~ pod_name
71
+
72
+ # The target Pod is passed in and no match, next
73
+ next if target_pods.length > 0 and target_pods.index(pod_name) == nil
74
+
75
+ gcc_line = ''
76
+ xcconfig_file = File.open(xcconfig)
77
+ xcconfig_file.each_line do |line|
78
+ if line.include?('GCC_PREPROCESSOR_DEFINITIONS') then
79
+ gcc_line = line
80
+ break
81
+ end
82
+ end
83
+ xcconfig_file.close
84
+
85
+ # no found GCC_PREPROCESSOR_DEFINITIONS line, next
86
+ next if gcc_line.empty?
87
+ # GCC_PREPROCESSOR_DEFINITIONS line already contains the target Preprocessor Macros, next
88
+ if gcc_line.include?(macro_name) then
89
+ already_pods.push(pod_name) unless already_pods.index(pod_name)
90
+ next
91
+ end
92
+
93
+ pre_macro = "#{macro_name}=@(\\\"#{pod_name}\\\")"
94
+ macro_line = gcc_line.chomp + " " + pre_macro + "\n"
95
+ xcconfig_text = File.read(xcconfig)
96
+ xcconfig_text = xcconfig_text.gsub(gcc_line, macro_line)
97
+
98
+ File.open(xcconfig, "w") do |file|
99
+ file.syswrite(xcconfig_text)
100
+ end
101
+
102
+ completed_pods.push(pod_name) unless completed_pods.index(pod_name)
103
+
104
+ end
105
+
106
+ if completed_pods.length > 0 then
107
+ UI.puts "Pod resource complete! These pods have been changed: #{completed_pods}."
108
+ end
109
+
110
+ if already_pods.length > 0 then
111
+ UI.puts "These pods already have current macro: #{already_pods}."
112
+ end
113
+
114
+ if completed_pods.length <= 0 and already_pods.length <= 0 then
115
+ UI.puts "No pod has been changed."
116
+ end
117
+
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsResource
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-resource/command'
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Resource do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ resource }).should.be.instance_of Command::Resource
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,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-resource
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - gonghonglou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-11 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: Resource file management configuration tool for Pod.
42
+ email:
43
+ - gonghonglou@icloud.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-resource.gemspec
54
+ - lib/cocoapods-resource.rb
55
+ - lib/cocoapods-resource/command.rb
56
+ - lib/cocoapods-resource/command/resource.rb
57
+ - lib/cocoapods-resource/gem_version.rb
58
+ - lib/cocoapods_plugin.rb
59
+ - spec/command/resource_spec.rb
60
+ - spec/spec_helper.rb
61
+ homepage: https://github.com/HoloFoundation/cocoapods-resource
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.7.7
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Configure the pod with Preprocessor Macros to get the name of the current
85
+ Pod at the line of code execution. By default, add configuration to all current
86
+ Pods.
87
+ test_files:
88
+ - spec/command/resource_spec.rb
89
+ - spec/spec_helper.rb