rakedotnet 1.1.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/TODO-publish.rb +2 -0
- data/lib/TODO-settingsfiles.rb +11 -0
- data/lib/base_config.rb +83 -0
- data/lib/basetask.rb +70 -0
- data/lib/bcp.rb +136 -0
- data/lib/config.rb +25 -0
- data/lib/database.rb +59 -0
- data/lib/dotframeworksymbolhelp.rb +8 -0
- data/lib/iis.rb +37 -0
- data/lib/jstest.rb +98 -0
- data/lib/minifyjs.rb +41 -0
- data/lib/msbuild.rb +101 -0
- data/lib/mstest.rb +35 -0
- data/lib/nunit.rb +102 -0
- data/lib/registry_accessor.rb +38 -0
- data/lib/sqlcmd.rb +195 -0
- data/lib/tools.rb +3 -0
- data/lib/windowspaths.rb +28 -0
- data/spec/base.rb +32 -0
- data/spec/basetask_spec.rb +66 -0
- data/spec/basetaskmocking.rb +44 -0
- data/spec/bcp_spec.rb +137 -0
- data/spec/config_spec.rb +43 -0
- data/spec/config_testdata/defaultpartialuser_default.rb +17 -0
- data/spec/config_testdata/defaultpartialuser_user.rb +9 -0
- data/spec/config_testdata/local_properties.rb +13 -0
- data/spec/config_testdata/local_properties_default.rb +15 -0
- data/spec/config_testdata/onlydefault.rb +17 -0
- data/spec/db_spec.rb +88 -0
- data/spec/iis_spec.rb +49 -0
- data/spec/jstest_spec.rb +114 -0
- data/spec/minifyjs_spec.rb +27 -0
- data/spec/msbuild_spec.rb +127 -0
- data/spec/mstest_spec.rb +25 -0
- data/spec/nunit_spec.rb +118 -0
- data/spec/registry_accessor_spec.rb +31 -0
- data/spec/sqlcmd_spec.rb +323 -0
- data/spec/windowspaths_spec.rb +39 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZTBkMjg0MzBiZjBlOGU0NjY0ZTUxM2I3NDJjZTBiMDI5YTA5NGZjNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDA3OGUzOGM4ZTU5Y2ZmMGZhNzVhMjM5MjIzMjBjMWE5ZjQyYmViMQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTcwYzVjNzFmODkwNDc2ZjEwMzJlODhlOWYwOGY3MjZjODc3NjJjMGRjYjEz
|
10
|
+
YWJmM2QwOGM2YjRjZGI0Y2VjMzNhMGVjZmUzNDVkYmRlOWUyZmM0Mjc4OTQ2
|
11
|
+
MTc4NTY5ODlmNzFlOTQ5MTlhZjFkNTdlOTI3NjdmM2I0YTEyYTc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDgxYjBlZWQ1M2NmNWEzOWNkM2VlZGNiM2M1ZDZhNjU2ZGVhOGE1ZTlhYzEw
|
14
|
+
YTMxNTgwOWI3YzFkMDFkNTc4NDFiZDdlNmFmYTRjMzMzYWU0Zjg1OTMxN2Fi
|
15
|
+
ZjgwZDIwMGE5N2U2MDhjM2E4NDA2MzM5OTQ3MTQ3MTRkMTg3MzU=
|
data/lib/TODO-publish.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# .NET has the various settings stuff going on (app settings you can manually include and access via Configuration.AppSettings
|
2
|
+
# and also the autogenerated .settings files.
|
3
|
+
|
4
|
+
# using .net adapters, the .settings file will be necessary.
|
5
|
+
|
6
|
+
# with a web project, regardless of what's in the backend projects, ultimately when it's running, it's the settings hanging off
|
7
|
+
# the web project that will be used
|
8
|
+
|
9
|
+
# nonetheless on a development machine, it's good to keep the .settings files that end up with DB connection strings in them
|
10
|
+
# out of version control and instead version templates. then, using the actual developer's DB connection string, create
|
11
|
+
# those files so they can work with the DB in Visual Studio
|
data/lib/base_config.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
module BradyW
|
2
|
+
class BaseConfig
|
3
|
+
def self.subclasses
|
4
|
+
ObjectSpace.each_object(Class).select { |k| k.ancestors.include?(self) and (k != self) }
|
5
|
+
.sort_by { |k| k.name }
|
6
|
+
end
|
7
|
+
|
8
|
+
def project_prefix
|
9
|
+
"BSW"
|
10
|
+
end
|
11
|
+
|
12
|
+
def db_hostname
|
13
|
+
"localhost\\sqlexpress"
|
14
|
+
end
|
15
|
+
|
16
|
+
def db_name
|
17
|
+
"@prefix@-@thismachinehostname@"
|
18
|
+
end
|
19
|
+
|
20
|
+
def db_object_creation_authmode
|
21
|
+
:winauth
|
22
|
+
end
|
23
|
+
|
24
|
+
def db_object_creation_user
|
25
|
+
"user"
|
26
|
+
end
|
27
|
+
|
28
|
+
def db_object_creation_password
|
29
|
+
"password"
|
30
|
+
end
|
31
|
+
|
32
|
+
# winauth or sqlauth
|
33
|
+
def db_general_authmode
|
34
|
+
:sqlauth
|
35
|
+
end
|
36
|
+
|
37
|
+
def db_general_user
|
38
|
+
db_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def db_general_password
|
42
|
+
"password"
|
43
|
+
end
|
44
|
+
|
45
|
+
def db_system_authmode
|
46
|
+
:winauth
|
47
|
+
end
|
48
|
+
|
49
|
+
def db_system_user
|
50
|
+
"user"
|
51
|
+
end
|
52
|
+
|
53
|
+
def db_system_password
|
54
|
+
"password"
|
55
|
+
end
|
56
|
+
|
57
|
+
def db_system_datadir
|
58
|
+
"D:/sqlserverdata"
|
59
|
+
end
|
60
|
+
|
61
|
+
def db_connect_string_winauth
|
62
|
+
"Data Source=@host@;Initial Catalog=@initialcatalog@;Persist Security Info=True;Min Pool Size=20;Max Pool Size=500;Connection Timeout=15;Trusted_Connection=Yes"
|
63
|
+
end
|
64
|
+
|
65
|
+
def db_connect_string_sqlauth
|
66
|
+
"Data Source=@host@;Initial Catalog=@initialcatalog@;Persist Security Info=True;User ID=@user@;Password=@password@;Min Pool Size=20;Max Pool Size=500;Connection Timeout=15;"
|
67
|
+
end
|
68
|
+
|
69
|
+
def build_type
|
70
|
+
:Debug
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_javascript_port
|
74
|
+
9876
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_javascript_browsers
|
78
|
+
["D:/Program Files/Mozilla Firefox/firefox.exe",
|
79
|
+
"C:/Users/brady/AppData/Local/Google/Chrome/Application/chrome.exe"]
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
data/lib/basetask.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
module BradyW
|
5
|
+
|
6
|
+
# Used to abstract some of the functionality of building custom tasks in Rake out
|
7
|
+
# and also provide a convenient point to mock them for testing purposes
|
8
|
+
class BaseTask < Rake::TaskLib
|
9
|
+
attr_accessor :name, :unless
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
# Validates whether value is in the allowed list and raises an exception, using name
|
14
|
+
# as documentation, if it does not
|
15
|
+
def self.validate(value, name, allowed)
|
16
|
+
if !allowed.include? value
|
17
|
+
symbols = allowed.collect { |sym| ":#{sym}" }
|
18
|
+
formatted = symbols.join(", ")
|
19
|
+
raise "Invalid #{name} value! Allowed values: #{formatted}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(parameters = :task)
|
24
|
+
parseParams parameters
|
25
|
+
yield self if block_given?
|
26
|
+
task @name => @dependencies if @dependencies unless @unless
|
27
|
+
define
|
28
|
+
end
|
29
|
+
|
30
|
+
# Setup here for mocking purposes and also to stop verbose messages from ending up
|
31
|
+
# in stderr and causing CruiseControl.net to display errors
|
32
|
+
def shell(*cmd, &block)
|
33
|
+
options = (Hash === cmd.last) ? cmd.pop : {}
|
34
|
+
options[:verbose] = false
|
35
|
+
command = cmd.first
|
36
|
+
puts "Running #{command} via Rake sh"
|
37
|
+
sh command, options, &block
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def parseParams parameters
|
43
|
+
@name = case parameters
|
44
|
+
when Hash
|
45
|
+
n = parameters.keys[0]
|
46
|
+
@dependencies = parameters[n]
|
47
|
+
n
|
48
|
+
else
|
49
|
+
parameters
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Create the tasks defined by this task lib.
|
54
|
+
def define
|
55
|
+
task name do
|
56
|
+
if not @unless
|
57
|
+
log "Running task: #{@name}"
|
58
|
+
exectask
|
59
|
+
else
|
60
|
+
log "Skipping task: #{@name} due to unless condition specified in rakefile"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def log text
|
67
|
+
puts text
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/bcp.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'basetask'
|
2
|
+
require 'windowspaths'
|
3
|
+
require 'database'
|
4
|
+
require 'csv'
|
5
|
+
|
6
|
+
module BradyW
|
7
|
+
=begin rdoc
|
8
|
+
Supports using Microsoft BCP to load CSV data. Unlike BCP out of the box, this task attempts
|
9
|
+
to "support" comma escaping by converting your CSV files to files with an odd delimiter before
|
10
|
+
loading them in with BCP.
|
11
|
+
=end
|
12
|
+
class BCP < BaseTask
|
13
|
+
|
14
|
+
# *Optional* If the delimiter exists in your code (the task will fail if it does),
|
15
|
+
# you need to change this attribute.
|
16
|
+
attr_accessor :delimiter
|
17
|
+
|
18
|
+
# *Required* Supply the files you wish to load into your tables here. They should be named
|
19
|
+
# using the following pattern SEQUENCE-TABLENAME.csv
|
20
|
+
# Example:
|
21
|
+
# 01-users.csv
|
22
|
+
# 02-accounts.csv
|
23
|
+
#
|
24
|
+
# OR
|
25
|
+
# 001-users.csv
|
26
|
+
# 002-accounts.csv
|
27
|
+
|
28
|
+
attr_accessor :files
|
29
|
+
|
30
|
+
# *Optional* By default, this looks for your installed version of BCP with SQL Server 2008.
|
31
|
+
# If you're using SQL Server 2005, set this to "90"
|
32
|
+
attr_accessor :version
|
33
|
+
|
34
|
+
# *Optional* If this is set to true, then BCP's "-E" command line argument will be used. If you
|
35
|
+
# have primary keys in your files you wish to preserve, set this to true. Default is false.
|
36
|
+
attr_accessor :identity_inserts
|
37
|
+
|
38
|
+
include WindowsPaths
|
39
|
+
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def initialize (parameters = :task)
|
44
|
+
super parameters
|
45
|
+
@dbprops = Database.new
|
46
|
+
@config = BradyW::Config.instance.values
|
47
|
+
tmpDir = ENV['TMP'] || '/tmp'
|
48
|
+
@tmp = "#{tmpDir}/bcp"
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_temp
|
52
|
+
rm_safe @tmp
|
53
|
+
mkdir @tmp
|
54
|
+
end
|
55
|
+
|
56
|
+
def exectask
|
57
|
+
create_temp
|
58
|
+
puts "Using #{@tmp} as a temp directory"
|
59
|
+
|
60
|
+
files.each do |csv|
|
61
|
+
currentdir = pwd
|
62
|
+
fileName = File.basename csv
|
63
|
+
csvtoCustomDelim csv, "#{@tmp}/#{fileName}"
|
64
|
+
cd @tmp
|
65
|
+
# need to trim off both the extension and the leading 2 numbers/hyphen
|
66
|
+
sequenceAndTable = File.basename(csv, ".csv")
|
67
|
+
tableName = sequenceAndTable.match(/\d+-(.*)/)[1]
|
68
|
+
args = "\"#{prefix}#{tableName}\" in #{fileName} #{connect_string} -t \"#{delimiter}\" /c #{identity_inserts}-m 1 -F 2"
|
69
|
+
|
70
|
+
shell "\"#{path}bcp.exe\" #{args}" do |ok,status|
|
71
|
+
if !ok
|
72
|
+
cd currentdir
|
73
|
+
# We want to clean up our temp files if we fail
|
74
|
+
rm_safe @tmp
|
75
|
+
fail "Command failed with status (#{status.exitstatus}):"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
cd currentdir
|
80
|
+
end
|
81
|
+
rm_safe @tmp
|
82
|
+
end
|
83
|
+
|
84
|
+
def csvtoCustomDelim(oldfile, newfile)
|
85
|
+
File.open(newfile, "a") do |file|
|
86
|
+
CSV.foreach(oldfile) do |row|
|
87
|
+
d = delimiter
|
88
|
+
row.each { |f| if f.include? d
|
89
|
+
puts "Your data contains the crazy delimiter that's currently configured, which is "
|
90
|
+
puts "#{d} "
|
91
|
+
puts " (the default one) " unless !d
|
92
|
+
puts "Pass in the 'delimiter' attribute from your rakefile with a different random value."
|
93
|
+
puts "Hopefully then it will not exist in your data and can be used with bcp to import"
|
94
|
+
puts "data into the database."
|
95
|
+
fail
|
96
|
+
end}
|
97
|
+
newRow = row.join(d)
|
98
|
+
file.puts newRow
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def path
|
104
|
+
p = @version || "100"
|
105
|
+
sql_tool p
|
106
|
+
end
|
107
|
+
|
108
|
+
def delimiter
|
109
|
+
@delimiter || "|d3l1m1t3r|"
|
110
|
+
end
|
111
|
+
|
112
|
+
# BCP doesn't allow initial catalogs for SQL auth, but does for winauth and we need them
|
113
|
+
# since winauth users might use several schemas
|
114
|
+
def prefix
|
115
|
+
if @config.db_general_authmode == :winauth
|
116
|
+
"%s.dbo." % [@dbprops.name]
|
117
|
+
else
|
118
|
+
""
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def identity_inserts
|
123
|
+
@identity_inserts ? "-E " : ""
|
124
|
+
end
|
125
|
+
|
126
|
+
def connect_string
|
127
|
+
if @config.db_general_authmode == :winauth
|
128
|
+
"-T -S %s" % [@dbprops.host]
|
129
|
+
else
|
130
|
+
"-U %s -P %s /S%s" % [@dbprops.user,
|
131
|
+
@dbprops.password,
|
132
|
+
@dbprops.host]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/lib/config.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "base_config"
|
2
|
+
require "singleton"
|
3
|
+
|
4
|
+
module BradyW
|
5
|
+
# Using the bwbuildconfig GEM, does a singleton fetch of properties from the YAML config files
|
6
|
+
class Config
|
7
|
+
include Singleton
|
8
|
+
attr_accessor :values
|
9
|
+
|
10
|
+
def initialize(defaultfile = "local_properties_default.rb",
|
11
|
+
userfile = "local_properties.rb")
|
12
|
+
puts "Using props file #{defaultfile} for default values"
|
13
|
+
require defaultfile
|
14
|
+
begin
|
15
|
+
puts "Attempting to use props file #{userfile} for user/environment values"
|
16
|
+
require userfile
|
17
|
+
rescue LoadError
|
18
|
+
puts "No user config file available"
|
19
|
+
end
|
20
|
+
configclass = BaseConfig.subclasses[-1]
|
21
|
+
puts "Using configuration class: #{configclass.name}"
|
22
|
+
@values = configclass.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/database.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'config'
|
3
|
+
|
4
|
+
module BradyW
|
5
|
+
# TODO: Merge this in with Base_Config
|
6
|
+
# Retrieves database related settings from our YAML configuration files
|
7
|
+
class Database
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@config = Config.instance.values
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def prefix
|
16
|
+
@config.project_prefix
|
17
|
+
end
|
18
|
+
|
19
|
+
public
|
20
|
+
|
21
|
+
CREDENTIALS = [:system, :objectcreation, :general]
|
22
|
+
|
23
|
+
# The hostname where the database lives (db: => hostname:)
|
24
|
+
def host
|
25
|
+
@config.db_hostname
|
26
|
+
end
|
27
|
+
|
28
|
+
# The name of the database/catalog (db: => name:)
|
29
|
+
def name
|
30
|
+
@config.db_name.gsub(/@thismachinehostname@/, Socket.gethostname).
|
31
|
+
gsub(/@prefix@/, prefix)
|
32
|
+
end
|
33
|
+
|
34
|
+
# General user's username
|
35
|
+
def user
|
36
|
+
@config.db_general_user.gsub(/@thismachinehostname@/, Socket.gethostname).
|
37
|
+
gsub(/@prefix@/, prefix)
|
38
|
+
end
|
39
|
+
|
40
|
+
# General user's password
|
41
|
+
def password
|
42
|
+
@config.db_general_password
|
43
|
+
end
|
44
|
+
|
45
|
+
# Using the template in the YAML files, produces a .NET connect string
|
46
|
+
def connect_code
|
47
|
+
if @config.db_general_authmode == :winauth
|
48
|
+
@config.db_connect_string_winauth.gsub(/@host@/, host).
|
49
|
+
gsub(/@initialcatalog@/, name)
|
50
|
+
else
|
51
|
+
@config.db_connect_string_sqlauth.gsub(/@host@/, host).
|
52
|
+
gsub(/@initialcatalog@/, name).
|
53
|
+
gsub(/@user@/, user).
|
54
|
+
gsub(/@password@/, @config.db_general_password)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/lib/iis.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'basetask'
|
2
|
+
|
3
|
+
module BradyW
|
4
|
+
|
5
|
+
# A task for starting/stopping IIS. The task will not fail if the service cannot be stopped
|
6
|
+
# successfully to avoid failing the build if IIS is already running.
|
7
|
+
class IIS < BaseTask
|
8
|
+
|
9
|
+
# *Required* Command to execute, should be either :start or :stop
|
10
|
+
attr_accessor :command
|
11
|
+
|
12
|
+
# *Optional* Service to bounce, by default W3SVC will be bounced.
|
13
|
+
attr_accessor :service
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# Create the tasks defined by this task lib.
|
18
|
+
def exectask
|
19
|
+
raise "You forgot to supply a service command (:start, :stop)" unless @command
|
20
|
+
puts "Starting/Stopping IIS Service"
|
21
|
+
cmd = "net.exe #{@command} #{service}"
|
22
|
+
shell cmd do |ok,status|
|
23
|
+
ok or
|
24
|
+
if @command == :stop
|
25
|
+
puts "Ignoring failure since we're stopping"
|
26
|
+
ok
|
27
|
+
else
|
28
|
+
fail "Command failed with status (#{status.exitstatus}):"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def service
|
34
|
+
@service || "W3SVC"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|