Class: Pod::Command::RepoArt::Add
- Inherits:
-
Pod::Command::RepoArt
- Object
- Pod::Command
- Pod::Command::RepoArt
- Pod::Command::RepoArt::Add
- Defined in:
- lib/pod/command/repo_art/add.rb
Constant Summary collapse
Instance Method Summary collapse
-
#create_artpodrc_file(repo_dir_root) ⇒ Object
Creates the .artpodrc file which contains the repository’s url in the root of the Spec repo.
-
#initialize(argv) ⇒ Add
constructor
A new instance of Add.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Add
Returns a new instance of Add.
21 22 23 24 25 |
# File 'lib/pod/command/repo_art/add.rb', line 21 def initialize(argv) @name, @url = argv.shift_argument, argv.shift_argument @silent = argv.flag?('silent', false) super end |
Instance Method Details
#create_artpodrc_file(repo_dir_root) ⇒ Object
Creates the .artpodrc file which contains the repository’s url in the root of the Spec repo
71 72 73 74 75 76 77 |
# File 'lib/pod/command/repo_art/add.rb', line 71 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 ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pod/command/repo_art/add.rb', line 34 def run UI.section("Retrieving index from `#{@url}` into local spec repo `#{@name}`") do config.repos_dir.mkpath repo_dir_root = "#{config.repos_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 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.}" 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.}."\ '- your Artifactory-backed Specs repo will not work correctly without it!' end end UI.puts "Successfully added repo #{@name}".green unless @silent end |
#validate! ⇒ Object
27 28 29 30 31 32 |
# File 'lib/pod/command/repo_art/add.rb', line 27 def validate! super unless @name && @url help! 'This command requires both a repo name and a url.' end end |