Class: Plus2GitTagger::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Plus2GitTagger::Task
- Defined in:
- lib/plus2_git_tagger/task.rb
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#add_global_reporters ⇒ Object
Adds tasks that will list all tags for this project, or all tags for the project for the month.
-
#add_reporters(tagger, task_name) ⇒ Object
Adds two reporting tasks for this tagger.
- #basename(taskname) ⇒ Object
-
#commit_preflight(&blk) ⇒ Object
API: set the preflight commit block.
-
#default_tagger(*prefix) ⇒ Object
API: define the default tagger.
-
#git_c(cmd) ⇒ Object
Runs a git command.
-
#git_s(cmd) ⇒ Object
Runs a git command, returning its standard out.
-
#initialize(name, &blk) ⇒ Task
constructor
A new instance of Task.
-
#preflight(&blk) ⇒ Object
API: set the preflight block.
-
#tagger(name, *prefix) ⇒ Object
API: define a tagger.
Constructor Details
#initialize(name, &blk) ⇒ Task
Returns a new instance of Task.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/plus2_git_tagger/task.rb', line 6 def initialize(name, &blk) @name = name @git = Plus2GitTagger::Git.new( Dir.pwd ) @prereqs = %w{preflight commit_preflight}.map {|p| "#{ name }:#{ p }"} @taggers = [] @reporters = [] @monthlys = [] instance_eval(&blk) add_global_reporters desc "Preflight (asset compilation, packing etc)" task "#{ name }:preflight" , &@preflight_block if @preflight_block desc "Commit compiled assets" task "#{ name }:commit_preflight", &@commit_preflight_block if @commit_preflight_block end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
4 5 6 |
# File 'lib/plus2_git_tagger/task.rb', line 4 def git @git end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/plus2_git_tagger/task.rb', line 4 def name @name end |
Instance Method Details
#add_global_reporters ⇒ Object
Adds tasks that will list all tags for this project, or all tags for the project for the month
97 98 99 100 101 102 103 |
# File 'lib/plus2_git_tagger/task.rb', line 97 def add_global_reporters desc 'List all tags' task 'tags:list:all' => @reporters desc 'List all tags for the month' task 'tags:list:month' => @monthlys end |
#add_reporters(tagger, task_name) ⇒ Object
Adds two reporting tasks for this tagger
Example:
tag:hotfix:list
tag:hotfix:list:month
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/plus2_git_tagger/task.rb', line 77 def add_reporters(tagger, task_name) @reporters << (report_all_name = "#{task_name}:list") desc "List all #{basename(task_name)} tags" task report_all_name do tagger.list end @monthlys << (report_month_name = "#{task_name}:list:month") desc "List all #{basename(task_name)} tags for the month" task report_month_name do tagger.month_list end end |
#basename(taskname) ⇒ Object
120 121 122 |
# File 'lib/plus2_git_tagger/task.rb', line 120 def basename(taskname) taskname == @name ? 'default' : taskname.gsub("#{@name}:", "") end |
#commit_preflight(&blk) ⇒ Object
API: set the preflight commit block
35 36 37 |
# File 'lib/plus2_git_tagger/task.rb', line 35 def commit_preflight(&blk) @commit_preflight_block = blk end |
#default_tagger(*prefix) ⇒ Object
API: define the default tagger
41 42 43 |
# File 'lib/plus2_git_tagger/task.rb', line 41 def default_tagger( *prefix ) @taggers << tagger(nil, *prefix) end |
#git_c(cmd) ⇒ Object
Runs a git command.
109 110 111 |
# File 'lib/plus2_git_tagger/task.rb', line 109 def git_c(cmd) @git.git(cmd) end |
#git_s(cmd) ⇒ Object
Runs a git command, returning its standard out.
115 116 117 |
# File 'lib/plus2_git_tagger/task.rb', line 115 def git_s(cmd) @git.git_s(cmd) end |
#preflight(&blk) ⇒ Object
API: set the preflight block
29 30 31 |
# File 'lib/plus2_git_tagger/task.rb', line 29 def preflight(&blk) @preflight_block = blk end |
#tagger(name, *prefix) ⇒ Object
API: define a tagger
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/plus2_git_tagger/task.rb', line 47 def tagger( name, *prefix ) name = nil if name && name.strip == '' task_name = if name "#{ @name }:#{ name }" else @name end string_prefix = [ prefix ].flatten.compact.join("/") tagger = Tags.new( @git, string_prefix ) @taggers << tagger desc "Tag a #{name || 'default'} release" task task_name => @prereqs do tagger.make! end add_reporters(tagger, task_name) end |