class Pod::Command::Repo::PushCodingAr
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
# File lib/coding_ar_command.rb, line 71 def initialize(argv) @repo = argv.shift_argument @podspec = argv.shift_argument super end
Public Instance Methods
coding_ar_repo_url()
click to toggle source
# File lib/coding_ar_command.rb, line 170 def coding_ar_repo_url File.read File.join(Config.instance.repos_dir, @repo, ".coding_ar_url") end
create_pod_tar_gz()
click to toggle source
# File lib/coding_ar_command.rb, line 103 def create_pod_tar_gz require 'digest/sha1' require 'find' pod_dir = File.join(tmp_dir, "pod") FileUtils.mkdir_p(pod_dir) pod_root = File.dirname Pathname(@podspec).realpath path_list = Pod::Sandbox::PathList.new(pod_root) file_accessors ||= spec.available_platforms.flat_map do |platform| Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(platform)) end pod_files = Pod::Sandbox::FileAccessor.all_files(file_accessors).map do |path| Find.find(path).select { |path| File.file? path} end pod_files.flatten.each do |source| target = File.join(pod_dir, Pathname(source).relative_path_from(pod_root)) FileUtils.mkdir_p(File.dirname(target)) FileUtils.copy_file(source, target) end tar_gz_path = File.join(tmp_dir, "#{spec.name}-#{spec.version}.tar.gz") Dir.chdir(pod_dir) { tar!('-czf', tar_gz_path, '.') } tar_gz_path end
create_spec_json()
click to toggle source
# File lib/coding_ar_command.rb, line 134 def create_spec_json require 'json' FileUtils.mkdir_p(tmp_dir) podspec_json_path = File.join(tmp_dir, "#{spec.name}.podspec.json") podspec_json = File.new(podspec_json_path, "wb") podspec_json.puts(spec.to_pretty_json) podspec_json.close podspec_json_path end
file_push_profile(path)
click to toggle source
# File lib/coding_ar_command.rb, line 174 def file_push_profile(path) require 'digest/sha1' content = File.read(path) { 'size' => File.lstat(path).size, 'base64_content' => Base64.strict_encode64(content), 'sha1_digest' => Digest::SHA1.hexdigest(content) } end
post_pod_with_spec(pod_path, spec_path)
click to toggle source
# File lib/coding_ar_command.rb, line 145 def post_pod_with_spec(pod_path, spec_path) require 'json' request_body = { 'pod' => file_push_profile(pod_path), 'spec' => file_push_profile(spec_path) } request_body_json_path = File.join(tmp_dir, "request_body.json") request_body_json = File.new(request_body_json_path, "wb") request_body_json.puts(request_body.to_json) request_body_json.close require 'coding_ar_util' CodingArUtil.push_pod(coding_ar_repo_url, request_body_json_path) end
run()
click to toggle source
# File lib/coding_ar_command.rb, line 84 def run unless File.file? File.join(Config.instance.repos_dir, @repo, ".coding_ar_url") raise Informative, "`#@repo` is not a CODING-AR repo.".red end FileUtils.mkdir_p tmp_dir begin UI.section("Pushing pod `#{spec.name} #{spec.version.to_s}`` to CODING-AR repo `#@repo`") do pod_tar_gz_path = create_pod_tar_gz podspec_json_path = create_spec_json post_pod_with_spec(pod_tar_gz_path, podspec_json_path) end UI.puts "Successfully push pod `#{spec.name} #{spec.version.to_s}`` to CODING-AR repo `#@repo`".green ensure FileUtils.rm_rf tmp_dir end end
spec()
click to toggle source
# File lib/coding_ar_command.rb, line 161 def spec spec_file = Pathname(@podspec) spec = Pod::Specification.from_file(spec_file) end
tmp_dir()
click to toggle source
# File lib/coding_ar_command.rb, line 166 def tmp_dir File.join(Config.instance.repos_dir, @repo, '.tmp', spec.name, spec.version.to_s) end
validate!()
click to toggle source
Calls superclass method
# File lib/coding_ar_command.rb, line 77 def validate! super unless @repo && @podspec help! 'This command requires both a repo and a podspec.' end end