Class: Blacksmith::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Blacksmith::RakeTask
- Defined in:
- lib/puppet_blacksmith/rake_tasks.rb
Instance Attribute Summary collapse
-
#tag_pattern ⇒ Object
Returns the value of attribute tag_pattern.
Instance Method Summary collapse
- #define(args, &task_block) ⇒ Object
-
#initialize(*args, &task_block) ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(*args, &task_block) ⇒ RakeTask
Returns a new instance of RakeTask.
10 11 12 13 14 |
# File 'lib/puppet_blacksmith/rake_tasks.rb', line 10 def initialize(*args, &task_block) @task_name = args.shift || "blacksmith" @desc = args.shift || "Puppet Forge utilities" define(args, &task_block) end |
Instance Attribute Details
#tag_pattern ⇒ Object
Returns the value of attribute tag_pattern.
8 9 10 |
# File 'lib/puppet_blacksmith/rake_tasks.rb', line 8 def tag_pattern @tag_pattern end |
Instance Method Details
#define(args, &task_block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 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 |
# File 'lib/puppet_blacksmith/rake_tasks.rb', line 16 def define(args, &task_block) task_block.call(*[self, args].slice(0, task_block.arity)) if task_block # clear any (auto-)pre-existing task [ :bump, :bump_major, :bump_minor, :bump_patch, :tag, :bump_commit, :push, :clean, :release, :dependency ].each do |t| Rake::Task.task_defined?("module:#{t}") && Rake::Task["module:#{t}"].clear end namespace :module do namespace :bump do [:major, :minor, :patch].each do |level| desc "Bump module version to the next #{level.upcase} version" task level do m = Blacksmith::Modulefile.new v = m.send("bump_#{level}!") puts "Bumping version from #{m.version} to #{v}" end end end desc "Bump module version to the next patch" task :bump do m = Blacksmith::Modulefile.new v = m.bump_patch! puts "Bumping version from #{m.version} to #{v}" end desc "Git tag with the current module version" task :tag do m = Blacksmith::Modulefile.new git = Blacksmith::Git.new git.tag_pattern = @tag_pattern git.tag!(m.version) end desc "Bump version and git commit" task :bump_commit => :bump do m = Blacksmith::Modulefile.new Blacksmith::Git.new.commit_modulefile!(m.version) end desc "Push module to the Puppet Forge" task :push => :build do m = Blacksmith::Modulefile.new forge = Blacksmith::Forge.new puts "Uploading to Puppet Forge #{forge.username}/#{m.name}" forge.push!(m.name) end desc "Runs clean again" task :clean do puts "Cleaning for module build" Rake::Task["clean"].execute end desc "Release the Puppet module, doing a clean, build, tag, push, bump_commit and git push." task :release => [:clean, :build, :tag, :push, :bump_commit] do puts "Pushing to remote git repo" Blacksmith::Git.new.push! end desc "Set specific module dependency version" task :dependency, [:module_name, :version] do |t, args| mn = args[:module_name] mv = args[:version] m = Blacksmith::Modulefile.new m.bump_dep! mn, mv puts "Updated module dependency #{mn} to #{mv}" end end end |