Class: Pod::Command::Mod::Info
- Inherits:
-
Pod::Command::Mod
- Object
- Pod::Command
- Pod::Command::Mod
- Pod::Command::Mod::Info
- Defined in:
- lib/cocoapods-modularization/command/mod/info.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Info
constructor
A new instance of Info.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Info
Returns a new instance of Info.
23 24 25 26 27 |
# File 'lib/cocoapods-modularization/command/mod/info.rb', line 23 def initialize(argv) @name = argv.shift_argument @use_binary = argv.flag?('use-binary') super end |
Class Method Details
.options ⇒ Object
17 18 19 20 21 |
# File 'lib/cocoapods-modularization/command/mod/info.rb', line 17 def self. [ ['--use-binary', 'Use this flag if the component supposed to be a binary, otherwise a source version will be added into dependencies'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cocoapods-modularization/command/mod/info.rb', line 37 def run repo_url = String.new if @use_binary repo_url = Private::PrivateCache.binary_repo_url(@name) else repo_url = Private::PrivateCache.source_repo_url(@name) end # 如果工作区有存在的Repo,先删除后clone if File.exist?("#{Private::PrivateCache.root_path}/Repo") FileUtils.rm_rf("#{Private::PrivateCache.root_path}/Repo") end system_build("/usr/bin/git clone #{repo_url} #{Private::PrivateCache.root_path}/Repo --single-branch --depth 1") # 遍历文件夹 max_version = Dir.glob("#{Private::PrivateCache.root_path}/Repo/#{@name}/*").map { |e| Gem::Version.new(e.match(/\d{1,2}\.\d{1,2}\.\d{1,2}/).to_s) }.max.to_s puts max_version end |
#validate! ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/cocoapods-modularization/command/mod/info.rb', line 29 def validate! super help! 'A name for the Pod is required.' unless @name help! 'The Pod name cannot contain spaces.' if @name =~ /\s/ help! 'The Pod name cannot contain plusses.' if @name =~ /\+/ help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.' end |