Class: Pod::Command::Report
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::Report
- Defined in:
- lib/cocoapods-ve/command/report.rb
Overview
Create a PR to add your plugin to CocoaPods/cocoapods.org in the `plugins.json` file, once your plugin is released.
This is an example of a cocoapods plugin adding a top-level subcommand to the 'pod' command.
You can also create subcommands of existing or new commands. Say you wanted to add a subcommand to `list` to show newly deprecated pods, (e.g. `pod list deprecated`), there are a few things that would need to change.
-
move this file to `lib/pod/command/list/deprecated.rb` and update the class to exist in the the Pod::Command::List namespace
-
change this class to extend from `List` instead of `Command`. This tells the plugin system that it is a subcommand of `list`.
-
edit `lib/cocoapods_plugins.rb` to require this file
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_dependencies(subspec, fileAccessors) ⇒ Object
-
#initialize(argv) ⇒ Report
constructor
A new instance of Report.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Report
Returns a new instance of Report.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cocoapods-ve/command/report.rb', line 37 def initialize(argv) @output = argv.option('output', nil ) @platform = argv.option('platform', :ios) @podspec = argv.option('podspec', nil ) if not @podspec @podspec = Dir.glob(FileUtils.pwd.to_s + '/**.podspec') if @podspec.length > 1 @podspec = @podspec[0] UI.puts "Multiple PodSpecs found, the first is selected by default:"+@podspec elsif @podspec.length == 0 UI.puts "No PodSpecs found, " exit(1) end end @podspec = Pathname.new(@podspec) @subspec = argv.option('subspec', nil ) if @subspec @subspec = @subspec.split(',') else @subspec = [] end super end |
Class Method Details
.options ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/cocoapods-ve/command/report.rb', line 29 def self. [ ['--platform', 'select platform'], ['--podspec', 'select podspec'], ['--subspec', 'select subspec'], ['--output', 'set output path'] ] end |
Instance Method Details
#fetch_dependencies(subspec, fileAccessors) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cocoapods-ve/command/report.rb', line 67 def fetch_dependencies(subspec,fileAccessors) if @root_spec.name == Specification.root_name(subspec) subspec = @root_spec.subspec_by_name(subspec) else return end if not fileAccessors[subspec.name] fileAccessors[subspec.name] = Sandbox::FileAccessor.new(@root_path_list, subspec.consumer(@platform)) dependencies = subspec.dependencies for depend in dependencies fetch_dependencies depend.name,fileAccessors end else return end end |
#run ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/cocoapods-ve/command/report.rb', line 85 def run @root_spec = Specification.from_file(@podspec) @root_path_list = Sandbox::PathList.new(@podspec.dirname) file_accessors={} files = [] if @subspec.length > 0 for subspecName in @subspec fetch_dependencies(@root_spec.name+'/'+subspecName,file_accessors) end end i=0 while i < file_accessors.values.length file_accessor = file_accessors.values[i] files.concat file_accessor.source_files files.concat file_accessor.resources files.concat file_accessor.developer_files i += 1 end files.uniq! if @output if Pathname.new(@output).parent.exist? puts "write result to :#{@output}" File.open(@output,'w+') do |file| files.each { |file_name| file.puts(file_name.to_s) } end else files.each { |file_name| puts(file_name.to_s) } end else files.each { |file_name| puts(file_name.to_s) } end end |
#validate! ⇒ Object
62 63 64 65 |
# File 'lib/cocoapods-ve/command/report.rb', line 62 def validate! super # help! 'A Pod name is required.' unless @specname end |