cocoapods-unused_pods 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/Rakefile +13 -0
- data/cocoapods-unused_pods.gemspec +23 -0
- data/lib/cocoapods-unused_pods.rb +1 -0
- data/lib/cocoapods-unused_pods/command.rb +1 -0
- data/lib/cocoapods-unused_pods/command/unused_pods.rb +105 -0
- data/lib/cocoapods-unused_pods/gem_version.rb +3 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/command/unused_pods_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 34449b09ad5bc65a2eb4cd04a8c7cc826ab1b32a
|
4
|
+
data.tar.gz: b687c1c1baa73bfe9423740cdcbbac0278f27d9f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a64f81ca9b335b6977eea5577125aef38bec49a4c4d5b2e99954a060747057c44516c59d01c88a6d20742f2dbe2b83087883e4e2cd06da04b340c85947367a31
|
7
|
+
data.tar.gz: 63748463ef3ebfa875b1633728ce47dcb8bf8fe139093e49987b26250e22bc970bca2d317ee7f7408d067b96b428e29982553b6f9a8f6ff5c0957ddf04913289
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 从权 <chaoyang.zcy@alibaba-inc.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
data/Rakefile
ADDED
@@ -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-unused_pods/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-unused_pods'
|
8
|
+
spec.version = CocoapodsUnused_pods::VERSION
|
9
|
+
spec.authors = ['张朝阳']
|
10
|
+
spec.email = ['zhzhy158@163.com']
|
11
|
+
spec.description = %q{list unused Pods of project.}
|
12
|
+
spec.summary = %q{list unused Pods of project.}
|
13
|
+
spec.homepage = 'https://github.com/EXAMPLE/cocoapods-unused_pods'
|
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-unused_pods/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-unused_pods/command/unused_pods'
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
6
|
+
# to the 'pod' command.
|
7
|
+
#
|
8
|
+
# You can also create subcommands of existing or new commands. Say you
|
9
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
10
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
11
|
+
# to change.
|
12
|
+
#
|
13
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
14
|
+
# the class to exist in the the Pod::Command::List namespace
|
15
|
+
# - change this class to extend from `List` instead of `Command`. This
|
16
|
+
# tells the plugin system that it is a subcommand of `list`.
|
17
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
18
|
+
|
19
|
+
class List < Command
|
20
|
+
class Unused_pods < List
|
21
|
+
self.command = 'unused_pods'
|
22
|
+
|
23
|
+
self.summary = 'Show unused pods of current project.'
|
24
|
+
|
25
|
+
self.description = <<-DESC
|
26
|
+
Show unused pods of current project, for clear unused pods.
|
27
|
+
DESC
|
28
|
+
|
29
|
+
def run
|
30
|
+
path = Dir.pwd + '/Podfile'
|
31
|
+
if !File.exists? path
|
32
|
+
help! "Please make sure current project has Podfile."
|
33
|
+
Process.exit! false
|
34
|
+
end
|
35
|
+
|
36
|
+
UI.puts "In progress:"
|
37
|
+
|
38
|
+
pods = parse_Podfile(path)
|
39
|
+
pods_header = collect_headers_path_of_pods(pods)
|
40
|
+
unused_pods = unused_pods(pods_header)
|
41
|
+
UI.puts "Unused Pods:"
|
42
|
+
UI.puts unused_pods
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_Podfile(podfile_path)
|
46
|
+
active_pods = Array.new
|
47
|
+
File.open(podfile_path, 'r') do |f|
|
48
|
+
active_pod_reg = /^[\t ]*pod *'(\w+)'[\n\r,]/
|
49
|
+
f.each_line do |line|
|
50
|
+
if active_pod_reg.match(line)
|
51
|
+
active_pods.push($1)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
active_pods
|
57
|
+
end
|
58
|
+
|
59
|
+
def collect_headers_path_of_pods(pods)
|
60
|
+
pods_header = Hash.new
|
61
|
+
public_header_path = Dir.pwd + '/Pods/Headers/Public'
|
62
|
+
pods.each do |pod|
|
63
|
+
pod_public_header_path = public_header_path + '/' + pod + '/**/*.h'
|
64
|
+
headers = Array.new
|
65
|
+
Dir.glob(pod_public_header_path) do |header_path|
|
66
|
+
headers.push(File.basename(header_path))
|
67
|
+
end
|
68
|
+
pods_header[pod] = headers
|
69
|
+
end
|
70
|
+
|
71
|
+
pods_header
|
72
|
+
end
|
73
|
+
|
74
|
+
def unused_pods(pods_header)
|
75
|
+
unused_pods = pods_header.keys
|
76
|
+
filepathes = Dir.glob('./**/*.{h,pch,m,mm,c,cpp}')
|
77
|
+
|
78
|
+
filepathes.each do |path|
|
79
|
+
File.open(path) do |file|
|
80
|
+
content = File.read(file)
|
81
|
+
if ! content.valid_encoding?
|
82
|
+
content = content.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
|
83
|
+
end
|
84
|
+
pods_header.each do |pod, headers|
|
85
|
+
if path =~ /\/Pods\/#{pod}/
|
86
|
+
next
|
87
|
+
end
|
88
|
+
headers.each do |header|
|
89
|
+
if header.length > 0 && content =~ /#import +.*#{header}[>\"]/
|
90
|
+
unused_pods.delete(pod)
|
91
|
+
pods_header.delete(pod)
|
92
|
+
break
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
unused_pods
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-unused_pods/command'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
describe Command::Unused_pods do
|
5
|
+
describe 'CLAide' do
|
6
|
+
it 'registers it self' do
|
7
|
+
Command.parse(%w{ unused_pods }).should.be.instance_of Command::Unused_pods
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -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,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-unused_pods
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 张朝阳
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-17 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: list unused Pods of project.
|
42
|
+
email:
|
43
|
+
- zhzhy158@163.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-unused_pods.gemspec
|
54
|
+
- lib/cocoapods-unused_pods.rb
|
55
|
+
- lib/cocoapods-unused_pods/command.rb
|
56
|
+
- lib/cocoapods-unused_pods/command/unused_pods.rb
|
57
|
+
- lib/cocoapods-unused_pods/gem_version.rb
|
58
|
+
- lib/cocoapods_plugin.rb
|
59
|
+
- spec/command/unused_pods_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
homepage: https://github.com/EXAMPLE/cocoapods-unused_pods
|
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.6.1
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: list unused Pods of project.
|
85
|
+
test_files:
|
86
|
+
- spec/command/unused_pods_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
has_rdoc:
|