iron_hammer 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/PostInstall.txt +5 -0
- data/README.rdoc +64 -0
- data/Rakefile +22 -0
- data/lib/iron_hammer.rb +44 -0
- data/lib/iron_hammer/anvil.rb +46 -0
- data/lib/iron_hammer/default_binaries_behavior.rb +18 -0
- data/lib/iron_hammer/default_configuration_behavior.rb +12 -0
- data/lib/iron_hammer/default_deliverables_behavior.rb +7 -0
- data/lib/iron_hammer/deliverables/configuration_file.rb +25 -0
- data/lib/iron_hammer/deliverables/deliverable.rb +30 -0
- data/lib/iron_hammer/hammer.rb +39 -0
- data/lib/iron_hammer/package.rb +34 -0
- data/lib/iron_hammer/projects/asp_net_mvc_project.rb +8 -0
- data/lib/iron_hammer/projects/asp_net_project.rb +12 -0
- data/lib/iron_hammer/projects/dll_project.rb +22 -0
- data/lib/iron_hammer/projects/generic_project.rb +39 -0
- data/lib/iron_hammer/projects/project_file.rb +40 -0
- data/lib/iron_hammer/projects/project_types.rb +26 -0
- data/lib/iron_hammer/projects/test_project.rb +28 -0
- data/lib/iron_hammer/solutions/solution.rb +19 -0
- data/lib/iron_hammer/solutions/solution_file.rb +31 -0
- data/lib/iron_hammer/tasks.rb +27 -0
- data/lib/iron_hammer/utils/dot_net_environment.rb +42 -0
- data/lib/iron_hammer/utils/file_system.rb +37 -0
- data/lib/iron_hammer/utils/windows.rb +24 -0
- data/lib/iron_hammer/utils/zipper.rb +13 -0
- data/lib/iron_hammer/version.rb +37 -0
- metadata +127 -0
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
= iron-hammer
|
|
2
|
+
|
|
3
|
+
* http://github.com/MACSkeptic/Iron-Hammer
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
It consists (or at least it will, when its done) of three main components: an Anvil, a Hammer, and a Blacksmith.
|
|
8
|
+
|
|
9
|
+
# Anvil
|
|
10
|
+
Parse the contents of a directory, loading information about projects and solutions contained there
|
|
11
|
+
|
|
12
|
+
# Hammer
|
|
13
|
+
Provides command lines for building and running tests
|
|
14
|
+
|
|
15
|
+
# Blacksmith
|
|
16
|
+
The "intelligent" part of the mix, provides a DSL for utilizing the tools described above.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
I might add more components to the mix if deemed necessary, like something to take care of the deployment process
|
|
20
|
+
|
|
21
|
+
== FEATURES/PROBLEMS:
|
|
22
|
+
|
|
23
|
+
TODO (list of features or problems)
|
|
24
|
+
|
|
25
|
+
== SYNOPSIS:
|
|
26
|
+
|
|
27
|
+
TODO (code sample of usage)
|
|
28
|
+
|
|
29
|
+
== REQUIREMENTS:
|
|
30
|
+
|
|
31
|
+
TODO (list of requirements)
|
|
32
|
+
|
|
33
|
+
== INSTALL:
|
|
34
|
+
|
|
35
|
+
TODO (sudo gem install, anything else)
|
|
36
|
+
|
|
37
|
+
== LICENSE:
|
|
38
|
+
|
|
39
|
+
(The MIT License)
|
|
40
|
+
|
|
41
|
+
MACSkeptic Iron-Hammer
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2010 Mozair Alves do Carmo Junior, http://codevil.com/
|
|
44
|
+
|
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
46
|
+
a copy of this software and associated documentation files (the
|
|
47
|
+
"Software"), to deal in the Software without restriction, including
|
|
48
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
49
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
50
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
51
|
+
the following conditions:
|
|
52
|
+
|
|
53
|
+
The above copyright notice and this permission notice shall be
|
|
54
|
+
included in all copies or substantial portions of the Software.
|
|
55
|
+
|
|
56
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
57
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
58
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
59
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
60
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
61
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
62
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
63
|
+
|
|
64
|
+
Date: 2010-01-16 18:11:01 -0300 (Sat, 18 Jan 2010)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
|
3
|
+
require 'hoe'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require './lib/iron_hammer'
|
|
6
|
+
|
|
7
|
+
Hoe.plugin :newgem
|
|
8
|
+
|
|
9
|
+
$hoe = Hoe.spec 'iron_hammer' do
|
|
10
|
+
self.developer 'Mozair Alves do Carmo Junior', 'macskeptic@gmail.com'
|
|
11
|
+
self.post_install_message = File.read('PostInstall.txt')
|
|
12
|
+
self.rubyforge_name = self.name
|
|
13
|
+
self.extra_deps = [['rubyzip2','>= 0.9.2']]
|
|
14
|
+
self.version = '0.3.2'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
require 'newgem/tasks'
|
|
18
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
|
19
|
+
|
|
20
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
|
21
|
+
# remove_task :default
|
|
22
|
+
# task :default => [:spec, :features]
|
data/lib/iron_hammer.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
3
|
+
|
|
4
|
+
module IronHammer
|
|
5
|
+
VERSION = '0.3.1'
|
|
6
|
+
|
|
7
|
+
module Defaults
|
|
8
|
+
CONFIGURATION_RUN = 'Release'
|
|
9
|
+
DELIVERY_DIRECTORY = 'delivery'
|
|
10
|
+
TEST_CONFIG = 'LocalTestRun.testrunconfig'
|
|
11
|
+
ENVIRONMENT = 'local'
|
|
12
|
+
SYSTEM_ROOT = 'c:\\Windows'
|
|
13
|
+
PROGRAM_FILES = 'c:\\Program Files'
|
|
14
|
+
end unless defined? IronHammer::Defaults
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
require 'iron_hammer/anvil'
|
|
18
|
+
require 'iron_hammer/default_binaries_behavior'
|
|
19
|
+
require 'iron_hammer/default_configuration_behavior'
|
|
20
|
+
require 'iron_hammer/default_deliverables_behavior'
|
|
21
|
+
require 'iron_hammer/deliverables/configuration_file'
|
|
22
|
+
require 'iron_hammer/deliverables/deliverable'
|
|
23
|
+
require 'iron_hammer/hammer'
|
|
24
|
+
require 'iron_hammer/package'
|
|
25
|
+
require 'iron_hammer/projects/asp_net_mvc_project'
|
|
26
|
+
require 'iron_hammer/projects/asp_net_project'
|
|
27
|
+
require 'iron_hammer/projects/dll_project'
|
|
28
|
+
require 'iron_hammer/projects/generic_project'
|
|
29
|
+
require 'iron_hammer/projects/project_file'
|
|
30
|
+
require 'iron_hammer/projects/project_types'
|
|
31
|
+
require 'iron_hammer/projects/test_project'
|
|
32
|
+
require 'iron_hammer/solutions/solution'
|
|
33
|
+
require 'iron_hammer/solutions/solution_file'
|
|
34
|
+
require 'iron_hammer/utils/dot_net_environment'
|
|
35
|
+
require 'iron_hammer/utils/file_system'
|
|
36
|
+
require 'iron_hammer/utils/windows'
|
|
37
|
+
require 'iron_hammer/utils/zipper'
|
|
38
|
+
require 'iron_hammer/version'
|
|
39
|
+
|
|
40
|
+
include IronHammer
|
|
41
|
+
include IronHammer::Projects
|
|
42
|
+
include IronHammer::Solutions
|
|
43
|
+
include IronHammer::Utils
|
|
44
|
+
include IronHammer::Deliverables
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'iron_hammer/solutions/solution'
|
|
2
|
+
require 'iron_hammer/projects/project_file'
|
|
3
|
+
require 'iron_hammer/solutions/solution_file'
|
|
4
|
+
|
|
5
|
+
module IronHammer
|
|
6
|
+
class Anvil
|
|
7
|
+
attr_accessor :solution
|
|
8
|
+
attr_accessor :projects
|
|
9
|
+
|
|
10
|
+
def initialize params={}
|
|
11
|
+
@solution = params[:solution]
|
|
12
|
+
@projects = params[:projects]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def load_projects_from_solution
|
|
16
|
+
@projects = @projects || []
|
|
17
|
+
@solution.file.projects.each do |p|
|
|
18
|
+
@projects << IronHammer::Projects::ProjectFile.type_of(
|
|
19
|
+
@solution.path,
|
|
20
|
+
path = p[:path],
|
|
21
|
+
csproj = p[:csproj]).
|
|
22
|
+
send(:new, p)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.load_solution_from *path
|
|
27
|
+
pattern = File.join path, '*.sln'
|
|
28
|
+
entries = Dir[pattern]
|
|
29
|
+
anvil = Anvil.new(
|
|
30
|
+
:solution => IronHammer::Solutions::Solution.new(
|
|
31
|
+
:name => entries.first.split('/').pop.sub('.sln', ''),
|
|
32
|
+
:file => IronHammer::Solutions::SolutionFile.parse_file(entries.first),
|
|
33
|
+
:path => File.join(*path)
|
|
34
|
+
)
|
|
35
|
+
) unless entries.nil? || entries.empty?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def dll_projects
|
|
39
|
+
@projects.select {|p| p.is_a? DllProject}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_projects
|
|
43
|
+
@projects.select {|p| p.is_a? TestProject}
|
|
44
|
+
end
|
|
45
|
+
end unless defined? Anvil
|
|
46
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'iron_hammer/deliverables/deliverable'
|
|
2
|
+
|
|
3
|
+
module IronHammer
|
|
4
|
+
module DefaultBinariesBehavior
|
|
5
|
+
BIN_PATTERN = '*.{dll,exe}'
|
|
6
|
+
|
|
7
|
+
def binaries params={}
|
|
8
|
+
path = path_to_binaries(params)
|
|
9
|
+
Dir[File.join(path, BIN_PATTERN)].collect do |file|
|
|
10
|
+
IronHammer::Deliverables::Deliverable.new(
|
|
11
|
+
:path_on_package => '',
|
|
12
|
+
:actual_path => path,
|
|
13
|
+
:actual_name => file.split('/').last
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end unless defined? DefaultBinariesBehavior
|
|
18
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'iron_hammer/deliverables/configuration_file'
|
|
2
|
+
|
|
3
|
+
module IronHammer
|
|
4
|
+
module DefaultConfigurationBehavior
|
|
5
|
+
def configuration environment
|
|
6
|
+
conf = IronHammer::Deliverables::ConfigurationFile::list :path => path_to_configuration, :environment => environment
|
|
7
|
+
secondary_configuration = IronHammer::Deliverables::ConfigurationFile::list :path => path_to_configuration
|
|
8
|
+
secondary_configuration.each {|c| conf << c unless conf.find {|prior| prior.name_on_package == c.name_on_package }}
|
|
9
|
+
conf
|
|
10
|
+
end
|
|
11
|
+
end unless defined? DefaultConfigurationBehavior
|
|
12
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'iron_hammer/deliverables/deliverable'
|
|
2
|
+
|
|
3
|
+
module IronHammer
|
|
4
|
+
module Deliverables
|
|
5
|
+
class ConfigurationFile
|
|
6
|
+
PATTERN = '*.{config,config.xml}'
|
|
7
|
+
|
|
8
|
+
def self.list params={}
|
|
9
|
+
path = params[:path] || raise(ArgumentError.new('must inform a path'))
|
|
10
|
+
environment = params[:environment]
|
|
11
|
+
suffix = environment ? ('.' + environment) : ''
|
|
12
|
+
pattern = PATTERN + suffix
|
|
13
|
+
|
|
14
|
+
Dir[File.join(path, pattern)].collect do |file|
|
|
15
|
+
Deliverable.new(
|
|
16
|
+
:path_on_package => '',
|
|
17
|
+
:actual_path => path,
|
|
18
|
+
:actual_name => original_name = file.split('/').last,
|
|
19
|
+
:name_on_package => original_name.sub(suffix, '')
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end unless defined? ConfigurationFile
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module IronHammer
|
|
2
|
+
module Deliverables
|
|
3
|
+
class Deliverable
|
|
4
|
+
attr_accessor :actual_path
|
|
5
|
+
attr_accessor :actual_name
|
|
6
|
+
attr_accessor :path_on_package
|
|
7
|
+
attr_accessor :name_on_package
|
|
8
|
+
|
|
9
|
+
def initialize params={}
|
|
10
|
+
@actual_path = params[:actual_path] || raise(ArgumentError.new 'must provide an actual_path')
|
|
11
|
+
@actual_name = params[:actual_name] || raise(ArgumentError.new 'must provide an actual_name')
|
|
12
|
+
@path_on_package = params[:path_on_package] || @actual_path
|
|
13
|
+
@name_on_package = params[:name_on_package] || @actual_name
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.create actual_path, actual_name, path_on_package=''
|
|
17
|
+
Deliverable.new :actual_path => actual_path, :actual_name => actual_name, :path_on_package => path_on_package
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def == other
|
|
21
|
+
other.class == Deliverable &&
|
|
22
|
+
instance_variables.inject(true) { |x, current| x && (send(prop = current.to_s.sub('@','')) == other.send(prop)) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def eql? other
|
|
26
|
+
self == other
|
|
27
|
+
end
|
|
28
|
+
end unless defined? Deliverable
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'iron_hammer/utils/windows'
|
|
2
|
+
require 'iron_hammer/projects/test_project'
|
|
3
|
+
require 'iron_hammer/solutions/solution'
|
|
4
|
+
require 'iron_hammer/utils/dot_net_environment'
|
|
5
|
+
|
|
6
|
+
module IronHammer
|
|
7
|
+
class Hammer
|
|
8
|
+
attr_accessor :dot_net_environment
|
|
9
|
+
attr_accessor :configuration
|
|
10
|
+
|
|
11
|
+
def initialize params={}
|
|
12
|
+
@configuration = params[:configuration] || IronHammer::Defaults::CONFIGURATION_RUN
|
|
13
|
+
@dot_net_environment = IronHammer::Utils::DotNetEnvironment.new params.merge(
|
|
14
|
+
:framework_path => params[:dot_net_path])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def details
|
|
18
|
+
['duration', 'errorstacktrace', 'errormessage', 'outcometext'].inject('') do |buffer, detail|
|
|
19
|
+
buffer << "/detail:#{detail} "
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def build solution
|
|
24
|
+
msbuild = @dot_net_environment.msbuild
|
|
25
|
+
configuration = @configuration
|
|
26
|
+
solution = solution.solution
|
|
27
|
+
"#{msbuild} /p:Configuration=#{configuration} #{solution} /t:Rebuild"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test *projects
|
|
31
|
+
containers = projects.collect{|project| "/testcontainer:#{project.container @configuration}"}
|
|
32
|
+
results = projects.first.results_file
|
|
33
|
+
mstest = @dot_net_environment.mstest
|
|
34
|
+
"#{mstest} #{containers.join ' '} /resultsfile:#{results} #{details}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end unless defined? Hammer
|
|
38
|
+
end
|
|
39
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'iron_hammer/utils/zipper'
|
|
2
|
+
require 'iron_hammer/utils/file_system'
|
|
3
|
+
|
|
4
|
+
module IronHammer
|
|
5
|
+
class Package
|
|
6
|
+
attr_accessor :root
|
|
7
|
+
attr_accessor :deliverables
|
|
8
|
+
|
|
9
|
+
def initialize params={}
|
|
10
|
+
@root = params[:root] || IronHammer::Defaults::DELIVERY_DIRECTORY
|
|
11
|
+
@deliverables = params[:deliverables]
|
|
12
|
+
raise(ArgumentError.new "must provide a list of deliverables") unless
|
|
13
|
+
@deliverables && !@deliverables.empty?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def pack!
|
|
17
|
+
organize_deliverables_for_packaging
|
|
18
|
+
self
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def zip! file='package.zip'
|
|
22
|
+
Dir.chdir(@root) { IronHammer::Utils::Zipper::zip_current_working_folder_into_this file }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
def organize_deliverables_for_packaging
|
|
27
|
+
@deliverables.each do |deliverable|
|
|
28
|
+
source = File.join deliverable.actual_path, deliverable.actual_name
|
|
29
|
+
destination = File.join @root, deliverable.path_on_package, deliverable.name_on_package
|
|
30
|
+
IronHammer::Utils::FileSystem::copy! source, destination
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end unless defined? Package
|
|
34
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'iron_hammer/projects/generic_project'
|
|
2
|
+
require 'iron_hammer/utils/windows'
|
|
3
|
+
|
|
4
|
+
module IronHammer
|
|
5
|
+
module Projects
|
|
6
|
+
class AspNetProject < GenericProject
|
|
7
|
+
def path_to_binaries
|
|
8
|
+
[@name, "bin"].patheticalize
|
|
9
|
+
end
|
|
10
|
+
end unless defined? AspNetProject
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'iron_hammer/projects/generic_project'
|
|
2
|
+
require 'iron_hammer/default_binaries_behavior'
|
|
3
|
+
require 'iron_hammer/default_configuration_behavior'
|
|
4
|
+
require 'iron_hammer/default_deliverables_behavior'
|
|
5
|
+
|
|
6
|
+
module IronHammer
|
|
7
|
+
module Projects
|
|
8
|
+
class DllProject < GenericProject
|
|
9
|
+
include IronHammer::DefaultBinariesBehavior
|
|
10
|
+
include IronHammer::DefaultConfigurationBehavior
|
|
11
|
+
include IronHammer::DefaultDeliverablesBehavior
|
|
12
|
+
|
|
13
|
+
def path_to_configuration
|
|
14
|
+
@path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def path_to_binaries params={}
|
|
18
|
+
File.join(@path, 'bin', run_configuration(params))
|
|
19
|
+
end
|
|
20
|
+
end unless defined? DllProject
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'iron_hammer/package'
|
|
2
|
+
|
|
3
|
+
module IronHammer
|
|
4
|
+
module Projects
|
|
5
|
+
class GenericProject
|
|
6
|
+
attr_accessor :name
|
|
7
|
+
attr_accessor :path
|
|
8
|
+
|
|
9
|
+
def initialize params={}
|
|
10
|
+
@name = params[:name] ||
|
|
11
|
+
raise(ArgumentError.new 'must provide a project name')
|
|
12
|
+
@path = params[:path] || @name
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def path_to_binaries params={}
|
|
16
|
+
''
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def deliverables params={}
|
|
20
|
+
[]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def package params={}
|
|
24
|
+
package_root(params)
|
|
25
|
+
Package.new :root => package_root, :deliverables => deliverables(params)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
protected
|
|
29
|
+
def package_root params={}
|
|
30
|
+
root = params[:root] || params[:target] || params[:package_root] || IronHammer::Defaults::DELIVERY_DIRECTORY
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def run_configuration params={}
|
|
34
|
+
configuration = params[:configuration]
|
|
35
|
+
config = (configuration && !configuration.empty? && configuration) || IronHammer::Defaults::CONFIGURATION_RUN
|
|
36
|
+
end
|
|
37
|
+
end unless defined? GenericProject
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'rexml/document'
|
|
2
|
+
require 'iron_hammer/projects/project_types'
|
|
3
|
+
require 'iron_hammer/projects/asp_net_project'
|
|
4
|
+
require 'iron_hammer/projects/asp_net_mvc_project'
|
|
5
|
+
require 'iron_hammer/projects/test_project'
|
|
6
|
+
require 'iron_hammer/projects/dll_project'
|
|
7
|
+
require 'iron_hammer/utils/file_system'
|
|
8
|
+
|
|
9
|
+
module IronHammer
|
|
10
|
+
module Projects
|
|
11
|
+
class ProjectFile
|
|
12
|
+
attr_accessor :type
|
|
13
|
+
|
|
14
|
+
GUID_EVALUATION_ORDER = [AspNetMvcProject, AspNetProject, TestProject]
|
|
15
|
+
GUID_PATH = '//Project/PropertyGroup/ProjectTypeGuids'
|
|
16
|
+
|
|
17
|
+
def initialize params={}
|
|
18
|
+
@type = params[:type] || DllProject
|
|
19
|
+
raise ArgumentError.new('type must be a Class') unless @type.class == Class
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.type_of *path
|
|
23
|
+
self.parse(IronHammer::Utils::FileSystem::read_file(*path)).type
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.parse xml
|
|
27
|
+
guids = guids_from xml
|
|
28
|
+
ProjectFile.new :type => ((GUID_EVALUATION_ORDER.inject(false) do |result, current|
|
|
29
|
+
result || (guids.include?(ProjectTypes::guid_for(current)) && current)
|
|
30
|
+
end) || DllProject)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.guids_from xml
|
|
34
|
+
doc = REXML::Document.new xml
|
|
35
|
+
elem = doc && doc.elements[GUID_PATH]
|
|
36
|
+
guids = ((elem && elem.text) || '').split(';').collect { |e| e.upcase }
|
|
37
|
+
end
|
|
38
|
+
end unless defined? ProjectFile
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'iron_hammer/projects/asp_net_project'
|
|
2
|
+
require 'iron_hammer/projects/asp_net_mvc_project'
|
|
3
|
+
require 'iron_hammer/projects/test_project'
|
|
4
|
+
require 'iron_hammer/projects/dll_project'
|
|
5
|
+
|
|
6
|
+
module IronHammer
|
|
7
|
+
module Projects
|
|
8
|
+
module ProjectTypes
|
|
9
|
+
GUIDS = {
|
|
10
|
+
TestProject => '{3AC096D0-A1C2-E12C-1390-A8335801FDAB}',
|
|
11
|
+
AspNetMvcProject => '{603C0E0B-DB56-11DC-BE95-000D561079B0}',
|
|
12
|
+
AspNetProject => '{349C5851-65DF-11DA-9384-00065B846F21}'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
TYPES = GUIDS.inject({}) { |buffer, tuple| buffer.merge(tuple.pop => tuple.first) }
|
|
16
|
+
|
|
17
|
+
def self.type_of guid
|
|
18
|
+
TYPES[guid.to_s.upcase]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.guid_for type
|
|
22
|
+
GUIDS[type]
|
|
23
|
+
end
|
|
24
|
+
end unless defined? ProjectTypes
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'iron_hammer/utils/windows'
|
|
2
|
+
require 'iron_hammer/projects/generic_project'
|
|
3
|
+
|
|
4
|
+
module IronHammer
|
|
5
|
+
module Projects
|
|
6
|
+
class TestProject < GenericProject
|
|
7
|
+
attr_accessor :config
|
|
8
|
+
attr_accessor :dll
|
|
9
|
+
attr_accessor :name
|
|
10
|
+
attr_accessor :path
|
|
11
|
+
|
|
12
|
+
def initialize params
|
|
13
|
+
@name = params[:name] || "#{ params[:project] || params[:solution] }.Tests"
|
|
14
|
+
@dll = "#{ params[:dll] || @name}.dll"
|
|
15
|
+
@config = params[:config] || IronHammer::Defaults::TEST_CONFIG
|
|
16
|
+
@path = params[:path]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def container configuration
|
|
20
|
+
[@name, 'bin', configuration, @dll].patheticalize
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def results_file
|
|
24
|
+
['TestResults', 'TestResults.trx'].patheticalize
|
|
25
|
+
end
|
|
26
|
+
end unless defined? TestProject
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module IronHammer
|
|
2
|
+
module Solutions
|
|
3
|
+
class Solution
|
|
4
|
+
attr_accessor :name
|
|
5
|
+
attr_accessor :file
|
|
6
|
+
attr_accessor :path
|
|
7
|
+
|
|
8
|
+
def initialize params
|
|
9
|
+
@name = params[:name] || raise(ArgumentError.new 'must provide a solution name')
|
|
10
|
+
@file = params[:file]
|
|
11
|
+
@path = params[:path]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def solution
|
|
15
|
+
"#{@name}.sln"
|
|
16
|
+
end
|
|
17
|
+
end unless defined? Solution
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'iron_hammer/utils/file_system'
|
|
2
|
+
|
|
3
|
+
module IronHammer
|
|
4
|
+
module Solutions
|
|
5
|
+
class SolutionFile
|
|
6
|
+
attr_accessor :projects
|
|
7
|
+
|
|
8
|
+
NAME_PATH_CSPROJ = /.* = \"(.+)\"\, \"(.+)\\(.+)\", .*/
|
|
9
|
+
STOP_TRIGGER = /^Global/
|
|
10
|
+
|
|
11
|
+
def initialize projects=[]
|
|
12
|
+
@projects = projects
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.parse lines
|
|
16
|
+
projects = []
|
|
17
|
+
lines.each do |line|
|
|
18
|
+
break if STOP_TRIGGER =~ line
|
|
19
|
+
line.scan(NAME_PATH_CSPROJ) do |name, path, csproj|
|
|
20
|
+
projects << { :name => name, :path => path, :csproj => csproj }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
SolutionFile.new projects
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.parse_file *path
|
|
27
|
+
self.parse IronHammer::Utils::FileSystem::read_lines(*path)
|
|
28
|
+
end
|
|
29
|
+
end unless defined? SolutionFile
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake/clean'
|
|
3
|
+
require 'iron_hammer'
|
|
4
|
+
|
|
5
|
+
CLEAN.include("TestResults/**")
|
|
6
|
+
|
|
7
|
+
namespace :iron do
|
|
8
|
+
task :initialize do
|
|
9
|
+
@anvil = Anvil.load_solution_from '.'
|
|
10
|
+
@anvil.load_projects_from_solution
|
|
11
|
+
@hammer = Hammer.new :visual_studio_path => VISUAL_STUDIO_PATH
|
|
12
|
+
FileUtils.mkdir 'TestResults' unless (File.exists?('TestResults') && File.directory?('TestResults'))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc 'Builds the solution'
|
|
16
|
+
task :build => [:clean, :initialize] do
|
|
17
|
+
sh @hammer.build @anvil.solution
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
namespace :test do
|
|
21
|
+
desc 'Runs the unit tests'
|
|
22
|
+
task :unit => [:build] do
|
|
23
|
+
sh @hammer.test *@anvil.test_projects
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'iron_hammer/utils/windows'
|
|
2
|
+
|
|
3
|
+
module IronHammer
|
|
4
|
+
module Utils
|
|
5
|
+
class DotNetEnvironment
|
|
6
|
+
attr_accessor :framework_path
|
|
7
|
+
attr_accessor :visual_studio_path
|
|
8
|
+
|
|
9
|
+
def initialize params={}
|
|
10
|
+
@framework_path = params[:framework_path] || default_framework_path
|
|
11
|
+
@visual_studio_path = params[:visual_studio_path] || default_visual_studio_path
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def msbuild
|
|
15
|
+
[@framework_path, 'msbuild.exe'].patheticalize
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def mstest
|
|
19
|
+
[@visual_studio_path, 'mstest.exe'].patheticalize
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
def default_framework_path
|
|
24
|
+
[
|
|
25
|
+
ENV['SystemRoot'] || (IronHammer::Defaults::SYSTEM_ROOT),
|
|
26
|
+
'Microsoft.NET',
|
|
27
|
+
'Framework',
|
|
28
|
+
'v3.5'
|
|
29
|
+
].patheticalize
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def default_visual_studio_path
|
|
33
|
+
[
|
|
34
|
+
ENV['ProgramFiles'] || IronHammer::Defaults::PROGRAM_FILES,
|
|
35
|
+
'Microsoft Visual Studio 2008',
|
|
36
|
+
'Common7',
|
|
37
|
+
'IDE'
|
|
38
|
+
].patheticalize
|
|
39
|
+
end
|
|
40
|
+
end unless defined? DotNetEnvironment
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module IronHammer
|
|
2
|
+
module Utils
|
|
3
|
+
class FileSystem
|
|
4
|
+
def self.copy_file! source, destination
|
|
5
|
+
raise(ArgumentError.new 'source must be a file') if File.directory?(source)
|
|
6
|
+
FileSystem::create_path! File.dirname(destination)
|
|
7
|
+
FileUtils.cp source, destination
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.copy_directory! source, destination
|
|
11
|
+
raise(ArgumentError.new 'source must be a directory') unless File.directory?(source)
|
|
12
|
+
FileUtils.cp_r source, destination
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.copy! source, destination
|
|
16
|
+
File.directory?(source) ? TheFiler::copy_directory!(source, destination) : FileSystem::copy_file!(source, destination)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.write! params={}
|
|
20
|
+
FileSystem::create_path! path = params[:path]
|
|
21
|
+
File.open(File.join(path, name = params[:name]), 'w') { |file| file.write(content = params[:content]) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.read_file *path
|
|
25
|
+
File.open(File.join(*path), 'r') { |file| content = file.read } unless path.nil? || path.empty?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.read_lines *path
|
|
29
|
+
File.open(File.join(*path), 'r') { |file| file.readlines } unless path.nil? || path.empty?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.create_path! *path
|
|
33
|
+
FileUtils.mkpath(File.join(*path)) unless path.nil? || path.empty? || File.exists?(File.join(*path))
|
|
34
|
+
end
|
|
35
|
+
end unless defined? FileSystem
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module IronHammer
|
|
2
|
+
module Utils
|
|
3
|
+
class Windows
|
|
4
|
+
def self.patheticalize *params
|
|
5
|
+
return '' if params.nil? || params.empty?
|
|
6
|
+
params[1..-1].inject(String.new params[0]) { |a, b| a << "\\#{b}" }
|
|
7
|
+
end
|
|
8
|
+
end unless defined? Windows
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Array
|
|
13
|
+
def patheticalize
|
|
14
|
+
IronHammer::Utils::Windows::patheticalize *self
|
|
15
|
+
end
|
|
16
|
+
end unless defined? IRON_HAMMER_UTILS_WINDOWS_ADDED_EXTENSIONS
|
|
17
|
+
|
|
18
|
+
class String
|
|
19
|
+
def patheticalize
|
|
20
|
+
IronHammer::Utils::Windows::patheticalize *self.split('/')
|
|
21
|
+
end
|
|
22
|
+
end unless defined? IRON_HAMMER_UTILS_WINDOWS_ADDED_EXTENSIONS
|
|
23
|
+
|
|
24
|
+
IRON_HAMMER_UTILS_WINDOWS_ADDED_EXTENSIONS = true
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'zip/zipfilesystem'
|
|
2
|
+
|
|
3
|
+
module IronHammer
|
|
4
|
+
module Utils
|
|
5
|
+
class Zipper
|
|
6
|
+
def self.zip_current_working_folder_into_this file
|
|
7
|
+
Zip::ZipFile::open(destination = file, true) do |zip|
|
|
8
|
+
Dir[File.join('**', '*')].each { |source| zip.add(entry = source, source) }
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end unless defined? Zipper
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'iron_hammer/utils/file_system'
|
|
3
|
+
|
|
4
|
+
module IronHammer
|
|
5
|
+
class Version
|
|
6
|
+
attr_accessor :build_number
|
|
7
|
+
attr_accessor :control_hash
|
|
8
|
+
attr_accessor :timestamp
|
|
9
|
+
attr_accessor :built_by
|
|
10
|
+
attr_accessor :major
|
|
11
|
+
attr_accessor :minor
|
|
12
|
+
attr_accessor :revision
|
|
13
|
+
|
|
14
|
+
def initialize params={}
|
|
15
|
+
@major = params[:major] || '#'
|
|
16
|
+
@minor = params[:minor] || '#'
|
|
17
|
+
@revision = params[:revision] || '#'
|
|
18
|
+
@build_number = params[:build_number] || '##'
|
|
19
|
+
@control_hash = params[:control_hash] || '**********'
|
|
20
|
+
@built_by = params[:built_by] || 'MACSkeptic Iron Hammer'
|
|
21
|
+
@timestamp = params[:timestamp] || Time.now.strftime('%Y-%m-%d %H:%M:%S')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_yaml
|
|
25
|
+
{
|
|
26
|
+
'Version' => { 'Major' => @major, 'Minor' => @minor, 'Revision' => @revision },
|
|
27
|
+
'Build' => { 'Number' => @build_number, 'Hash' => @control_hash },
|
|
28
|
+
'Timestamp' => @timestamp,
|
|
29
|
+
'Built By' => @built_by
|
|
30
|
+
}.to_yaml
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def create! path, name='version.yaml'
|
|
34
|
+
IronHammer::Utils::FileSystem::write! :path => path, :name => name, :content => to_yaml
|
|
35
|
+
end
|
|
36
|
+
end unless defined? Version
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: iron_hammer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mozair Alves do Carmo Junior
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2010-01-22 00:00:00 -02:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: rubyzip2
|
|
17
|
+
type: :runtime
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.9.2
|
|
24
|
+
version:
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: rubyforge
|
|
27
|
+
type: :development
|
|
28
|
+
version_requirement:
|
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.0.3
|
|
34
|
+
version:
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: gemcutter
|
|
37
|
+
type: :development
|
|
38
|
+
version_requirement:
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 0.3.0
|
|
44
|
+
version:
|
|
45
|
+
- !ruby/object:Gem::Dependency
|
|
46
|
+
name: hoe
|
|
47
|
+
type: :development
|
|
48
|
+
version_requirement:
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 2.5.0
|
|
54
|
+
version:
|
|
55
|
+
description: "It consists (or at least it will, when its done) of three main components: an Anvil, a Hammer, and a Blacksmith."
|
|
56
|
+
email:
|
|
57
|
+
- macskeptic@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
|
|
60
|
+
extensions: []
|
|
61
|
+
|
|
62
|
+
extra_rdoc_files:
|
|
63
|
+
- PostInstall.txt
|
|
64
|
+
files:
|
|
65
|
+
- PostInstall.txt
|
|
66
|
+
- README.rdoc
|
|
67
|
+
- Rakefile
|
|
68
|
+
- lib/iron_hammer.rb
|
|
69
|
+
- lib/iron_hammer/anvil.rb
|
|
70
|
+
- lib/iron_hammer/default_binaries_behavior.rb
|
|
71
|
+
- lib/iron_hammer/default_configuration_behavior.rb
|
|
72
|
+
- lib/iron_hammer/default_deliverables_behavior.rb
|
|
73
|
+
- lib/iron_hammer/deliverables/configuration_file.rb
|
|
74
|
+
- lib/iron_hammer/deliverables/deliverable.rb
|
|
75
|
+
- lib/iron_hammer/hammer.rb
|
|
76
|
+
- lib/iron_hammer/package.rb
|
|
77
|
+
- lib/iron_hammer/projects/asp_net_mvc_project.rb
|
|
78
|
+
- lib/iron_hammer/projects/asp_net_project.rb
|
|
79
|
+
- lib/iron_hammer/projects/dll_project.rb
|
|
80
|
+
- lib/iron_hammer/projects/generic_project.rb
|
|
81
|
+
- lib/iron_hammer/projects/project_file.rb
|
|
82
|
+
- lib/iron_hammer/projects/project_types.rb
|
|
83
|
+
- lib/iron_hammer/projects/test_project.rb
|
|
84
|
+
- lib/iron_hammer/solutions/solution.rb
|
|
85
|
+
- lib/iron_hammer/solutions/solution_file.rb
|
|
86
|
+
- lib/iron_hammer/tasks.rb
|
|
87
|
+
- lib/iron_hammer/utils/dot_net_environment.rb
|
|
88
|
+
- lib/iron_hammer/utils/file_system.rb
|
|
89
|
+
- lib/iron_hammer/utils/windows.rb
|
|
90
|
+
- lib/iron_hammer/utils/zipper.rb
|
|
91
|
+
- lib/iron_hammer/version.rb
|
|
92
|
+
has_rdoc: true
|
|
93
|
+
homepage: http://github.com/MACSkeptic/Iron-Hammer
|
|
94
|
+
licenses: []
|
|
95
|
+
|
|
96
|
+
post_install_message: |-
|
|
97
|
+
============================================
|
|
98
|
+
|
|
99
|
+
Thanks for installing Iron-Hammer
|
|
100
|
+
|
|
101
|
+
============================================
|
|
102
|
+
rdoc_options:
|
|
103
|
+
- --main
|
|
104
|
+
- README.rdoc
|
|
105
|
+
require_paths:
|
|
106
|
+
- lib
|
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: "0"
|
|
112
|
+
version:
|
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: "0"
|
|
118
|
+
version:
|
|
119
|
+
requirements: []
|
|
120
|
+
|
|
121
|
+
rubyforge_project: iron_hammer
|
|
122
|
+
rubygems_version: 1.3.5
|
|
123
|
+
signing_key:
|
|
124
|
+
specification_version: 3
|
|
125
|
+
summary: "It consists (or at least it will, when its done) of three main components: an Anvil, a Hammer, and a Blacksmith."
|
|
126
|
+
test_files: []
|
|
127
|
+
|