Class: Pod::Command::Package
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::Package
- Defined in:
- lib/pod_utils.rb,
lib/pod/command/package.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_in_sandbox(platform) ⇒ Object
- #build_package ⇒ Object
- #create_target_directory ⇒ Object
- #create_working_directory ⇒ Object
-
#initialize(argv) ⇒ Package
constructor
A new instance of Package.
- #install_pod(platform_name) ⇒ Object
- #perform_build(platform, sandbox) ⇒ Object
- #podfile_from_spec(path, spec_name, platform_name, deployment_target) ⇒ Object
- #run ⇒ Object
- #spec_with_name(name) ⇒ Object
- #spec_with_path(path) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Package
Returns a new instance of Package.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pod/command/package.rb', line 18 def initialize(argv) = argv.flag?('embedded') @force = argv.flag?('force') @library = argv.flag?('library') @mangle = argv.flag?('mangle', true) @name = argv.shift_argument @source = argv.shift_argument @source_dir = Dir.pwd @spec = spec_with_path(@name) @spec = spec_with_name(@name) unless @spec super end |
Class Method Details
.options ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/pod/command/package.rb', line 9 def self. [ ['--force', 'Overwrite existing files.'], ['--no-mangle', 'Do not mangle symbols of depedendant Pods.'], ['--embedded', 'Generate embedded frameworks.'], ['--library', 'Generate static libraries.'] ] end |
Instance Method Details
#build_in_sandbox(platform) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pod/command/package.rb', line 52 def build_in_sandbox(platform) config.sandbox_root = 'Pods' config.integrate_targets = false config.skip_repo_update = true sandbox = install_pod(platform.name) perform_build(platform, sandbox) Pathname.new(config.sandbox_root).rmtree FileUtils.rm_f('Podfile.lock') end |
#build_package ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pod/command/package.rb', line 65 def build_package builder = SpecBuilder.new(@spec, @source) newspec = builder. @spec.available_platforms.each do |platform| build_in_sandbox(platform) newspec += builder.spec_platform(platform) end newspec += builder.spec_close File.open(@spec.name + '.podspec', 'w') { |file| file.write(newspec) } end |
#create_target_directory ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pod/command/package.rb', line 79 def create_target_directory target_dir = "#{@source_dir}/#{@spec.name}-#{@spec.version}" if File.exist? target_dir if @force Pathname.new(target_dir).rmtree else UI.puts "Target directory '#{target_dir}' already exists." return nil end end target_dir end |
#create_working_directory ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/pod/command/package.rb', line 92 def create_working_directory target_dir = create_target_directory return if target_dir.nil? work_dir = Dir.tmpdir + '/cocoapods-' + Array.new(8) { rand(36).to_s(36) }.join Pathname.new(work_dir).mkdir `cp #{@path} #{work_dir}` Dir.chdir(work_dir) [target_dir, work_dir] end |
#install_pod(platform_name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pod_utils.rb', line 6 def install_pod(platform_name) podfile = podfile_from_spec( File.basename(@path), @spec.name, platform_name, @spec.deployment_target(platform_name)) sandbox = Sandbox.new(config.sandbox_root) installer = Installer.new(sandbox, podfile) installer.install! sandbox end |
#perform_build(platform, sandbox) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/pod/command/package.rb', line 104 def perform_build(platform, sandbox) builder = Pod::Builder.new( @source_dir, config.sandbox_root, sandbox.public_headers.root, @spec, , @mangle) builder.build(platform, @library) return unless builder. end |
#podfile_from_spec(path, spec_name, platform_name, deployment_target) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pod_utils.rb', line 20 def podfile_from_spec(path, spec_name, platform_name, deployment_target) Pod::Podfile.new do platform(platform_name, deployment_target) if path pod spec_name, :podspec => path else pod spec_name, :path => '.' end end end |
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pod/command/package.rb', line 37 def run if @path.nil? || @spec.nil? help! 'Unable to find a podspec with path or name.' return end target_dir, work_dir = create_working_directory return if target_dir.nil? build_package `mv #{work_dir} #{target_dir}` Dir.chdir(@source_dir) end |
#spec_with_name(name) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/pod_utils.rb', line 31 def spec_with_name(name) return if name.nil? set = SourcesManager.search(Dependency.new(name)) return nil if set.nil? set.specification.root end |
#spec_with_path(path) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/pod_utils.rb', line 40 def spec_with_path(path) return if path.nil? || !Pathname.new(path).exist? @path = path Specification.from_file(path) end |
#validate! ⇒ Object
32 33 34 35 |
# File 'lib/pod/command/package.rb', line 32 def validate! super help! 'A podspec name or path is required.' unless @spec end |