class Pod::Command::RepoArt::Add
Constants
- UTIL
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
# File lib/pod/command/repo_art/add.rb, line 21 def initialize(argv) init @name, @url = argv.shift_argument, argv.shift_argument @silent = argv.flag?('silent', false) super end
Public Instance Methods
create_artpodrc_file(repo_dir_root)
click to toggle source
Creates the .artpodrc file which contains the repository’s url in the root of the Spec repo
@param [String] repo_dir_root root of the Spec repo
# File lib/pod/command/repo_art/add.rb, line 84 def create_artpodrc_file(repo_dir_root) artpodrc_path = "#{repo_dir_root}/.artpodrc" artpodrc = File.new(artpodrc_path, "wb") artpodrc << @url artpodrc.close artpodrc_path end
run()
click to toggle source
# File lib/pod/command/repo_art/add.rb, line 35 def run UI.section("Retrieving index from `#{@url}` into local spec repo `#{@name}`") do # Check if a repo with the same name under repos/ already exists repos_path = "#{Pod::Config.instance.home_dir}/repos" raise Informative, "Path #{repos_path}/#{@name} already exists - remove it first, "\ "or run 'pod repo-art update #{@name}' to update it" if File.exist?("#{repos_path}/#{@name}") && !@silent # Check if a repo with the same name under repo-art/ already exists repo_dir_root = "#{@repos_art_dir}/#{@name}" raise Informative, "Path #{repo_dir_root} already exists - remove it first, "\ "or run 'pod repo-art update #{@name}' to update it" if File.exist?(repo_dir_root) && !@silent FileUtils::mkdir_p repo_dir_root repo_dir_specs = "#{repo_dir_root}/Specs" begin downloader = Pod::Downloader::Http.new(repo_dir_specs, "#{@url}/index/fetchIndex", :type => 'tgz', :indexDownload => true) downloader.download rescue => e FileUtils.remove_entry_secure(repo_dir_root, :force => true) raise Informative, "Error getting the index from Artifactory at: '#{@url}' : #{e.message}" end begin UTIL.cleanup_index_download(repo_dir_specs) UTIL.del_redundant_spec_dir("#{repo_dir_specs}/Specs") rescue => e UI.warn("Failed cleaning up temp files in #{repo_dir_specs}") end begin artpodrc_path = create_artpodrc_file(repo_dir_root) rescue => e raise Informative, "Cannot create file '#{artpodrc_path}' because : #{e.message}."\ '- your Artifactory-backed Specs repo will not work correctly without it!' end # Create a local git repository in the newly added Artifactory local repo system "cd '#{repo_dir_root}' && git init && git add . && git commit -m 'Artifactory repo init'" # Create local repo under repos/ which is a remote for the new local git repository system "cd '#{repos_path}' && git clone file://#{repo_dir_root}" end UI.puts "Successfully added repo #{@name}".green unless @silent end
validate!()
click to toggle source
Calls superclass method
# File lib/pod/command/repo_art/add.rb, line 28 def validate! super unless @name && @url help! 'This command requires both a repo name and a url.' end end