Sha256: d08e2b4b00a4ac0c8be55fbcb28866bc2a0d4e447d99ba0c92dcbd457dffe1c5

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

module PatternPark
  
  class RemoteFileTarget < FileTarget
    attr_accessor :url,
                  :type,
                  :sprout,
                  :archive_type,
                  :archive_path,
                  :install_path,
                  :project_path,
                  :post_install,
                  :executable,
                  :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(executable && User.in_path?(executable))
	return
      end

      if(url.nil? || url == '')
        @file_name = ''
      else
        @file_name = url.split('/').pop
        @downloaded_path = File.join(Sprout.cache, type, install_path, file_name)
      end
      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)

      if(url.nil? || url == '')
        return
      end

      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)
        if(post_install)
          eval(post_install)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sprout-0.5.25 lib/remote_file_target.rb
sprout-0.5.29 lib/remote_file_target.rb
sprout-0.5.23 lib/remote_file_target.rb