fuburake 0.5.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjI5MjRkMThmYWU0ODY4YTNmMDgxMmY3ZGEzZmU4MWQxOGVlZDcyMg==
5
+ data.tar.gz: !binary |-
6
+ NDAyNTEzZmUxM2U3NDUyNjVjNzQ5N2U4ODlmZjczNGQ4NDg2NmM0OA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjNlMGMwODZjN2FmZDQzMzFlODMyYTYyMmY5MTgxMzBjMmJiNThjNTQyYjIz
10
+ YjdhY2Q0OTA2OGJmMzExM2RhYjQ0YjVlMjIxZjk3Y2E4OWJmZDM2ZjkzODli
11
+ NGI4MDg2ZmI2ZjY0OTM0ODM2NTE3MjI3YjI4MzczYjVlMDc1OTg=
12
+ data.tar.gz: !binary |-
13
+ MWU0MmY4Y2NhNzczNWQ5NjU1ZWUzMTYxMTc0NjlkM2U5N2IwNGE1ZDkwYTdh
14
+ MzA5Yjc0MmQwYjBiZDRlYjFmY2M4MWNhZjQzZmFkMGVlYWRjYzI4ZDQ4YzI2
15
+ MDc4YzM0NWFmZDc3NjlmZmZjYTc0MmIxZDA5MjkzNjgyOTA5ZDI=
@@ -0,0 +1,48 @@
1
+ module FubuRake
2
+ class AssemblyInfo
3
+ def self.create tasks, options
4
+ if tasks.assembly_info == nil
5
+ return nil
6
+ end
7
+
8
+ versionTask = Rake::Task.define_task :version do
9
+ begin
10
+ commit = `git log -1 --pretty=format:%H`
11
+ rescue
12
+ commit = "git unavailable"
13
+ end
14
+ puts "##teamcity[buildNumber '#{options[:build_number]}']" unless options[:tc_build_number].nil?
15
+ puts "Version: #{options[:build_number]}" if options[:tc_build_number].nil?
16
+
17
+ options = {
18
+ :trademark => commit,
19
+ :product_name => 'CHANGEME',
20
+ :description => options[:build_number],
21
+ :version => options[:asm_version],
22
+ :file_version => options[:build_number],
23
+ :informational_version => options[:asm_version],
24
+ :copyright => 'CHANGEME',
25
+ :output_file => 'src/CommonAssemblyInfo.cs'
26
+ }
27
+
28
+ options = options.merge(tasks.assembly_info)
29
+
30
+ File.open(options[:output_file], 'w') do |file|
31
+ file.write "using System.Reflection;\n"
32
+ file.write "using System.Runtime.InteropServices;\n"
33
+ file.write "[assembly: AssemblyDescription(\"#{options[:description]}\")]\n"
34
+ file.write "[assembly: AssemblyProduct(\"#{options[:product_name]}\")]\n"
35
+ file.write "[assembly: AssemblyCopyright(\"#{options[:copyright]}\")]\n"
36
+ file.write "[assembly: AssemblyTrademark(\"#{options[:trademark]}\")]\n"
37
+ file.write "[assembly: AssemblyVersion(\"#{options[:version]}\")]\n"
38
+ file.write "[assembly: AssemblyFileVersion(\"#{options[:file_version]}\")]\n"
39
+ file.write "[assembly: AssemblyInformationalVersion(\"#{options[:informational_version]}\")]\n"
40
+ end
41
+ end
42
+
43
+ versionTask.add_description "Update the version information for the build"
44
+
45
+ return versionTask
46
+ end
47
+ end
48
+ end
data/lib/bottles.rb ADDED
@@ -0,0 +1,19 @@
1
+ module FubuRake
2
+ class AssemblyBottle
3
+ def initialize(project)
4
+ @project = project
5
+ end
6
+
7
+ def create(options)
8
+ cleaned_name = @project.gsub('.', '_').downcase
9
+
10
+ name = "bottle_#{cleaned_name}"
11
+ task = Rake::Task.define_task name do
12
+ sh "bottles assembly-pak src/#{@project} -p #{@project}.csproj"
13
+ end
14
+
15
+ task.add_description "Assembly bottle packing for #{@project}"
16
+ Rake::Task[:compile].enhance [name]
17
+ end
18
+ end
19
+ end
data/lib/fubudocs.rb ADDED
@@ -0,0 +1,26 @@
1
+ namespace :docs do
2
+ desc "Tries to run a documentation project hosted in FubuWorld"
3
+ task :run do
4
+ sh "fubudocs run -o"
5
+ end
6
+
7
+ desc "Tries to run the documentation projects in this solution in a 'watched' mode in Firefox"
8
+ task :run_firefox do
9
+ sh "fubudocs run --watched --browser Firefox"
10
+ end
11
+
12
+ desc "Tries to run the documentation projects in this solution in a 'watched' mode in Firefox"
13
+ task :run_chrome do
14
+ sh "fubudocs run --watched --browser Chrome"
15
+ end
16
+
17
+ desc "'Bottles' up a single project in the solution with 'Docs' in its name"
18
+ task :bottle do
19
+ sh "fubudocs bottle"
20
+ end
21
+
22
+ desc "Gathers up code snippets from the solution into the Docs project"
23
+ task :snippets do
24
+ sh "fubudocs snippets"
25
+ end
26
+ end
data/lib/fuburake.rb ADDED
@@ -0,0 +1,183 @@
1
+ include FileUtils
2
+ include FileTest
3
+
4
+ require_relative 'nunit'
5
+ require_relative 'msbuild'
6
+ require_relative 'nuget'
7
+ require_relative 'platform'
8
+ require_relative 'ripple'
9
+ require_relative 'assembly_info'
10
+ require_relative 'bottles'
11
+
12
+ load "VERSION.txt"
13
+
14
+ module FubuRake
15
+ class SolutionTasks
16
+ attr_accessor :clean,
17
+ :compile,
18
+ :assembly_info,
19
+ :ripple_enabled,
20
+ :fubudocs_enabled,
21
+ :options,
22
+ :defaults,
23
+ :ci_steps,
24
+ :precompile,
25
+ :integration_test,
26
+ :compilations
27
+
28
+
29
+
30
+ def compile_step(name, solution)
31
+ @compilations ||= []
32
+
33
+ @compilations << CompileTarget.new(name, solution)
34
+ end
35
+
36
+ def assembly_bottle(project)
37
+ @compilations ||= []
38
+
39
+ @compilations << FubuRake::AssemblyBottle.new(project)
40
+ end
41
+ end
42
+
43
+ class Solution
44
+ attr_accessor :options, :compilemode, :build_number
45
+
46
+ def initialize(&block)
47
+ tasks = SolutionTasks.new
48
+ block.call(tasks)
49
+
50
+ @defaultTask = create_task(:default, "**Default**, compiles and runs tests")
51
+ @ciTask = create_task(:ci, "Target used for the CI server")
52
+ @ciTask.enhance [:default]
53
+
54
+ options = tasks.options
55
+ options ||= {}
56
+
57
+ tc_build_number = ENV["BUILD_NUMBER"]
58
+ build_revision = tc_build_number || Time.new.strftime('5%H%M')
59
+ asm_version = BUILD_VERSION + ".0"
60
+ @build_number = "#{BUILD_VERSION}.#{build_revision}"
61
+
62
+ # SAMPLE: fuburake-options
63
+ @options = {
64
+ :compilemode => ENV['config'].nil? ? "Debug" : ENV['config'],
65
+ :clrversion => 'v4.0.30319',
66
+ :platform => 'x86',
67
+ :unit_test_list_file => 'TESTS.txt',
68
+ :unit_test_projects => [],
69
+ :build_number => @build_number,
70
+ :asm_version => asm_version,
71
+ :tc_build_number => tc_build_number,
72
+ :build_revision => build_revision,
73
+ :source => 'src'}.merge(options)
74
+ # ENDSAMPLE
75
+
76
+ @compilemode = @options[:compilemode]
77
+
78
+ tasks.clean ||= []
79
+ tasks.defaults ||= []
80
+ tasks.ci_steps ||= []
81
+ tasks.precompile ||= []
82
+
83
+
84
+ enable_docs tasks
85
+ FubuRake::AssemblyInfo.create tasks, @options
86
+ FubuRake::Ripple.create tasks, @options
87
+ make_clean tasks
88
+ FubuRake::MSBuild.create_task tasks, @options
89
+ FubuRake::NUnit.create_task tasks, @options
90
+
91
+ add_dependency :compile, [:clean, :version, 'ripple:restore', 'docs:bottle']
92
+
93
+ Rake::Task[:compile].enhance(tasks.precompile)
94
+ add_dependency :unit_test, :compile
95
+ add_dependency :default, [:compile, :unit_test]
96
+ add_dependency :default, :unit_test
97
+ Rake::Task[:default].enhance tasks.defaults
98
+ Rake::Task[:ci].enhance tasks.ci_steps
99
+ add_dependency :ci, tasks.ci_steps
100
+ add_dependency :ci, ["ripple:history", "ripple:package"]
101
+
102
+ tasks.compilations ||= []
103
+ tasks.compilations.each do |c|
104
+ c.create @options
105
+ end
106
+ end
107
+
108
+ def add_dependency(from, to)
109
+ if to.kind_of?(Array)
110
+ to.each do |dep|
111
+ add_dependency from, dep
112
+ end
113
+ end
114
+
115
+ if !Rake::Task.task_defined?(from)
116
+ return
117
+ end
118
+
119
+ if !Rake::Task.task_defined?(to)
120
+ return
121
+ end
122
+
123
+ Rake::Task[from].enhance [to]
124
+ end
125
+
126
+ def create_task(name, description)
127
+ task = Rake::Task.define_task name do
128
+
129
+ end
130
+ task.add_description description
131
+
132
+ return task
133
+ end
134
+
135
+ def make_clean(tasks)
136
+ if tasks.clean.any?
137
+ @cleanTask = Rake::Task.define_task :clean do
138
+ tasks.clean.each do |dir|
139
+ cleanDirectory dir
140
+ end
141
+ end
142
+
143
+ @cleanTask.add_description "Prepares the working directory for a new build"
144
+ end
145
+ end
146
+
147
+
148
+ def enable_docs(tasks)
149
+ if tasks.fubudocs_enabled
150
+ require_relative 'fubudocs'
151
+ end
152
+ end
153
+ end
154
+ end
155
+
156
+
157
+
158
+
159
+ def copyOutputFiles(fromDir, filePattern, outDir)
160
+ Dir.glob(File.join(fromDir, filePattern)){|file|
161
+ copy(file, outDir) if File.file?(file)
162
+ }
163
+ end
164
+
165
+ def waitfor(&block)
166
+ checks = 0
167
+ until block.call || checks >10
168
+ sleep 0.5
169
+ checks += 1
170
+ end
171
+ raise 'waitfor timeout expired' if checks > 10
172
+ end
173
+
174
+ def cleanDirectory(dir)
175
+ puts 'Cleaning directory ' + dir
176
+ FileUtils.rm_rf dir;
177
+ waitfor { !exists?(dir) }
178
+ Dir.mkdir dir
179
+ end
180
+
181
+ def cleanFile(file)
182
+ File.delete file unless !File.exist?(file)
183
+ end
data/lib/msbuild.rb ADDED
@@ -0,0 +1,84 @@
1
+ module FubuRake
2
+ class MSBuild
3
+ def self.create_task(tasks, options)
4
+ if tasks.compile == nil
5
+ return nil
6
+ end
7
+
8
+ compileTask = Rake::Task.define_task :compile do
9
+ MSBuildRunner.compile options.merge(tasks.compile)
10
+ end
11
+
12
+ compileTask.add_description "Compiles the application"
13
+
14
+ return compileTask
15
+ end
16
+ end
17
+
18
+ class CompileTarget
19
+ def initialize(name, solution)
20
+ @name = name
21
+ @solution = solution
22
+ end
23
+
24
+ def create(options)
25
+ compileTask = Rake::Task.define_task @name do
26
+ MSBuildRunner.compile options.merge({:solutionfile => @solution})
27
+ end
28
+
29
+ compileTask.add_description "Compiles #{@solution}"
30
+ end
31
+ end
32
+ end
33
+
34
+
35
+ class MSBuildRunner
36
+ def self.compile(attributes)
37
+ compileTarget = attributes.fetch(:compilemode, 'debug')
38
+ solutionFile = attributes[:solutionfile]
39
+
40
+ attributes[:projFile] = solutionFile
41
+ attributes[:properties] ||= []
42
+ attributes[:properties] << "Configuration=#{compileTarget}"
43
+ attributes[:extraSwitches] = ["v:m", "t:rebuild"]
44
+ attributes[:extraSwitches] << "maxcpucount:2" unless Platform.is_nix
45
+
46
+ self.runProjFile(attributes);
47
+ end
48
+
49
+ def self.runProjFile(attributes)
50
+ version = attributes.fetch(:clrversion, 'v4.0.30319')
51
+ compileTarget = attributes.fetch(:compilemode, 'debug')
52
+ projFile = attributes[:projFile]
53
+
54
+ if Platform.is_nix
55
+ msbuildFile = `which xbuild`.chop
56
+ attributes[:properties] << "TargetFrameworkProfile="""""
57
+ else
58
+ frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
59
+ msbuildFile = File.join(frameworkDir, 'msbuild.exe')
60
+ end
61
+
62
+ properties = attributes.fetch(:properties, [])
63
+
64
+ switchesValue = ""
65
+
66
+ properties.each do |prop|
67
+ switchesValue += " /property:#{prop}"
68
+ end
69
+
70
+ extraSwitches = attributes.fetch(:extraSwitches, [])
71
+
72
+ extraSwitches.each do |switch|
73
+ switchesValue += " /#{switch}"
74
+ end
75
+
76
+ targets = attributes.fetch(:targets, [])
77
+ targetsValue = ""
78
+ targets.each do |target|
79
+ targetsValue += " /t:#{target}"
80
+ end
81
+
82
+ sh "#{msbuildFile} #{projFile} #{targetsValue} #{switchesValue}"
83
+ end
84
+ end
data/lib/nuget.rb ADDED
@@ -0,0 +1,25 @@
1
+ module Nuget
2
+ def self.tool(package, tool)
3
+ nugetDir = Dir.glob(File.join(package_root,"#{package}*")).sort.last
4
+ return File.join(nugetDir, "tools", tool) if File.directory?(nugetDir)
5
+
6
+
7
+ File.join(Dir.glob(File.join(package_root,"#{package}.[0-9]*")).sort.last, "tools", tool)
8
+ end
9
+
10
+ def self.package_root
11
+ root = nil
12
+
13
+ packroots = Dir.glob("{source,src}/packages")
14
+
15
+ return packroots.last if packroots.length > 0
16
+
17
+ Dir.glob("{source,src}").each do |d|
18
+ packroot = File.join d, "packages"
19
+ FileUtils.mkdir_p(packroot)
20
+ root = packroot
21
+ end
22
+
23
+ root
24
+ end
25
+ end
data/lib/nunit.rb ADDED
@@ -0,0 +1,76 @@
1
+ module FubuRake
2
+ class NUnit
3
+ def self.create_task(tasks, options)
4
+ nunitTask = nil
5
+ if options[:unit_test_projects].any?
6
+ nunitTask = Rake::Task.define_task :unit_test do
7
+ runner = NUnitRunner.new options
8
+ runner.executeTests options[:unit_test_projects]
9
+ end
10
+ elsif options[:unit_test_list_file] != nil
11
+ file = options[:unit_test_list_file]
12
+
13
+ nunitTask = Rake::Task.define_task :unit_test do
14
+ runner = NUnitRunner.new options
15
+ runner.executeTestsInFile file
16
+ end
17
+ end
18
+
19
+ if nunitTask != nil
20
+ nunitTask.enhance [:compile]
21
+ nunitTask.add_description "Runs unit tests"
22
+ end
23
+
24
+ if tasks.integration_test != nil
25
+ integrationTask = Rake::Task.define_task :integration_test do
26
+ runner = NUnitRunner.new options
27
+ runner.executeTests tasks.integration_test
28
+ end
29
+
30
+ integrationTask.enhance [:compile]
31
+ integrationTask.add_description "integration tests: #{tasks.integration_test.join(', ')}"
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ class NUnitRunner
38
+ include FileTest
39
+
40
+ def initialize(paths)
41
+ @sourceDir = paths.fetch(:source, 'src')
42
+ @resultsDir = paths.fetch(:results, 'results')
43
+ @compilePlatform = paths.fetch(:platform, 'x86')
44
+ @compileTarget = paths.fetch(:compilemode, 'debug')
45
+ @nunitExe = Nuget.tool("NUnit", "nunit-console#{(@compilePlatform.empty? ? '' : "-#{@compilePlatform}")}.exe") + Platform.switch("nothread")
46
+ end
47
+
48
+ def executeTests(assemblies)
49
+ Dir.mkdir @resultsDir unless exists?(@resultsDir)
50
+
51
+ assemblies.each do |assem|
52
+ file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{@compileTarget}/#{assem}.dll")
53
+ sh Platform.runtime("#{@nunitExe} -xml=#{@resultsDir}/#{assem}-TestResults.xml \"#{file}\"")
54
+ end
55
+ end
56
+
57
+ def executeTestsInFile(file)
58
+ if !File.exist?(file)
59
+ throw "File #{file} does not exist"
60
+ end
61
+
62
+ tests = Array.new
63
+
64
+ file = File.new(file, "r")
65
+ assemblies = file.readlines()
66
+ assemblies.each do |a|
67
+ test = a.gsub("\r\n", "").gsub("\n", "")
68
+ tests.push(test)
69
+ end
70
+ file.close
71
+
72
+ if (!tests.empty?)
73
+ executeTests tests
74
+ end
75
+ end
76
+ end
data/lib/platform.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Platform
2
+
3
+ def self.is_nix
4
+ !RUBY_PLATFORM.match("linux|darwin").nil?
5
+ end
6
+
7
+ def self.runtime(cmd)
8
+ command = cmd
9
+ if self.is_nix
10
+ runtime = (CLR_TOOLS_VERSION || "v4.0.30319")
11
+ command = "mono --runtime=#{runtime} #{cmd}"
12
+ end
13
+ command
14
+ end
15
+
16
+ def self.switch(arg)
17
+ sw = self.is_nix ? " -" : " /"
18
+ sw + arg
19
+ end
20
+
21
+ end
data/lib/ripple.rb ADDED
@@ -0,0 +1,38 @@
1
+ module FubuRake
2
+ class Ripple
3
+ def self.create(tasks, options)
4
+ if !tasks.ripple_enabled
5
+ return
6
+ end
7
+
8
+ tasks.clean << 'artifacts'
9
+
10
+ restoreTask = Rake::Task.define_task 'ripple:restore' do
11
+ puts 'Restoring all the nuget package files'
12
+ sh 'ripple restore'
13
+ end
14
+ restoreTask.add_description "Restores nuget package files and updates all floating nugets"
15
+
16
+ updateTask = Rake::Task.define_task 'ripple:update' do
17
+ puts 'Cleaning out existing packages out of paranoia'
18
+ sh 'ripple clean'
19
+
20
+ puts 'Updating all the nuget package files'
21
+ sh 'ripple update'
22
+ end
23
+ updateTask.add_description "Updates nuget package files to the latest"
24
+
25
+
26
+ historyTask = Rake::Task.define_task 'ripple:history' do
27
+ sh 'ripple history'
28
+ end
29
+ historyTask.add_description "creates a history file for nuget dependencies"
30
+
31
+ packageTask = Rake::Task.define_task 'ripple:package' do
32
+ sh "ripple local-nuget --version #{options[:build_number]} --destination artifacts"
33
+ end
34
+ packageTask.add_description "packages the nuget files from the nuspec files in packaging/nuget and publishes to /artifacts"
35
+ end
36
+ end
37
+ end
38
+
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuburake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0.8
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy D. Miller
8
+ - Josh Arnold
9
+ - Joshua Flanagan
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-05-15 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Rake helpers for FubuDocs, ripple, NUnit, and cross platform fubu project
16
+ development
17
+ email: fubumvc-devel@googlegroups.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/assembly_info.rb
23
+ - lib/bottles.rb
24
+ - lib/fubudocs.rb
25
+ - lib/fuburake.rb
26
+ - lib/msbuild.rb
27
+ - lib/nuget.rb
28
+ - lib/nunit.rb
29
+ - lib/platform.rb
30
+ - lib/ripple.rb
31
+ homepage: http://fubu-project.org
32
+ licenses:
33
+ - Apache 2
34
+ metadata: {}
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project: fuburake
51
+ rubygems_version: 2.0.3
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Rake tasks for fubu related projects
55
+ test_files: []