Class: Pod::Command::Mod::Binary
- Inherits:
-
Pod::Command::Mod
- Object
- Pod::Command
- Pod::Command::Mod
- Pod::Command::Mod::Binary
- Defined in:
- lib/cocoapods-modularization/command/mod/binary.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Binary
constructor
A new instance of Binary.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Binary
Returns a new instance of Binary.
25 26 27 28 29 30 |
# File 'lib/cocoapods-modularization/command/mod/binary.rb', line 25 def initialize(argv) @name = argv.shift_argument @path = argv.option('path', nil) @use_local = argv.flag?('local') super end |
Class Method Details
.options ⇒ Object
18 19 20 21 22 23 |
# File 'lib/cocoapods-modularization/command/mod/binary.rb', line 18 def self. [ ["--path='./'", 'local_path of binary'], ["--local", 'use local binary, if local path is not specified, will clone from remote'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cocoapods-modularization/command/mod/binary.rb', line 56 def run begin Meta::MetaAccessor.set_binary(@name) if @path && !@path.empty? UI.puts("Switch #{@name} to local path") # 写入缓存 Private::PrivateCache.write_path_into_cache(@name, @path) Meta::MetaAccessor.set_local_path(@name, @path) elsif @use_local path = Private::PrivateCache.start(@name) UI.puts("Switch #{@name} to local path: #{path}") Meta::MetaAccessor.set_local_path(@name, path) else UI.puts("Switch #{@name} to remote") Meta::MetaAccessor.remove_local_path(@name) end Meta::MetaReference.encode_podfile UI.puts("Podfile encoded") rescue Exception => e UI.puts e end end |
#validate! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cocoapods-modularization/command/mod/binary.rb', line 32 def validate! super help! "meta not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.) help! "data not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.data_path) 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] == '.' dependencies = Meta::MetaAccessor.dependencies() help! "#{@name} not found in dependencies: #{dependencies}" unless dependencies.include?(@name) if @path.kind_of?(String) && @path.empty? podspec_exists = false if File::exists?(@path) podspec_exists = true elsif File::exists?("#{@path}/#{@name}.podspec") podspec_exists = true end help! "#{@name}.podspec not found #{@path}" unless podspec_exists end end |