Sha256: b08f4443d9ad3954fd9155bd9ba3007d45b0963afbfc0aaf0011375108d4a665

Contents?: true

Size: 1.25 KB

Versions: 21

Compression:

Stored size: 1.25 KB

Contents

module Sprout

  class BuilderError < StandardError #:nodoc:
  end

  # accepts a destination path and a sprout specification
  # and will download and unpack the platform-specific
  # archives that are identified in the spec
  class Builder # :nodoc:
    
    def self.build(file_targets_yaml, destination)
      data = nil
      
      File.open(file_targets_yaml, 'r') do |f|
        data = f.read
      end
      
      targets = YAML.load(data)
      targets.each do |target|
        # iterate over the provided RemoteFileTargets until we 
        # encounter one that is appropriate for our platform,
        # or one that claims to be universal.
        # When authoring a sprout.spec for libraries or tools,
        # put the most specific RemoteFileTargets first, then
        # universals to catch unexpected platforms.
        if(target.platform == platform || target.platform == 'universal')
          target.install_path = FileUtils.mkdir_p(destination)
          target.resolve
          return target
        end
      end
      raise BuilderError.new("Sprout::Builder.build failed, unsupported platform [#{platform}] or unexpected yaml")
    end
    
    private
    
    def self.platform
      @@platform ||= User.new.platform.to_s
    end
    
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sprout-0.7.229 lib/sprout/builder.rb
sprout-0.7.229-x86-linux lib/sprout/builder.rb
sprout-0.7.229-x86-darwin-10 lib/sprout/builder.rb
sprout-0.7.229-mswin32 lib/sprout/builder.rb
sprout-0.7.229-darwin lib/sprout/builder.rb
sprout-0.7.228 lib/sprout/builder.rb
sprout-0.7.228-x86-linux lib/sprout/builder.rb
sprout-0.7.228-x86-darwin-10 lib/sprout/builder.rb
sprout-0.7.228-mswin32 lib/sprout/builder.rb
sprout-0.7.228-darwin lib/sprout/builder.rb
sprout-0.7.227 lib/sprout/builder.rb
sprout-0.7.227-x86-linux lib/sprout/builder.rb
sprout-0.7.227-x86-darwin-10 lib/sprout/builder.rb
sprout-0.7.227-mswin32 lib/sprout/builder.rb
sprout-0.7.227-darwin lib/sprout/builder.rb
sprout-0.7.226 lib/sprout/builder.rb
sprout-0.7.226-x86-linux lib/sprout/builder.rb
sprout-0.7.226-x86-darwin-10 lib/sprout/builder.rb
sprout-0.7.226-mswin32 lib/sprout/builder.rb
sprout-0.7.226-darwin lib/sprout/builder.rb