Sha256: 03c491b51d9713ff7ddf25c9e555b71fbf7a33b2b0287fe8d1688d92f2019a44

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

module Distil
  
  class RemoteProject < Project

    option :name, String
    option :href, URI
    option :linkage, WEAK_LINKAGE, :valid_values=> [WEAK_LINKAGE, STRONG_LINKAGE, LAZY_LINKAGE]

    def initialize(config, parent=nil)

      super(config, parent)

      if !href.respond_to?(:read)
        raise ValidationError, "Cannot read from project source url: #{source}"
      end
      
      @source_path= File.join(parent.output_folder, href.host, href.path)
      self.source_folder=  File.dirname(@source_path)
      
      if !File.exist?(@source_path)
        FileUtils.mkdir_p(source_folder)
        begin
          text= href.read
        rescue OpenURI::HTTPError => http_error
          raise ValidationError, "Unable to fetch remote project: status=#{http_error.io.status[0]} url=#{href}"
        end
        File.open(@source_path, "w") { |output|
          output.write text
        }
      end
      
    end

    def product_name(product_type, extension)
      File.join(File.dirname(@source_path), "#{File.basename(@source_path, ".*")}.#{extension}")
    end
    
    def build
    end
    
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
distil-0.13.6 lib/distil/project/remote-project.rb
distil-0.13.5 lib/distil/project/remote-project.rb
distil-0.13.4 lib/distil/project/remote-project.rb
distil-0.13.3 lib/distil/project/remote-project.rb
distil-0.13.2 lib/distil/project/remote-project.rb
distil-0.13.1 lib/distil/project/remote-project.rb
distil-0.13.0 lib/distil/project/remote-project.rb
distil-0.12.6 lib/distil/project/remote-project.rb
distil-0.12.4 lib/distil/project/remote-project.rb