Skip to content

Commit

Permalink
working on greatly simplifying the tasks, and adding more rakeish syn…
Browse files Browse the repository at this point in the history
…tax. got the assemblyinfo, command, expandtemplates, and msbuild done so far.
  • Loading branch information
Derick Bailey committed Dec 3, 2009
1 parent 0b35de9 commit 9a760ce
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 54 deletions.
27 changes: 11 additions & 16 deletions lib/rake/assemblyinfotask.rb
@@ -1,22 +1,17 @@
require 'rake/tasklib'

module Albacore
class AssemblyInfoTask < Rake::TaskLib
attr_accessor :name

def initialize(name=:assemblyinfo, &block)
@name = name
@block = block
define
end

def define
task name do
@asm = AssemblyInfo.new
@block.call(@asm) unless @block.nil?
@asm.write
fail if @asm.failed
end

def self.assemblyinfo(name=:assemblyinfo, *args, &block)
MSBuildTask.new(name, *args, &block)
end

class AssemblyInfoTask < Albacore::AlbacoreTask
def execute(task_args)
@asm = AssemblyInfo.new
@block.call(@asm, *task_args) unless @block.nil?
@asm.write
fail if @asm.failed
end
end
end
26 changes: 10 additions & 16 deletions lib/rake/commandtask.rb
@@ -1,22 +1,16 @@
require 'rake/tasklib'

module Albacore
class CommandTask < Rake::TaskLib
attr_accessor :name

def initialize(name=:command, &block)
@name = name
@block = block
define
end

def define
task name do
cmd = Command.new
@block.call(cmd) unless @block.nil?
cmd.execute
fail if cmd.failed
end
def self.command(name=:command, *args, &block)
MSBuildTask.new(name, *args, &block)
end

class CommandTask < Albacore::AlbacoreTask
def execute(task_args)
cmd = Command.new
@block.call(cmd, *task_args) unless @block.nil?
cmd.execute
fail if cmd.failed
end
end
end
24 changes: 9 additions & 15 deletions lib/rake/expandtemplatestask.rb
@@ -1,21 +1,15 @@
require 'rake/tasklib'

module Albacore
class ExpandTemplatesTask < Rake::TaskLib
attr_accessor :name

def initialize(name=:expandtemplates, &block)
@name = name
@block = block
define
end

def define
task @name do
@exp = ExpandTemplates.new
@block.call(@exp) unless @block.nil?
@exp.expand
end
def self.expandtemplates(name=:expandtemplates, *args, &block)
MSBuildTask.new(name, *args, &block)
end

class ExpandTemplatesTask < Albacore::AlbacoreTask
def execute(task_args)
@exp = ExpandTemplates.new
@block.call(@exp, *task_args) unless @block.nil?
@exp.expand
end
end
end
5 changes: 2 additions & 3 deletions lib/rake/msbuildtask.rb
Expand Up @@ -6,11 +6,10 @@ def self.msbuild(name=:msbuild, *args, &block)
MSBuildTask.new(name, *args, &block)
end

class MSBuildTask < AlbacoreTask

class MSBuildTask < Albacore::AlbacoreTask
def execute(task_args)
@msbuild = MSBuild.new
@block.call(@msbuild, task_args) unless @block.nil?
@block.call(@msbuild, *task_args) unless @block.nil?
@msbuild.build
fail if @msbuild.failed
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rake/support/albacoretask.rb
@@ -1,5 +1,5 @@
module Albacore
class AlbacoreTask < Rake::TaskLib
class AlbacoreTask < ::Rake::TaskLib
attr_accessor :name

def initialize(name, *args, &block)
Expand Down
13 changes: 13 additions & 0 deletions rakefile.rb
Expand Up @@ -214,3 +214,16 @@
gs.add_development_dependency('jekyll', '>= 0.5.4')
end
end

task :foo do
puts "foo"
end

desc "test"
Albacore::msbuild :msbuild, [:env] => :foo do |msb|
puts "--------------------------------#{msb}}"
msb.log_level = :verbose
msb.properties = {:configuration => :debug}
msb.targets [:Clean, :Build]
msb.solution = "spec/support/TestSolution/TestSolution.sln"
end
2 changes: 1 addition & 1 deletion spec/commandtask_spec.rb
Expand Up @@ -5,7 +5,7 @@

describe Albacore::CommandTask, "when running" do
before :all do
task = Albacore::CommandTask.new() do |t|
task = Albacore::CommandTask.new(:command) do |t|
@yielded_object = t
end
task.extend(TasklibPatch)
Expand Down
2 changes: 1 addition & 1 deletion spec/expandtemplatestask_spec.rb
Expand Up @@ -5,7 +5,7 @@

describe Albacore::ExpandTemplatesTask, "when running" do
before :each do
task = Albacore::ExpandTemplatesTask.new() do |t|
task = Albacore::ExpandTemplatesTask.new(:expandtemplates) do |t|
@yielded_object = t
end
task.extend(TasklibPatch)
Expand Down
2 changes: 1 addition & 1 deletion spec/msbuildtask_spec.rb
Expand Up @@ -5,7 +5,7 @@

describe Albacore::MSBuildTask, "when running" do
before :all do
task = Albacore::MSBuildTask.new() do |t|
task = Albacore::MSBuildTask.new(:msbuild) do |t|
@yielded_object = t
end
task.extend(TasklibPatch)
Expand Down
2 changes: 2 additions & 0 deletions spec/support/spec_helper.rb
Expand Up @@ -5,6 +5,8 @@
$: << File.join(@root_dir, "spec/patches")
$: << File.join(@root_dir, "spec/support")

require 'rake/tasklib'
require 'lib/rake/support/albacoretask.rb'
require 'not_a_mock'
require 'system_patch'
require 'tasklib_patch'
Expand Down

0 comments on commit 9a760ce

Please sign in to comment.