Top Level Namespace

Defined Under Namespace

Modules: Rake, RakePlus Classes: Path, Pathname, Recipe

Instance Method Summary collapse

Instance Method Details

#bdep(args, &block) ⇒ Object



42
43
44
45
46
# File 'lib/rake-plus/bdep.rb', line 42

def bdep(args, &block)
  t = Rake::BuildDependency.define_task(args, &block)
  Rake::Task["bdeps"].prerequisites.push(t.name).uniq!
  t
end

#git(*args, &block) ⇒ Object Also known as: git_dep



94
95
96
# File 'lib/rake-plus/git_dep.rb', line 94

def git(*args, &block)
  Rake::GitDependency.define_task(*args, &block)
end

#gitver(branch_or_file = nil) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
# File 'lib/rake-plus/gitver.rb', line 3

def gitver(branch_or_file=nil)
  ret = `git log -n 1 --oneline #{branch_or_file}`
  raise ArgumentError, "could not find #{branch_or_file}" if $?.exitstatus > 0
  raise "parse error" unless (ret =~ /^([^\s]+)/)
  commit_id = $1
  commit_num = `git log --oneline #{branch_or_file} | wc -l`.chomp.to_i
  "#{commit_num}-#{commit_id}"
end

#path(*args) ⇒ Object



88
89
90
# File 'lib/rake-plus/path.rb', line 88

def path(*args)
  Path[ *args ]
end

#recipe(*args, &block) ⇒ Object



219
220
221
# File 'lib/rake-plus/recipe.rb', line 219

def recipe(*args, &block)
  Recipe.define_task(*args, &block)
end

#remote_package(*args, &block) ⇒ Object



72
73
74
75
76
# File 'lib/rake-plus/remote_package.rb', line 72

def remote_package(*args, &block)
  t = Rake::RemotePackage.define_task(*args, &block)
  Rake::Task["remote_packages"].prerequisites.push(t.name).uniq!
  t
end

#sudo(*command) ⇒ Object

Raises:

  • (ArgumentError)


1
2
3
4
5
6
7
8
# File 'lib/rake-plus/sudo.rb', line 1

def sudo(*command)
  raise ArgumentError, "command missing" if command.empty?
  if command.length == 1
    sh "sudo #{command.first}"
  else
    sh "sudo", *command
  end
end

#svn(*args, &block) ⇒ Object Also known as: svn_dep



60
61
62
# File 'lib/rake-plus/svn_dep.rb', line 60

def svn(*args, &block)
  Rake::SvnDependency.define_task(*args, &block)
end

#tpl(name, target, variables = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/rake-plus/tpl.rb', line 4

def tpl(name, target, variables={})
  ctx = OpenStruct.new(variables)
  tpl_str = File.read(RakePlus.template_dir / "#{name}.erb")
  tpl = ERB.new(tpl_str)
  out = tpl.result ctx.send(:binding)
  FileUtils.mkdir_p File.dirname(target)
  File.open(target, 'w') do |f| f.write out end
end