alpacabuildtool 1.0.0

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.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +48 -0
  3. data/.rubocop.yml +12 -0
  4. data/.semver +6 -0
  5. data/.travis.yml +10 -0
  6. data/CHANGELOG +18 -0
  7. data/Gemfile +7 -0
  8. data/LICENSE +22 -0
  9. data/README.md +235 -0
  10. data/README.rdoc +39 -0
  11. data/Rakefile +74 -0
  12. data/alpacabuildtool.gemspec +34 -0
  13. data/alpacabuildtool.rdoc +5 -0
  14. data/alpacabuildtool.todo +9 -0
  15. data/bin/alpaca +142 -0
  16. data/features/alpaca.feature +8 -0
  17. data/features/step_definitions/alpaca_steps.rb +13 -0
  18. data/features/step_definitions/visual_studio_solutions_steps.rb +47 -0
  19. data/features/support/env.rb +10 -0
  20. data/features/visual_studio_solutions.feature +43 -0
  21. data/lib/alpacabuildtool.rb +4 -0
  22. data/lib/alpacabuildtool/application.rb +195 -0
  23. data/lib/alpacabuildtool/configuration.rb +209 -0
  24. data/lib/alpacabuildtool/data/.alpaca.conf +148 -0
  25. data/lib/alpacabuildtool/data/doom.flf +826 -0
  26. data/lib/alpacabuildtool/data/logo.jpg +0 -0
  27. data/lib/alpacabuildtool/entities/nuspec.rb +107 -0
  28. data/lib/alpacabuildtool/entities/project.rb +54 -0
  29. data/lib/alpacabuildtool/entities/solution.rb +104 -0
  30. data/lib/alpacabuildtool/entities/xml.rb +41 -0
  31. data/lib/alpacabuildtool/entities/xml_node.rb +75 -0
  32. data/lib/alpacabuildtool/log/font.rb +92 -0
  33. data/lib/alpacabuildtool/log/log.rb +15 -0
  34. data/lib/alpacabuildtool/log/rainbowify_formatter.rb +70 -0
  35. data/lib/alpacabuildtool/log/rainbowify_logger.rb +47 -0
  36. data/lib/alpacabuildtool/managers/build_manager.rb +32 -0
  37. data/lib/alpacabuildtool/managers/package_manager.rb +136 -0
  38. data/lib/alpacabuildtool/managers/report_manager.rb +33 -0
  39. data/lib/alpacabuildtool/managers/test_manager.rb +35 -0
  40. data/lib/alpacabuildtool/os.rb +29 -0
  41. data/lib/alpacabuildtool/package_types/project_package.rb +44 -0
  42. data/lib/alpacabuildtool/package_types/tool_package.rb +53 -0
  43. data/lib/alpacabuildtool/tools/git.rb +22 -0
  44. data/lib/alpacabuildtool/tools/msbuild.rb +29 -0
  45. data/lib/alpacabuildtool/tools/nuget.rb +49 -0
  46. data/lib/alpacabuildtool/tools/nunit.rb +28 -0
  47. data/lib/alpacabuildtool/tools/nunit_orange.rb +18 -0
  48. data/lib/alpacabuildtool/tools/open_cover.rb +29 -0
  49. data/lib/alpacabuildtool/tools/report_generator.rb +25 -0
  50. data/lib/alpacabuildtool/tools/tool.rb +84 -0
  51. data/lib/alpacabuildtool/tools/wrapper.rb +66 -0
  52. data/lib/alpacabuildtool/versioning/version.rb +163 -0
  53. data/lib/alpacabuildtool/versioning/versioning.rb +84 -0
  54. data/spec/lib/alpacabuildtool/configuration_spec.rb +201 -0
  55. data/spec/lib/alpacabuildtool/entities/xml_spec.rb +39 -0
  56. data/spec/lib/alpacabuildtool/versioning/version_spec.rb +86 -0
  57. data/spec/lib/alpacabuildtool/versioning/versioning_spec.rb +194 -0
  58. data/spec/spec_helper.rb +3 -0
  59. data/spec/support/coverage.rb +26 -0
  60. data/test_data/sln1/.alpaca.conf +11 -0
  61. data/test_data/sln1/.semver +6 -0
  62. data/test_data/sln1/TestSolution.sln +22 -0
  63. data/test_data/sln1/TestSolution/App.config +6 -0
  64. data/test_data/sln1/TestSolution/Program.cs +16 -0
  65. data/test_data/sln1/TestSolution/Properties/AssemblyInfo.cs +36 -0
  66. data/test_data/sln1/TestSolution/TestSolution.csproj +59 -0
  67. data/test_data/sln2/.alpaca.conf +8 -0
  68. data/test_data/sln2/.semver +6 -0
  69. data/test_data/sln2/ProjectName/ProjectName.csproj +54 -0
  70. data/test_data/sln2/ProjectName/Properties/AssemblyInfo.cs +36 -0
  71. data/test_data/sln2/ProjectName/SomeFolderInProject/SomeClass.cs +16 -0
  72. data/test_data/sln2/ProjectName2/ProjectName2.csproj +58 -0
  73. data/test_data/sln2/ProjectName2/Properties/AssemblyInfo.cs +37 -0
  74. data/test_data/sln2/SolutionName.sln +34 -0
  75. data/test_data/sln2/Unit.Tests/Properties/AssemblyInfo.cs +36 -0
  76. data/test_data/sln2/Unit.Tests/SomeClassTests.cs +21 -0
  77. data/test_data/sln2/Unit.Tests/Unit.Tests.csproj +65 -0
  78. data/test_data/sln2/Unit.Tests/packages.config +4 -0
  79. data/test_data/sln3/TestSolution.nobuild.sln +22 -0
  80. data/test_data/sln3/TestSolution/App.config +6 -0
  81. data/test_data/sln3/TestSolution/Program.cs +16 -0
  82. data/test_data/sln3/TestSolution/Properties/AssemblyInfo.cs +36 -0
  83. data/test_data/sln3/TestSolution/TestSolution.nobuild.csproj +59 -0
  84. metadata +309 -0
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'alpacabuildtool/versioning/versioning'
4
+ version = ((AlpacaBuildTool::Versioning.find).to_s '%M.%m.%p%s').gsub('-', '.')
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'alpacabuildtool'
8
+ s.version = version
9
+ s.author = 'Vasyl Purchel'
10
+ s.email = 'vasyl.purchel@gmail.com'
11
+ s.homepage = 'https://github.com/vasyl-purchel/alpaca'
12
+ s.license = 'MIT'
13
+ s.platform = Gem::Platform::RUBY
14
+ s.summary = 'yet another build tool for Visual Studio solutions'
15
+ s.files = `git ls-files -z`.split("\x0")
16
+ s.test_files = s.files.grep(/^(test|spec|features|test_data)/)
17
+ s.require_paths << 'lib'
18
+ s.has_rdoc = true
19
+ s.extra_rdoc_files = ['README.rdoc', 'alpacabuildtool.rdoc']
20
+ s.rdoc_options << '--title' << 'AlpacaBuildTool'
21
+ s.rdoc_options << '--main' << 'README.rdoc' << '-ri'
22
+ s.bindir = 'bin'
23
+ s.executables << 'alpaca'
24
+ s.add_development_dependency('rake')
25
+ s.add_development_dependency('rdoc')
26
+ s.add_development_dependency('cucumber', '~> 2.0.0')
27
+ s.add_development_dependency('rspec', '~> 3.2.0')
28
+ s.add_development_dependency('fakefs')
29
+ s.add_development_dependency('rubocop', '~> 0.30.1')
30
+ s.add_development_dependency('bundler', '~> 1.6')
31
+ s.add_development_dependency('simplecov', '~> 0.7')
32
+ s.add_runtime_dependency('gli', '2.13.0')
33
+ s.add_runtime_dependency('rainbow')
34
+ end
@@ -0,0 +1,5 @@
1
+ = alpacabuildtool
2
+
3
+ Generate this with
4
+ alpacabuildtool rdoc
5
+ After you have described your command line interface
@@ -0,0 +1,9 @@
1
+ tasks:
2
+ ☐ decouple from tools (configure test_tool with formatter type, parameters
3
+ and so on from configs instead of NUnit class)
4
+ ☐ add nunit tests categories (not types like unit, service, ...
5
+ but MetaTestsAttribute, CoreTestsAttribute...)
6
+ ☐ add service tests running:
7
+ ☐ eval 'service_tests_script' to update service configuration
8
+ ☐ run 'exe' in child process
9
+ ☐ run 'service' type project tests
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ require 'alpacabuildtool'
4
+
5
+ module AlpacaBuildTool
6
+ ##
7
+ # The *GliWrapper* module provides command line interface by using GLI::App
8
+ module GliWrapper
9
+ include GLI::App
10
+ extend self
11
+
12
+ program_desc 'is a build tool for Visual Studio solutions'
13
+ subcommand_option_handling :normal
14
+ arguments :strict
15
+ gem_path = File.join(File.expand_path(File.dirname(__FILE__)), '..')
16
+ version Versioning.parse(File.join(gem_path, '.semver')).to_s
17
+
18
+ on_error do |exception|
19
+ puts exception.backtrace if ENV['DEV'] == 'true'
20
+ true
21
+ end
22
+
23
+ desc 'Solutions search pattern'
24
+ default_value '**/*.sln'
25
+ flag [:p, :pattern]
26
+
27
+ desc 'Compile solution[s]'
28
+ long_desc 'Compiling each solution founded from pattern in global options'
29
+ command :compile do |command|
30
+ command.desc 'Build solution in Debug mode'
31
+ command.switch :d, :debug
32
+
33
+ command.desc 'Update project versions'
34
+ command.switch :u, :update
35
+
36
+ command.action do |global, options, _|
37
+ Application.new.compile(global[:p],
38
+ debug: options[:d] || false,
39
+ update_version: options[:u] || false)
40
+ end
41
+ end
42
+
43
+ desc 'Test solution[s]'
44
+ long_desc 'Testing each solution founded from pattern in global options'
45
+ command :test do |command|
46
+ command.desc 'Test solution in Debug mode'
47
+ command.switch :d, :debug, negatable: false
48
+
49
+ command.desc 'Run tests with coverage'
50
+ command.switch [:c, :coverage]
51
+
52
+ command.desc 'Test type'
53
+ command.default_value 'all'
54
+ command.flag :t, :type
55
+
56
+ command.action do |global, options, _|
57
+ Application.new.test(global[:p],
58
+ debug: options[:d] || false,
59
+ coverage: options[:c] || false,
60
+ type: options[:t])
61
+ end
62
+ end
63
+
64
+ desc 'Generate reports for solution[s]'
65
+ long_desc 'Generate reports for all founded results for solutions'
66
+ command :report do |command|
67
+ command.desc 'Report category'
68
+ command.default_value 'all'
69
+ command.flag :t, :type
70
+
71
+ command.action do |global, options, _|
72
+ Application.new.report(global[:p], type: options[:t])
73
+ end
74
+ end
75
+
76
+ desc 'Create packages for solution[s]'
77
+ long_desc 'Create new packages for solutions'
78
+ command :pack do |command|
79
+ command.desc 'Pack package in Debug mode'
80
+ command.switch :d, :debug, negatable: false, default_value: false
81
+
82
+ command.desc 'Push package after it created if it contains changes'
83
+ command.switch :p, :push, default_value: false
84
+
85
+ command.desc 'Force push package after it created'
86
+ command.switch :f, :force, default_value: false
87
+
88
+ command.action do |global, options, _|
89
+ Application.new.package(global[:p], options)
90
+ end
91
+ end
92
+
93
+ desc 'Release packages for solution[s]'
94
+ long_desc 'Update package to release version and push it'
95
+ command :release do |command|
96
+ command.desc 'Push to the source after released'
97
+ command.switch :p, :push, default_value: true
98
+
99
+ command.desc 'Force push package after it created'
100
+ command.switch :f, :force, default_value: false
101
+
102
+ command.action do |global, options, _|
103
+ Application.new.release(global[:p], options)
104
+ end
105
+ end
106
+
107
+ desc 'Update solution[s] versions'
108
+ long_desc 'Update version for each solution'
109
+ command :update do |command|
110
+ command.desc 'Version dimension to be updated(patch, minor..)'
111
+ command.default_value 'patch'
112
+ command.flag :d, :dimension
113
+
114
+ command.action do |global, options, _|
115
+ Application.new.update(global[:p], options)
116
+ end
117
+ end
118
+
119
+ desc 'Configure alpaca to your needs'
120
+ long_desc 'Save configuration into local/global conf files
121
+ for further usage'
122
+ command :configure do |command|
123
+ command.desc 'configure solution[s] from global pattern'
124
+ command.arg_name 'node1.node2.property=value', :multiple
125
+ command.command :local do |subcommand|
126
+ subcommand.action do |global, _, arguments|
127
+ Application.new.configure_local(global[:p], arguments)
128
+ end
129
+ end
130
+
131
+ command.desc 'configure alpaca in user wide sence'
132
+ command.arg_name 'node1.node2.property=value', :multiple
133
+ command.command :global do |subcommand|
134
+ subcommand.action do |_, _, arguments|
135
+ Application.new.configure_global(arguments)
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
141
+
142
+ exit AlpacaBuildTool::GliWrapper.run(ARGV)
@@ -0,0 +1,8 @@
1
+ @windows @linux
2
+ Feature: Alpaca app kinda works
3
+ In order to do anything with application I need to
4
+ be sure that it still runs ok
5
+
6
+ Scenario: App just runs
7
+ When I get help for "alpaca"
8
+ Then the exit status should be 0
@@ -0,0 +1,13 @@
1
+ When(/^I run "(.*?)"$/) do |command_line|
2
+ call = "#{prefix}#{command_line}"
3
+ @call_result = `#{call}`
4
+ end
5
+
6
+ When(/I get help for "(.*)"/) do |app_name|
7
+ @app_name = app_name
8
+ step %(I run "#{@app_name} help")
9
+ end
10
+
11
+ Then(/the exit status should be (.*)/) do |status|
12
+ expect($CHILD_STATUS.to_i).to eq status.to_i
13
+ end
@@ -0,0 +1,47 @@
1
+ Then(/^alpaca build file (.*?)$/) do |project_file|
2
+ proj = File.basename(project_file, '.*')
3
+ build_project = /#{proj} -> (.*?)\\#{project_file}/
4
+ expect(@call_result.match(build_project)).to_not be nil
5
+ end
6
+
7
+ Then(/^alpaca do not build file (.*?)$/) do |project_file|
8
+ proj = File.basename(project_file, '.*')
9
+ build_project = /#{proj} -> (.*?)\\#{project_file}/
10
+ expect(@call_result.match(build_project)).to be nil
11
+ end
12
+
13
+ Then(/^alpaca restore nuget packages for (.*?)$/) do |solution_file|
14
+ solution_dir = File.dirname(File.expand_path(solution_file))
15
+ nuget_call = /Nuget.exe restore #{File.expand_path(solution_file)}/
16
+ expect(@call_result.match(nuget_call)).to_not be nil
17
+ expect(Dir.glob(solution_dir + '/packages/*').count).to be > 0
18
+ end
19
+
20
+ Then(/^solution has failing unit test$/) do
21
+ # nothing to do here as there is failing unit test in solution 2
22
+ # step is used only as a marker in reports
23
+ end
24
+
25
+ Then(/^alpaca generate unit test results (.*?)$/) do |results_file|
26
+ expect(File.exist?(results_file)).to be true
27
+ end
28
+
29
+ Then(/^alpaca generate test coverage summary (.*?)$/) do |summary_file|
30
+ expect(File.exist?(summary_file)).to be true
31
+ end
32
+
33
+ Then(/^alpaca generate unit tests report (.*?)$/) do |report_file|
34
+ expect(File.exist?(report_file)).to be true
35
+ end
36
+
37
+ Then(/^alpaca generate coverage report (.*?)$/) do |index_file|
38
+ expect(File.exist?(index_file)).to be true
39
+ end
40
+
41
+ Then(/^alpaca creates (.*?)$/) do |package_file|
42
+ expect(File.exist?(package_file)).to be true
43
+ end
44
+
45
+ AfterStep('@teardown_changes') do
46
+ `git stash save --keep-index --include-untracked`
47
+ end
@@ -0,0 +1,10 @@
1
+ require 'rbconfig'
2
+
3
+ def prefix
4
+ case RbConfig::CONFIG['host_os']
5
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
6
+ 'bundle exec ruby bin/'
7
+ else
8
+ 'bin/'
9
+ end
10
+ end
@@ -0,0 +1,43 @@
1
+ @windows
2
+ Feature: Alpaca can work with Visual Studio solutions
3
+ In order to work with visual studio solutions I need to be sure
4
+ that alpaca can be used as a build tool for them
5
+
6
+ Scenario: Alpaca compile solution
7
+ When I run "alpaca compile"
8
+ And alpaca build file TestSolution.exe
9
+ And alpaca do not build file TestSolution.nobuild.exe
10
+ And alpaca restore nuget packages for test_data/sln2/SolutionName.sln
11
+ And alpaca build file ProjectName.dll
12
+ And alpaca build file ProjectName2.dll
13
+ And the exit status should be 0
14
+
15
+ Scenario: Alpaca test solution
16
+ When I run "alpaca test"
17
+ And solution has failing unit test
18
+ Then the exit status should be 256
19
+
20
+ Scenario: Alpaca test with coverage solution
21
+ When I run "alpaca test -c"
22
+ Then alpaca generate unit test results test_data/sln2/.tests/UnitTestsResult.xml
23
+ And alpaca generate test coverage summary test_data/sln2/.tests/coverage.xml
24
+ And the exit status should be 0
25
+
26
+ Scenario: Alpaca report tests results
27
+ When I run "alpaca report"
28
+ Then alpaca generate unit tests report test_data/sln2/.tests/UnitTestsResult.html
29
+ Then alpaca generate coverage report test_data/sln2/.tests/index.htm
30
+
31
+ Scenario: Alpaca pack solution
32
+ When I run "alpaca pack"
33
+ Then alpaca creates test_data/sln1/.output/TestData.FirstSolution.0.0.1-alpha.nupkg
34
+ Then alpaca creates test_data/sln1/.output/TestData.FirstSolution.0.0.1-alpha.symbols.nupkg
35
+ And alpaca creates test_data/sln2/.output/TestData.SecondSolution.2.0.11.nupkg
36
+ And alpaca creates test_data/sln2/.output/TestData.SecondSolution.2.0.11.symbols.nupkg
37
+ And the exit status should be 0
38
+
39
+ @teardown_changes
40
+ Scenario: Alpaca release package
41
+ When I run "alpaca -p '**/TestSolution.sln' release --no-push"
42
+ Then alpaca creates test_data/sln1/.output/TestData.FirstSolution.0.0.1.nupkg
43
+ And the exit status should be 0
@@ -0,0 +1,4 @@
1
+ require 'alpacabuildtool/application'
2
+ require 'alpacabuildtool/versioning/versioning'
3
+
4
+ # :main: README.rdoc
@@ -0,0 +1,195 @@
1
+ require 'alpacabuildtool/log/log'
2
+ require 'alpacabuildtool/entities/solution'
3
+ require 'alpacabuildtool/managers/build_manager'
4
+ require 'alpacabuildtool/managers/package_manager'
5
+ require 'alpacabuildtool/managers/test_manager'
6
+ require 'alpacabuildtool/managers/report_manager'
7
+
8
+ module AlpacaBuildTool
9
+ ##
10
+ # Application is a main entry point for CLI
11
+ class Application
12
+ include Log
13
+
14
+ ##
15
+ # Compiles solution [s]
16
+ #
17
+ # +pattern+:: pattern for solutions search
18
+ # +options+:: hash with compilation options
19
+ # <tt>options[:debug] = true</tt> is to compile solution in debug mode<br>
20
+ # <tt>options[:update_version] = true</tt> is to update project versions
21
+ # before compiling
22
+ #
23
+ # app.compile('**/*.sln', debug: true, update_version: true)
24
+ # # => building found solutions in debug mode
25
+ # # with updating project versions
26
+ def compile(pattern, options)
27
+ log.header 'Compile'
28
+ each_solution(pattern) do |solution|
29
+ build_manager = BuildManager.new(solution)
30
+ build_manager.build(options[:debug], options[:update_version])
31
+ end
32
+ end
33
+
34
+ ##
35
+ # Run tests for solution [s]
36
+ #
37
+ # +pattern+:: pattern for solutions search
38
+ # +options+:: hash with testing options
39
+ # <tt>options[:debug] = true</tt> is to run tests in debug mode<br>
40
+ # <tt>options[:coverage] = true</tt> is to run coverage<br>
41
+ # <tt>options[:type] = 'all'</tt> is to run 'all' test types
42
+ # ('all', 'unit', 'service')
43
+ #
44
+ # app.test('**/*.sln', coverage: true, type: 'unit')
45
+ # # => running unit tests with coverage
46
+ def test(pattern, options)
47
+ log.header 'Test'
48
+ each_solution(pattern) do |solution|
49
+ test_projects = solution.specific_projects(options[:type])
50
+ next log.info 'no tests discovered' if test_projects.empty?
51
+ test_manager = TestManager.new(solution)
52
+ test_manager.test(test_projects, options[:coverage], options[:debug])
53
+ end
54
+ end
55
+
56
+ ##
57
+ # Convert test results into reports for solution [s]
58
+ #
59
+ # +pattern+:: pattern for solutions search
60
+ # +options+:: hash with reporting options
61
+ # <tt>options[:type] = 'all'</tt> is to convert 'all' results into reports
62
+ # ('all', 'tests', 'coverage')
63
+ #
64
+ # app.report('**/*.sln', type: 'coverage')
65
+ # # => converting coverage results into html reports
66
+ def report(pattern, options)
67
+ log.header 'Report'
68
+ each_solution(pattern) do |solution|
69
+ report_manager = ReportManager.new(solution)
70
+ report_manager.convert(options[:type])
71
+ end
72
+ end
73
+
74
+ ##
75
+ # Create packages for solution [s]
76
+ #
77
+ # +pattern+:: pattern for solutions search
78
+ # +options+:: hash with packaging options
79
+ # <tt>options[:debug] = true</tt> is to create packages from debug mode<br\>
80
+ # <tt>options[:push] = true</tt> is to push packages after they are created
81
+ # <br\>
82
+ # <tt>options[:force] = true</tt> is to create/push packages even if it has
83
+ # no changes
84
+ #
85
+ # app.package('**/*.sln')
86
+ # # => creating only packages with changes in release mode without
87
+ # # pushing them
88
+ def package(pattern, options)
89
+ log.header 'Package'
90
+ each_solution(pattern) do |solution|
91
+ version = solution.package_version
92
+ package_manager = PackageManager.new(solution)
93
+ (solution.configuration['packages'] || []).each do |package|
94
+ package_manager.create_package(package, version, options)
95
+ end
96
+ end
97
+ end
98
+
99
+ ##
100
+ # Release packages for solution [s]
101
+ #
102
+ # Updates .semver file to get release version if it is not release yet
103
+ # Rebuilds solution and create release package
104
+ # Changes are checked from last release package
105
+ #
106
+ # +pattern+:: pattern for solutions search
107
+ # +options+:: hash with releasing options
108
+ # <tt>options[:push] = true</tt> is to push packages after they are created
109
+ # <br>
110
+ # <tt>options[:force] = true</tt> is to create/push packages even if it has
111
+ # no changes
112
+ #
113
+ # app.release('**/*.sln')
114
+ # # => creating only packages with changes without pushing them
115
+ def release(pattern, options)
116
+ log.header 'Release'
117
+ each_solution(pattern) do |solution|
118
+ semver = Versioning.find(solution.dir)
119
+ semver.release if semver.prerelease?
120
+ Versioning.save semver
121
+ end
122
+ compile(pattern, debug: false, update_version: true)
123
+ test(pattern, {})
124
+ options[:debug] = false
125
+ package(pattern, options)
126
+ end
127
+
128
+ ##
129
+ # Update .semver files for solution [s]
130
+ #
131
+ # +pattern+:: pattern for solutions search
132
+ # +options+:: hash with releasing options
133
+ # <tt>options['dimension'] = :patch</tt> is to update version patch
134
+ # (major, minor, patch, prerelease)
135
+ #
136
+ # app.update('**/*.sln', 'dimension' => :minor)
137
+ # # => increase minor version in .semver by 1
138
+ def update(pattern, options)
139
+ log.header 'Update'
140
+ each_solution(pattern) do |solution|
141
+ semver = Versioning.find(solution.dir)
142
+ semver.increase(options['dimension'].to_sym)
143
+ Versioning.save semver
144
+ end
145
+ end
146
+
147
+ ##
148
+ # Update/create *~/.alpaca.conf*
149
+ #
150
+ # +properties+:: array of properties to store in global configuration
151
+ # in format node1.node2.property=value
152
+ #
153
+ # app.configure_global(['hello.world=yay'])
154
+ # # => produce yaml text in ~/.alpaca.conf:
155
+ # # hello:
156
+ # # world: yay
157
+ def configure_global(properties)
158
+ log.header 'Configure'
159
+ Configuration.set(properties)
160
+ end
161
+
162
+ ##
163
+ # Update/create *local configuration*
164
+ #
165
+ # +pattern+:: pattern for solutions search
166
+ # +properties+:: array of properties to store in global configuration
167
+ # in format node1.node2.property=value
168
+ #
169
+ # app.configure_local('**/*.sln', ['hello.world=yay'])
170
+ # # => produce yaml text in .alpaca.conf for each solution:
171
+ # # hello:
172
+ # # world: yay
173
+ def configure_local(pattern, properties)
174
+ log.header 'Configure'
175
+ Solutions.each(pattern) do |solution|
176
+ log.puts "saving configuration for #{solution.name}"
177
+ Configuration.new(solution).set(properties)
178
+ end
179
+ end
180
+
181
+ private
182
+
183
+ def each_solution(pattern)
184
+ Dir.glob(pattern).each do |file|
185
+ next unless File.file?(file) && file.end_with?('.sln')
186
+ solution = Solution.new(file)
187
+ log.puts solution
188
+ next log.info 'no build solution' if solution.no_build?
189
+ Dir.chdir(solution.dir) do
190
+ yield solution
191
+ end
192
+ end
193
+ end
194
+ end
195
+ end