albacore 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
1
  source 'http://rubygems.org'
2
+
3
+ gem 'rubyzip', '0.9.4'
2
4
 
3
5
  group :development do
4
- gem 'rake', '0.8.7'
5
- gem 'rubyzip', '0.9.4'
6
+ gem 'nokogiri', '1.4.4'
7
+ gem 'version_bumper', '0.3.0'
6
8
  gem 'jeweler', '1.4.0'
7
9
  gem 'rspec', '1.2.9'
8
- gem 'derickbailey-notamock', '0.0.1'
9
10
  gem 'jekyll', '0.8.0'
10
11
  gem 'watchr', '0.7'
11
12
  end
@@ -2,12 +2,10 @@
2
2
 
3
3
  albacore is a professional quality suite of Rake tasks to help automate the process of building a .NET based system.
4
4
 
5
- ## How To Install albacore From Gemcutter Gems:
5
+ ## How To Install albacore:
6
6
 
7
7
  If you would like to install the current, stable release of albacore, you can do so easily through the standard RubyGems.org server. Follow these simple instructions and you will be good to go.
8
8
 
9
- **Step 1:** Install the albacore gem
10
-
11
9
  > gem install albacore
12
10
 
13
11
  That's it! You're now equiped with everything you need to get up and running with albacore!
@@ -24,19 +22,21 @@ Use your Github account to fork albacore, or clone it directly from my public cl
24
22
 
25
23
  **Step 2:** Install Required Dependencies
26
24
 
27
- In your local clone of albacore, run the "install_dependencies.rb" script:
25
+ You will need the Bundler gem installed, to install the other albacore dependencies
26
+
27
+ > gem install bundler
28
+
29
+ In your local clone of albacore, run bundler
28
30
 
29
- > ruby install_dependencies.rb
31
+ > bundle install
30
32
 
31
- This will install all of the gem dependencies that you need, to build the albacore gem.
33
+ This will install all of the gem dependencies that you need to build the albacore gem and add your own contributions to albacore.
32
34
 
33
35
  **Step 3:** Build the gem
34
36
 
35
37
  In your local clone of albacore, use the jeweler rake tasks to build the latest version of the albacore code into a gem.
36
38
 
37
- > rake jeweler:gemspec
38
- >
39
- > rake jeweler:build
39
+ > rake jeweler:gemspec jeweler:build
40
40
 
41
41
  this will produce an 'albacore-#.#.#.gem' file in the 'pkg' folder, where '#.#.#' is the version number. For example 'albacore-0.1.2.gem'.
42
42
 
@@ -50,7 +50,7 @@ where '#.#.#' is the version number of the gem. For example 'albacore-0.1.2.gem'
50
50
 
51
51
  ## How To Use albacore
52
52
 
53
- On systems do not have the "RUBYOPT" environment variable set to automatically include rubygems, you will also need to add
53
+ On systems do not have the "RUBYOPT" environment variable set to automatically include rubygems, you may need to add
54
54
 
55
55
  require 'rubygems'
56
56
 
@@ -60,7 +60,7 @@ to the top of your rakefile. Then, you can add
60
60
 
61
61
  to your rakefile. This will allow you to use the tasks that albacore includes.
62
62
 
63
- desc "Run a sample build using the MSBuildTask"
63
+ desc "Run a sample build using the MSBuild Task"
64
64
  msbuild do |msb|
65
65
  msb.properties :configuration => :Debug
66
66
  msb.targets :Clean, :Build
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -4,5 +4,6 @@ $: << File.join(albacore_root, "albacore")
4
4
  $: << File.join(albacore_root, "albacore", 'support')
5
5
  $: << File.join(albacore_root, "albacore", 'config')
6
6
 
7
- runtime_is_ironruby = (!defined?(IRONRUBY_VERSION).nil?)
7
+ IS_IRONRUBY = (defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby")
8
+
8
9
  Dir.glob(File.join(albacore_root, 'albacore/*.rb')).each {|f| require f }
@@ -0,0 +1,15 @@
1
+ require 'albacore/support/openstruct'
2
+
3
+ module Configuration
4
+ module FluentMigrator
5
+ include Albacore::Configuration
6
+
7
+ def fluentmigrator
8
+ @fluentmigratorconfig ||= OpenStruct.new.extend(OpenStructToHash).extend(FluentMigrator)
9
+ yield(@fluentmigratorconfig) if block_given?
10
+ @fluentmigratorconfig
11
+ end
12
+ end
13
+ end
14
+
15
+
@@ -0,0 +1,15 @@
1
+ require 'ostruct'
2
+ require 'albacore/support/openstruct'
3
+
4
+ module Configuration
5
+ module NChurn
6
+ include Albacore::Configuration
7
+
8
+ def nchurn
9
+ @nchurnconfig ||= OpenStruct.new.extend(OpenStructToHash)
10
+ yield(@nchurnconfig) if block_given?
11
+ @nchurnconfig
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,19 @@
1
+ require 'ostruct'
2
+ require 'albacore/support/openstruct'
3
+
4
+ module Configuration
5
+ module NuGetPack
6
+ include Albacore::Configuration
7
+
8
+ def self.nugetpackconfig
9
+ @config ||= OpenStruct.new.extend(OpenStructToHash).extend(NuGetPack)
10
+ end
11
+
12
+ def nugetpack
13
+ @config ||= NuGetPack.nugetpackconfig
14
+ yield(@config) if block_given?
15
+ @config
16
+ end
17
+
18
+ end
19
+ end
@@ -8,7 +8,7 @@ class CSC
8
8
  include Configuration::CSC
9
9
  include SupportsLinuxEnvironment
10
10
 
11
- attr_accessor :output, :target, :optimize, :debug, :doc
11
+ attr_accessor :output, :target, :optimize, :debug, :doc, :main
12
12
  attr_array :compile, :references, :resources, :define
13
13
 
14
14
  def initialize
@@ -21,6 +21,7 @@ class CSC
21
21
  params = []
22
22
  params << @references.map{|r| format_reference(r)} unless @references.nil?
23
23
  params << @resources.map{|r| format_resource(r)} unless @resources.nil?
24
+ params << main_entry unless @main.nil?
24
25
  params << "\"/out:#{@output}\"" unless @output.nil?
25
26
  params << "/target:#{@target}" unless @target.nil?
26
27
  params << "/optimize+" if @optimize
@@ -51,6 +52,10 @@ class CSC
51
52
  end
52
53
  end
53
54
 
55
+ def main_entry
56
+ "/main:#{@main}"
57
+ end
58
+
54
59
  def format_resource(resource)
55
60
  "/res:#{resource}"
56
61
  end
@@ -0,0 +1,46 @@
1
+ require 'albacore/albacoretask'
2
+
3
+ class FluentMigratorRunner
4
+ TaskName = :fluentmigrator
5
+ include Albacore::Task
6
+ include Albacore::RunCommand
7
+
8
+ attr_accessor :target, :provider, :connection, :namespace, :output, :preview, :steps, :task, :version, :verbose, :script_directory, :profile, :timeout
9
+
10
+ def initialize(command=nil)
11
+ super()
12
+ update_attributes Albacore.configuration.fluentmigrator.to_hash
13
+ @command = command unless command.nil?
14
+ end
15
+
16
+ def get_command_line
17
+ commandline = "#{@command}"
18
+ commandline << get_command_parameters
19
+ @logger.debug "Build FuentMigrator Test Runner Command Line: " + commandline
20
+ commandline
21
+ end
22
+
23
+ def get_command_parameters
24
+ params = " /target \"#{@target}\""
25
+ params << " /provider #{@provider}"
26
+ params << " /connection \"#{@connection}\""
27
+ params << " /ns #{@namespace}" unless @namespace.nil?
28
+ params << " /out #{@output}" unless @output.nil?
29
+ params << " /preview #{@preview}" unless @preview.nil?
30
+ params << " /steps #{@steps}" unless @steps.nil? || @steps == 0
31
+ params << " /task #{@task}" unless @task.nil?
32
+ params << " /version #{@version}" unless @version.nil? || @version == 0
33
+ params << " /verbose #{@verbose}" unless @verbose.nil?
34
+ params << " /wd \"#{@script_directory}\"" unless @script_directory.nil?
35
+ params << " /profile #{@profile}" unless @profile.nil?
36
+ params << " /timeout #{@timeout}" unless @timeout.nil?
37
+ params
38
+ end
39
+
40
+ def execute()
41
+ result = run_command "FluentMigrator", get_command_parameters
42
+
43
+ failure_message = "FluentMigrator failed. See build log for detail."
44
+ fail_with_message failure_message if !result
45
+ end
46
+ end
@@ -0,0 +1,74 @@
1
+ require 'albacore/albacoretask'
2
+
3
+ class NChurn
4
+ include Albacore::Task
5
+ include Albacore::RunCommand
6
+
7
+ attr_reader :from, :churn, :top, :report_as, :env_path, :adapter, :exclude, :include, :output
8
+
9
+
10
+ def initialize
11
+ super()
12
+ update_attributes Albacore.configuration.nchurn.to_hash
13
+ end
14
+
15
+
16
+
17
+ def execute
18
+ command_parameters = []
19
+ command_parameters << ['-d',@from] if @from
20
+ command_parameters << ['-i',@input.to_s] if @input
21
+ command_parameters << ['-c',@churn.to_s] if @churn
22
+ command_parameters << ['-t',@top.to_s] if @top
23
+ command_parameters << ['-r',@report_as.to_s] if @report_as
24
+ command_parameters << ['-p',@env_path.to_s] if @env_path
25
+ command_parameters << ['-a',@adapter.to_s] if @adapter
26
+ command_parameters << ['-x',@exclude] if @exclude
27
+ command_parameters << ['-n',@include] if @include
28
+ command_parameters << ['>',@output] if @output
29
+
30
+ result = run_command "NChurn", command_parameters.join(" ")
31
+
32
+ failure_msg = 'Churn Analysis Failed. See Build Log For Detail.'
33
+ fail_with_message failure_msg if !result
34
+ end
35
+
36
+ def churn_precent(p)
37
+ @churn = p/100.0
38
+ end
39
+ def input(p)
40
+ @input = quotes(p)
41
+ end
42
+ def from(p)
43
+ @from = quotes(p.strftime('%d-%m-%Y'))
44
+ end
45
+ def churn(p)
46
+ @churn = p
47
+ end
48
+ def top(p)
49
+ @top= p
50
+ end
51
+ def report_as(p)
52
+ @report_as = p
53
+ end
54
+ def env_path(p)
55
+ @env_path = quotes(p)
56
+ end
57
+ def adapter(p)
58
+ @adapter = p
59
+ end
60
+ def exclude(p)
61
+ @exclude = quotes(p)
62
+ end
63
+ def include(p)
64
+ @include = quotes(p)
65
+ end
66
+ def output(p)
67
+ @output = quotes(p)
68
+ end
69
+
70
+ private
71
+ def quotes(s)
72
+ %{"#{s}"}
73
+ end
74
+ end
@@ -0,0 +1,41 @@
1
+ require 'albacore/albacoretask'
2
+ require 'albacore/config/nugetpackconfig'
3
+ require 'albacore/support/supportlinux'
4
+
5
+ class NuGetPack
6
+ include Albacore::Task
7
+ include Albacore::RunCommand
8
+ include Configuration::NuGetPack
9
+ include SupportsLinuxEnvironment
10
+
11
+ attr_accessor :nuspec,
12
+ :output,
13
+ :base_folder,
14
+ :command
15
+
16
+ def initialize(command = "NuGet.exe") # users might have put the NuGet.exe in path
17
+ super()
18
+ update_attributes nugetpack.to_hash
19
+ @command = command
20
+ end
21
+
22
+ def execute
23
+
24
+ fail_with_message 'nuspec must be specified.' if @nuspec.nil?
25
+
26
+ params = []
27
+ params << "pack"
28
+ params << "#{nuspec}"
29
+ params << "-b #{base_folder}" unless @base_folder.nil?
30
+ params << "-o #{output}" unless @output.nil?
31
+
32
+ merged_params = params.join(' ')
33
+
34
+ @logger.debug "Build NuGet pack Command Line: #{merged_params}"
35
+ result = run_command "NuGet", merged_params
36
+
37
+ failure_message = 'NuGet Failed. See Build Log For Detail'
38
+ fail_with_message failure_message if !result
39
+ end
40
+
41
+ end
@@ -0,0 +1,108 @@
1
+ require 'albacore/albacoretask'
2
+ require 'rexml/document'
3
+
4
+ class NuspecFile
5
+ def initialize(src, target)
6
+ @src = src
7
+ @target = target
8
+ end
9
+
10
+ def render(xml)
11
+ depend = xml.add_element 'file', { 'src' => @src }
12
+
13
+ depend.add_attribute( 'target', @target ) if @target.to_s == 0
14
+ end
15
+ end
16
+
17
+ class NuspecDependency
18
+
19
+ attr_accessor :id, :version
20
+
21
+ def initialize(id, version)
22
+ @id = id
23
+ @version = version
24
+ end
25
+
26
+ def render( xml )
27
+ depend = xml.add_element 'dependency', {'id' => @id, 'version' => @version}
28
+ end
29
+ end
30
+
31
+ class Nuspec
32
+ include Albacore::Task
33
+
34
+ attr_accessor :id, :version, :authors, :description, :language, :licenseUrl, :projectUrl, :output_file,
35
+ :owners, :summary, :iconUrl, :requireLicenseAcceptance, :tags, :working_directory
36
+
37
+ def initialize()
38
+ @dependencies = Array.new
39
+ @files = Array.new
40
+ super()
41
+ end
42
+
43
+ def dependency(id, version)
44
+ @dependencies.push NuspecDependency.new(id, version)
45
+ end
46
+
47
+ def file(src, target=nil)
48
+ @files.push NuspecFile.new(src, target)
49
+ end
50
+
51
+ def execute
52
+ check_required_field @output_file, "output_file"
53
+ check_required_field @id, "id"
54
+ check_required_field @version, "version"
55
+ check_required_field @authors, "authors"
56
+ check_required_field @description, "description"
57
+
58
+ if(! @working_directory.nil?)
59
+ @working_output_file = File.join(@working_directory, @output_file)
60
+ else
61
+ @working_output_file = @output_file
62
+ end
63
+
64
+ builder = REXML::Document.new
65
+ build(builder)
66
+ output=""
67
+ builder.write(output)
68
+
69
+ File.open(@working_output_file, 'w') {|f| f.write(output) }
70
+ end
71
+
72
+ def build(document)
73
+ document << REXML::XMLDecl.new
74
+
75
+ package = document.add_element('package')
76
+ package.add_attribute("xmlns", "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd")
77
+
78
+ metadata = package.add_element('metadata')
79
+
80
+ metadata.add_element('id').add_text(@id)
81
+ metadata.add_element('version').add_text(@version)
82
+ metadata.add_element('authors').add_text(@authors)
83
+ metadata.add_element('description').add_text(@description)
84
+ metadata.add_element('language').add_text(@language) if !@language.nil?
85
+ metadata.add_element('licenseUrl').add_text(@licenseUrl) if !@licenseUrl.nil?
86
+ metadata.add_element('projectUrl').add_text(@projectUrl) if !@projectUrl.nil?
87
+ metadata.add_element('owners').add_text(@owners) if !@owners.nil?
88
+ metadata.add_element('summary').add_text(@summary) if !@summary.nil?
89
+ metadata.add_element('iconUrl').add_text(@iconUrl) if !@iconUrl.nil?
90
+ metadata.add_element('requireLicenseAcceptance').add_text(@requireLicenseAcceptance) if !@requireLicenseAcceptance.nil?
91
+ metadata.add_element('tags').add_text(@tags) if !@tags.nil?
92
+
93
+ if @dependencies.length > 0
94
+ depend = metadata.add_element('dependencies')
95
+ @dependencies.each {|x| x.render(depend)}
96
+ end
97
+
98
+ if @files.length > 0
99
+ files = package.add_element('files')
100
+ @files.each {|x| x.render(files)}
101
+ end
102
+ end
103
+
104
+ def check_required_field(field, fieldname)
105
+ return true if !field.nil?
106
+ raise "Nuget: required field '#{fieldname}' is not defined"
107
+ end
108
+ end
@@ -0,0 +1,98 @@
1
+ require 'albacore/albacoretask'
2
+ require 'erb'
3
+ require 'ostruct'
4
+
5
+ class OutputBuilder
6
+ include FileUtils
7
+
8
+ def initialize(dir_to, dir_from)
9
+ @dir_to = dir_to
10
+ @dir_from = dir_from
11
+ end
12
+
13
+ def dir(dir)
14
+ cp_r "#{@dir_from}/#{dir}", @dir_to
15
+ end
16
+
17
+ def file(f)
18
+ file(f,f)
19
+ end
20
+
21
+ def file(f, ft)
22
+ #todo find more elegant way to create base dir if missing for file.
23
+ initialize_to_path(ft)
24
+ cp "#{@dir_from}/#{f}", "#{@dir_to}/#{ft}"
25
+ end
26
+
27
+ def erb(f, ft, locals)
28
+ initialize_to_path(ft)
29
+ erb = ERB.new(File.read("#{@dir_from}/#{f}"))
30
+ File.open("#{@dir_to}/#{ft}", 'w') {|f| f.write erb.result(ErbBinding.new(locals).get_binding)}
31
+ end
32
+
33
+ def self.output_to(dir_to, dir_from)
34
+ rmtree dir_to
35
+ mkdir dir_to
36
+ yield OutputBuilder.new(dir_to, dir_from)
37
+ end
38
+
39
+ private
40
+ def initialize_to_path(ft)
41
+ topath = File.dirname("#{@dir_to}/#{ft}")
42
+ mkdir_p topath unless File.exist? topath
43
+ topath
44
+ end
45
+ end
46
+
47
+ class ErbBinding < OpenStruct
48
+ def get_binding
49
+ return binding()
50
+ end
51
+ end
52
+
53
+
54
+ class Output
55
+ include Albacore::Task
56
+
57
+ def initialize
58
+ super()
59
+
60
+ @files = []
61
+ @erbs = []
62
+ @directories = []
63
+ end
64
+
65
+ def execute()
66
+ fail_with_message 'No base dir' if @from_dir.nil?
67
+ fail_with_message 'No output dir' if @to_dir.nil?
68
+
69
+ OutputBuilder.output_to(@to_dir, @from_dir) do |o|
70
+ @directories.each { |f| o.dir f }
71
+ @files.each { |f| o.file *f }
72
+ @erbs.each { |f| o.erb *f }
73
+ end
74
+ end
75
+
76
+ def file(f, opts={})
77
+ f_to = opts[:as] || f
78
+ @files << [f,f_to]
79
+ end
80
+
81
+ def erb(f, opts={})
82
+ f_to = opts[:as] || f
83
+ @erbs << [f,f_to,opts[:locals]||{}]
84
+ end
85
+
86
+ def dir(d)
87
+ @directories << d
88
+ end
89
+
90
+ def from(from_dir)
91
+ @from_dir = from_dir
92
+ end
93
+
94
+ def to(to_dir)
95
+ @to_dir = to_dir
96
+ end
97
+
98
+ end