bake-bundler 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3941301d7c18a70facd801d775a2c790148f1a44ef55051c5534573daef0d718
4
- data.tar.gz: '08baac5d1674e2deec4000dd67703029c4a40c41a8e4d9e163277087eba60009'
3
+ metadata.gz: 89d2d07ef7b08cae451893bb496204dc3f550f8782e15a107a52f1566db5f661
4
+ data.tar.gz: 4496ce5ca8127f0ab4712ab6d2389b3b642ceabe495a4e2261b039287024f26a
5
5
  SHA512:
6
- metadata.gz: ac6315e94eea735104cddc272240e35a4cb0357479f3c05c7d743b9093a2ea9af29cbd17c2cad29356782f30d56d50b848fb3182f9474f17e3fac832f830d81b
7
- data.tar.gz: 45634c01ec7d8b5fadc4ee1f0d1205f28a326d43b9de1dfebb9ab5a049d4688de23dadcfa95d81293390ab75ad61de4f4c06f1a3f2adb48557bd880ccdde0864
6
+ metadata.gz: 6c26a33f579f8b9876b44cf08b7540f9a44353bca0ced16dfadaa49a6f7b9d431f65ed4f49578df0e1d7eb5784a2ae58a71e51eaef6d4529c30485a4f1c68d9e
7
+ data.tar.gz: '090529eeba906cdcb7e73a368b9aed9b9eb88bd53cc47a95fbc60deaee3d35b63b1205b81d756873e211a564d1ff632afd4952c899a2ec4838c588ff546d1eec'
data/README.md CHANGED
@@ -1,36 +1,65 @@
1
1
  # Bake::Bundler
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bake/bundler`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Provides bake tasks for releasing gems using bundler.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ ```
8
+ bundle add bake-bundler
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Build
14
+
15
+ ```
16
+ bake bundler:build
17
+ ```
18
+
19
+ ### Install
10
20
 
11
- ```ruby
12
- gem 'bake-bundler'
21
+ ```
22
+ bake bundler:install
13
23
  ```
14
24
 
15
- And then execute:
25
+ ### Release
16
26
 
17
- $ bundle install
27
+ ```
28
+ bake bundler:release
29
+ ```
18
30
 
19
- Or install it yourself as:
31
+ ## Contributing
20
32
 
21
- $ gem install bake-bundler
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
22
38
 
23
- ## Usage
39
+ ## See Also
24
40
 
25
- TODO: Write usage instructions here
41
+ - [Bake](https://github.com/ioquatix/bake) The bake task execution tool.
26
42
 
27
- ## Development
43
+ ## License
28
44
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+ Released under the MIT license.
30
46
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+ Copyright, 2020, by [Samuel G. D. Williams](http://www.codeotaku.com).
32
48
 
33
- ## Contributing
49
+ Permission is hereby granted, free of charge, to any person obtaining a copy
50
+ of this software and associated documentation files (the "Software"), to deal
51
+ in the Software without restriction, including without limitation the rights
52
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
+ copies of the Software, and to permit persons to whom the Software is
54
+ furnished to do so, subject to the following conditions:
34
55
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bake-bundler.
56
+ The above copyright notice and this permission notice shall be included in
57
+ all copies or substantial portions of the Software.
36
58
 
59
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
65
+ THE SOFTWARE.
@@ -8,6 +8,8 @@ def initialize(context)
8
8
  @built_gem_path = nil
9
9
  end
10
10
 
11
+ attr :helper
12
+
11
13
  # Build the gem into the pkg directory.
12
14
  def build
13
15
  @built_gem_path ||= @helper.build_gem
@@ -37,8 +39,3 @@ def release(remote: nil)
37
39
  end
38
40
  end
39
41
 
40
- private
41
-
42
- def instance
43
-
44
- end
@@ -0,0 +1,78 @@
1
+
2
+ # Increment the patch number of the current version ("major.minor.patch").
3
+ def patch
4
+ publish([nil, nil, 1], message: "Patch version bump.")
5
+ end
6
+
7
+ # Increment the patch number of the current version ("major.minor.patch").
8
+ def minor
9
+ publish([nil, 1, 0], message: "Minor version bump.")
10
+ end
11
+
12
+ # Increment the patch number of the current version ("major.minor.patch").
13
+ def major
14
+ publish([1, 0, 0], message: "Major version bump.")
15
+ end
16
+
17
+ VERSION_PATTERN = /VERSION = ['"](?<value>\d+\.\d+\.\d+)(?<pre>.*?)['"]/
18
+
19
+ # Scans the files listed in the gemspec for a file named `version.rb`. Extracts the VERSION constant and updates it according to the version bump. Commits the changes to git using the specified message.
20
+ #
21
+ # @param bump [Array(Integer | Nil)] the version bump to apply before publishing.
22
+ # @param message [String] the git commit message to use.
23
+ def increment(bump, message: "Bump version.")
24
+ release = context.lookup('bundler:release')
25
+ helper = release.instance.helper
26
+ gemspec = helper.gemspec
27
+
28
+ version_path = gemspec.files.grep(/version.rb/).first
29
+
30
+ Console.logger.info(self) {"Preparing to update #{version_path}..."}
31
+
32
+ lines = File.readlines(version_path)
33
+ version = nil
34
+
35
+ lines.each do |line|
36
+ if match = line.match(VERSION_PATTERN)
37
+ version = match[:value].split(/\./).map(&:to_i)
38
+ bump.each_with_index do |increment, index|
39
+ if increment == 1
40
+ version[index] += 1
41
+ elsif increment == 0
42
+ version[index] = 0
43
+ end
44
+ end
45
+
46
+ line.sub!(match[:value], version.join('.'))
47
+ end
48
+ end
49
+
50
+ if version
51
+ File.write(version_path, lines.join)
52
+
53
+ system("git", "add", version_path, chdir: context.root)
54
+ system("git", "commit", "-m", message, chdir: context.root)
55
+
56
+ version_string = version.join('.')
57
+
58
+ Console.logger.info(self) {"Updated version to #{version_string}"}
59
+
60
+ # Ensure that any subsequent tasks use the correct version!
61
+ gemspec.version = Gem::Version.new(version_string)
62
+ else
63
+ raise "Could not find version number!"
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def publish(*arguments, **options)
70
+ release = context.lookup('bundler:release')
71
+ helper = release.instance.helper
72
+
73
+ helper.guard_clean
74
+
75
+ increment(*arguments, **options)
76
+
77
+ release.call
78
+ end
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Bake
24
24
  module Bundler
25
- VERSION = "0.1.0"
25
+ VERSION = "0.2.0"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-25 00:00:00.000000000 Z
11
+ date: 2020-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bake
@@ -37,6 +37,7 @@ files:
37
37
  - README.md
38
38
  - bake-bundler.gemspec
39
39
  - bake/bundler.rb
40
+ - bake/bundler/publish.rb
40
41
  - lib/bake/bundler.rb
41
42
  - lib/bake/bundler/helper.rb
42
43
  - lib/bake/bundler/version.rb