Class: Gondler::Gomfile
- Inherits:
-
Object
- Object
- Gondler::Gomfile
- Defined in:
- lib/gondler/gomfile.rb
Defined Under Namespace
Classes: NotFound
Instance Attribute Summary collapse
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
Instance Method Summary collapse
- #autodetect ⇒ Object
- #gom(name, options = {}) ⇒ Object (also: #package)
- #group(*groups) ⇒ Object
-
#initialize(path) ⇒ Gomfile
constructor
A new instance of Gomfile.
- #itself(name) ⇒ Object
- #itself_package ⇒ Object
- #load(path) ⇒ Object
- #os(*oss) ⇒ Object
Constructor Details
Instance Attribute Details
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
12 13 14 |
# File 'lib/gondler/gomfile.rb', line 12 def packages @packages end |
Instance Method Details
#autodetect ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/gondler/gomfile.rb', line 68 def autodetect deps = `go list -f '{{join .Deps "\\n"}}' ./...`.strip.split(/\n+/) deps.each do |dep| gom(dep) unless dep.include?('.') end end |
#gom(name, options = {}) ⇒ Object Also known as: package
45 46 47 48 49 50 51 |
# File 'lib/gondler/gomfile.rb', line 45 def gom(name, = {}) [:group] = @now_group if @now_group [:os] = @now_os if @now_os package = Gondler::Package.new(name, ) @packages.push(package) if package.installable? end |
#group(*groups) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/gondler/gomfile.rb', line 54 def group(*groups) @now_group = groups yield if block_given? ensure @now_group = nil end |
#itself(name) ⇒ Object
14 15 16 |
# File 'lib/gondler/gomfile.rb', line 14 def itself(name) @itself = name end |
#itself_package ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gondler/gomfile.rb', line 18 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 |
#load(path) ⇒ Object
40 41 42 43 |
# File 'lib/gondler/gomfile.rb', line 40 def load(path) @path = File.(path) instance_eval(File.read(path)) end |
#os(*oss) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/gondler/gomfile.rb', line 61 def os(*oss) @now_os = oss yield if block_given? ensure @now_os = nil end |