Class: Pindo::Command::Lib::Lint
- Inherits:
-
Pindo::Command::Lib
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Lib
- Pindo::Command::Lib::Lint
- Defined in:
- lib/pindo/command/lib/lint.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Lint
constructor
A new instance of Lint.
- #podspecs_to_lint ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pindo::Command
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, which, which!
Constructor Details
#initialize(argv) ⇒ Lint
Returns a new instance of Lint.
26 27 28 29 30 31 32 |
# File 'lib/pindo/command/lib/lint.rb', line 26 def initialize(argv) @pod_spec_file = argv.shift_argument || nil @project_dir = argv.option('p') super(argv) @additional_args = argv.remainder! end |
Class Method Details
.options ⇒ Object
20 21 22 23 24 |
# File 'lib/pindo/command/lib/lint.rb', line 20 def self. [ ['--p', '指定需要lint的pod库所在目录, 例如 --p=~/Users/xxx/MyPod'], ].concat(super) end |
Instance Method Details
#podspecs_to_lint ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/pindo/command/lib/lint.rb', line 99 def podspecs_to_lint if !@podspecs_paths.empty? Array(@podspecs_paths) else podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.json,}') if podspecs.count.zero? raise Informative, 'Unable to find a podspec in the working ' \ 'directory' end podspecs end end |
#run ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/pindo/command/lib/lint.rb', line 39 def run working_dir = @project_dir podspecs = [] if @pod_spec_file && (@pod_spec_file.to_s.end_with?('.podspec') || @pod_spec_file.to_s.end_with?('.json')) podspecs = [@pod_spec_file] else podspecs = Pathname.glob(File.join(working_dir, '*.podspec{.json,}')) end if podspecs.count.zero? raise Informative, '工作目录下没有任何podspec文件' end pod_array = pindo_single_config.pod_repo_dict pod_index_url = nil if !pod_array.nil? pod_index_url = pod_array['podindex'] else raise Informative, '私有Pod索引地址未知!!' end sources = Pod::Config.instance.sources_manager.all public_source = sources.select { |s| s.is_a?(Pod::CDNSource) }.first if public_source.nil? public_source = sources.select { |s| s.git? && s.url.to_s.include?("CocoaPods/Specs.git") }.first end if public_source.nil? raise Informative, '公有Pod地址未知,请pod install安装pod库' end private_source = sources.select { |s| s.git? && s.url.to_s.eql?(pod_index_url)}.first if private_source.nil? raise Informative, "私有Pod索引地址未知!" end command_array = [] puts "即将执行下列命令:" podspecs.each do |podspec| command = "pod lib lint #{podspec} --sources=#{private_source.url},#{public_source.url} --allow-warnings --use-libraries --use-modular-headers --no-clean --fail-fast --verbose" puts puts command puts command_array << command end answer = agree("是否运行以上命令(Y/n):") unless answer raise Informative, "停止运行!!!" end command_array.each do |command| puts "正在运行命令:" puts puts command system command end end |
#validate! ⇒ Object
34 35 36 37 |
# File 'lib/pindo/command/lib/lint.rb', line 34 def validate! super @project_dir=Dir.pwd if @project_dir.nil? || @project_dir.empty? end |