logirel 0.0.15 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/dictionaries/xyz.xml +3 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +11 -0
- data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
- data/.idea/logirel.iml +65 -0
- data/.idea/misc.xml +8 -0
- data/.idea/modules.xml +9 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +666 -0
- data/.semver +1 -1
- data/README.md +36 -36
- data/Rakefile.rb +0 -1
- data/lib/logirel/Initer.rb +103 -150
- data/lib/logirel/cli.rb +64 -63
- data/lib/logirel/cli_helper.rb +86 -0
- data/lib/logirel/queries/bool_q.rb +34 -0
- data/lib/logirel/queries/query.rb +7 -0
- data/lib/logirel/queries/str_q.rb +36 -0
- data/lib/logirel/queries.rb +2 -0
- data/lib/logirel/tasks/albacore_tasks.rb +15 -0
- data/lib/logirel/tasks/aspnet.rb +23 -0
- data/lib/logirel/tasks/assembly_info.rb +15 -0
- data/lib/logirel/tasks/core.rb +36 -0
- data/lib/logirel/tasks/ncover.rb +23 -0
- data/lib/logirel/tasks/nuget.rb +17 -0
- data/lib/logirel/tasks/nunit.rb +14 -0
- data/lib/logirel/tasks/nuspec.rb +4 -0
- data/lib/logirel/tasks/output.rb +4 -0
- data/lib/logirel/tasks/xunit.rb +15 -0
- data/lib/logirel/tasks/zip.rb +4 -0
- data/lib/logirel/templates/Gemfile.tt +6 -0
- data/lib/logirel/templates/Rakefile.tt +9 -0
- data/lib/logirel/templates/environment.tt +114 -0
- data/lib/logirel/templates/gitignore.tt +6 -0
- data/lib/logirel/templates/paths.tt +40 -0
- data/lib/logirel/templates/project_details.tt +5 -0
- data/{content/utils.rb → lib/logirel/templates/utils.tt} +1 -1
- data/lib/logirel/utils.rb +8 -0
- data/lib/logirel/version.rb +2 -10
- data/lib/logirel/vs/environment.rb +22 -0
- data/lib/logirel/vs/project_types.rb +27 -0
- data/lib/logirel/vs/solution.rb +113 -0
- data/lib/logirel.rb +2 -9
- data/logirel.gemspec +8 -5
- data/spec/queries/bool_query_spec.rb +32 -27
- data/spec/queries/string_query_spec.rb +57 -53
- data/spec/support/with_sample_projects.rb +3 -3
- data/spec/version_spec.rb +2 -3
- data/vendor/cache/albacore-0.2.6.gem +0 -0
- data/vendor/cache/nokogiri-1.4.6-x86-mingw32.gem +0 -0
- data/vendor/cache/semver-1.0.6.gem +0 -0
- metadata +75 -38
- data/content/environment.rb +0 -82
- data/lib/logirel/NuGet.rb +0 -8
- data/lib/logirel/details_emitter.rb +0 -0
- data/lib/logirel/q_model.rb +0 -65
- data/lib/logirel/querier.rb +0 -8
- data/spec/dependencies/nuget_spec.rb +0 -10
- data/spec/filesystem/filestructure_spec.rb +0 -56
- data/spec/filesystem/path_init_spec.rb +0 -35
- data/spec/filesystem/rakefile_init_spec.rb +0 -32
- data/spec/initer_spec.rb +0 -29
- data/spec/queries/querier_spec.rb +0 -45
- data/vendor/cache/albacore-0.2.5.gem +0 -0
- data/vendor/cache/rubyzip-0.9.4.gem +0 -0
- data/vendor/cache/semver-1.0.5.gem +0 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'logirel/queries/query'
|
2
|
+
|
3
|
+
module Logirel
|
4
|
+
module Queries
|
5
|
+
class StrQ < Query
|
6
|
+
def initialize(question,
|
7
|
+
default = nil,
|
8
|
+
io_source = STDIN,
|
9
|
+
validator = nil,
|
10
|
+
io_target = STDOUT)
|
11
|
+
@question = question
|
12
|
+
@default = default
|
13
|
+
@io_source = io_source
|
14
|
+
@validator = validator || lambda { |_| true }
|
15
|
+
@io_target = io_target
|
16
|
+
@answer = ""
|
17
|
+
end
|
18
|
+
|
19
|
+
def answer
|
20
|
+
@answer.empty? ? @default : @answer
|
21
|
+
end
|
22
|
+
|
23
|
+
def exec
|
24
|
+
@io_target.print @question + " [#{@default}]: "
|
25
|
+
|
26
|
+
begin
|
27
|
+
@answer = @io_source.gets.chomp
|
28
|
+
valid = @validator.call(@answer)
|
29
|
+
end while !valid || (!valid && @answer.empty?)
|
30
|
+
@answer = @answer.empty? ? @default : @answer
|
31
|
+
@io_target.puts "Chose '#{@answer}'."
|
32
|
+
@answer
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Logirel::Tasks
|
2
|
+
def aspnet_task(web_output_folder=nil, opts={})
|
3
|
+
web_output_folder = tuck_and_get :web_output_folder, web_output_folder
|
4
|
+
|
5
|
+
if vars[:solution].has_web_projects?
|
6
|
+
vars[:solution].web_projects.each do |p|
|
7
|
+
# todo: snake case p.name in const.
|
8
|
+
|
9
|
+
append_to_file BUILD_FILE, <<-EOF, :verbose => false
|
10
|
+
|
11
|
+
desc "asp compile"
|
12
|
+
aspnetcompiler #{ inject_task_name opts, 'precompile' }_#{p.name}#{ inject_dependency opts } do |c|
|
13
|
+
c.physical_path = "#{p.directory}"
|
14
|
+
c.target_path = "#{web_output_folder || 'web_out' }/#{p.name}"
|
15
|
+
c.updateable = true
|
16
|
+
c.force = true
|
17
|
+
end
|
18
|
+
EOF
|
19
|
+
end #each
|
20
|
+
end #if
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Logirel::Tasks
|
2
|
+
def assembly_info_task(opts={})
|
3
|
+
append_to_file BUILD_FILE, <<-EOF, :verbose => false
|
4
|
+
|
5
|
+
assemblyinfo #{ inject_task_name opts, 'assemblyinfo' }#{ inject_dependency opts } do |asm|
|
6
|
+
asm.version = BUILD_VERSION
|
7
|
+
asm.file_version = BUILD_VERSION
|
8
|
+
asm.company_name = "#{vars[:env].organization}"
|
9
|
+
asm.product_name = "#{vars[:solution].name}"
|
10
|
+
asm.copyright = "Copyright (c) #{vars[:env].organization}"
|
11
|
+
asm.output_file = "AssemblyInfo.cs"
|
12
|
+
end
|
13
|
+
EOF
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'zip/zip'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Logirel::Tasks
|
5
|
+
include FileUtils
|
6
|
+
|
7
|
+
BUILD_FILE = 'Rakefile'
|
8
|
+
|
9
|
+
|
10
|
+
def unzip(zipfile, opts)
|
11
|
+
opts = {:to =>'.'}.merge(opts)
|
12
|
+
Zip::ZipFile.open(zipfile) do |z|
|
13
|
+
z.each do |f|
|
14
|
+
to_file = File.join(opts[:to], f.name)
|
15
|
+
mkdir_p(File.dirname(to_file))
|
16
|
+
z.extract(f, to_file) unless File.exist?(to_file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
rm zipfile if opts[:remove]
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
private
|
24
|
+
def inject_dependency(params)
|
25
|
+
' => ' + params[:depends].inspect.to_s if params[:depends]
|
26
|
+
end
|
27
|
+
|
28
|
+
def inject_task_name(opts, default_name)
|
29
|
+
":#{opts[:name] || default_name}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def tuck_and_get(param_name, param_default_value)
|
33
|
+
return settings[param_name] = param_default_value if param_default_value
|
34
|
+
settings[param_name]
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Logirel::Tasks
|
2
|
+
def ncover_task(ncover_exe_folder=nil, nunit_exe_folder=nil, opts={})
|
3
|
+
ncover_exe_folder = tuck_and_get :ncover_exe_folder, ncover_exe_folder
|
4
|
+
nunit_exe_folder = tuck_and_get :nunit_exe_folder, nunit_exe_folder
|
5
|
+
|
6
|
+
append_to_file BUILD_FILE, <<-EOF, :verbose => false
|
7
|
+
|
8
|
+
desc "NCover Console code coverage"
|
9
|
+
ncoverconsole #{ inject_task_name opts, 'ncover' }#{ inject_dependency opts } |ncc|
|
10
|
+
ncc.command = "#{ncover_exe_folder || 'tools/ncover'}/NCover.Console.exe"
|
11
|
+
ncc.output :xml => "test-coverage.xml"
|
12
|
+
ncc.cover_assemblies '#{ vars[:solution].find_project(:output=>'OUTPUT') { |p| !p.test? }.output }'
|
13
|
+
|
14
|
+
nunit = NUnitTestRunner.new("#{nunit_exe_folder || 'tools/nunit' }/nunit-console.exe")
|
15
|
+
# nunit.options '/framework=4.0.30319', '/noshadow'
|
16
|
+
nunit.options '/noshadow'
|
17
|
+
nunit.assemblies '#{ vars[:solution].find_project(:output=>'TEST_ASSEMBLY') { |p| p.test? }.output }'
|
18
|
+
ncc.testrunner = nunit
|
19
|
+
end
|
20
|
+
EOF
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Logirel::Tasks
|
2
|
+
def nuget_task(nuget_exe_folder = nil, nuget_input_folder = nil, opts={})
|
3
|
+
nuget_exe_folder = tuck_and_get :nuget_exe_folder, nuget_exe_folder
|
4
|
+
nuget_input_folder = tuck_and_get :nuget_input_folder, nuget_input_folder
|
5
|
+
|
6
|
+
append_to_file BUILD_FILE, <<-EOF, :verbose => false
|
7
|
+
|
8
|
+
desc "create a nuget package"
|
9
|
+
nugetpack #{ inject_task_name opts, 'nuget' }#{ inject_dependency opts } do |nuget|
|
10
|
+
nuget.command = "#{nuget_exe_folder || 'tools/nuget'}/nuget.exe"
|
11
|
+
nuget.nuspec = "#{vars[:solution].name}.nuspec"
|
12
|
+
nuget.base_folder = "#{nuget_input_folder || 'out'}"
|
13
|
+
nuget.output = "pkg"
|
14
|
+
end
|
15
|
+
EOF
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Logirel::Tasks
|
2
|
+
def nunit_task(nunit_exe_folder=nil, opts={})
|
3
|
+
nunit_exe_folder = tuck_and_get :nunit_exe_folder, nunit_exe_folder
|
4
|
+
|
5
|
+
append_to_file BUILD_FILE, <<-EOF, :verbose => false
|
6
|
+
|
7
|
+
desc "Run tests"
|
8
|
+
nunit #{ inject_task_name opts, 'nunit' }#{ inject_dependency opts } do |nunit|
|
9
|
+
nunit.command = "#{ nunit_exe_folder || 'tools/nunit' }/nunit-console.exe"
|
10
|
+
nunit.assemblies "#{ vars[:solution].find_project(:output=>'TEST_ASSEMBLY') { |p| p.test? }.output }"
|
11
|
+
end
|
12
|
+
EOF
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Logirel::Tasks
|
2
|
+
def xunit_task(xunit_exe_folder=nil, opts={})
|
3
|
+
xunit_exe_folder = tuck_and_get :xunit_exe_folder, xunit_exe_folder
|
4
|
+
|
5
|
+
append_to_file BUILD_FILE, <<-EOF, :verbose => false
|
6
|
+
|
7
|
+
desc "Run tests with XUnit"
|
8
|
+
xunit #{ inject_task_name opts, 'xunit' }#{ inject_dependency opts } do |xunit|
|
9
|
+
xunit.command = "#{xunit_exe_folder || 'tools/xunit'}/xunit.console.exe"
|
10
|
+
xunit.assembly "#{ vars[:solution].find_project(:output=>'TEST_ASSEMBLY') { |p| p.test? }.output }"
|
11
|
+
end
|
12
|
+
EOF
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require "<%=folders[:buildscripts]%>/paths"
|
2
|
+
require "<%=folders[:buildscripts]%>/project_details"
|
3
|
+
require 'semver'
|
4
|
+
|
5
|
+
namespace :env do
|
6
|
+
|
7
|
+
task :common do
|
8
|
+
# version management
|
9
|
+
fv = version SemVer.find.to_s
|
10
|
+
revision = (!fv[3] || fv[3] == 0) ? (ENV['BUILD_NUMBER'] || Time.now.strftime('%j%H')) : fv[3] # (day of year 0-265)(hour 00-24)
|
11
|
+
|
12
|
+
ENV['BUILD_VERSION'] = BUILD_VERSION = SemVer.new(fv[0], fv[1], fv[2], revision).to_s
|
13
|
+
puts "Assembly Version: #{BUILD_VERSION}."
|
14
|
+
puts "##teamcity[buildNumber '#{BUILD_VERSION}']" # tell teamcity our decision
|
15
|
+
|
16
|
+
# .net/mono configuration management
|
17
|
+
ENV['FRAMEWORK'] = FRAMEWORK = ENV['FRAMEWORK'] || (Rake::Win32::windows? ? "net40" : "mono28")
|
18
|
+
puts "Framework: #{FRAMEWORK}"
|
19
|
+
end
|
20
|
+
|
21
|
+
# configure the output directories
|
22
|
+
task :configure, [:str] do |_, args|
|
23
|
+
ENV['CONFIGURATION'] = CONFIGURATION = args[:str]
|
24
|
+
FOLDERS[:binaries] = File.join(FOLDERS[:build], FRAMEWORK, args[:str].downcase)
|
25
|
+
CLEAN.include(File.join(FOLDERS[:binaries], "*"))
|
26
|
+
end
|
27
|
+
|
28
|
+
task :set_dirs do
|
29
|
+
<% metas.each do |m| %>
|
30
|
+
<% k = m[:ruby_key] %>
|
31
|
+
FOLDERS[:<%=k%>][:out] = File.join(FOLDERS[:src], PROJECTS[:<%=k%>][:dir], 'bin', CONFIGURATION)
|
32
|
+
CLEAN.include(FOLDERS[:<%=k%>][:out])
|
33
|
+
|
34
|
+
# for tests
|
35
|
+
FOLDERS[:<%=k%>] = File.join(FOLDERS[:src], PROJECTS[:<%=k%>][:test_dir], 'bin', CONFIGURATION)
|
36
|
+
FILES[:<%=k%>][:test] = File.join(FOLDERS[:<%=k%>][:test_out], "#{PROJECTS[:<%=k%>][:test_dir]}.dll")
|
37
|
+
CLEAN.include(FOLDERS[:test_out])
|
38
|
+
<% end %>
|
39
|
+
end
|
40
|
+
|
41
|
+
# DEBUG/RELEASE
|
42
|
+
|
43
|
+
desc "set debug environment variables"
|
44
|
+
task :debug => [:common] do
|
45
|
+
Rake::Task["env:configure"].invoke('Debug')
|
46
|
+
Rake::Task["env:set_dirs"].invoke
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "set release environment variables"
|
50
|
+
task :release => [:common] do
|
51
|
+
Rake::Task["env:configure"].invoke('Release')
|
52
|
+
Rake::Task["env:set_dirs"].invoke
|
53
|
+
end
|
54
|
+
|
55
|
+
# FRAMEWORKS
|
56
|
+
|
57
|
+
desc "set net40 framework"
|
58
|
+
task :net40 do
|
59
|
+
ENV['FRAMEWORK'] = 'net40'
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "set net35 framework"
|
63
|
+
task :net35 do
|
64
|
+
ENV['FRAMEWORK'] = 'net35'
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "set net20 framework"
|
68
|
+
task :net20 do
|
69
|
+
ENV['FRAMEWORK'] = 'net20'
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "set mono28 framework"
|
73
|
+
task :mono28 do
|
74
|
+
ENV['FRAMEWORK'] = 'mono28'
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "set mono30 framework"
|
78
|
+
task :net30 do
|
79
|
+
ENV['FRAMEWORK'] = 'mono30'
|
80
|
+
end
|
81
|
+
|
82
|
+
# ENVIRONMENT VARS FOR PRODUCT RELEASES
|
83
|
+
|
84
|
+
desc "set GA envionment variables"
|
85
|
+
task :ga do
|
86
|
+
puts "##teamcity[progressMessage 'Setting environment variables for GA']"
|
87
|
+
ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "4000"
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "set release candidate environment variables"
|
91
|
+
task :rc, [:number] do |t, args|
|
92
|
+
puts "##teamcity[progressMessage 'Setting environment variables for Release Candidate']"
|
93
|
+
arg_num = args[:number].to_i
|
94
|
+
num = arg_num != 0 ? arg_num : 1
|
95
|
+
ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "#{3000 + num}"
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "set beta-environment variables"
|
99
|
+
task :beta, [:number] do |t, args|
|
100
|
+
puts "##teamcity[progressMessage 'Setting environment variables for Beta']"
|
101
|
+
arg_num = args[:number].to_i
|
102
|
+
num = arg_num != 0 ? arg_num : 1
|
103
|
+
ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "#{2000 + num}"
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "set alpha environment variables"
|
107
|
+
task :alpha, [:number] do |t, args|
|
108
|
+
puts "##teamcity[progressMessage 'Setting environment variables for Alpha']"
|
109
|
+
arg_num = args[:number].to_i
|
110
|
+
num = arg_num != 0 ? arg_num : 1
|
111
|
+
|
112
|
+
ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "#{1000 + num}"
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
root_folder = File.expand_path("#{File.dirname(__FILE__)}/..")
|
2
|
+
require "<%=folders[:buildscripts]%>/project_details"
|
3
|
+
|
4
|
+
# The folders array denoting where to place build artifacts
|
5
|
+
|
6
|
+
FOLDERS = {
|
7
|
+
:root => root_folder,
|
8
|
+
:src => "<%= folders[:src] %>",
|
9
|
+
:build => "<%= folders[:build] %>",
|
10
|
+
:binaries => "placeholder - environment.rb sets this depending on target",
|
11
|
+
:tests => "<%= folders[:tests] %>",
|
12
|
+
:tools => "<%= folders[:tools] %>",
|
13
|
+
:nuget => "<%= folders[:nuget] %>",
|
14
|
+
<% metas.each do |m| %>
|
15
|
+
:<%=m[:ruby_key]%> => {
|
16
|
+
:test_dir => '<%= m[:test_dir] %>',
|
17
|
+
:out => 'placeholder - environment.rb will sets this',
|
18
|
+
:test_out => 'placeholder - environment.rb sets this'
|
19
|
+
},
|
20
|
+
<% end %>
|
21
|
+
}
|
22
|
+
|
23
|
+
FILES = {
|
24
|
+
:sln => "<%= files[:sln] %>",
|
25
|
+
<% metas.each do |m| %>
|
26
|
+
:<%= m[:ruby_key] %> => {
|
27
|
+
:nuspec => File.join(FOLDERS[:<%= m[:ruby_key] %>], "#{PROJECTS[:<%= m[:ruby_key] %>][:id]}.nuspec")
|
28
|
+
},
|
29
|
+
<% end %>
|
30
|
+
}
|
31
|
+
|
32
|
+
COMMANDS = {
|
33
|
+
:nunit => File.join(FOLDERS[:nunit], "nunit-console.exe"),
|
34
|
+
:nuget => File.join(FOLDERS[:tools], "NuGet.exe"),
|
35
|
+
:ilmerge => File.join(FOLDERS[:tools], "ILMerge.exe")
|
36
|
+
}
|
37
|
+
|
38
|
+
URIS = {
|
39
|
+
:nuget_offical => "http://packages.nuget.org/v1/"
|
40
|
+
}
|
data/lib/logirel/version.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
1
|
module Logirel
|
2
|
+
VERSION = "0.0.x"
|
2
3
|
begin
|
3
4
|
require 'semver'
|
4
|
-
begin
|
5
|
-
VERSION = SemVer.find.format "%M.%m.%p"
|
6
|
-
rescue SemVerMissingError
|
7
|
-
VERSION = "0.0.x"
|
8
|
-
end
|
9
|
-
|
10
5
|
class Version < SemVer
|
11
6
|
def parse_numeric(str)
|
12
|
-
str.scan(/(\d{1,5}).?/).flatten.collect{|x| x.to_i}
|
7
|
+
str.scan(/(\d{1,5}).?/).flatten.collect { |x| x.to_i }
|
13
8
|
end
|
14
9
|
end
|
15
|
-
|
16
10
|
rescue LoadError
|
17
11
|
puts 'First time installing, eh? Just run "bundle install"! (unless this is you running it right now!)'
|
18
|
-
VERSION = "0.0.x"
|
19
12
|
end
|
20
|
-
|
21
13
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'win32/registry'
|
2
|
+
|
3
|
+
module Logirel::VS
|
4
|
+
class Environment
|
5
|
+
attr_reader :owner
|
6
|
+
attr_reader :organization
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@owner = registry_get 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'RegisteredOwner' || 'OWNER'
|
10
|
+
@organization = registry_get 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'RegisteredOrganization' || 'ORGANIZATION'
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def registry_get(path, key)
|
15
|
+
Win32::Registry::HKEY_LOCAL_MACHINE.open(path) do |reg|
|
16
|
+
reg_typ, reg_val = reg.read(key)
|
17
|
+
reg_val
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Logirel::VS
|
2
|
+
module ProjectTypes
|
3
|
+
TYPEMAP = {
|
4
|
+
'{3AC096D0-A1C2-E12C-1390-A8335801FDAB}' => :test,
|
5
|
+
'{39D444FD-B490-1554-5274-2D612A165298}' => :test_cs,
|
6
|
+
'{4FD007E8-1A56-7E75-70CA-0466484D4F98}' => :test_vb,
|
7
|
+
'{349C5851-65DF-11DA-9384-00065B846F21}' => :web_aspnet,
|
8
|
+
'{F85E285D-A4E0-4152-9332-AB1D724D3325}' => :web_mvc2,
|
9
|
+
'{E53F8FEA-EAE0-44A6-8774-FFD645390401}' => :web_mvc3
|
10
|
+
}
|
11
|
+
|
12
|
+
WEB = [:test, :test_cs, :test_vb]
|
13
|
+
TEST = [:web_aspnet, :web_mvc2, :web_mvc3]
|
14
|
+
|
15
|
+
def self.to_type(guid)
|
16
|
+
TYPEMAP[guid.upcase]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.test?(type)
|
20
|
+
WEB.include? type
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.web?(type)
|
24
|
+
TEST.include? type
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'pathname'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Logirel
|
6
|
+
module VS
|
7
|
+
class Project
|
8
|
+
attr_reader :name
|
9
|
+
attr_reader :file
|
10
|
+
attr_reader :output
|
11
|
+
attr_reader :project_types
|
12
|
+
|
13
|
+
def initialize(prfile, opts = {})
|
14
|
+
@file = File.expand_path("#{prfile}")
|
15
|
+
@name = File.basename(@file, ".csproj")
|
16
|
+
|
17
|
+
@solution_path = opts[:solution_path] || '.'
|
18
|
+
@project_types = []
|
19
|
+
|
20
|
+
throw "Project #{@file} must exist." unless File.exists? @file
|
21
|
+
|
22
|
+
parse(File.read(@file))
|
23
|
+
end
|
24
|
+
|
25
|
+
def directory
|
26
|
+
File.dirname(file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test?
|
30
|
+
project_types.any? {|t| ProjectTypes.test? t }
|
31
|
+
end
|
32
|
+
|
33
|
+
def web?
|
34
|
+
project_types.any? {|t| ProjectTypes.web? t }
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def parse(contents)
|
39
|
+
doc = ::Nokogiri::XML(contents)
|
40
|
+
|
41
|
+
populate_project_types doc
|
42
|
+
populate_output doc
|
43
|
+
end
|
44
|
+
|
45
|
+
def populate_project_types(doc)
|
46
|
+
guids = doc.css('ProjectTypeGuids').text.split ';'
|
47
|
+
@project_types = guids.map {|g| ProjectTypes.to_type g }.compact
|
48
|
+
end
|
49
|
+
|
50
|
+
def populate_output(doc)
|
51
|
+
@output = File.join File.dirname(file),
|
52
|
+
(doc.css('PropertyGroup[Condition*=Release] > OutputPath').text || doc.css('PropertyGroup[Condition*=Debug] > OutputPath').text).gsub("\\","/"),
|
53
|
+
doc.css('PropertyGroup > AssemblyName').text
|
54
|
+
@output += ".dll"
|
55
|
+
@output = solution_relative_path @output
|
56
|
+
end
|
57
|
+
|
58
|
+
def solution_relative_path(path)
|
59
|
+
Pathname.new(path).relative_path_from(Pathname.new(@solution_path)).to_s
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
class Solution
|
66
|
+
attr_reader :file
|
67
|
+
attr_reader :name
|
68
|
+
attr_reader :path
|
69
|
+
attr_reader :projects
|
70
|
+
|
71
|
+
def initialize(slfile)
|
72
|
+
@file = File.expand_path("#{slfile}")
|
73
|
+
throw "Solution #{@file} must exist." unless File.exist?(@file)
|
74
|
+
|
75
|
+
@name = File.basename(@file, ".sln")
|
76
|
+
@path = File.dirname(@file)
|
77
|
+
@projects = []
|
78
|
+
|
79
|
+
populate_projects File.read(@file)
|
80
|
+
end
|
81
|
+
|
82
|
+
def find_project(defaults=nil)
|
83
|
+
projects.find{|p| yield p} || OpenStruct.new(defaults)
|
84
|
+
end
|
85
|
+
|
86
|
+
def has_test_projects?
|
87
|
+
test_projects.count > 0
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_projects
|
91
|
+
projects.select { |p| p.test? || p.name =~ /(Test|Tests)$/ }
|
92
|
+
end
|
93
|
+
|
94
|
+
def has_web_projects?
|
95
|
+
web_projects.count > 0
|
96
|
+
end
|
97
|
+
|
98
|
+
def web_projects
|
99
|
+
projects.select {|p| p.web? }
|
100
|
+
end
|
101
|
+
private
|
102
|
+
|
103
|
+
def populate_projects(contents)
|
104
|
+
contents.lines.each do |line|
|
105
|
+
@projects << Project.new(File.join(@path, $1), :solution_path => path) if(line =~ /Project.*=.*?,\s*"(.*)"\s*,.*?/ && File.exist?(File.join(@path, $1)))
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
data/lib/logirel.rb
CHANGED
data/logirel.gemspec
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
3
5
|
require "logirel/version"
|
4
6
|
|
5
7
|
Gem::Specification.new do |s|
|
6
8
|
s.name = "logirel"
|
7
|
-
s.version =
|
9
|
+
s.version = SemVer.find.format "%M.%m.%p"
|
8
10
|
s.platform = Gem::Platform::RUBY
|
9
11
|
s.authors = ["Henrik Feldt"]
|
10
12
|
s.email = ["henrik@haf.se"]
|
@@ -26,11 +28,12 @@ Gem::Specification.new do |s|
|
|
26
28
|
s.add_development_dependency "rspec", "~> 2.6.0"
|
27
29
|
s.add_development_dependency "memoize"
|
28
30
|
s.add_development_dependency "devver-construct"
|
29
|
-
s.add_dependency "albacore", "~> 0.2.
|
31
|
+
s.add_dependency "albacore", "~> 0.2.6"
|
30
32
|
s.add_dependency "semver", "~> 1.0.6"
|
31
33
|
s.add_dependency "bundler", "~> 1.0.14"
|
32
|
-
s.add_dependency "thor"
|
33
|
-
s.add_dependency "uuid"
|
34
|
+
s.add_dependency "thor", "~> 0.14.6"
|
35
|
+
s.add_dependency "uuid", "~> 2.3.2"
|
36
|
+
s.add_dependency "nokogiri", "~>1.4.4"
|
34
37
|
|
35
38
|
s.requirements << '.Net or Mono installation'
|
36
39
|
s.requirements << 'xbuild (on linux) or msbuild (on windows) for csproj files'
|