semvergen 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.
- checksums.yaml +7 -0
- data/.gitignore +37 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +86 -0
- data/Guardfile +8 -0
- data/LICENSE +21 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/bin/semvergen +23 -0
- data/lib/semvergen/bump.rb +134 -0
- data/lib/semvergen/change_log_file.rb +19 -0
- data/lib/semvergen/interface.rb +15 -0
- data/lib/semvergen/launcher.rb +61 -0
- data/lib/semvergen/release.rb +31 -0
- data/lib/semvergen/shell.rb +49 -0
- data/lib/semvergen/version.rb +3 -0
- data/lib/semvergen/version_file.rb +41 -0
- data/lib/semvergen.rb +27 -0
- data/semvergen.gemspec +28 -0
- data/spec/semvergen/bump_spec.rb +25 -0
- data/spec/semvergen/shell_spec.rb +33 -0
- data/spec/spec_helper.rb +81 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75dcf2a58c9a2a6c241045ee8c51f139d2b073d7
|
4
|
+
data.tar.gz: 24463c3cd30605cc1a2d7e4ee823136f6cd0b400
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c25bf3934540a29dddd0c4eb435ed61f21888393ccc47a61a43f98a4c2984448dd307ca79a780ff54ea854673f37bcb376e98c0a3773e3bc4ef7a0020dea3fa
|
7
|
+
data.tar.gz: aad011f3c0c6db0df085a933cd8c29aaf8acc9388cf0c47e820b793b1019d4fb854c152683fb5a9e732f64bae7ecaebc101e637fcc849068f897a28c838e1f1b
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
.idea
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
36
|
+
|
37
|
+
.gem_server
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
semvergen
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.0
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
semvergen (0.1.0)
|
5
|
+
geminabox
|
6
|
+
highline (~> 1.6)
|
7
|
+
thor (~> 0.14)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
builder (3.2.2)
|
13
|
+
celluloid (0.15.2)
|
14
|
+
timers (~> 1.1.0)
|
15
|
+
coderay (1.1.0)
|
16
|
+
diff-lcs (1.2.5)
|
17
|
+
faraday (0.9.0)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
ffi (1.9.3)
|
20
|
+
formatador (0.2.5)
|
21
|
+
geminabox (0.12.4)
|
22
|
+
builder
|
23
|
+
faraday
|
24
|
+
httpclient (>= 2.2.7)
|
25
|
+
nesty
|
26
|
+
sinatra (>= 1.2.7)
|
27
|
+
guard (2.6.1)
|
28
|
+
formatador (>= 0.2.4)
|
29
|
+
listen (~> 2.7)
|
30
|
+
lumberjack (~> 1.0)
|
31
|
+
pry (>= 0.9.12)
|
32
|
+
thor (>= 0.18.1)
|
33
|
+
guard-rspec (4.2.10)
|
34
|
+
guard (~> 2.1)
|
35
|
+
rspec (>= 2.14, < 4.0)
|
36
|
+
highline (1.6.21)
|
37
|
+
httpclient (2.4.0)
|
38
|
+
listen (2.7.9)
|
39
|
+
celluloid (>= 0.15.2)
|
40
|
+
rb-fsevent (>= 0.9.3)
|
41
|
+
rb-inotify (>= 0.9)
|
42
|
+
lumberjack (1.0.9)
|
43
|
+
method_source (0.8.2)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nesty (1.0.2)
|
46
|
+
pry (0.10.0)
|
47
|
+
coderay (~> 1.1.0)
|
48
|
+
method_source (~> 0.8.1)
|
49
|
+
slop (~> 3.4)
|
50
|
+
rack (1.5.2)
|
51
|
+
rack-protection (1.5.3)
|
52
|
+
rack
|
53
|
+
rake (10.3.2)
|
54
|
+
rb-fsevent (0.9.4)
|
55
|
+
rb-inotify (0.9.5)
|
56
|
+
ffi (>= 0.5.0)
|
57
|
+
rspec (3.0.0)
|
58
|
+
rspec-core (~> 3.0.0)
|
59
|
+
rspec-expectations (~> 3.0.0)
|
60
|
+
rspec-mocks (~> 3.0.0)
|
61
|
+
rspec-core (3.0.2)
|
62
|
+
rspec-support (~> 3.0.0)
|
63
|
+
rspec-expectations (3.0.2)
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
+
rspec-support (~> 3.0.0)
|
66
|
+
rspec-mocks (3.0.2)
|
67
|
+
rspec-support (~> 3.0.0)
|
68
|
+
rspec-support (3.0.2)
|
69
|
+
sinatra (1.4.5)
|
70
|
+
rack (~> 1.4)
|
71
|
+
rack-protection (~> 1.4)
|
72
|
+
tilt (~> 1.3, >= 1.3.4)
|
73
|
+
slop (3.5.0)
|
74
|
+
thor (0.19.1)
|
75
|
+
tilt (1.4.1)
|
76
|
+
timers (1.1.0)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
ruby
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
bundler (~> 1.6)
|
83
|
+
guard-rspec (~> 4.0)
|
84
|
+
rake (~> 10.1)
|
85
|
+
rspec (~> 3.0)
|
86
|
+
semvergen!
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Brendon McLean
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/semvergen
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
4
|
+
|
5
|
+
require 'thor'
|
6
|
+
require 'semvergen'
|
7
|
+
|
8
|
+
class SemvergenCLI < Thor
|
9
|
+
|
10
|
+
desc "bump", "Bump the version of this gem"
|
11
|
+
option :ignore_dirty, type: :boolean, banner: "Skip the git-index-dirty check"
|
12
|
+
def bump
|
13
|
+
Semvergen.bump!(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "publish", "Publish the gem to your gem server"
|
17
|
+
def release
|
18
|
+
Semvergen.release!(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
SemvergenCLI.start(ARGV)
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Semvergen
|
2
|
+
|
3
|
+
class Bump
|
4
|
+
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
PATCH = "Patch: Bug fixes, recommended for all (default)"
|
8
|
+
MINOR = "Minor: New features, but backwards compatible"
|
9
|
+
MAJOR = "Major: Breaking changes"
|
10
|
+
|
11
|
+
RELEASE_TYPES = [
|
12
|
+
PATCH,
|
13
|
+
MINOR,
|
14
|
+
MAJOR
|
15
|
+
]
|
16
|
+
|
17
|
+
def_delegators :@interface, :say, :ask, :color, :choose, :newline, :agree
|
18
|
+
|
19
|
+
def initialize(interface, version_file, change_log_file, shell)
|
20
|
+
@interface = interface
|
21
|
+
@version_file = version_file
|
22
|
+
@change_log_file = change_log_file
|
23
|
+
@shell = shell
|
24
|
+
end
|
25
|
+
|
26
|
+
def run!(options)
|
27
|
+
if @shell.git_index_dirty? && !options[:ignore_dirty]
|
28
|
+
say color("Git index dirty. Commit changes before continuing", :red, :bold)
|
29
|
+
else
|
30
|
+
say color("Cut new Quattro Release", :white, :underline, :bold)
|
31
|
+
|
32
|
+
newline
|
33
|
+
|
34
|
+
release_type = choose do |menu|
|
35
|
+
menu.header = "Select release type"
|
36
|
+
menu.default = "1"
|
37
|
+
menu.select_by = :index
|
38
|
+
menu.choices *RELEASE_TYPES
|
39
|
+
end
|
40
|
+
|
41
|
+
new_version = next_version(@version_file.version, release_type)
|
42
|
+
|
43
|
+
newline
|
44
|
+
|
45
|
+
say "Current version: #{color(@version_file.version, :bold)}"
|
46
|
+
say "Bumped version : #{color(new_version, :bold, :green)}"
|
47
|
+
|
48
|
+
newline
|
49
|
+
|
50
|
+
say "Enter change log features (or a blank line to finish):"
|
51
|
+
|
52
|
+
features = []
|
53
|
+
|
54
|
+
while true
|
55
|
+
response = ask "* " do |q|
|
56
|
+
q.validate = lambda { |answer| features.size > 0 || answer.length > 0 }
|
57
|
+
q.responses[:not_valid] = color("Enter at least one feature", :red)
|
58
|
+
q.responses[:invalid_type] = color("Enter at least one feature", :red)
|
59
|
+
q.responses[:ask_on_error] = "* "
|
60
|
+
end
|
61
|
+
|
62
|
+
if response.length == 0
|
63
|
+
features << "\n"
|
64
|
+
break
|
65
|
+
else
|
66
|
+
features << "* #{response}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
change_log_lines = ["# #{new_version}"] + features
|
71
|
+
change_log_message = change_log_lines.join("\n")
|
72
|
+
diff_change_log = change_log_lines.map { |l| color("+++ ", :white) + color(l, :green) }.join("\n")
|
73
|
+
|
74
|
+
newline
|
75
|
+
|
76
|
+
say color("Will add the following to CHANGELOG.md", :underline)
|
77
|
+
say color(diff_change_log)
|
78
|
+
|
79
|
+
commit_message = ask("Git commit subject line: ") do |q|
|
80
|
+
q.validate = /.{10,}/
|
81
|
+
q.responses[:not_valid] = color("Message must be more than 10 chars", :red)
|
82
|
+
q.responses[:invalid_type] = color("Message must be more than 10 chars", :red)
|
83
|
+
end
|
84
|
+
|
85
|
+
newline
|
86
|
+
|
87
|
+
say color("Summary of actions:", :underline, :green, :red)
|
88
|
+
newline
|
89
|
+
|
90
|
+
say "Bumping version: #{color(@version_file.version, :yellow)} -> #{color(new_version, :green)}"
|
91
|
+
newline
|
92
|
+
|
93
|
+
say "Adding features to CHANGELOG.md:"
|
94
|
+
say color(diff_change_log, :green)
|
95
|
+
|
96
|
+
say "Staging files for commit:"
|
97
|
+
say color("* lib/quattro/version.rb", :green)
|
98
|
+
say color("* CHANGELOG.md", :green)
|
99
|
+
newline
|
100
|
+
|
101
|
+
say "Committing with message: #{color(commit_message, :green)}"
|
102
|
+
newline
|
103
|
+
|
104
|
+
if agree("Proceed? ")
|
105
|
+
@version_file.version = new_version
|
106
|
+
|
107
|
+
@change_log_file << change_log_message
|
108
|
+
|
109
|
+
@shell.commit(@version_file.path, new_version, commit_message, features)
|
110
|
+
|
111
|
+
newline
|
112
|
+
|
113
|
+
say color("To release, use semvergen release", :bold, :green)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def next_version(current_version, release_type)
|
119
|
+
version_tuples = current_version.split(".")
|
120
|
+
|
121
|
+
release_index = 2 - RELEASE_TYPES.index(release_type)
|
122
|
+
|
123
|
+
bumping = version_tuples[release_index]
|
124
|
+
unchanged = version_tuples[0...release_index]
|
125
|
+
zeroing = version_tuples[(release_index + 1)..-1]
|
126
|
+
|
127
|
+
new_version_tuples = unchanged + [bumping.to_i + 1] + (["0"] * zeroing.size)
|
128
|
+
|
129
|
+
new_version_tuples.join(".")
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Semvergen
|
2
|
+
|
3
|
+
class ChangeLogFile
|
4
|
+
|
5
|
+
def <<(message)
|
6
|
+
current_change_log = File.exist?(change_log_file) ? File.read(change_log_file) : ""
|
7
|
+
new_change_log = "# Changelog\n\n#{message}" + current_change_log.gsub("# Changelog\n", "")
|
8
|
+
File.open(change_log_file, "w") { |f| f.write new_change_log }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def change_log_file
|
14
|
+
File.join("CHANGELOG.md")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Semvergen
|
2
|
+
|
3
|
+
class Launcher
|
4
|
+
|
5
|
+
def bump!(options={})
|
6
|
+
Semvergen::Bump.new(interface, version_file, change_log_file, shell).run!(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def release!(options={})
|
10
|
+
Semvergen::Release.new(interface, gem_name, gem_server, shell, version_file).run!(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def version_file
|
16
|
+
VersionFile.new(File.open(version_path, "r+"))
|
17
|
+
end
|
18
|
+
|
19
|
+
def change_log_file
|
20
|
+
ChangeLogFile.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def shell
|
24
|
+
Shell.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def version_path
|
28
|
+
File.join("lib", gem_name, "version.rb")
|
29
|
+
end
|
30
|
+
|
31
|
+
def gem_name
|
32
|
+
File.basename(gem_spec).gsub(".gemspec", "")
|
33
|
+
end
|
34
|
+
|
35
|
+
def interface
|
36
|
+
@interface ||= Interface.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def gem_spec
|
40
|
+
gemspecs = Dir["*.gemspec"]
|
41
|
+
interface.fail_exit("No gemspec found in current dir") if gemspecs.count == 0
|
42
|
+
interface.fail_exit("More than one gemspec found in current dir") if gemspecs.count > 1
|
43
|
+
|
44
|
+
gemspecs[0]
|
45
|
+
end
|
46
|
+
|
47
|
+
def gem_server
|
48
|
+
if File.exists?(gem_server_file)
|
49
|
+
File.read(gem_server_file)
|
50
|
+
else
|
51
|
+
interface.fail_exit "To publish, place the url (with optional username and pass) in a .gem_server file"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def gem_server_file
|
56
|
+
File.join(".gem_server")
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Semvergen
|
2
|
+
|
3
|
+
class Release
|
4
|
+
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :@interface, :say, :ask, :color, :choose, :newline, :agree
|
8
|
+
|
9
|
+
def initialize(interface, gem_name, gem_server, shell, version_file)
|
10
|
+
@interface = interface
|
11
|
+
@gem_name = gem_name
|
12
|
+
@gem_server = gem_server
|
13
|
+
@shell = shell
|
14
|
+
@version_file = version_file
|
15
|
+
end
|
16
|
+
|
17
|
+
def run!(options)
|
18
|
+
say "Found gemspec: #{color(@gem_name, :green)}"
|
19
|
+
newline
|
20
|
+
|
21
|
+
say color("Building gem: ")
|
22
|
+
@shell.build_gem(@gem_name)
|
23
|
+
say color("OK", :green, :bold)
|
24
|
+
|
25
|
+
say color("Publishing: ")
|
26
|
+
@shell.publish(@gem_name, @version_file.version, @gem_server)
|
27
|
+
say color("OK", :green, :bold)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Semvergen
|
2
|
+
|
3
|
+
class Shell
|
4
|
+
|
5
|
+
def initialize(execute_function = method(:system_exec).to_proc)
|
6
|
+
@execute_function = execute_function
|
7
|
+
end
|
8
|
+
|
9
|
+
def git_index_dirty?
|
10
|
+
execute("git status --porcelain") =~ /^\s*(D|M|A|R|C)\s/
|
11
|
+
end
|
12
|
+
|
13
|
+
def commit(version_path, new_version, commit_subject, features)
|
14
|
+
commit_body = COMMIT_MESSAGE % [new_version, commit_subject, features.join("\n")]
|
15
|
+
|
16
|
+
execute "git add CHANGELOG.md"
|
17
|
+
execute "git add #{version_path}"
|
18
|
+
execute %Q[git commit -m "#{commit_body}"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_gem(gem_name)
|
22
|
+
execute "gem build #{gem_name}.gemspec --force"
|
23
|
+
end
|
24
|
+
|
25
|
+
def publish(gem_name, version, gem_server)
|
26
|
+
execute "gem inabox #{gem_name}-#{version}.gem --host #{gem_server}"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def execute(command)
|
32
|
+
@execute_function[command]
|
33
|
+
end
|
34
|
+
|
35
|
+
def system_exec(command)
|
36
|
+
result = `#{command}`
|
37
|
+
raise if $?.exitstatus > 0
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
COMMIT_MESSAGE = <<-STR
|
42
|
+
Version %s: %s
|
43
|
+
|
44
|
+
%s
|
45
|
+
STR
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Semvergen
|
2
|
+
|
3
|
+
class VersionFile
|
4
|
+
|
5
|
+
def initialize(file)
|
6
|
+
@file = file
|
7
|
+
end
|
8
|
+
|
9
|
+
def version
|
10
|
+
if file.read =~ /VERSION = "(\d+\.\d+\.\d+)"/
|
11
|
+
$1
|
12
|
+
else
|
13
|
+
raise "Don't understand version"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def version=(new_version)
|
18
|
+
content = file.read.gsub(/VERSION.*$/, %Q[VERSION = "#{new_version}"])
|
19
|
+
file.truncate(0)
|
20
|
+
file.write content
|
21
|
+
file.flush
|
22
|
+
end
|
23
|
+
|
24
|
+
def file
|
25
|
+
@file.rewind
|
26
|
+
@file
|
27
|
+
end
|
28
|
+
|
29
|
+
def path
|
30
|
+
@file.path
|
31
|
+
end
|
32
|
+
|
33
|
+
VERSION_TEMPLATE = <<-RUBY
|
34
|
+
module Quattro
|
35
|
+
VERSION = "%s"
|
36
|
+
end
|
37
|
+
RUBY
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/semvergen.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "semvergen/version"
|
2
|
+
|
3
|
+
require "semvergen/launcher"
|
4
|
+
require "semvergen/interface"
|
5
|
+
require "semvergen/bump"
|
6
|
+
require "semvergen/release"
|
7
|
+
require "semvergen/change_log_file"
|
8
|
+
require "semvergen/shell"
|
9
|
+
require "semvergen/version_file"
|
10
|
+
|
11
|
+
module Semvergen
|
12
|
+
|
13
|
+
def self.bump!(options)
|
14
|
+
launcher.bump!(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.release!(options)
|
18
|
+
launcher.release!(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.launcher
|
24
|
+
Semvergen::Launcher.new
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/semvergen.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'semvergen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "semvergen"
|
8
|
+
spec.version = Semvergen::VERSION
|
9
|
+
spec.authors = ["Brendon McLean"]
|
10
|
+
spec.email = ["brendon@intellectionsoftware.com"]
|
11
|
+
spec.summary = "Interactive semantic version and gem publishing"
|
12
|
+
spec.homepage = "https://github.com/brendon9x/semvergen"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "highline", "~> 1.6"
|
21
|
+
spec.add_runtime_dependency "thor", "~> 0.14"
|
22
|
+
spec.add_runtime_dependency "geminabox"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "guard-rspec", "~> 4.0"
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe Semvergen::Bump do
|
2
|
+
let(:semvergen) { Semvergen::Bump.new nil, nil, nil, nil }
|
3
|
+
|
4
|
+
describe :next_version do
|
5
|
+
let(:next_version) { semvergen.next_version current_version, release_type }
|
6
|
+
let(:current_version) { "3.2.19" }
|
7
|
+
|
8
|
+
context "when bumping a major version" do
|
9
|
+
let(:release_type) { Semvergen::Bump::MAJOR }
|
10
|
+
it { expect(next_version).to eq "4.0.0" }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when bumping a minor version" do
|
14
|
+
let(:release_type) { Semvergen::Bump::MINOR }
|
15
|
+
it { expect(next_version).to eq "3.3.0" }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when bumping a patch version" do
|
19
|
+
let(:release_type) { Semvergen::Bump::PATCH }
|
20
|
+
it { expect(next_version).to eq "3.2.20" }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Semvergen::Shell do
|
4
|
+
|
5
|
+
let :shell do
|
6
|
+
Semvergen::Shell.new(command_map)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe :git_index_dirty? do
|
10
|
+
|
11
|
+
let :with_added do
|
12
|
+
<<-STR
|
13
|
+
M file_a
|
14
|
+
A file_b
|
15
|
+
AM file_c
|
16
|
+
?? file_d
|
17
|
+
STR
|
18
|
+
end
|
19
|
+
|
20
|
+
let :with_only_changed do
|
21
|
+
<<-STR
|
22
|
+
?? file_x
|
23
|
+
STR
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns true when index dirty" do
|
27
|
+
expect(Semvergen::Shell.new("git status --porcelain" => with_added).git_index_dirty?).to be_truthy
|
28
|
+
expect(Semvergen::Shell.new("git status --porcelain" => with_only_changed).git_index_dirty?).to be_falsey
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, make a
|
10
|
+
# separate helper file that requires this one and then use it only in the specs
|
11
|
+
# that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
|
18
|
+
require 'semvergen'
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# The settings below are suggested to provide a good initial experience
|
22
|
+
# with RSpec, but feel free to customize to your heart's content.
|
23
|
+
=begin
|
24
|
+
# These two settings work together to allow you to limit a spec run
|
25
|
+
# to individual examples or groups you care about by tagging them with
|
26
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
27
|
+
# get run.
|
28
|
+
config.filter_run :focus
|
29
|
+
config.run_all_when_everything_filtered = true
|
30
|
+
|
31
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
32
|
+
# file, and it's useful to allow more verbose output when running an
|
33
|
+
# individual spec file.
|
34
|
+
if config.files_to_run.one?
|
35
|
+
# Use the documentation formatter for detailed output,
|
36
|
+
# unless a formatter has already been configured
|
37
|
+
# (e.g. via a command-line flag).
|
38
|
+
config.default_formatter = 'doc'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Print the 10 slowest examples and example groups at the
|
42
|
+
# end of the spec run, to help surface which specs are running
|
43
|
+
# particularly slow.
|
44
|
+
config.profile_examples = 10
|
45
|
+
|
46
|
+
# Run specs in random order to surface order dependencies. If you find an
|
47
|
+
# order dependency and want to debug it, you can fix the order by providing
|
48
|
+
# the seed, which is printed after each run.
|
49
|
+
# --seed 1234
|
50
|
+
config.order = :random
|
51
|
+
|
52
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
53
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
54
|
+
# test failures related to randomization by passing the same `--seed` value
|
55
|
+
# as the one that triggered the failure.
|
56
|
+
Kernel.srand config.seed
|
57
|
+
|
58
|
+
# rspec-expectations config goes here. You can use an alternate
|
59
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
60
|
+
# assertions if you prefer.
|
61
|
+
config.expect_with :rspec do |expectations|
|
62
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
63
|
+
# For more details, see:
|
64
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
65
|
+
expectations.syntax = :expect
|
66
|
+
end
|
67
|
+
|
68
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
69
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
70
|
+
config.mock_with :rspec do |mocks|
|
71
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
72
|
+
# For more details, see:
|
73
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
74
|
+
mocks.syntax = :expect
|
75
|
+
|
76
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
77
|
+
# a real object. This is generally recommended.
|
78
|
+
mocks.verify_partial_doubles = true
|
79
|
+
end
|
80
|
+
=end
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: semvergen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brendon McLean
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: highline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.14'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: geminabox
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- brendon@intellectionsoftware.com
|
114
|
+
executables:
|
115
|
+
- semvergen
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".ruby-gemset"
|
122
|
+
- ".ruby-version"
|
123
|
+
- CHANGELOG.md
|
124
|
+
- Gemfile
|
125
|
+
- Gemfile.lock
|
126
|
+
- Guardfile
|
127
|
+
- LICENSE
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/semvergen
|
131
|
+
- lib/semvergen.rb
|
132
|
+
- lib/semvergen/bump.rb
|
133
|
+
- lib/semvergen/change_log_file.rb
|
134
|
+
- lib/semvergen/interface.rb
|
135
|
+
- lib/semvergen/launcher.rb
|
136
|
+
- lib/semvergen/release.rb
|
137
|
+
- lib/semvergen/shell.rb
|
138
|
+
- lib/semvergen/version.rb
|
139
|
+
- lib/semvergen/version_file.rb
|
140
|
+
- semvergen.gemspec
|
141
|
+
- spec/semvergen/bump_spec.rb
|
142
|
+
- spec/semvergen/shell_spec.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
homepage: https://github.com/brendon9x/semvergen
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 2.2.2
|
165
|
+
signing_key:
|
166
|
+
specification_version: 4
|
167
|
+
summary: Interactive semantic version and gem publishing
|
168
|
+
test_files:
|
169
|
+
- spec/semvergen/bump_spec.rb
|
170
|
+
- spec/semvergen/shell_spec.rb
|
171
|
+
- spec/spec_helper.rb
|