bozo 0.3.8 → 0.4.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.
- checksums.yaml +8 -8
- data/README.md +443 -426
- data/VERSION +1 -1
- data/bin/bozo +8 -8
- data/lib/bozo.rb +131 -130
- data/lib/bozo/bozo.rb +6 -6
- data/lib/bozo/bozo_configuration.rb +319 -299
- data/lib/bozo/build_dependency_resolver.rb +106 -0
- data/lib/bozo/class_name_helpers.rb +16 -16
- data/lib/bozo/configuration_error.rb +29 -29
- data/lib/bozo/execution_error.rb +35 -35
- data/lib/bozo/executor.rb +263 -288
- data/lib/bozo/logging.rb +40 -40
- data/lib/bozo/runner.rb +63 -63
- data/lib/bozo/versioning/version.rb +96 -96
- data/lib/bozo/versioning/version_bump_error.rb +29 -29
- data/lib/bozo/versioning/version_bumper.rb +36 -36
- data/test/bozo_configuration_version_tests.rb +41 -41
- data/test/test_helper.rb +2 -2
- data/test/version_bumper_tests.rb +61 -61
- data/test/version_tests.rb +25 -25
- metadata +3 -2
data/lib/bozo/logging.rb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
module Bozo
|
2
|
-
|
3
|
-
# Module that provides functionality for logging.
|
4
|
-
module Logging
|
5
|
-
|
6
|
-
# Records a `debug` log message.
|
7
|
-
#
|
8
|
-
# @param [String] msg
|
9
|
-
# The message to log.
|
10
|
-
def log_debug(msg)
|
11
|
-
puts " #{msg.bright.color(:black)}"
|
12
|
-
end
|
13
|
-
|
14
|
-
# Records a `fatal` log message.
|
15
|
-
#
|
16
|
-
# @param [String] msg
|
17
|
-
# The message to log.
|
18
|
-
def log_fatal(msg)
|
19
|
-
puts msg.color(:red).bright
|
20
|
-
end
|
21
|
-
|
22
|
-
# Records an `info` log message.
|
23
|
-
#
|
24
|
-
# @param [String] msg
|
25
|
-
# The message to log.
|
26
|
-
def log_info(msg)
|
27
|
-
puts msg.color(:cyan).bright
|
28
|
-
end
|
29
|
-
|
30
|
-
# Records a `warn` log message.
|
31
|
-
#
|
32
|
-
# @param [String] msg
|
33
|
-
# The message to log.
|
34
|
-
def log_warn(msg)
|
35
|
-
puts msg.color(:yellow).bright
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
1
|
+
module Bozo
|
2
|
+
|
3
|
+
# Module that provides functionality for logging.
|
4
|
+
module Logging
|
5
|
+
|
6
|
+
# Records a `debug` log message.
|
7
|
+
#
|
8
|
+
# @param [String] msg
|
9
|
+
# The message to log.
|
10
|
+
def log_debug(msg)
|
11
|
+
puts " #{msg.bright.color(:black)}"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Records a `fatal` log message.
|
15
|
+
#
|
16
|
+
# @param [String] msg
|
17
|
+
# The message to log.
|
18
|
+
def log_fatal(msg)
|
19
|
+
puts msg.color(:red).bright
|
20
|
+
end
|
21
|
+
|
22
|
+
# Records an `info` log message.
|
23
|
+
#
|
24
|
+
# @param [String] msg
|
25
|
+
# The message to log.
|
26
|
+
def log_info(msg)
|
27
|
+
puts msg.color(:cyan).bright
|
28
|
+
end
|
29
|
+
|
30
|
+
# Records a `warn` log message.
|
31
|
+
#
|
32
|
+
# @param [String] msg
|
33
|
+
# The message to log.
|
34
|
+
def log_warn(msg)
|
35
|
+
puts msg.color(:yellow).bright
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/bozo/runner.rb
CHANGED
@@ -1,63 +1,63 @@
|
|
1
|
-
module Bozo
|
2
|
-
|
3
|
-
# Module mixed into the all Bozo executors that provides functionality for
|
4
|
-
# command execution and logging.
|
5
|
-
module Runner
|
6
|
-
|
7
|
-
include Bozo::Logging
|
8
|
-
|
9
|
-
# Returns the global parameters.
|
10
|
-
attr_accessor :global_params
|
11
|
-
|
12
|
-
# Returns the command parameters.
|
13
|
-
attr_accessor :params
|
14
|
-
|
15
|
-
# Returns the environment variables.
|
16
|
-
attr_accessor :env
|
17
|
-
|
18
|
-
# Returns the build configuration.
|
19
|
-
attr_accessor :build_configuration
|
20
|
-
|
21
|
-
# Returns whether the build is being run on a build server.
|
22
|
-
def build_server?
|
23
|
-
global_params[:build_server]
|
24
|
-
end
|
25
|
-
|
26
|
-
# Returns whether a pre release should be created.
|
27
|
-
def pre_release?
|
28
|
-
params[:pre_release]
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns the environment the build is being execute in.
|
32
|
-
def environment
|
33
|
-
global_params[:environment]
|
34
|
-
end
|
35
|
-
|
36
|
-
# Executes a command line tool.
|
37
|
-
#
|
38
|
-
# Raises a `Bozo::ExecutionError` if the command responds with a non-zero
|
39
|
-
# exit code.
|
40
|
-
#
|
41
|
-
# @param [Symbol] tool
|
42
|
-
# A friendly identifier for the tool.
|
43
|
-
# @param [Array] args
|
44
|
-
# An array of arguments making up the command to execute.
|
45
|
-
def execute_command(tool, args)
|
46
|
-
args.flatten!
|
47
|
-
|
48
|
-
executable = File.basename(args.first)
|
49
|
-
arguments = args[1..-1].join(' ')
|
50
|
-
|
51
|
-
log_info " #{tool} - #{executable} #{arguments}"
|
52
|
-
|
53
|
-
raise Bozo::ExecutionError.new(tool, args, $?.exitstatus) unless system args.join ' '
|
54
|
-
end
|
55
|
-
|
56
|
-
# Returns the build version.
|
57
|
-
def version
|
58
|
-
build_configuration.version
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
1
|
+
module Bozo
|
2
|
+
|
3
|
+
# Module mixed into the all Bozo executors that provides functionality for
|
4
|
+
# command execution and logging.
|
5
|
+
module Runner
|
6
|
+
|
7
|
+
include Bozo::Logging
|
8
|
+
|
9
|
+
# Returns the global parameters.
|
10
|
+
attr_accessor :global_params
|
11
|
+
|
12
|
+
# Returns the command parameters.
|
13
|
+
attr_accessor :params
|
14
|
+
|
15
|
+
# Returns the environment variables.
|
16
|
+
attr_accessor :env
|
17
|
+
|
18
|
+
# Returns the build configuration.
|
19
|
+
attr_accessor :build_configuration
|
20
|
+
|
21
|
+
# Returns whether the build is being run on a build server.
|
22
|
+
def build_server?
|
23
|
+
global_params[:build_server]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns whether a pre release should be created.
|
27
|
+
def pre_release?
|
28
|
+
params[:pre_release]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns the environment the build is being execute in.
|
32
|
+
def environment
|
33
|
+
global_params[:environment]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Executes a command line tool.
|
37
|
+
#
|
38
|
+
# Raises a `Bozo::ExecutionError` if the command responds with a non-zero
|
39
|
+
# exit code.
|
40
|
+
#
|
41
|
+
# @param [Symbol] tool
|
42
|
+
# A friendly identifier for the tool.
|
43
|
+
# @param [Array] args
|
44
|
+
# An array of arguments making up the command to execute.
|
45
|
+
def execute_command(tool, args)
|
46
|
+
args.flatten!
|
47
|
+
|
48
|
+
executable = File.basename(args.first)
|
49
|
+
arguments = args[1..-1].join(' ')
|
50
|
+
|
51
|
+
log_info " #{tool} - #{executable} #{arguments}"
|
52
|
+
|
53
|
+
raise Bozo::ExecutionError.new(tool, args, $?.exitstatus) unless system args.join ' '
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the build version.
|
57
|
+
def version
|
58
|
+
build_configuration.version
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -1,97 +1,97 @@
|
|
1
|
-
module Bozo::Versioning
|
2
|
-
|
3
|
-
class Version
|
4
|
-
|
5
|
-
# @param major [Integer]
|
6
|
-
# @param minor [Integer]
|
7
|
-
# @param patch [Integer]
|
8
|
-
# @param extension [String]
|
9
|
-
def initialize(major, minor, patch, extension = nil)
|
10
|
-
@major = major
|
11
|
-
@minor = minor
|
12
|
-
@patch = patch
|
13
|
-
@extension = extension
|
14
|
-
end
|
15
|
-
|
16
|
-
# Loads the version from the VERSION file
|
17
|
-
def self.load_from_file
|
18
|
-
raise no_version_file unless File.exist? 'VERSION'
|
19
|
-
version = File.read('VERSION').strip
|
20
|
-
raise no_version if version.empty?
|
21
|
-
parse version
|
22
|
-
end
|
23
|
-
|
24
|
-
# Parses a version string to create a Version instance
|
25
|
-
#
|
26
|
-
# @param version [String]
|
27
|
-
def self.parse(version)
|
28
|
-
major, minor, patch = *version.split('.').map(&:to_i)
|
29
|
-
Version.new major, minor, patch
|
30
|
-
end
|
31
|
-
|
32
|
-
def major
|
33
|
-
@major
|
34
|
-
end
|
35
|
-
|
36
|
-
def minor
|
37
|
-
@minor
|
38
|
-
end
|
39
|
-
|
40
|
-
def patch
|
41
|
-
@patch
|
42
|
-
end
|
43
|
-
|
44
|
-
def extension
|
45
|
-
@extension
|
46
|
-
end
|
47
|
-
|
48
|
-
# Writes the version from the VERSION file
|
49
|
-
def write_to_file filename="VERSION"
|
50
|
-
File.open(filename, 'w') { |f| f << to_s }
|
51
|
-
end
|
52
|
-
|
53
|
-
# Bumps the part of the version
|
54
|
-
#
|
55
|
-
# @param part [Symbol]
|
56
|
-
def bump(part)
|
57
|
-
send "bump_#{part}".to_sym
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_s
|
61
|
-
if @extension.nil?
|
62
|
-
"#{@major}.#{@minor}.#{@patch}"
|
63
|
-
else
|
64
|
-
"#{@major}.#{@minor}.#{@patch}-#{@extension}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
def bump_major
|
71
|
-
@major += 1
|
72
|
-
@minor = 0
|
73
|
-
@patch = 0
|
74
|
-
end
|
75
|
-
|
76
|
-
def bump_minor
|
77
|
-
@minor += 1
|
78
|
-
@patch = 0
|
79
|
-
end
|
80
|
-
|
81
|
-
def bump_patch
|
82
|
-
@patch += 1
|
83
|
-
end
|
84
|
-
|
85
|
-
# Error if no version has been specified
|
86
|
-
def self.no_version
|
87
|
-
Bozo::ConfigurationError.new 'No version specified'
|
88
|
-
end
|
89
|
-
|
90
|
-
# Error if the version file could not be found
|
91
|
-
def self.no_version_file
|
92
|
-
Bozo::ConfigurationError.new "VERSION file could not be found in project #{Dir.pwd}"
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
1
|
+
module Bozo::Versioning
|
2
|
+
|
3
|
+
class Version
|
4
|
+
|
5
|
+
# @param major [Integer]
|
6
|
+
# @param minor [Integer]
|
7
|
+
# @param patch [Integer]
|
8
|
+
# @param extension [String]
|
9
|
+
def initialize(major, minor, patch, extension = nil)
|
10
|
+
@major = major
|
11
|
+
@minor = minor
|
12
|
+
@patch = patch
|
13
|
+
@extension = extension
|
14
|
+
end
|
15
|
+
|
16
|
+
# Loads the version from the VERSION file
|
17
|
+
def self.load_from_file
|
18
|
+
raise no_version_file unless File.exist? 'VERSION'
|
19
|
+
version = File.read('VERSION').strip
|
20
|
+
raise no_version if version.empty?
|
21
|
+
parse version
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parses a version string to create a Version instance
|
25
|
+
#
|
26
|
+
# @param version [String]
|
27
|
+
def self.parse(version)
|
28
|
+
major, minor, patch = *version.split('.').map(&:to_i)
|
29
|
+
Version.new major, minor, patch
|
30
|
+
end
|
31
|
+
|
32
|
+
def major
|
33
|
+
@major
|
34
|
+
end
|
35
|
+
|
36
|
+
def minor
|
37
|
+
@minor
|
38
|
+
end
|
39
|
+
|
40
|
+
def patch
|
41
|
+
@patch
|
42
|
+
end
|
43
|
+
|
44
|
+
def extension
|
45
|
+
@extension
|
46
|
+
end
|
47
|
+
|
48
|
+
# Writes the version from the VERSION file
|
49
|
+
def write_to_file filename="VERSION"
|
50
|
+
File.open(filename, 'w') { |f| f << to_s }
|
51
|
+
end
|
52
|
+
|
53
|
+
# Bumps the part of the version
|
54
|
+
#
|
55
|
+
# @param part [Symbol]
|
56
|
+
def bump(part)
|
57
|
+
send "bump_#{part}".to_sym
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_s
|
61
|
+
if @extension.nil?
|
62
|
+
"#{@major}.#{@minor}.#{@patch}"
|
63
|
+
else
|
64
|
+
"#{@major}.#{@minor}.#{@patch}-#{@extension}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def bump_major
|
71
|
+
@major += 1
|
72
|
+
@minor = 0
|
73
|
+
@patch = 0
|
74
|
+
end
|
75
|
+
|
76
|
+
def bump_minor
|
77
|
+
@minor += 1
|
78
|
+
@patch = 0
|
79
|
+
end
|
80
|
+
|
81
|
+
def bump_patch
|
82
|
+
@patch += 1
|
83
|
+
end
|
84
|
+
|
85
|
+
# Error if no version has been specified
|
86
|
+
def self.no_version
|
87
|
+
Bozo::ConfigurationError.new 'No version specified'
|
88
|
+
end
|
89
|
+
|
90
|
+
# Error if the version file could not be found
|
91
|
+
def self.no_version_file
|
92
|
+
Bozo::ConfigurationError.new "VERSION file could not be found in project #{Dir.pwd}"
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
97
|
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
module Bozo::Versioning
|
2
|
-
|
3
|
-
# Error raised when a runner or hook finds the configuration or build in an
|
4
|
-
# unexpected state.
|
5
|
-
class VersionBumpError < StandardError
|
6
|
-
|
7
|
-
# The code the program should exit with upon handling this error.
|
8
|
-
attr_reader :exit_code
|
9
|
-
|
10
|
-
# A message explaining the corrective actions someone can take to avoid the
|
11
|
-
# error.
|
12
|
-
attr_reader :message
|
13
|
-
|
14
|
-
# Creates a new instance.
|
15
|
-
#
|
16
|
-
# @param [String] message
|
17
|
-
# A message explaining the corrective actions someone can take to avoid
|
18
|
-
# the error.
|
19
|
-
def initialize(message)
|
20
|
-
@message = message
|
21
|
-
@exit_code = -1
|
22
|
-
end
|
23
|
-
|
24
|
-
def inspect
|
25
|
-
"Version bump error: #{message}"
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
1
|
+
module Bozo::Versioning
|
2
|
+
|
3
|
+
# Error raised when a runner or hook finds the configuration or build in an
|
4
|
+
# unexpected state.
|
5
|
+
class VersionBumpError < StandardError
|
6
|
+
|
7
|
+
# The code the program should exit with upon handling this error.
|
8
|
+
attr_reader :exit_code
|
9
|
+
|
10
|
+
# A message explaining the corrective actions someone can take to avoid the
|
11
|
+
# error.
|
12
|
+
attr_reader :message
|
13
|
+
|
14
|
+
# Creates a new instance.
|
15
|
+
#
|
16
|
+
# @param [String] message
|
17
|
+
# A message explaining the corrective actions someone can take to avoid
|
18
|
+
# the error.
|
19
|
+
def initialize(message)
|
20
|
+
@message = message
|
21
|
+
@exit_code = -1
|
22
|
+
end
|
23
|
+
|
24
|
+
def inspect
|
25
|
+
"Version bump error: #{message}"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
30
|
end
|