Sha256: b1959ce222f31e4cc3906bcb35fb59375ebbeee0a18dee7b6bf5d8b68dfbcd37

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

module PatternPark
  
  class RemoteFileTarget < FileTarget
    attr_accessor :url,
                  :type,
                  :sprout,
                  :archive_type,
                  :archive_path,
                  :install_path,
                  :project_path,
                  :post_install,
                  :mount_path
    attr_reader   :downloaded_path,
                  :file_name,
                  :copy_path
    
    def resolve
      # already run once, don't run again in this session
      if(!file_name.nil?)
        return
      end
      if(url.nil? || url == '')
        return
      end
      @file_name = url.split('/').pop
      @downloaded_path = File.join(Sprout.cache, type, install_path, file_name)
      if(archive_type == 'txt' || archive_type == 'exe')
        @install_path = File.join(Sprout.cache, type, install_path)
      else
        @install_path = File.join(Sprout.cache, type, install_path, archive_type)
      end
      @copy_path = File.join(install_path, archive_path)
      loader = RemoteFileLoader.new

      if(Sprout.update || !File.exists?(downloaded_path))
        # retrieve from the network
        loader.get_remote_file(url, downloaded_path)
      end
      
      if(Sprout.update || !File.exists?(install_path))
        # unpack into install path
        loader.unpack_downloaded_file(downloaded_path, install_path)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sprout-0.5.10 lib/remote_file_target.rb
sprout-0.5.11 lib/remote_file_target.rb
sprout-0.5.13 lib/remote_file_target.rb
sprout-0.5.9 lib/remote_file_target.rb