nbuild 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Mark Ryall
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,7 @@
1
+ This is a simple gem containing some utilities for running tasks required for a .net build.
2
+
3
+ Usage:
4
+
5
+ require 'nbuild'
6
+
7
+
data/lib/nbuild/cmd.rb ADDED
@@ -0,0 +1,34 @@
1
+ module Nbuild
2
+ class Cmd
3
+ def initialize params
4
+ @params = params
5
+ end
6
+
7
+ def command
8
+ @params[:command]
9
+ end
10
+
11
+ def execute
12
+ if @params[:wd]
13
+ execute_in @params[:wd]
14
+ else
15
+ execute_internal
16
+ end
17
+ end
18
+
19
+ def execute_in wd
20
+ Dir.chdir(wd) { execute_internal }
21
+ end
22
+ private
23
+ def execute_internal
24
+ puts "running command \"#{command}\""
25
+ system "#{command} 2>&1"
26
+ puts "exit status was #{$?}"
27
+ raise "Process failed" unless $?.success?
28
+ end
29
+ end
30
+
31
+ def command params
32
+ Cmd.new(params).execute
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ module Nbuild
2
+ class FileFilter
3
+ def initialize replacements
4
+ @replacements = replacements
5
+ end
6
+
7
+ def filter from, to
8
+ File.open(from) do |io_in|
9
+ File.open(to, 'w') do |io_out|
10
+ io_in.each do |line|
11
+ @replacements.each {|k, v| line.gsub!(k, v)}
12
+ io_out.puts line
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ require 'nbuild/cmd'
2
+
3
+ module Nbuild
4
+ class InstallUtilCmd < Cmd
5
+ def initialize params={}
6
+ @path = 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727'
7
+ @params = params
8
+ end
9
+
10
+ def command
11
+ install_switch = @params[:install] ? '-i' : '-u'
12
+ "\"#{@path}\\installutil.EXE\" #{install_switch} \"#{@params[:assembly]}\""
13
+ end
14
+ end
15
+
16
+ def install_util_task params={}
17
+ InstallUtilCmd.new(params).execute
18
+ end
19
+
20
+ def install_util_tasks task, assembly, *deps
21
+ description = task.to_s.gsub('_',' ')
22
+
23
+ desc 'install ' + description
24
+ task "installed_#{task}".to_sym => deps do
25
+ install_util_task :assembly => assembly, :install => true
26
+ end
27
+
28
+ desc 'uninstall ' + description
29
+ task "uninstalled_#{task}".to_sym => deps do
30
+ install_util_task :assembly => assembly, :install => false
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ require 'nbuild/cmd'
2
+
3
+ module Nbuild
4
+ class MSBuildCmd < Cmd
5
+ def initialize params={}
6
+ @path = 'C:\WINDOWS\Microsoft.NET\Framework\v3.5'
7
+ @params = params
8
+ end
9
+
10
+ def command
11
+ p = @params.dup
12
+ project = p.delete(:project)
13
+ raise 'msbuild: a project or solution parameter is required' unless project
14
+ targets = p.delete(:targets)
15
+ t = "/t:#{targets.join(';')}" if targets
16
+ properties = p.map {|k,v| "/p:#{k}=#{v}"}
17
+ "\"#{@path}\\msbuild.exe\" #{project} #{t} #{properties.join(' ')}"
18
+ end
19
+ end
20
+
21
+ def msbuild_command params={}
22
+ MSBuildCmd.new(params).execute
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'nbuild/cmd'
2
+
3
+ module Nbuild
4
+ class MSTestCmd < Cmd
5
+ def initialize params={}
6
+ @path = ENV['MSTEST_HOME'] || 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE'
7
+ @params = params
8
+ end
9
+
10
+ def command
11
+ testmetadata = "/testmetadata:\"#{@params[:testmetadata ]}\"" if @params[:testmetadata ]
12
+ testlist = "/testlist:\"#{@params[:testlist]}\"" if @params[:testlist]
13
+ resultsfile = "/resultsfile:\"#{@params[:resultsfile]}\"" if @params[:resultsfile]
14
+ "\"#{@path}\\mstest.exe\" #{testmetadata} #{testlist} #{resultsfile}"
15
+ end
16
+ end
17
+
18
+ def mstest_command params={}
19
+ MSTestCmd.new(params).execute
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ require 'nbuild/cmd'
2
+
3
+ module Nbuild
4
+ class NCacheCmd < Cmd
5
+ def initialize params={}
6
+ @path = 'C:\Program Files\NCache\bin\tools'
7
+ @params = params
8
+ end
9
+
10
+ def command
11
+ cmd = @params[:stop] ? 'stopcache' : 'startcache'
12
+ cache = @params[:cache]
13
+ "\"#{@path}\\#{cmd}\" #{cache}"
14
+ end
15
+ end
16
+
17
+ def ncache params={}
18
+ NCacheCmd.new(params).execute
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ require 'nbuild/cmd'
2
+
3
+ module Nbuild
4
+ class NCoverCmd < Cmd
5
+ def initialize params={}
6
+ @path = 'C:\Program Files\NCover'
7
+ @params = params
8
+ end
9
+
10
+ def command
11
+ "\"#{@path}\\ncover.console.exe\" //h CoverageReport //pm vstesthost.exe #{@params[:cmd].command}"
12
+ end
13
+ end
14
+
15
+ def NCoverCmd params={}
16
+ NCoverCmd.new(params).execute
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ require 'nbuild/cmd'
2
+
3
+ module Nbuild
4
+ class NDependCmd < Cmd
5
+ def initialize params={}
6
+ raise 'please create an environment variable NDEPEND_PATH to specify the location of your ndpend installation' unless ENV['NDEPEND_PATH']
7
+ @path = ENV['NDEPEND_PATH']
8
+ @params = params
9
+ end
10
+
11
+ def command
12
+ "\"#{@path}\\NDepend.Console.exe\" \"#{@params[:project]}\""
13
+ end
14
+ end
15
+
16
+ def NDependCmd params={}
17
+ NDependCmd.new(params).execute
18
+ end
19
+ end
data/lib/nbuild/tf.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'ostruct'
2
+
3
+ module Nbuild
4
+ class TFS
5
+ def initialize
6
+ @dir = 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE'
7
+ end
8
+
9
+ def repository_info
10
+ repo = OpenStruct.new
11
+ lines = tf('workfold .')
12
+ ignore, repo.workspace_name, repo.workspace_owner = lines[1].split
13
+ repo.workspace_owner = repo.workspace_owner.slice(1..-2)
14
+ ignore, repo.server_host = lines[2].split(':').map{|s|s.strip}
15
+ repo.server_path, repo.local_path = lines[3].split(': ').map{|s|s.strip}
16
+ repo
17
+ end
18
+
19
+ def label params
20
+ info = repository_info
21
+ tf("label \"#{params[:name]}\" . /version:\"W#{info.workspace_name};#{info.workspace_owner}\" /comment:\"#{params[:comment]}\" /recursive")
22
+ end
23
+ private
24
+ def tf command
25
+ lines = []
26
+ `\"#{@dir}\\tf.exe\" #{command} 2>&1`.each_line {|l| lines << l.chomp }
27
+ lines
28
+ end
29
+ end
30
+ end
data/lib/nbuild.rb ADDED
@@ -0,0 +1 @@
1
+ Dir.glob(File.dirname(__FILE__)+'/nbuild/*.rb').each {|child| require child[0..-4]}
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nbuild
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark Ryall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-23 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: |
17
+ Some helper classes for creating .net builds
18
+
19
+ email: mark@ryall.name
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - lib/nbuild/cmd.rb
28
+ - lib/nbuild/file_filter.rb
29
+ - lib/nbuild/install_util_cmd.rb
30
+ - lib/nbuild/msbuild_cmd.rb
31
+ - lib/nbuild/mstest_cmd.rb
32
+ - lib/nbuild/ncache_cmd.rb
33
+ - lib/nbuild/ncover_cmd.rb
34
+ - lib/nbuild/ndepend_cmd.rb
35
+ - lib/nbuild/tf.rb
36
+ - lib/nbuild.rb
37
+ - README
38
+ - MIT-LICENSE
39
+ has_rdoc: true
40
+ homepage: http://bitbucket.org/markryall/nbuild/
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.5
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: miscellaneous helpers for creating .net builds
67
+ test_files: []
68
+