Class: RakeVersion::Tasks
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RakeVersion::Tasks
- Defined in:
- lib/rake-version/tasks.rb
Constant Summary collapse
- NAMES =
[ 'version', 'version:bump:major', 'version:bump:minor', 'version:bump:patch', 'version:set' ]
- OTHER_NAMES =
[ 'version:write' ]
Instance Method Summary collapse
- #clear_tasks(options = {}) ⇒ Object
- #define(options = {}) ⇒ Object
-
#initialize(options = {}) {|@config| ... } ⇒ Tasks
constructor
A new instance of Tasks.
- #task(*args, &block) ⇒ Object
Constructor Details
#initialize(options = {}) {|@config| ... } ⇒ Tasks
Returns a new instance of Tasks.
8 9 10 11 12 13 14 |
# File 'lib/rake-version/tasks.rb', line 8 def initialize = {}, &block @manager = RakeVersion::Manager.new @config = RakeVersion::Config.new yield @config if block_given? @manager.config = @config define end |
Instance Method Details
#clear_tasks(options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/rake-version/tasks.rb', line 52 def clear_tasks = {} task_names = NAMES task_names += OTHER_NAMES unless [:clear_strict] task_names.each{ |task| remove_task task } end |
#define(options = {}) ⇒ 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 |
# File 'lib/rake-version/tasks.rb', line 16 def define = {} clear_tasks unless [:clear] == false desc 'Show the current version' task :version do |t| handle_missing_version{ puts @manager.version.to_s } end namespace :version do desc 'Set the version (rake "version:set[1.2.3]")' task :set, :value do |t, args| puts @manager.set(args.value.to_s) end namespace :bump do [ :major, :minor, :patch ].each do |type| desc "Bump the #{type} version" task type do |t| handle_missing_version{ puts @manager.bump(type).to_s } end end end end end |
#task(*args, &block) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rake-version/tasks.rb', line 44 def task *args, &block super *args do |t, args| @manager.with_context context(t) do |m| yield t, args if block_given? end end end |