Sha256: 4514c594e6a09c6afb4f1ed15257e39a2a93a155aa556400baf9abbad394d76d
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
require 'gondler/package' module Gondler class Gomfile def initialize(path) raise NotFound, path unless File.exist?(path) @packages = [] @itself = nil load(path) end attr_reader :packages def itself(name) @itself = name end def itself_package if !@itself && Gondler.env.orig_path realpath = proc do |path| if File.respond_to?(:realpath) # 1.9+ File.realpath(path) else path end end orig_src = realpath[File.join(Gondler.env.orig_path, 'src')] dir = realpath[File.dirname(@path)] if dir.start_with?(orig_src) @itself = dir[orig_src.size.succ .. -1] end end if @itself Gondler::Package.new(@itself, :path => '.') end end def load(path) @path = File.expand_path(path) instance_eval(File.read(path)) end def gom(name, options = {}) options[:group] = @now_group if @now_group options[:os] = @now_os if @now_os package = Gondler::Package.new(name, options) @packages.push(package) if package.installable? end alias_method :package, :gom def group(*groups) @now_group = groups yield if block_given? ensure @now_group = nil end def os(*oss) @now_os = oss yield if block_given? ensure @now_os = nil end class NotFound < StandardError def initialize(gomfile) @gomfile = gomfile end def message "Gondler require gomfile. Your gomfile is not found: #{@gomfile}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gondler-0.3.1 | lib/gondler/gomfile.rb |
gondler-0.3.0 | lib/gondler/gomfile.rb |
gondler-0.2.0 | lib/gondler/gomfile.rb |