Class: Rake::BuildDependency

Inherits:
Task
  • Object
show all
Includes:
DSL
Defined in:
lib/rake-plus/bdep.rb

Overview

TODO: abstract dependencies from the package system

Constant Summary collapse

ON_OSX =
(`uname` == "Darwin\n")

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Task

#file_missing?, #out_of_date?

Class Method Details

.scope_name(scope, task_name) ⇒ Object

Apply the scope to the task name according to the rules for this kind of task. File based tasks ignore the scope when creating the name.



35
36
37
# File 'lib/rake-plus/bdep.rb', line 35

def scope_name(scope, task_name)
  ":bdep:#{task_name}"
end

Instance Method Details

#basenameObject



28
29
30
# File 'lib/rake-plus/bdep.rb', line 28

def basename
  name.sub(':bdep:','')
end

#execute(args = nil) ⇒ Object



23
24
25
26
# File 'lib/rake-plus/bdep.rb', line 23

def execute(args=nil)
  sudo "apt-get install -qy \"#{basename}\""
  super
end

#needed?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
# File 'lib/rake-plus/bdep.rb', line 10

def needed?
  return if ON_OSX
  # dpkg-query also returns old packages, so '^ii ' guarantees only installed
  sh("dpkg-query -l \"#{basename}\" | grep -e '^ii ' > /dev/null 2>&1") do |ok, res|
    return :package_missing unless ok
  end
  return
end

#timestampObject



19
20
21
# File 'lib/rake-plus/bdep.rb', line 19

def timestamp
  Rake::EARLY
end