Module: Logirel::Tasks

Includes:
FileUtils
Included in:
CLI
Defined in:
lib/logirel/tasks/zip.rb,
lib/logirel/tasks/core.rb,
lib/logirel/tasks/nuget.rb,
lib/logirel/tasks/nunit.rb,
lib/logirel/tasks/xunit.rb,
lib/logirel/tasks/aspnet.rb,
lib/logirel/tasks/ncover.rb,
lib/logirel/tasks/nuspec.rb,
lib/logirel/tasks/output.rb,
lib/logirel/tasks/msbuild.rb,
lib/logirel/tasks/assembly_info.rb

Constant Summary collapse

BUILD_FILE =
'Rakefile.rb'

Instance Method Summary collapse

Instance Method Details

#aspnet_task(web_output_folder = nil, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/logirel/tasks/aspnet.rb', line 2

def aspnet_task(web_output_folder=nil, opts={})
  web_output_folder = tuck_and_get :web_output_folder, web_output_folder

  if vars[:solution].has_web_projects?
    vars[:solution].web_projects.each do |p|
      # todo: snake case p.name in const.

      append_to_file BUILD_FILE, <<-EOF, :verbose => false

desc "asp compile"
aspnetcompiler #{ inject_task_name opts, 'precompile' }_#{p.name}#{ inject_dependency opts } do |c|
c.physical_path = "#{p.directory}"
c.target_path = "#{web_output_folder || 'web_out' }/#{p.name}"
c.updateable = true
c.force = true
end
      EOF
    end #each
  end #if
end

#assembly_info_task(proj_meta, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/logirel/tasks/assembly_info.rb', line 2

def assembly_info_task proj_meta, opts={}

  k = proj_meta[:ruby_key]

  append_to_file BUILD_FILE, <<-EOF, :verbose => false

desc 'generate the shared assembly info'
assemblyinfo #{inject_task_name opts, 'assemblyinfo' }#{ inject_dependency opts } do |asm|
data = commit_data() #hash + date
asm.product_name = asm.title = PROJECTS[:#{k}][:title]
asm.description = PROJECTS[:#{k}][:description] + " \#{data[0]} - \#{data[1]}"
asm.company_name = PROJECTS[:#{k}][:company]
# This is the version number used by framework during build and at runtime to locate, link and load the assemblies. When you add reference to any assembly in your project, it is this version number which gets embedded.
asm.version = BUILD_VERSION
# Assembly File Version : This is the version number given to file as in file system. It is displayed by Windows Explorer. Its never used by .NET framework or runtime for referencing.
asm.file_version = BUILD_VERSION
asm.custom_attributes :AssemblyInformationalVersion => "\#{BUILD_VERSION}", # disposed as product version in explorer
  :CLSCompliantAttribute => false,
  :AssemblyConfiguration => "\#{CONFIGURATION}",
  :Guid => PROJECTS[:#{k}][:guid]
asm.com_visible = false
asm.copyright = PROJECTS[:#{k}][:copyright]
asm.output_file = File.join(FOLDERS[:src], 'SharedAssemblyInfo.cs')
end

  EOF
end

#msbuild_task(opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/logirel/tasks/msbuild.rb', line 2

def msbuild_task opts={}

  task_name = inject_task_name opts, 'msbuild'

  append_to_file File.join(@root, BUILD_FILE), <<-EOF, :verbose => false

desc "build sln file"
msbuild #{ task_name }#{ inject_dependency opts } do |msb|
msb.solution   = FILES[:sln]
msb.properties :Configuration => CONFIGURATION
msb.targets    :Clean, :Build
end

  EOF
end

#ncover_task(ncover_exe_folder = nil, nunit_exe_folder = nil, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/logirel/tasks/ncover.rb', line 2

def ncover_task(ncover_exe_folder=nil, nunit_exe_folder=nil, opts={})
  ncover_exe_folder = tuck_and_get :ncover_exe_folder, ncover_exe_folder
  nunit_exe_folder = tuck_and_get :nunit_exe_folder, nunit_exe_folder

  append_to_file BUILD_FILE, <<-EOF, :verbose => false

desc "NCover Console code coverage"
ncoverconsole #{ inject_task_name opts, 'ncover' }#{ inject_dependency opts } |ncc|
ncc.command = "#{ncover_exe_folder || 'tools/ncover'}/NCover.Console.exe"
ncc.output :xml => "test-coverage.xml"
ncc.cover_assemblies '#{ vars[:solution].find_project(:output=>'OUTPUT') { |p| !p.test? }.output }'

nunit = NUnitTestRunner.new("#{nunit_exe_folder || 'tools/nunit' }/nunit-console.exe")
#  nunit.options '/framework=4.0.30319', '/noshadow'
nunit.options '/noshadow'
nunit.assemblies '#{ vars[:solution].find_project(:output=>'TEST_ASSEMBLY') { |p| p.test? }.output }'
ncc.testrunner = nunit
end
  EOF

end

#nuget_task(proj_meta, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/logirel/tasks/nuget.rb', line 2

def nuget_task(proj_meta, opts={})

  k = proj_meta[:ruby_key]

  append_to_file BUILD_FILE, <<-EOF, :verbose => false

desc "nuget pack '#{proj_meta[:title]}'"
nugetpack #{ inject_task_name opts, k + "_nuget" }#{ inject_dependency opts } do |nuget|
 nuget.command     = "\#{COMMANDS[:nuget]}"
 nuget.nuspec      = "\#{FILES[:#{k}][:nuspec]}"
 # nuget.base_folder = "."
 nuget.output      = "\#{FOLDERS[:nuget]}"
end

  EOF
end

#nunit_task(nunit_exe_folder = nil, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/logirel/tasks/nunit.rb', line 2

def nunit_task(nunit_exe_folder=nil, opts={})
  nunit_exe_folder = tuck_and_get :nunit_exe_folder, nunit_exe_folder

  append_to_file BUILD_FILE, <<-EOF, :verbose => false

desc "Run tests"
nunit #{ inject_task_name opts, 'nunit' }#{ inject_dependency opts } do |nunit|
nunit.command = "#{ nunit_exe_folder || 'tools/nunit' }/nunit-console.exe"
nunit.assemblies "#{ vars[:solution].find_project(:output=>'TEST_ASSEMBLY') { |p| p.test? }.output }"
end
  EOF
end

#nuspec_task(proj_meta, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/logirel/tasks/nuspec.rb', line 2

def nuspec_task proj_meta, opts={}

  k = proj_meta[:ruby_key]

  append_to_file BUILD_FILE, <<-EOF, :verbose => false

desc "Create a nuspec for '#{proj_meta[:title]}'"
nuspec #{inject_task_name opts, k + "_nuspec"}#{ inject_dependency opts } do |nuspec|
nuspec.id = "\#{PROJECTS[:#{k}][:nuget_key]}"
nuspec.version = BUILD_VERSION
nuspec.authors = "\#{PROJECTS[:#{k}][:authors]}"
nuspec.description = "\#{PROJECTS[:#{k}][:description]}"
nuspec.title = "\#{PROJECTS[:#{k}][:title]}"
# nuspec.projectUrl = 'http://github.com/haf' # TODO: Set this for nuget generation
nuspec.language = "en-US"
nuspec.licenseUrl = "http://www.apache.org/licenses/LICENSE-2.0" # TODO: set this for nuget generation
nuspec.requireLicenseAcceptance = "false"
#{proj_meta[:dependencies].
  collect{|dep| "  nuspec.dependency '#{dep[:nuget_key]}', '#{dep[:version]}'" }.
  join("\n") unless proj_meta[:dependencies].empty?
}
nuspec.output_file = FILES[:#{k}][:nuspec]
nuspec_copy(:#{k}, "\#{PROJECTS[:#{k}][:id]}.{dll,pdb,xml}")
end

EOF
end

#output_task(proj_meta, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/logirel/tasks/output.rb', line 2

def output_task proj_meta, opts={}

  k = proj_meta[:ruby_key]

  append_to_file BUILD_FILE, <<-EOF, :verbose => false

task #{inject_task_name opts, k + "_output"}#{ inject_dependency opts } do
target = File.join(FOLDERS[:binaries], PROJECTS[:#{k}][:id])
copy_files FOLDERS[:#{k}][:out], "*.{xml,dll,pdb,config}", target
CLEAN.include(target)
end

EOF
end

#unzip(zipfile, opts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/logirel/tasks/core.rb', line 10

def unzip(zipfile, opts)
  opts = {:to =>'.'}.merge(opts)
  Zip::ZipFile.open(zipfile) do |z|
    z.each do |f|
      to_file = File.join(opts[:to], f.name)
      mkdir_p(File.dirname(to_file))
      z.extract(f, to_file) unless File.exist?(to_file)
    end
  end
  rm zipfile if opts[:remove]
end

#xunit_task(xunit_exe_folder = nil, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/logirel/tasks/xunit.rb', line 2

def xunit_task(xunit_exe_folder=nil, opts={})
  xunit_exe_folder = tuck_and_get :xunit_exe_folder, xunit_exe_folder

  append_to_file BUILD_FILE, <<-EOF, :verbose => false

desc "Run tests with XUnit"
xunit #{ inject_task_name opts, 'xunit' }#{ inject_dependency opts } do |xunit|
xunit.command = "#{xunit_exe_folder || 'tools/xunit'}/xunit.console.exe"
xunit.assembly "#{ vars[:solution].find_project(:output=>'TEST_ASSEMBLY') { |p| p.test? }.output }"
end
  EOF

end

#zip_taskObject



2
3
# File 'lib/logirel/tasks/zip.rb', line 2

def zip_task
end