Class: Reissue::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Reissue::Task
- Includes:
- Gem
- Defined in:
- lib/reissue/rake.rb
Instance Attribute Summary collapse
-
#changelog_file ⇒ Object
The path to the changelog file.
-
#commit ⇒ Object
Whether to commit the changes.
-
#commit_finalize ⇒ Object
Whether to commit the finalize change to the changelog.
-
#description ⇒ Object
A description of the main task.
-
#name ⇒ Object
The name of the main task and the namespace for the other tasks.
-
#updated_paths ⇒ Object
Additional paths to add to the commit.
-
#version_file ⇒ Object
The path to the version file.
-
#version_limit ⇒ Object
The number of versions to retain in the changelog file.
-
#version_redo_proc ⇒ Object
A proc that can be used to create the new version string.
Class Method Summary collapse
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :reissue) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(name = :reissue) ⇒ Task
Returns a new instance of Task.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/reissue/rake.rb', line 43 def initialize(name = :reissue) @name = name @description = "Prepare the code for work on a new version." @version_file = nil @updated_paths = [] @changelog_file = "CHANGELOG.md" @commit = true @commit_finalize = true @version_limit = 2 @version_redo_proc = nil end |
Instance Attribute Details
#changelog_file ⇒ Object
The path to the changelog file.
32 33 34 |
# File 'lib/reissue/rake.rb', line 32 def changelog_file @changelog_file end |
#commit ⇒ Object
Whether to commit the changes. Default: true.
38 39 40 |
# File 'lib/reissue/rake.rb', line 38 def commit @commit end |
#commit_finalize ⇒ Object
Whether to commit the finalize change to the changelog. Default: true.
41 42 43 |
# File 'lib/reissue/rake.rb', line 41 def commit_finalize @commit_finalize end |
#description ⇒ Object
A description of the main task.
20 21 22 |
# File 'lib/reissue/rake.rb', line 20 def description @description end |
#name ⇒ Object
The name of the main task and the namespace for the other tasks.
17 18 19 |
# File 'lib/reissue/rake.rb', line 17 def name @name end |
#updated_paths ⇒ Object
Additional paths to add to the commit.
35 36 37 |
# File 'lib/reissue/rake.rb', line 35 def updated_paths @updated_paths end |
#version_file ⇒ Object
The path to the version file. Required.
23 24 25 |
# File 'lib/reissue/rake.rb', line 23 def version_file @version_file end |
#version_limit ⇒ Object
The number of versions to retain in the changelog file. Defaults to 2.
26 27 28 |
# File 'lib/reissue/rake.rb', line 26 def version_limit @version_limit end |
#version_redo_proc ⇒ Object
A proc that can be used to create the new version string.
29 30 31 |
# File 'lib/reissue/rake.rb', line 29 def version_redo_proc @version_redo_proc end |
Class Method Details
.create(name = :reissue, &block) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/reissue/rake.rb', line 8 def self.create name = :reissue, &block task = new name task.instance_eval(&block) if block raise "No Reissue task.version_file specified" unless task.version_file task.define task end |
Instance Method Details
#define ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/reissue/rake.rb', line 55 def define desc description task name, [:segment] do |task, args| segment = args[:segment] || "patch" new_version = Reissue.call(segment:, version_file:, version_limit:, version_redo_proc:) if defined?(Bundler) Bundler.with_unbundled_env do system("bundle install") end end system("git add -u") if updated_paths.any? system("git add #{updated_paths.join(" ")}") end = "Bump version to #{new_version}" if commit system("git commit -m '#{}'") else system("echo '#{}'") end end desc "Reformat the changelog file to ensure it is correctly formatted." task "#{name}:reformat", [:version_limit] do |task, args| version_limit = if args[:version_limit].nil? self.version_limit else args[:version_limit].to_i end Reissue.reformat(changelog_file, version_limit:) end desc "Finalize the changelog for an unreleased version to set the release date." task "#{name}:finalize", [:date] do |task, args| date = args[:date] || Time.now.strftime("%Y-%m-%d") version, date = Reissue.finalize(date, changelog_file:) = "Finalize the changelog for version #{version} on #{date}" if commit_finalize system("git add -u") system("git commit -m '#{}'") else system("echo '#{}'") end end end |