distrib_builder 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +5 -0
- data/CMakeLists.txt +2 -0
- data/DistribBuilder.yml +9 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +31 -0
- data/MIT-LICENSE +20 -0
- data/README.md +16 -0
- data/distrib_builder.gemspec +8 -2
- data/lib/distrib_builder/builder.rb +12 -0
- data/lib/distrib_builder/templates/DistribBuilder.yml +80 -0
- data/lib/distrib_builder/version.rb +3 -0
- data/lib/distrib_builder/versioner/argument_processor.rb +72 -0
- data/lib/distrib_builder/versioner/file_processor.rb +75 -0
- data/lib/distrib_builder/versioner/logger.rb +79 -0
- data/lib/distrib_builder/versioner/version_processor.rb +50 -0
- data/lib/distrib_builder/versioner.rb +87 -0
- data/lib/distrib_builder.rb +37 -4
- data/spec/lib/distrib_builder/builder_spec.rb +6 -0
- data/spec/lib/distrib_builder/versioner/argument_processor_spec.rb +133 -0
- data/spec/lib/distrib_builder/versioner/file_processor_spec.rb +84 -0
- data/spec/lib/distrib_builder/versioner/logger_spec.rb +77 -0
- data/spec/lib/distrib_builder/versioner/version_processor_spec.rb +57 -0
- data/spec/lib/distrib_builder/versioner_spec.rb +109 -0
- data/spec/lib/distrib_builder_spec.rb +34 -0
- data/spec/spec_helper.rb +6 -0
- metadata +47 -4
- data/README +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cf1be6311e91b48dc2a0818371c64339aa3cfe1
|
4
|
+
data.tar.gz: 616a226a531de42bd712332042b854d0ea651be0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b04a7b6de504e2114581fec720c612b6751215c6bba99fce35c79cb1e8beeea0c1d649bdf26cf5519f4a33fea174ba5109dd753ee877079f91136dfb118555f
|
7
|
+
data.tar.gz: df59cd460dcf4a4d79152da8b0455baf032a5a9244d23f31c62730697a31e0b689a444d0a01ade4c38682fc53b1cf903fb70a27b35bfe27d3b6cf8b2dc9616a7
|
data/CHANGES
ADDED
data/CMakeLists.txt
ADDED
data/DistribBuilder.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
distrib_builder (0.0.2)
|
5
|
+
mustache (~> 1.0, >= 1.0.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
mustache (1.0.3)
|
12
|
+
rspec (3.5.0)
|
13
|
+
rspec-core (~> 3.5.0)
|
14
|
+
rspec-expectations (~> 3.5.0)
|
15
|
+
rspec-mocks (~> 3.5.0)
|
16
|
+
rspec-core (3.5.4)
|
17
|
+
rspec-support (~> 3.5.0)
|
18
|
+
rspec-expectations (3.5.0)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.5.0)
|
21
|
+
rspec-mocks (3.5.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.5.0)
|
24
|
+
rspec-support (3.5.0)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
distrib_builder!
|
31
|
+
rspec
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Artem Rufanov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Distrib Builder
|
2
|
+
## Usage
|
3
|
+
Run distrib builder --help to know pararmetes:
|
4
|
+
* family: Window, Unix, MacOSX
|
5
|
+
* os: All, Windows2000, ...
|
6
|
+
* arch: Win32, X64, I686, X86_64
|
7
|
+
toolset: MSVC8, MSVC10, MSVC12, Gcc
|
8
|
+
|
9
|
+
## How to make you own gem
|
10
|
+
Introduction is here: http://guides.rubygems.org/make-your-own-gem/
|
11
|
+
Here is usefull commands:
|
12
|
+
* gem build distrib_builder.gemspec
|
13
|
+
* gem list distrib_builder
|
14
|
+
* gem install ./distrib_builder-0.0.1.gem
|
15
|
+
* gem uninstall distrib_builder
|
16
|
+
|
data/distrib_builder.gemspec
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'distrib_builder/version'
|
4
|
+
|
1
5
|
Gem::Specification.new do |s|
|
2
6
|
s.name = 'distrib_builder'
|
3
|
-
s.version =
|
7
|
+
s.version = DistribBuilder::VERSION
|
4
8
|
s.executables = 'distrib_builder'
|
5
9
|
s.date = '2015-03-17'
|
6
10
|
s.summary = 'Distrib Builder'
|
7
11
|
s.description = 'Distrib Builder'
|
8
|
-
s.authors = ['Artem Rufanov']
|
12
|
+
s.authors = ['Artem Rufanov', 'Nikita Levchuk']
|
9
13
|
s.email = 'developers@majoron.com'
|
10
14
|
s.files = Dir.glob("**/*")
|
11
15
|
s.homepage = 'http://rubygems.org/gems/distrib_builder'
|
16
|
+
|
17
|
+
s.add_runtime_dependency "mustache", "~> 1.0", ">= 1.0.3"
|
12
18
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
files:
|
2
|
+
"CMakeLists.txt": [
|
3
|
+
'_VERSION "\d+\.\d+\.\d+"',
|
4
|
+
'_BUILD "\d+"'
|
5
|
+
]
|
6
|
+
"ComputerAgent/include/ComputerAgentConstants.hpp": [
|
7
|
+
'APPVERSION = "\d+\.\d+\.\d+"'
|
8
|
+
]
|
9
|
+
"ComputerAgent/res/windows/ComputerAgent.rc": [
|
10
|
+
'FILEVERSION \d+,\d+,\d+,\d+',
|
11
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+',
|
12
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"',
|
13
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"'
|
14
|
+
]
|
15
|
+
"CoreFeatures/include/CoreFeatures.hpp": [
|
16
|
+
'_VERSION_STR\s+"\d+\.\d+\.\d+"'
|
17
|
+
]
|
18
|
+
"CoreFeatures/res/windows/CoreFeatures.rc": [
|
19
|
+
'FILEVERSION \d+,\d+,\d+,\d+',
|
20
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+',
|
21
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"',
|
22
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"'
|
23
|
+
]
|
24
|
+
"EmployeeAgent/include/EmployeeAgentConstants.hpp": [
|
25
|
+
'APPVERSION = "\d+\.\d+\.\d+"'
|
26
|
+
]
|
27
|
+
"EmployeeAgent/res/windows/EmployeeAgent.rc": [
|
28
|
+
'FILEVERSION \d+,\d+,\d+,\d+',
|
29
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+',
|
30
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"',
|
31
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"'
|
32
|
+
]
|
33
|
+
"LicenseHub/include/LicenseHubConstants.hpp": [
|
34
|
+
'APPVERSION = "\d+\.\d+\.\d+"'
|
35
|
+
]
|
36
|
+
"LicenseHub/res/windows/LicenseHub.rc": [
|
37
|
+
'FILEVERSION \d+,\d+,\d+,\d+',
|
38
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+',
|
39
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"',
|
40
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"'
|
41
|
+
]
|
42
|
+
"Packaging/WiXAddons/res/windows/WiXAddons.rc": [
|
43
|
+
'FILEVERSION \d+,\d+,\d+,\d+',
|
44
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+',
|
45
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"',
|
46
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"'
|
47
|
+
]
|
48
|
+
"TimeTrackerd/include/TimeTrackerdConstants.hpp": [
|
49
|
+
'APPVERSION = "\d+\.\d+\.\d+"'
|
50
|
+
]
|
51
|
+
"TimeTrackerd/res/windows/TimeTrackerd.rc": [
|
52
|
+
'FILEVERSION \d+,\d+,\d+,\d+',
|
53
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+',
|
54
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"',
|
55
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"'
|
56
|
+
]
|
57
|
+
"UnitTests/TimeTracker/res/windows/CoreFeatures.rc": [
|
58
|
+
'FILEVERSION \d+,\d+,\d+,\d+',
|
59
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+',
|
60
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"',
|
61
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"'
|
62
|
+
]
|
63
|
+
|
64
|
+
patterns:
|
65
|
+
'FILEVERSION \d+,\d+,\d+,\d+': 'FILEVERSION {{major}},{{minor}},{{patch}},{{build}}'
|
66
|
+
'PRODUCTVERSION \d+,\d+,\d+,\d+': 'PRODUCTVERSION {{major}},{{minor}},{{patch}},{{build}}'
|
67
|
+
'VALUE "FileVersion", "\d+, *\d+, *\d+, *\d+"': 'VALUE "FileVersion", "{{major}}, {{minor}}, {{patch}}, {{build}}"'
|
68
|
+
'VALUE "ProductVersion", "\d+, *\d+, *\d+, *\d+"': 'VALUE "ProductVersion", "{{major}}, {{minor}}, {{patch}}, {{build}}"'
|
69
|
+
'APPVERSION = "\d+\.\d+\.\d+"': 'APPVERSION = "{{major}}.{{minor}}.{{patch}}"'
|
70
|
+
'define ProductVersion = "\d+\.\d+\.\d+\.\d+"': 'define ProductVersion = "{{major}}.{{minor}}.{{patch}}.{{build}}"'
|
71
|
+
'USERAGENT = "UserAgent/\d+\.\d+\.\d+"': 'USERAGENT = "UserAgent/{{major}}.{{minor}}.{{patch}}"'
|
72
|
+
'SESSIONAGENT = "SessionAgent/\d+\.\d+\.\d+"': 'SESSIONAGENT = "SessionAgent/{{major}}.{{minor}}.{{patch}}"'
|
73
|
+
'USERAGENT = "TimeTrackerd/\d+\.\d+\.\d+"': 'USERAGENT = "TimeTrackerd/{{major}}.{{minor}}.{{patch}}"'
|
74
|
+
'AC_INIT\(\[TimeTracker\]\,\[\d+\.\d+\.\d+\]': 'AC_INIT\(\[TimeTracker\]\,\[{{major}}.{{minor}}.{{patch}}\]'
|
75
|
+
'^project.version=\d+\.\d+\.\d+$': '^project.version={{major}}.{{minor}}.{{patch}}$'
|
76
|
+
'\$\{Version\}\s+\d+\.\d+\.\d+': '\$\{Version\} {{major}}.{{minor}}.{{patch}}'
|
77
|
+
'%version \d+\.\d+\.*\d*': '%version {{major}}.{{minor}}.{{patch}}'
|
78
|
+
'_VERSION_STR\s+"\d+\.\d+\.\d+"': '_VERSION_STR "{{major}}.{{minor}}.{{patch}}"'
|
79
|
+
'_VERSION "\d+\.\d+\.\d+"': '_VERSION "{{major}}.{{minor}}.{{patch}}"'
|
80
|
+
'_BUILD "\d+"': '_BUILD "{{build}}"'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module DistribBuilder
|
2
|
+
module Versioner
|
3
|
+
class ArgumentProcessor
|
4
|
+
attr_accessor :show, :setup_version, :setup_build, :increment_build, :decrement_build, :verbose, :logger,
|
5
|
+
:option_keys
|
6
|
+
|
7
|
+
# nlevchuk: need to use logger here without passing it through argument to .new()
|
8
|
+
def initialize(args, logger=nil)
|
9
|
+
@args = args
|
10
|
+
@option_keys = []
|
11
|
+
@logger = logger
|
12
|
+
@show = nil
|
13
|
+
@setup_version = nil
|
14
|
+
@setup_build = nil
|
15
|
+
@increment_build = false
|
16
|
+
@decrement_build = false
|
17
|
+
@verbose = false
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse
|
21
|
+
parser = OptionParser.new { |opts|
|
22
|
+
opts.banner = 'Usage: distrib_builder version [options]'
|
23
|
+
|
24
|
+
opts.on('-s', '--show [all|version|build]', String, [:all, :version, :build], 'Show current version and/or build') do |v|
|
25
|
+
@show = v
|
26
|
+
@option_keys << "show"
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on('--setup-version [VERSION]', String, 'Setup version VERSION in format: 1.2.3') do |v|
|
30
|
+
@setup_version = v
|
31
|
+
@option_keys << "setup-version"
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('--setup-build [BUILD]', String, 'Setup build in format: 1') do |v|
|
35
|
+
@setup_build = v
|
36
|
+
@option_keys << "setup-build"
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on('-i', '--increment-build', 'Increment current build by 1') do
|
40
|
+
@increment_build = true
|
41
|
+
@option_keys << "increment-build"
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on('-d', '--decrement-build', 'Decrement current build by 1') do
|
45
|
+
@decrement_build = true
|
46
|
+
@option_keys << "decrement-build"
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('--verbose', 'Output detail information about changed files') do
|
50
|
+
@verbose = true
|
51
|
+
@option_keys << "verbose"
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on('--help', 'Display нelp') {
|
55
|
+
puts opts
|
56
|
+
exit
|
57
|
+
}
|
58
|
+
}
|
59
|
+
parser.parse!(@args.dup)
|
60
|
+
end
|
61
|
+
|
62
|
+
def validate_options
|
63
|
+
if option_keys.include?("setup-build") && (setup_build.nil? || !/^\d+$/.match(setup_build))
|
64
|
+
logger.incorrect_setup_build(setup_build)
|
65
|
+
end
|
66
|
+
if option_keys.include?("setup-version") && (setup_version.nil? || !/^\d+\.\d+\.\d+$/.match(setup_version))
|
67
|
+
logger.incorrect_setup_version(setup_version)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module DistribBuilder
|
2
|
+
module Versioner
|
3
|
+
class FileProcessor
|
4
|
+
attr_accessor :config_path, :cmakelist_path, :config, :cmakelist, :logger
|
5
|
+
|
6
|
+
# nlevchuk: need to use logger here without passing it through argument to .new()
|
7
|
+
def initialize(logger=nil)
|
8
|
+
@logger = logger
|
9
|
+
@config_path = WORK_DIR + "/" + CONFIG_FILE
|
10
|
+
@cmakelist_path = WORK_DIR + "/" + CMAKELIST_FILE
|
11
|
+
@config = nil
|
12
|
+
@cmakelist = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_existing_files
|
16
|
+
unless File.exists?(config_path) && File.exists?(cmakelist_path)
|
17
|
+
logger.missing_files
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def check_mandatory_sections_in_config
|
22
|
+
unless (config.has_key?('files') && !config['files'].empty?) &&
|
23
|
+
(config.has_key?('patterns') && !config['patterns'].empty?)
|
24
|
+
logger.missing_mandatory_sections_in_config
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def read_config_files
|
29
|
+
check_existing_files
|
30
|
+
@config = YAML.load_file(config_path)
|
31
|
+
File.open(cmakelist_path, 'r') { |file| @cmakelist = file.read }
|
32
|
+
end
|
33
|
+
|
34
|
+
def read_version_and_build
|
35
|
+
version = []
|
36
|
+
File.readlines(cmakelist_path).each do |line|
|
37
|
+
if line.match(VERSION_PATTERN)
|
38
|
+
line.slice!(/.*_VERSION/)
|
39
|
+
line.gsub!(/[\"\) ]/, '')
|
40
|
+
version = line.split('.').map { |s| s.to_i }
|
41
|
+
end
|
42
|
+
if line.match(BUILD_PATTERN)
|
43
|
+
line.slice!(/.*_BUILD/)
|
44
|
+
line.gsub!(/[\"\) ]/, '')
|
45
|
+
version << line.to_i
|
46
|
+
end
|
47
|
+
end
|
48
|
+
version
|
49
|
+
end
|
50
|
+
|
51
|
+
def replace_version_and_build_in_files(versions_hash)
|
52
|
+
check_mandatory_sections_in_config
|
53
|
+
config['files'].each do |path, patterns_array|
|
54
|
+
full_path = WORK_DIR + "/" + path
|
55
|
+
logger.file_not_found(full_path) unless File.exists?(full_path)
|
56
|
+
text = File.read(full_path)
|
57
|
+
|
58
|
+
patterns_array.each do |pattern|
|
59
|
+
if text.match(pattern)
|
60
|
+
prepared_pattern = config['patterns'][pattern]
|
61
|
+
template = Mustache.render(prepared_pattern, versions_hash)
|
62
|
+
text.gsub!(Regexp.new(pattern), template)
|
63
|
+
logger.found_and_replace_pattern_in_text(pattern, path)
|
64
|
+
else
|
65
|
+
logger.pattern_not_match(pattern, path)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
File.open(full_path, 'w') { |file| file.puts text }
|
70
|
+
logger.write_changes_into_file(path)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module DistribBuilder
|
2
|
+
module Versioner
|
3
|
+
class Logger
|
4
|
+
attr_accessor :verbose
|
5
|
+
|
6
|
+
def initialize(verbose=false)
|
7
|
+
@verbose = verbose
|
8
|
+
end
|
9
|
+
|
10
|
+
def missing_files
|
11
|
+
raise "DistribBuilder.yml or CMakeLists.txt is missing in current directory"
|
12
|
+
end
|
13
|
+
|
14
|
+
def show_current_version(version)
|
15
|
+
puts "Current version: #{version}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def show_current_build(build)
|
19
|
+
puts "Current build: #{build}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def new_version(version)
|
23
|
+
puts "New version: #{version}" if @verbose
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_changed(build)
|
27
|
+
puts "Build changed to #{build}" if @verbose
|
28
|
+
end
|
29
|
+
|
30
|
+
def version_changed(version)
|
31
|
+
puts "Version changed to #{version}" if @verbose
|
32
|
+
end
|
33
|
+
|
34
|
+
def file_not_found(path)
|
35
|
+
raise "File not found: #{path}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def found_and_replace_pattern_in_text(pattern, path)
|
39
|
+
puts "Pattern '#{pattern}' was found and replaced in the file '#{path}'" if @verbose
|
40
|
+
end
|
41
|
+
|
42
|
+
def write_changes_into_file(path)
|
43
|
+
puts "Write new changes into file '#{path}'" if @verbose
|
44
|
+
end
|
45
|
+
|
46
|
+
def start_increment_build
|
47
|
+
puts "Start increment build process" if @verbose
|
48
|
+
end
|
49
|
+
|
50
|
+
def start_decrement_build
|
51
|
+
puts "Start decrement build process" if @verbose
|
52
|
+
end
|
53
|
+
|
54
|
+
def start_setup_build
|
55
|
+
puts "Start setup build process" if @verbose
|
56
|
+
end
|
57
|
+
|
58
|
+
def start_setup_version
|
59
|
+
puts "Start setup version process" if @verbose
|
60
|
+
end
|
61
|
+
|
62
|
+
def pattern_not_match(pattern, path)
|
63
|
+
raise "Pattern '#{pattern}' was not matched in file '#{path}'"
|
64
|
+
end
|
65
|
+
|
66
|
+
def missing_mandatory_sections_in_config
|
67
|
+
raise "DistribBuilder.yml must contains both files and patterns sections. See lib/distrib_builder/templates/DistribBuilder.yml for more information"
|
68
|
+
end
|
69
|
+
|
70
|
+
def incorrect_setup_build(build)
|
71
|
+
raise "Incorrect build number. It must be digit but it was '#{build}'"
|
72
|
+
end
|
73
|
+
|
74
|
+
def incorrect_setup_version(version)
|
75
|
+
raise "Incorrect version number. It must be in format X.X.X but it was '#{version}'"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module DistribBuilder
|
2
|
+
module Versioner
|
3
|
+
class VersionProcessor
|
4
|
+
attr_accessor :major, :minor, :patch, :build
|
5
|
+
|
6
|
+
def initialize(array)
|
7
|
+
@major = array[0]
|
8
|
+
@minor = array[1]
|
9
|
+
@patch = array[2]
|
10
|
+
@build = array[3]
|
11
|
+
end
|
12
|
+
|
13
|
+
def versions_hash
|
14
|
+
{
|
15
|
+
major: major,
|
16
|
+
minor: minor,
|
17
|
+
patch: patch,
|
18
|
+
build: build
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# => 0.5.0
|
23
|
+
def only_version
|
24
|
+
[major, minor, patch].join(".")
|
25
|
+
end
|
26
|
+
|
27
|
+
# => 0.5.0.0
|
28
|
+
def full_version
|
29
|
+
[major, minor, patch, build].join(".")
|
30
|
+
end
|
31
|
+
|
32
|
+
def build_up!
|
33
|
+
@build += 1
|
34
|
+
end
|
35
|
+
|
36
|
+
def build_down!
|
37
|
+
return if build == 0
|
38
|
+
@build -= 1
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_build!(build)
|
42
|
+
@build = build.to_i
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_version!(version)
|
46
|
+
@major, @minor, @patch = version.split(".").map{ |d| d.to_i }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'distrib_builder/versioner/argument_processor'
|
2
|
+
require 'distrib_builder/versioner/file_processor'
|
3
|
+
require 'distrib_builder/versioner/version_processor'
|
4
|
+
require 'distrib_builder/versioner/logger'
|
5
|
+
|
6
|
+
module DistribBuilder
|
7
|
+
module Versioner
|
8
|
+
class Main
|
9
|
+
attr_accessor :arg_processor, :file_processor, :version_processor, :logger
|
10
|
+
|
11
|
+
def initialize(args)
|
12
|
+
@args = args
|
13
|
+
@arg_processor = nil
|
14
|
+
@file_processor = nil
|
15
|
+
@version_processor = nil
|
16
|
+
@logger = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
prepare_processors
|
21
|
+
if arg_processor.show; show
|
22
|
+
elsif arg_processor.increment_build; increment_build
|
23
|
+
elsif arg_processor.decrement_build; decrement_build
|
24
|
+
elsif arg_processor.setup_build; setup_build
|
25
|
+
elsif arg_processor.setup_version; setup_version
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def increment_build
|
30
|
+
logger.start_increment_build
|
31
|
+
version_processor.build_up!
|
32
|
+
logger.new_version(version_processor.full_version)
|
33
|
+
file_processor.replace_version_and_build_in_files(version_processor.versions_hash)
|
34
|
+
logger.build_changed(version_processor.build)
|
35
|
+
end
|
36
|
+
|
37
|
+
def decrement_build
|
38
|
+
logger.start_decrement_build
|
39
|
+
version_processor.build_down!
|
40
|
+
logger.new_version(version_processor.full_version)
|
41
|
+
file_processor.replace_version_and_build_in_files(version_processor.versions_hash)
|
42
|
+
logger.build_changed(version_processor.build)
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_build
|
46
|
+
logger.start_setup_build
|
47
|
+
version_processor.setup_build!(arg_processor.setup_build)
|
48
|
+
logger.new_version(version_processor.full_version)
|
49
|
+
file_processor.replace_version_and_build_in_files(version_processor.versions_hash)
|
50
|
+
logger.build_changed(version_processor.build)
|
51
|
+
end
|
52
|
+
|
53
|
+
def setup_version
|
54
|
+
logger.start_setup_version
|
55
|
+
version_processor.setup_version!(arg_processor.setup_version)
|
56
|
+
logger.new_version(version_processor.full_version)
|
57
|
+
file_processor.replace_version_and_build_in_files(version_processor.versions_hash)
|
58
|
+
logger.version_changed(version_processor.only_version)
|
59
|
+
end
|
60
|
+
|
61
|
+
def show
|
62
|
+
case arg_processor.show
|
63
|
+
when :version
|
64
|
+
logger.show_current_version(version_processor.only_version)
|
65
|
+
when :build
|
66
|
+
logger.show_current_build(version_processor.build)
|
67
|
+
else
|
68
|
+
logger.show_current_version(version_processor.only_version)
|
69
|
+
logger.show_current_build(version_processor.build)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def prepare_processors
|
76
|
+
@logger = Logger.new
|
77
|
+
@arg_processor = ArgumentProcessor.new(@args, logger)
|
78
|
+
@arg_processor.parse
|
79
|
+
@logger.verbose = arg_processor.verbose # nlevchuk: need to fix later
|
80
|
+
@arg_processor.validate_options
|
81
|
+
@file_processor = FileProcessor.new(logger)
|
82
|
+
@file_processor.read_config_files
|
83
|
+
@version_processor = VersionProcessor.new(file_processor.read_version_and_build)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/distrib_builder.rb
CHANGED
@@ -1,11 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'optparse'
|
2
|
+
require 'yaml'
|
3
|
+
require 'mustache'
|
4
|
+
|
5
|
+
require 'distrib_builder/builder'
|
6
|
+
require 'distrib_builder/versioner'
|
7
|
+
require 'distrib_builder/version'
|
4
8
|
|
5
9
|
module DistribBuilder
|
10
|
+
DISTRIB_TYPES = ['build', 'version']
|
11
|
+
WORK_DIR = Dir.pwd
|
12
|
+
CONFIG_FILE = "DistribBuilder.yml"
|
13
|
+
CMAKELIST_FILE = "CMakeLists.txt"
|
14
|
+
VERSION_PATTERN = Regexp.new('_VERSION \"\d+\.\d+\.\d+\"')
|
15
|
+
BUILD_PATTERN = Regexp.new('_BUILD \"\d+\"')
|
16
|
+
|
6
17
|
class Main
|
7
18
|
def self.run
|
8
|
-
|
19
|
+
args = duplicate_argv
|
20
|
+
type = args.shift
|
21
|
+
|
22
|
+
if type == '--version'
|
23
|
+
puts VERSION
|
24
|
+
return
|
25
|
+
elsif !DISTRIB_TYPES.include?(type) && args.empty?
|
26
|
+
puts "Use 'distrib_builder version --help' or 'distrib_builder build --help' for more information"
|
27
|
+
puts "Exit"
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
if type == 'build'
|
32
|
+
Builder::Main.new(args).run
|
33
|
+
else
|
34
|
+
Versioner::Main.new(args).run
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def self.duplicate_argv
|
41
|
+
ARGV.dup
|
9
42
|
end
|
10
43
|
end
|
11
44
|
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DistribBuilder
|
4
|
+
module Versioner
|
5
|
+
describe ArgumentProcessor do
|
6
|
+
it "does take '-s all' argument", broken: true do
|
7
|
+
processor = described_class.new(["-s all"])
|
8
|
+
expect( processor.show ).to be_nil
|
9
|
+
processor.parse
|
10
|
+
expect( processor.show ).to eq(:all)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "does take '--show all' argument", broken: true do
|
14
|
+
processor = described_class.new(["--show all"])
|
15
|
+
expect( processor.show ).to be_nil
|
16
|
+
processor.parse
|
17
|
+
expect( processor.show ).to eq(:all)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does take '-s version' argument", broken: true do
|
21
|
+
processor = described_class.new(["-s version"])
|
22
|
+
expect( processor.show ).to be_nil
|
23
|
+
processor.parse
|
24
|
+
expect( processor.show ).to eq(:version)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "does take '--show version' argument", broken: true do
|
28
|
+
processor = described_class.new(["--show version"])
|
29
|
+
expect( processor.show ).to be_nil
|
30
|
+
processor.parse
|
31
|
+
expect( processor.show ).to eq(:version)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "does take '-s build' argument", broken: true do
|
35
|
+
processor = described_class.new(["-s build"])
|
36
|
+
expect( processor.show ).to be_nil
|
37
|
+
processor.parse
|
38
|
+
expect( processor.show ).to eq(:build)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "does take '--show build' argument", broken: true do
|
42
|
+
processor = described_class.new(["--show build"])
|
43
|
+
expect( processor.show ).to be_nil
|
44
|
+
processor.parse
|
45
|
+
expect( processor.show ).to eq(:build)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does take '-i' argument" do
|
49
|
+
processor = described_class.new(["-i"])
|
50
|
+
expect( processor.increment_build ).to be(false)
|
51
|
+
processor.parse
|
52
|
+
expect( processor.increment_build ).to be(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "does take '--icrement-build' argument" do
|
56
|
+
processor = described_class.new(["--increment-build"])
|
57
|
+
expect( processor.increment_build ).to be(false)
|
58
|
+
processor.parse
|
59
|
+
expect( processor.increment_build ).to be(true)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "does take '-d' argument" do
|
63
|
+
processor = described_class.new(["-d"])
|
64
|
+
expect( processor.decrement_build ).to be(false)
|
65
|
+
processor.parse
|
66
|
+
expect( processor.decrement_build ).to be(true)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "does take '--decrement-build' argument" do
|
70
|
+
processor = described_class.new(["--decrement-build"])
|
71
|
+
expect( processor.decrement_build ).to be(false)
|
72
|
+
processor.parse
|
73
|
+
expect( processor.decrement_build ).to be(true)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "does take '--setup-version 1.2.3' argument", broken: true do
|
77
|
+
processor = described_class.new(["--setup-version 1.2.3"])
|
78
|
+
expect( processor.setup_version ).to be_nil
|
79
|
+
processor.parse
|
80
|
+
expect( processor.setup_version ).to eq("1.2.3")
|
81
|
+
end
|
82
|
+
|
83
|
+
it "does take '--setup-build 1' argument", broken: true do
|
84
|
+
processor = described_class.new(["--setup-build 1"])
|
85
|
+
expect( processor.setup_build ).to be_nil
|
86
|
+
processor.parse
|
87
|
+
expect( processor.setup_build ).to eq("1")
|
88
|
+
end
|
89
|
+
|
90
|
+
context "#validate_options" do
|
91
|
+
let(:processor) { described_class.new([], Logger.new) }
|
92
|
+
|
93
|
+
it "does raise an error if --setup-build argument present but nil" do
|
94
|
+
allow( processor ).to receive(:option_keys).and_return("setup-build")
|
95
|
+
expect( processor.logger ).to receive(:incorrect_setup_build).with(nil)
|
96
|
+
processor.validate_options
|
97
|
+
end
|
98
|
+
|
99
|
+
it "does raise an error if --setup-build present but non a digit" do
|
100
|
+
allow( processor ).to receive(:option_keys).and_return("setup-build")
|
101
|
+
allow( processor ).to receive(:setup_build).and_return("t")
|
102
|
+
expect( processor.logger ).to receive(:incorrect_setup_build).with("t")
|
103
|
+
processor.validate_options
|
104
|
+
end
|
105
|
+
|
106
|
+
it "does be OK if --setup-build present and a digit" do
|
107
|
+
allow( processor ).to receive(:option_keys).and_return("setup-build")
|
108
|
+
allow( processor ).to receive(:setup_build).and_return("123")
|
109
|
+
processor.validate_options
|
110
|
+
end
|
111
|
+
|
112
|
+
it "does raise an error if --setup-version argument present but nil" do
|
113
|
+
allow( processor ).to receive(:option_keys).and_return("setup-version")
|
114
|
+
expect( processor.logger ).to receive(:incorrect_setup_version).with(nil)
|
115
|
+
processor.validate_options
|
116
|
+
end
|
117
|
+
|
118
|
+
it "does raise an error if --setup-version present but non a valid string" do
|
119
|
+
allow( processor ).to receive(:option_keys).and_return("setup-version")
|
120
|
+
allow( processor ).to receive(:setup_version).and_return("t")
|
121
|
+
expect( processor.logger ).to receive(:incorrect_setup_version).with("t")
|
122
|
+
processor.validate_options
|
123
|
+
end
|
124
|
+
|
125
|
+
it "does be OK if --setup-version present and a digit" do
|
126
|
+
allow( processor ).to receive(:option_keys).and_return("setup-version")
|
127
|
+
allow( processor ).to receive(:setup_version).and_return("1.2.3")
|
128
|
+
processor.validate_options
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DistribBuilder
|
4
|
+
module Versioner
|
5
|
+
describe FileProcessor do
|
6
|
+
let(:processor) { described_class.new(Logger.new) }
|
7
|
+
|
8
|
+
context "#check_existing_files" do
|
9
|
+
it "does raise an error unless config file present" do
|
10
|
+
allow( processor ).to receive(:config_path).and_return("")
|
11
|
+
expect( processor.logger ).to receive(:missing_files)
|
12
|
+
processor.check_existing_files
|
13
|
+
end
|
14
|
+
|
15
|
+
it "does raise an error unless cmakelist present" do
|
16
|
+
allow( processor ).to receive(:cmakelist_path).and_return("")
|
17
|
+
expect( processor.logger ).to receive(:missing_files)
|
18
|
+
processor.check_existing_files
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "#check_mandatory_sections_in_config" do
|
23
|
+
it "does raise an error unless files section present" do
|
24
|
+
allow( processor ).to receive(:config).and_return({})
|
25
|
+
expect( processor.logger ).to receive(:missing_mandatory_sections_in_config)
|
26
|
+
processor.check_mandatory_sections_in_config
|
27
|
+
end
|
28
|
+
|
29
|
+
it "does raise an error if files section is empty" do
|
30
|
+
allow( processor ).to receive(:config).and_return('files' => {})
|
31
|
+
expect( processor.logger ).to receive(:missing_mandatory_sections_in_config)
|
32
|
+
processor.check_mandatory_sections_in_config
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does raise an error unless patterns section present" do
|
36
|
+
allow( processor ).to receive(:config).and_return('files' => { 'CMakeLists.txt' => [] })
|
37
|
+
expect( processor.logger ).to receive(:missing_mandatory_sections_in_config)
|
38
|
+
processor.check_mandatory_sections_in_config
|
39
|
+
end
|
40
|
+
|
41
|
+
it "does raise an error if patterns section is empty" do
|
42
|
+
allow( processor ).to receive(:config).and_return('files' => { 'CMakeLists.txt' => [] }, 'patterns' => {})
|
43
|
+
expect( processor.logger ).to receive(:missing_mandatory_sections_in_config)
|
44
|
+
processor.check_mandatory_sections_in_config
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "#read_config_files" do
|
49
|
+
before(:each) do
|
50
|
+
allow( processor ).to receive(:check_existing_files)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "does read config file" do
|
54
|
+
expect( processor.config ).to be_nil
|
55
|
+
processor.read_config_files
|
56
|
+
expect( processor.config ).to_not be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it "does read cmakelist file" do
|
60
|
+
expect( processor.cmakelist ).to be_nil
|
61
|
+
processor.read_config_files
|
62
|
+
expect( processor.cmakelist ).to_not be_nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "#read_version_and_build" do
|
67
|
+
it "does be ok" do
|
68
|
+
processor.read_version_and_build
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "#replace_version_and_build_in_files", broken: true do
|
73
|
+
before(:each) do
|
74
|
+
@versions_hash = { major: 1 }
|
75
|
+
allow( processor ).to receive(:check_mandatory_sections_in_config)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "" do
|
79
|
+
processor.replace_version_and_build_in_files(@versions_hash)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DistribBuilder
|
4
|
+
module Versioner
|
5
|
+
describe Logger do
|
6
|
+
let(:logger) { described_class.new(true) } # verbose = true
|
7
|
+
|
8
|
+
it "does raise an error" do
|
9
|
+
expect{ logger.missing_files }.to raise_error(RuntimeError, /DistribBuilder.yml or CMakeLists.txt is missing in current directory/)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "does print string with current version" do
|
13
|
+
logger.show_current_version("1.2.3")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "does print string with current build" do
|
17
|
+
logger.show_current_build(1)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does print string with new version" do
|
21
|
+
logger.new_version("1.2.3.4")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "does print string about changing build" do
|
25
|
+
logger.build_changed(2)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "does print string about changing version" do
|
29
|
+
logger.version_changed("1.2.3")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "does raise an error" do
|
33
|
+
expect{ logger.file_not_found('CMakeLists.txt') }.to raise_error(RuntimeError, /File not found:/)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "does print string about replacing pattern in file" do
|
37
|
+
logger.found_and_replace_pattern_in_text("_BUILD \d+", "CMakeLists.txt")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "does print string about writing changes into file" do
|
41
|
+
logger.write_changes_into_file('CMakeLists.txt')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "does print string about starting increment build process" do
|
45
|
+
logger.start_increment_build
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does print string about starting decrement build process" do
|
49
|
+
logger.start_decrement_build
|
50
|
+
end
|
51
|
+
|
52
|
+
it "does print string about starting setup build process" do
|
53
|
+
logger.start_setup_build
|
54
|
+
end
|
55
|
+
|
56
|
+
it "does print string about starting setup version process" do
|
57
|
+
logger.start_setup_version
|
58
|
+
end
|
59
|
+
|
60
|
+
it "does raise an error" do
|
61
|
+
expect{ logger.pattern_not_match("_BUILD \d+", 'CMakeLists.txt') }.to raise_error(RuntimeError, /was not matched in file/)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "does raise an error" do
|
65
|
+
expect{ logger.missing_mandatory_sections_in_config }.to raise_error(RuntimeError, /DistribBuilder.yml must contains both files and patterns sections/)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "does raise an error" do
|
69
|
+
expect{ logger.incorrect_setup_build("A") }.to raise_error(RuntimeError, /Incorrect build number. It must be digit but it was 'A'/)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "does raise an error" do
|
73
|
+
expect{ logger.incorrect_setup_version("123") }.to raise_error(RuntimeError, /Incorrect version number. It must be in format X.X.X but it was '123'/)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DistribBuilder
|
4
|
+
module Versioner
|
5
|
+
describe VersionProcessor do
|
6
|
+
let(:processor) { described_class.new([1,2,3,4]) }
|
7
|
+
|
8
|
+
it "does to be" do
|
9
|
+
expect( VersionProcessor.new([]) ).to be
|
10
|
+
end
|
11
|
+
|
12
|
+
it "does return version's hash with names" do
|
13
|
+
expect( processor.versions_hash ).to eq({ major: 1, minor: 2, patch: 3, build: 4 })
|
14
|
+
end
|
15
|
+
|
16
|
+
it "does return 1.2.3" do
|
17
|
+
expect( processor.only_version ).to eq("1.2.3")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does return 1.2.3.4" do
|
21
|
+
expect( processor.full_version ).to eq("1.2.3.4")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "does up build (mutate)" do
|
25
|
+
expect( processor.build ).to eq(4)
|
26
|
+
processor.build_up!
|
27
|
+
expect( processor.build ).to eq(5)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "does down build (mutate)" do
|
31
|
+
expect( processor.build ).to eq(4)
|
32
|
+
processor.build_down!
|
33
|
+
expect( processor.build ).to eq(3)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "does not down build if build == 0" do
|
37
|
+
processor.build = 0
|
38
|
+
expect( processor.build ).to eq(0)
|
39
|
+
processor.build_down!
|
40
|
+
expect( processor.build ).to eq(0)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "does setup build (mutate)" do
|
44
|
+
processor.build = 5
|
45
|
+
expect( processor.build ).to eq(5)
|
46
|
+
processor.setup_build!(12)
|
47
|
+
expect( processor.build ).to eq(12)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "does setup version (mutate)" do
|
51
|
+
expect( processor.only_version ).to eq("1.2.3")
|
52
|
+
processor.setup_version!("4.5.6")
|
53
|
+
expect( processor.only_version ).to eq("4.5.6")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DistribBuilder
|
4
|
+
module Versioner
|
5
|
+
describe Main do
|
6
|
+
let(:versioner) { described_class.new([]) }
|
7
|
+
before do
|
8
|
+
allow( versioner ).to receive(:logger).and_return(Logger.new)
|
9
|
+
allow( versioner ).to receive(:arg_processor).and_return(ArgumentProcessor.new([]))
|
10
|
+
allow( versioner ).to receive(:file_processor).and_return(FileProcessor.new)
|
11
|
+
allow( versioner ).to receive(:version_processor).and_return(VersionProcessor.new([1,2,3,4]))
|
12
|
+
end
|
13
|
+
|
14
|
+
context "#run" do
|
15
|
+
it "does call prepare_processors method" do
|
16
|
+
expect( versioner ).to receive(:prepare_processors)
|
17
|
+
versioner.run
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "#increment_build" do
|
22
|
+
before(:each) do
|
23
|
+
allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "does call version_processor.build_up! method" do
|
27
|
+
expect( versioner.version_processor ).to receive(:build_up!)
|
28
|
+
versioner.increment_build
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does call file_processor.replace_version_and_build_in_files method" do
|
32
|
+
expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
33
|
+
versioner.increment_build
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "#decrement_build" do
|
38
|
+
before(:each) do
|
39
|
+
allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "does call version_processor.build_up! method" do
|
43
|
+
expect( versioner.version_processor ).to receive(:build_down!)
|
44
|
+
versioner.decrement_build
|
45
|
+
end
|
46
|
+
|
47
|
+
it "does call file_processor.replace_version_and_build_in_files method" do
|
48
|
+
expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
49
|
+
versioner.decrement_build
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "#setup_build" do
|
54
|
+
before(:each) do
|
55
|
+
allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
56
|
+
allow( versioner.arg_processor ).to receive(:setup_build).and_return("123")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "does call version_processor.setup_build! method" do
|
60
|
+
expect( versioner.version_processor ).to receive(:setup_build!).with("123")
|
61
|
+
versioner.setup_build
|
62
|
+
end
|
63
|
+
|
64
|
+
it "does call file_processor.replace_version_and_build_in_files method" do
|
65
|
+
expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
66
|
+
versioner.setup_build
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "#setup_version" do
|
71
|
+
before(:each) do
|
72
|
+
allow( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
73
|
+
allow( versioner.arg_processor ).to receive(:setup_version).and_return("1.2.3")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "does call version_processor.setup_version! method" do
|
77
|
+
expect( versioner.version_processor ).to receive(:setup_version!).with("1.2.3")
|
78
|
+
versioner.setup_version
|
79
|
+
end
|
80
|
+
|
81
|
+
it "does call file_processor.replace_version_and_build_in_files method" do
|
82
|
+
expect( versioner.file_processor ).to receive(:replace_version_and_build_in_files)
|
83
|
+
versioner.setup_version
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "#show" do
|
88
|
+
it "does call logger.show_current_version method" do
|
89
|
+
allow( versioner.arg_processor ).to receive(:show).and_return(:version)
|
90
|
+
expect( versioner.logger ).to receive(:show_current_version)
|
91
|
+
versioner.show
|
92
|
+
end
|
93
|
+
|
94
|
+
it "does call logger.show_current_build method" do
|
95
|
+
allow( versioner.arg_processor ).to receive(:show).and_return(:build)
|
96
|
+
expect( versioner.logger ).to receive(:show_current_build)
|
97
|
+
versioner.show
|
98
|
+
end
|
99
|
+
|
100
|
+
it "does call logger's show_current_version and show_current_build methods" do
|
101
|
+
allow( versioner.arg_processor ).to receive(:show).and_return(:all)
|
102
|
+
expect( versioner.logger ).to receive(:show_current_version)
|
103
|
+
expect( versioner.logger ).to receive(:show_current_build)
|
104
|
+
versioner.show
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DistribBuilder
|
4
|
+
describe Main do
|
5
|
+
let(:opts) { %w(--option value) }
|
6
|
+
|
7
|
+
it "does return nil if type argument is missing" do
|
8
|
+
#expect( described_class.run ).to be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it "does return nil if type argument is missing" do
|
12
|
+
allow( described_class ).to receive(:duplicate_argv).and_return(['build'])
|
13
|
+
#expect( described_class.run ).to be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "does call an instance of Builder class" do
|
17
|
+
allow( described_class ).to receive(:duplicate_argv).and_return(['build'] + opts)
|
18
|
+
allow_any_instance_of( Builder::Main ).to receive(:run)
|
19
|
+
expect( Builder::Main ).to receive(:new).
|
20
|
+
with(opts).
|
21
|
+
and_return(Builder::Main.new(opts))
|
22
|
+
described_class.run
|
23
|
+
end
|
24
|
+
|
25
|
+
it "does call an instance of Versioner class" do
|
26
|
+
allow( described_class ).to receive(:duplicate_argv).and_return(['version'] + opts)
|
27
|
+
allow_any_instance_of( Versioner::Main ).to receive(:run)
|
28
|
+
expect( Versioner::Main ).to receive(:new).
|
29
|
+
with(opts).
|
30
|
+
and_return(Versioner::Main.new(opts))
|
31
|
+
described_class.run
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,15 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distrib_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Rufanov
|
8
|
+
- Nikita Levchuk
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
date: 2015-03-17 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mustache
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.0'
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.3
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.0'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.3
|
13
34
|
description: Distrib Builder
|
14
35
|
email: developers@majoron.com
|
15
36
|
executables:
|
@@ -17,10 +38,32 @@ executables:
|
|
17
38
|
extensions: []
|
18
39
|
extra_rdoc_files: []
|
19
40
|
files:
|
20
|
-
-
|
41
|
+
- CHANGES
|
42
|
+
- CMakeLists.txt
|
43
|
+
- DistribBuilder.yml
|
44
|
+
- Gemfile
|
45
|
+
- Gemfile.lock
|
46
|
+
- MIT-LICENSE
|
47
|
+
- README.md
|
21
48
|
- bin/distrib_builder
|
22
49
|
- distrib_builder.gemspec
|
23
50
|
- lib/distrib_builder.rb
|
51
|
+
- lib/distrib_builder/builder.rb
|
52
|
+
- lib/distrib_builder/templates/DistribBuilder.yml
|
53
|
+
- lib/distrib_builder/version.rb
|
54
|
+
- lib/distrib_builder/versioner.rb
|
55
|
+
- lib/distrib_builder/versioner/argument_processor.rb
|
56
|
+
- lib/distrib_builder/versioner/file_processor.rb
|
57
|
+
- lib/distrib_builder/versioner/logger.rb
|
58
|
+
- lib/distrib_builder/versioner/version_processor.rb
|
59
|
+
- spec/lib/distrib_builder/builder_spec.rb
|
60
|
+
- spec/lib/distrib_builder/versioner/argument_processor_spec.rb
|
61
|
+
- spec/lib/distrib_builder/versioner/file_processor_spec.rb
|
62
|
+
- spec/lib/distrib_builder/versioner/logger_spec.rb
|
63
|
+
- spec/lib/distrib_builder/versioner/version_processor_spec.rb
|
64
|
+
- spec/lib/distrib_builder/versioner_spec.rb
|
65
|
+
- spec/lib/distrib_builder_spec.rb
|
66
|
+
- spec/spec_helper.rb
|
24
67
|
homepage: http://rubygems.org/gems/distrib_builder
|
25
68
|
licenses: []
|
26
69
|
metadata: {}
|
@@ -40,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
83
|
version: '0'
|
41
84
|
requirements: []
|
42
85
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.2.2
|
44
87
|
signing_key:
|
45
88
|
specification_version: 4
|
46
89
|
summary: Distrib Builder
|
data/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Distrib Builder
|