build_info 0.1.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.
- data/.gitignore +2 -0
- data/Gemfile +0 -0
- data/LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/TODO +4 -0
- data/VERSION +1 -0
- data/build_info.gemspec +54 -0
- data/lib/build_info/build.rb +74 -0
- data/lib/build_info/tasks.rb +171 -0
- data/lib/build_info.rb +5 -0
- data/spec/build_info_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- metadata +82 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 YOUR NAME
|
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.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "build_info"
|
8
|
+
gem.summary = "A way to manage project builds."
|
9
|
+
gem.email = "chris@tech9computers.com"
|
10
|
+
gem.homepage = "http://github.com/chrismoos/build_info_rb"
|
11
|
+
gem.authors = ["Chris Moos"]
|
12
|
+
end
|
13
|
+
Jeweler::GemcutterTasks.new
|
14
|
+
rescue LoadError
|
15
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rake/testtask'
|
19
|
+
Rake::TestTask.new(:test) do |test|
|
20
|
+
test.libs << 'test'
|
21
|
+
test.pattern = 'test/**/*_test.rb'
|
22
|
+
test.verbose = true
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'rcov/rcovtask'
|
27
|
+
Rcov::RcovTask.new do |test|
|
28
|
+
test.libs << 'test'
|
29
|
+
test.pattern = 'test/**/*_test.rb'
|
30
|
+
test.verbose = true
|
31
|
+
end
|
32
|
+
rescue LoadError
|
33
|
+
task :rcov do
|
34
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
task :test => :check_dependencies
|
39
|
+
|
40
|
+
task :default => :test
|
data/TODO
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/build_info.gemspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{build_info}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Chris Moos"]
|
12
|
+
s.date = %q{2010-09-25}
|
13
|
+
s.email = %q{chris@tech9computers.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc",
|
17
|
+
"TODO"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"TODO",
|
26
|
+
"VERSION",
|
27
|
+
"build_info.gemspec",
|
28
|
+
"lib/build_info.rb",
|
29
|
+
"lib/build_info/build.rb",
|
30
|
+
"lib/build_info/tasks.rb",
|
31
|
+
"spec/build_info_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/chrismoos/build_info_rb}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.7}
|
38
|
+
s.summary = %q{A way to manage project builds.}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/build_info_spec.rb",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
else
|
50
|
+
end
|
51
|
+
else
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup
|
4
|
+
|
5
|
+
module BuildInfo
|
6
|
+
class Build
|
7
|
+
|
8
|
+
def self.build(release_info={})
|
9
|
+
f = File.new('.build_info', 'w')
|
10
|
+
f.write(YAML::dump(release_info))
|
11
|
+
f.close
|
12
|
+
@build_info = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.load
|
16
|
+
begin
|
17
|
+
f = File.new('.build_info', 'r')
|
18
|
+
@build_info = YAML::load(f.read)
|
19
|
+
rescue
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.build_info_str
|
25
|
+
str = ''
|
26
|
+
str += "\nBuild Information\n\n"
|
27
|
+
|
28
|
+
items.each do |i|
|
29
|
+
print (i[1].nil ? "NOT AVAILABLE" : i[1])
|
30
|
+
print "\n"
|
31
|
+
end
|
32
|
+
print "\n"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.print_build_info_color
|
36
|
+
print_color(:green, "\nBuild Information\n\n")
|
37
|
+
|
38
|
+
items.each do |i|
|
39
|
+
print_color(:yellow, "#{i[0]}: ")
|
40
|
+
print (i[1].nil? ? "NOT AVAILABLE" : i[1])
|
41
|
+
print "\n"
|
42
|
+
end
|
43
|
+
print "\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.info
|
47
|
+
if @build_info.nil?
|
48
|
+
load
|
49
|
+
return {} if @build_info.nil?
|
50
|
+
end
|
51
|
+
@build_info
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def self.items
|
57
|
+
items = [["Name", info['name']], ["Type", info['type']],
|
58
|
+
["Version", info['version']], ["Revision", info['revision']],
|
59
|
+
["Build Number", info['build']]]
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.print_color(color, txt)
|
63
|
+
colorCode = case color
|
64
|
+
when :blue then "\033[94m"
|
65
|
+
when :green then "\033[92m"
|
66
|
+
when :red then "\033[91m"
|
67
|
+
when :yellow then "\033[93m"
|
68
|
+
else "\033[0m]"
|
69
|
+
end
|
70
|
+
|
71
|
+
print "#{colorCode}#{txt}\033[0m"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
namespace :build_info do
|
4
|
+
BUILD_INFO_VARS = {
|
5
|
+
:name => "BUILD_INFO_NAME",
|
6
|
+
:version => "BUILD_INFO_VERSION",
|
7
|
+
:revision => "BUILD_INFO_REVISION",
|
8
|
+
:build => "BUILD_INFO_NUMBER",
|
9
|
+
:type => "BUILD_INFO_TYPE"
|
10
|
+
}
|
11
|
+
|
12
|
+
def create_build(type)
|
13
|
+
unless ENV.include?("BUILD_INFO_VERSION") and ENV.include?("BUILD_INFO_NAME")
|
14
|
+
vars = BUILD_INFO_VARS.collect { |k,v| "#{v}= "}.join(" ")
|
15
|
+
raise "usage: rake build_info:init #{vars}"
|
16
|
+
end
|
17
|
+
|
18
|
+
options = {}
|
19
|
+
BUILD_INFO_VARS.each do |k,v|
|
20
|
+
options[k.to_s] = ENV[v] if ENV[v]
|
21
|
+
end
|
22
|
+
|
23
|
+
BuildInfo::Build.build(options)
|
24
|
+
|
25
|
+
BuildInfo::Build.print_build_info_color
|
26
|
+
end
|
27
|
+
|
28
|
+
def update_build_info(build_info, name, var)
|
29
|
+
build_info[name.to_s] = var == '' ? nil : var if not var.nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_build_info
|
33
|
+
current_build = BuildInfo::Build.info
|
34
|
+
unless current_build.length > 0
|
35
|
+
raise "There is no build_info in this project. Please run rake build_info:init."
|
36
|
+
end
|
37
|
+
current_build
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_version(build_info)
|
41
|
+
regex = Regexp.new(/(\d+)\.(\d+)(\.(\d+))?/)
|
42
|
+
match = regex.match(build_info['version'])
|
43
|
+
|
44
|
+
raise "No or invalid version in build information" if match.nil?
|
45
|
+
|
46
|
+
{:major => match[1], :minor => match[2], :patch => match[4]}
|
47
|
+
end
|
48
|
+
|
49
|
+
def version_string(version_info)
|
50
|
+
return version_info[:major] if not version_info[:minor]
|
51
|
+
return "#{version_info[:major]}.#{version_info[:minor]}" if not version_info[:patch]
|
52
|
+
return "#{version_info[:major]}.#{version_info[:minor]}.#{version_info[:patch]}"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Tasks
|
56
|
+
|
57
|
+
desc "Initializes a new build."
|
58
|
+
task :init do
|
59
|
+
if File.exists?('.build_info')
|
60
|
+
raise "The file .build_info already exists. Please remove it before running this command."
|
61
|
+
end
|
62
|
+
|
63
|
+
create_build("development")
|
64
|
+
|
65
|
+
puts "Created a new build in: #{File.expand_path('.build_info')}"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Releases the current version."
|
69
|
+
task :release do
|
70
|
+
current_build = BuildInfo::Build.info
|
71
|
+
unless current_build.length > 0
|
72
|
+
raise "Unable to release version because there is no build information."
|
73
|
+
end
|
74
|
+
|
75
|
+
BuildInfo::Build.build(current_build.merge({
|
76
|
+
'type' => 'release'
|
77
|
+
}))
|
78
|
+
end
|
79
|
+
|
80
|
+
namespace :version do
|
81
|
+
|
82
|
+
namespace :bump do
|
83
|
+
desc "Bumps the build's major version."
|
84
|
+
task :major do
|
85
|
+
current_build = get_build_info
|
86
|
+
version_info = get_version(current_build)
|
87
|
+
|
88
|
+
raise "No major version in build information." if version_info[:major].nil?
|
89
|
+
|
90
|
+
version_info[:major] = version_info[:major].to_i + 1
|
91
|
+
version_info[:minor] = 0
|
92
|
+
version_info[:patch] = 0 if not version_info[:patch].nil?
|
93
|
+
|
94
|
+
BuildInfo::Build.build(current_build.merge({'version' => version_string(version_info)}))
|
95
|
+
puts "Bumped version."
|
96
|
+
BuildInfo::Build.print_build_info_color
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "Bumps the build's minor version."
|
100
|
+
task :minor do
|
101
|
+
current_build = get_build_info
|
102
|
+
version_info = get_version(current_build)
|
103
|
+
|
104
|
+
raise "No minor version in build information." if version_info[:minor].nil?
|
105
|
+
|
106
|
+
version_info[:minor] = version_info[:minor].to_i + 1
|
107
|
+
version_info[:patch] = 0 if not version_info[:patch].nil?
|
108
|
+
|
109
|
+
BuildInfo::Build.build(current_build.merge({'version' => version_string(version_info)}))
|
110
|
+
puts "Bumped version."
|
111
|
+
BuildInfo::Build.print_build_info_color
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "Bumps the build's major version."
|
115
|
+
task :patch do
|
116
|
+
current_build = get_build_info
|
117
|
+
version_info = get_version(current_build)
|
118
|
+
|
119
|
+
if not version_info[:patch].nil?
|
120
|
+
version_info[:patch] = version_info[:patch].to_i + 1
|
121
|
+
else
|
122
|
+
version_info[:patch] = 1
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
BuildInfo::Build.build(current_build.merge({'version' => version_string(version_info)}))
|
127
|
+
puts "Bumped version."
|
128
|
+
BuildInfo::Build.print_build_info_color
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
desc "Set the build version"
|
133
|
+
task :update do
|
134
|
+
unless ENV.include?("BUILD_INFO_VERSION")
|
135
|
+
raise "Please specify the BUILD_INFO_VERSION variable (i.e - 1.0.2)"
|
136
|
+
end
|
137
|
+
|
138
|
+
current_build = get_build_info
|
139
|
+
|
140
|
+
build_version = current_build['version']
|
141
|
+
unless not build_version.nil?
|
142
|
+
raise "No build version set, unable to increment."
|
143
|
+
end
|
144
|
+
|
145
|
+
BuildInfo::Build.build(current_build.merge({
|
146
|
+
'version' => ENV['BUILD_INFO_VERSION']
|
147
|
+
}))
|
148
|
+
|
149
|
+
puts "Updated version."
|
150
|
+
BuildInfo::Build.print_build_info_color
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
desc "Updates the build information."
|
155
|
+
task :update do
|
156
|
+
current_build = get_build_info
|
157
|
+
|
158
|
+
BUILD_INFO_VARS.each do |k,v|
|
159
|
+
update_build_info(current_build, k, ENV[v])
|
160
|
+
end
|
161
|
+
|
162
|
+
BuildInfo::Build.build(current_build)
|
163
|
+
puts "Updated build."
|
164
|
+
BuildInfo::Build.print_build_info_color
|
165
|
+
end
|
166
|
+
|
167
|
+
desc "Shows information about the current build."
|
168
|
+
task :show do
|
169
|
+
BuildInfo::Build.print_build_info_color
|
170
|
+
end
|
171
|
+
end
|
data/lib/build_info.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: build_info
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Chris Moos
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-25 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: chris@tech9computers.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- LICENSE
|
30
|
+
- README.rdoc
|
31
|
+
- TODO
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- TODO
|
39
|
+
- VERSION
|
40
|
+
- build_info.gemspec
|
41
|
+
- lib/build_info.rb
|
42
|
+
- lib/build_info/build.rb
|
43
|
+
- lib/build_info/tasks.rb
|
44
|
+
- spec/build_info_spec.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://github.com/chrismoos/build_info_rb
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --charset=UTF-8
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.7
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: A way to manage project builds.
|
80
|
+
test_files:
|
81
|
+
- spec/build_info_spec.rb
|
82
|
+
- spec/spec_helper.rb
|