gem_semver 0.2.0 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +15 -13
- data/gem_semver.gemspec +1 -1
- data/lib/gem_semver/version.rb +1 -1
- data/lib/gem_semver/version_updater.rb +25 -6
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ba2261aa38ac500be89e40337c09091e8380d9ba134e3065aad1ee3c6d7475c
|
4
|
+
data.tar.gz: e994170fe205032dc7c6ff13bbb8cb5505a40154747f97eb2b5465f4a04ac14a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2a494e049437eb3a63a8141fca6995867c860b388f47495248a0b04d722c0c162722ff0832502776e373827af1dbbd41643909d8ed641c7b90d3bbf71641c59
|
7
|
+
data.tar.gz: 2686adf851ce4520701afa94890754875ef085172cce83f7f627758d6cf34b6c9713e735b069653ef6fc3bbb39f72a229ab9b62985879819356eebb48c0c7e94
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
# GemSemver
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This gem adds the `bump` command to your path so you can update the version of your gem using semantic versioning. It does not create commits, it just updates
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
Run this command in your terminal:
|
10
8
|
|
11
|
-
|
12
|
-
gem 'gem_semver'
|
13
|
-
```
|
9
|
+
$ gem install gem_semver
|
14
10
|
|
15
|
-
|
11
|
+
## Usage
|
16
12
|
|
17
|
-
|
13
|
+
```bump major```
|
18
14
|
|
19
|
-
|
15
|
+
Updates the major version number and resets the minor and patch version numbers to 0. Also creates a backup of the Gemfile.lock and the version.rb.
|
20
16
|
|
21
|
-
|
17
|
+
```bump minor```
|
22
18
|
|
23
|
-
|
19
|
+
Updates the minor version number and resets the patch version number to 0. Also creates a backup of the Gemfile.lock and the version.rb.
|
20
|
+
|
21
|
+
```bump patch```
|
22
|
+
|
23
|
+
Updates the patch version number. Also creates a backup of the Gemfile.lock and the version.rb.
|
24
|
+
|
25
|
+
```bump clean```
|
24
26
|
|
25
|
-
|
27
|
+
Removes the .bak files created by running any of the version bumps. The backups are created just in case of a power outage or accidental shutoff before the update completes. Once you're happy with
|
26
28
|
|
27
29
|
## Development
|
28
30
|
|
data/gem_semver.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["dakotaleemusic@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Updates the version of your Gem (use in conjunction with rake release)}
|
13
|
-
spec.description = %q{Updates the version of your Gem (use in conjunction with rake release)}
|
13
|
+
spec.description = %q{Updates the version of your Gem (use in conjunction with rake release)Running `bump major` will result in a major version change, `bump minor` results in a minor version change, and `bump patch` results in a patch version change. Updating versions will create backups of the version file and the Gemfile.lock. You can delete these by running `bump clean`}
|
14
14
|
spec.homepage = "https://github.com/DakotaLMartinez/gem_semver"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
data/lib/gem_semver/version.rb
CHANGED
@@ -14,9 +14,11 @@ class GemSemver::VersionUpdater
|
|
14
14
|
@output << "Whoops! Something went wrong"
|
15
15
|
if !update_type
|
16
16
|
@output << "Make sure you pass an argument: (bump minor)"
|
17
|
-
elsif !["major", "minor", "patch"].include?(update_type)
|
17
|
+
elsif !["major", "minor", "patch", "clean"].include?(update_type)
|
18
18
|
@output << "Make sure to specify the type of update (major | minor | patch)"
|
19
19
|
@output << "Run one of these: bump major | bump minor | bump patch"
|
20
|
+
@output << "You can also run `bump clean` to remove the 2 .bak files"
|
21
|
+
@output << "created by updating the version number."
|
20
22
|
elsif !File.exist?(version_file_path)
|
21
23
|
@output << "Current directory doesn't have a version.rb file at: "
|
22
24
|
@output << "#{Dir.pwd}/lib/#{gem_name}/version.rb"
|
@@ -29,23 +31,37 @@ class GemSemver::VersionUpdater
|
|
29
31
|
@output << "gemspec and run bundle install to create it)."
|
30
32
|
else
|
31
33
|
@output.pop
|
34
|
+
handle_update_type
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def handle_update_type
|
39
|
+
if update_type == "clean"
|
40
|
+
delete_bak_files
|
41
|
+
else
|
32
42
|
update_version
|
33
43
|
end
|
34
44
|
end
|
35
45
|
|
46
|
+
def delete_bak_files
|
47
|
+
FileUtils.remove_file("#{version_file_path}.bak") if File.exist?("#{version_file_path}.bak")
|
48
|
+
FileUtils.remove_file(File.join(Dir.pwd, "Gemfile.lock.bak")) if File.exist?(File.join(Dir.pwd, "Gemfile.lock.bak"))
|
49
|
+
@output << ".bak files deleted"
|
50
|
+
end
|
51
|
+
|
36
52
|
def update_version
|
37
53
|
capture_version_number
|
38
54
|
if update_type == "major"
|
39
|
-
@current_major_version = (current_major_version
|
55
|
+
@current_major_version = add_one(current_major_version)
|
40
56
|
@current_minor_version = "0"
|
41
57
|
@current_patch_version = "0"
|
42
58
|
@output << "Major version change:"
|
43
59
|
elsif update_type == "minor"
|
44
|
-
@current_minor_version = (current_minor_version
|
60
|
+
@current_minor_version = add_one(current_minor_version)
|
45
61
|
@current_patch_version = "0"
|
46
62
|
@output << "Minor version change:"
|
47
63
|
elsif update_type == "patch"
|
48
|
-
@current_patch_version = (current_patch_version
|
64
|
+
@current_patch_version = add_one(current_patch_version)
|
49
65
|
@output << "Patch version change:"
|
50
66
|
end
|
51
67
|
@new_version = [current_major_version, current_minor_version, current_patch_version].join('.')
|
@@ -62,6 +78,10 @@ class GemSemver::VersionUpdater
|
|
62
78
|
@version_file.close
|
63
79
|
end
|
64
80
|
|
81
|
+
def add_one(string)
|
82
|
+
(string.to_i + 1).to_s
|
83
|
+
end
|
84
|
+
|
65
85
|
def update_version_file
|
66
86
|
tmp = Tempfile.new("new_version")
|
67
87
|
File.foreach(@version_file) do |line|
|
@@ -86,8 +106,7 @@ class GemSemver::VersionUpdater
|
|
86
106
|
end
|
87
107
|
|
88
108
|
def print_output
|
89
|
-
output.each { |
|
109
|
+
output.each { |message| puts message }
|
90
110
|
end
|
91
111
|
|
92
|
-
|
93
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_semver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DakotaLMartinez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,11 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description: Updates the version of your Gem (use in conjunction with rake release)
|
55
|
+
description: Updates the version of your Gem (use in conjunction with rake release)Running
|
56
|
+
`bump major` will result in a major version change, `bump minor` results in a minor
|
57
|
+
version change, and `bump patch` results in a patch version change. Updating versions
|
58
|
+
will create backups of the version file and the Gemfile.lock. You can delete these
|
59
|
+
by running `bump clean`
|
56
60
|
email:
|
57
61
|
- dakotaleemusic@gmail.com
|
58
62
|
executables:
|