Class: Ditz::Operator
- Defined in:
- lib/ditz/operator.rb,
lib/ditz/plugins/git.rb,
lib/ditz/plugins/git-sync.rb,
lib/ditz/plugins/issue-claiming.rb,
lib/ditz/plugins/issue-labeling.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
-
.build_args(project, method, args) ⇒ Object
parse the specs, and the commandline arguments, and resolve them.
- .build_opts(method, args) ⇒ Object
- .die_with_completions(project, method, spec) ⇒ Object
- .has_operation?(op) ⇒ Boolean
- .method_to_op(meth) ⇒ Object
- .op_to_method(op) ⇒ Object
- .operation(method, desc, *args_spec, &options_blk) ⇒ Object
- .operations ⇒ Object
Instance Method Summary collapse
- #__issue_claiming_close ⇒ Object
- #__issue_claiming_start ⇒ Object
- #__issue_claiming_stop ⇒ Object
- #actually_do_todo(project, config, releases, full) ⇒ Object
- #add(project, config, opts) ⇒ Object
- #add_component(project, config) ⇒ Object
- #add_reference(project, config, opts, issue) ⇒ Object
- #add_release(project, config, opts, maybe_name) ⇒ Object
- #archive(project, config, release, dir) ⇒ Object
- #assign(project, config, opts, issue, maybe_release) ⇒ Object
- #changelog(project, config, r) ⇒ Object
- #claim(project, config, opts, issue) ⇒ Object
- #claimed(project, config, opts, releases) ⇒ Object
- #close(project, config, opts, issue) ⇒ Object
- #comment(project, config, opts, issue) ⇒ Object
- #commit(project, config, opts, issue) ⇒ Object
- #do(op, project, config, args) ⇒ Object
- #drop(project, config, issue) ⇒ Object
- #edit(project, config, opts, issue) ⇒ Object
- #grep(project, config, opts, match) ⇒ Object
- #help(project, config, opts, command) ⇒ Object
- #help_single(command) ⇒ Object
- #html(project, config, dir) ⇒ Object
- #init ⇒ Object
- #label(project, config, issue, label_names) ⇒ Object
- #labeled(project, config, opts, labels, releases) ⇒ Object
- #log(project, config) ⇒ Object
- #mine(project, config, opts, releases) ⇒ Object
- #new_label(project, config, maybe_label) ⇒ Object
- #print_todo_list_by_release_for(project, issues) ⇒ Object
- #reconfigure(project, config) ⇒ Object
- #release(project, config, opts, release) ⇒ Object
- #releases(project, config) ⇒ Object
- #set_branch(project, config, issue, maybe_string) ⇒ Object
- #set_component(project, config, opts, issue, maybe_component) ⇒ Object
- #shortlog(project, config) ⇒ Object
- #show(project, config, issue) ⇒ Object
- #start(project, config, opts, issue) ⇒ Object
- #status(project, config, releases) ⇒ Object
- #status_bar_for(issues) ⇒ Object
- #stop(project, config, opts, issue) ⇒ Object
- #sync(project, config, opts) ⇒ Object
- #todo(project, config, opts, releases) ⇒ Object
- #todo_list_for(issues, opts = {}) ⇒ Object
- #unassign(project, config, opts, issue) ⇒ Object
- #unclaim(project, config, opts, issue) ⇒ Object
- #unclaimed(project, config, opts, releases) ⇒ Object
- #unlabel(project, config, issue, label_names) ⇒ Object
- #validate(project, config) ⇒ Object
Class Method Details
.build_args(project, method, args) ⇒ Object
parse the specs, and the commandline arguments, and resolve them. does typechecking but currently doesn’t check for open_issues actually being open, unstarted_issues being unstarted, etc. probably will check for this in the future.
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 |
# File 'lib/ditz/operator.rb', line 32 def build_args project, method, args specs = @operations[method][:args_spec] command = "command '#{method_to_op method}'" if specs.empty? && args == ["<options>"] die_with_completions project, method, nil end built_args = specs.map do |spec| optional = spec.to_s =~ /^maybe_/ spec = spec.to_s.gsub(/^maybe_/, "").intern # :( val = args.shift case val when nil next if optional specname = spec.to_s.gsub("_", " ") article = specname =~ /^[aeiou]/ ? "an" : "a" raise Error, "#{command} requires #{article} #{specname}" when "<options>" die_with_completions project, method, spec end case spec when :issue, :open_issue, :unstarted_issue, :started_issue, :assigned_issue ## issue completion sticks the title on there, so this will strip it off valr = val.sub(/\A(\w+-\d+)_.*$/,'\1') issues = project.issues_for valr case issues.size when 0; raise Error, "no issue with name #{val.inspect}" when 1; issues.first else raise Error, "multiple issues matching name #{val.inspect}" end when :release, :unreleased_release if val == "unassigned" :unassigned else project.release_for(val) or raise Error, "no release with name #{val}" end when :component project.component_for(val) or raise Error, "no component with name #{val}" if val else val # no translation for other types end end raise Error, "too many arguments for #{command}" unless args.empty? built_args end |
.build_opts(method, args) ⇒ Object
23 24 25 26 |
# File 'lib/ditz/operator.rb', line 23 def build_opts method, args = @operations[method][:options_blk] and args, & or nil end |
.die_with_completions(project, method, spec) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/ditz/operator.rb', line 83 def die_with_completions project, method, spec puts(case spec when :issue, :open_issue, :unstarted_issue, :started_issue, :assigned_issue m = { :issue => nil, :open_issue => :open?, :unstarted_issue => :unstarted?, :started_issue => :in_progress?, :assigned_issue => :assigned?, }[spec] project.issues.select { |i| m.nil? || i.send(m) }.sort_by { |i| i.creation_time }.reverse.map { |i| "#{i.name}_#{i.title.gsub(/\W+/, '-')}" } when :release project.releases.map { |r| r.name } + ["unassigned"] when :unreleased_release project.releases.select { |r| r.unreleased? }.map { |r| r.name } when :component project.components.map { |c| c.name } when :command operations.map { |name, _| name } else "" end) exit 0 end |
.has_operation?(op) ⇒ Boolean
21 |
# File 'lib/ditz/operator.rb', line 21 def has_operation? op; @operations.member? op_to_method(op) end |
.method_to_op(meth) ⇒ Object
9 |
# File 'lib/ditz/operator.rb', line 9 def method_to_op meth; meth.to_s.gsub("_", "-") end |
.op_to_method(op) ⇒ Object
10 |
# File 'lib/ditz/operator.rb', line 10 def op_to_method op; op.gsub("-", "_").intern end |
.operation(method, desc, *args_spec, &options_blk) ⇒ Object
12 13 14 15 16 |
# File 'lib/ditz/operator.rb', line 12 def operation method, desc, *args_spec, & @operations ||= {} @operations[method] = { :desc => desc, :args_spec => args_spec, :options_blk => } end |
.operations ⇒ Object
18 19 20 |
# File 'lib/ditz/operator.rb', line 18 def operations @operations.map { |k, v| [method_to_op(k), v] }.sort_by { |k, v| k } end |
Instance Method Details
#__issue_claiming_close ⇒ Object
82 83 84 85 86 87 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 82 def close project, config, opts, issue puts "Closing issue #{issue.name}: #{issue.title}." disp = ask_for_selection Issue::DISPOSITIONS, "disposition", lambda { |x| Issue::DISPOSITION_STRINGS[x] || x.to_s } issue.close disp, config.user, get_comment(opts) puts "Closed issue #{issue.name} with disposition #{issue.disposition_string}." end |
#__issue_claiming_start ⇒ Object
64 65 66 67 68 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 64 def start project, config, opts, issue puts "Starting work on issue #{issue.name}: #{issue.title}." issue.start_work config.user, get_comment(opts) puts "Recorded start of work for #{issue.name}." end |
#__issue_claiming_stop ⇒ Object
73 74 75 76 77 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 73 def stop project, config, opts, issue puts "Stopping work on issue #{issue.name}: #{issue.title}." issue.stop_work config.user, get_comment(opts) puts "Recorded work stop for #{issue.name}." end |
#actually_do_todo(project, config, releases, full) ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/ditz/operator.rb', line 338 def actually_do_todo project, config, releases, full run_pager releases ||= project.unreleased_releases + [:unassigned] releases = [*releases] releases.each do |r| puts r == :unassigned ? "Unassigned:" : "#{r.name} (#{r.status}):" issues = project.issues_for_release r issues = issues.select { |i| i.open? } unless full puts(todo_list_for(issues.sort_by { |i| i.sort_order }) || "No open issues.") puts end end |
#add(project, config, opts) ⇒ Object
197 198 199 200 201 202 203 |
# File 'lib/ditz/operator.rb', line 197 def add project, config, opts issue = Issue.create_interactively(:args => [config, project]) or return issue.log "created", config.user, get_comment(opts) project.add_issue issue project.assign_issue_names! puts "Added issue #{issue.name} (#{issue.id})." end |
#add_component(project, config) ⇒ Object
224 225 226 227 228 |
# File 'lib/ditz/operator.rb', line 224 def add_component project, config component = Component.create_interactively(:args => [project, config]) or return project.add_component component puts "Added component #{component.name}." end |
#add_reference(project, config, opts, issue) ⇒ Object
234 235 236 237 238 239 240 |
# File 'lib/ditz/operator.rb', line 234 def add_reference project, config, opts, issue puts "Adding a reference to #{issue.name}: #{issue.title}." reference = ask "Reference" issue.add_reference reference issue.log "added reference #{issue.references.size}", config.user, get_comment(opts) puts "Added reference to #{issue.name}." end |
#add_release(project, config, opts, maybe_name) ⇒ Object
215 216 217 218 219 220 221 |
# File 'lib/ditz/operator.rb', line 215 def add_release project, config, opts, maybe_name puts "Adding release #{maybe_name}." if maybe_name release = Release.create_interactively(:args => [project, config], :with => { :name => maybe_name }) or return release.log "created", config.user, get_comment(opts) project.add_release release puts "Added release #{release.name}." end |
#archive(project, config, release, dir) ⇒ Object
565 566 567 568 569 570 571 572 573 574 |
# File 'lib/ditz/operator.rb', line 565 def archive project, config, release, dir dir ||= "ditz-archive-#{release.name}" FileUtils.mkdir dir FileUtils.cp project.pathname, dir project.issues_for_release(release).each do |i| FileUtils.cp i.pathname, dir project.drop_issue i end puts "Archived to #{dir}." end |
#assign(project, config, opts, issue, maybe_release) ⇒ Object
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/ditz/operator.rb', line 391 def assign project, config, opts, issue, maybe_release if maybe_release && maybe_release.name == issue.release raise Error, "issue #{issue.name} already assigned to release #{issue.release}" end puts "Issue #{issue.name} currently " + if issue.release "assigned to release #{issue.release}." else "not assigned to any release." end release = maybe_release || begin releases = project.releases.sort_by { |r| (r.release_time || 0).to_i } releases -= [releases.find { |r| r.name == issue.release }] if issue.release ask_for_selection(releases, "release") do |r| r.name + if r.released? " (released #{r.release_time.pretty_date})" else " (unreleased)" end end end issue.assign_to_release release, config.user, get_comment(opts) puts "Assigned #{issue.name} to #{release.name}." end |
#changelog(project, config, r) ⇒ Object
491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/ditz/operator.rb', line 491 def changelog project, config, r run_pager puts "== #{r.name} / #{r.released? ? r.release_time.pretty_date : 'unreleased'}" project.group_issues(project.issues_for_release(r)).each do |type, issues| issues.select { |i| i.closed? }.each do |i| if type == :bugfix puts "* #{type}: #{i.title}" else puts "* #{i.title}" end end end end |
#claim(project, config, opts, issue) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 94 def claim project, config, opts, issue puts "Claiming issue #{issue.name}: #{issue.title}." comment = ask_multiline "Comments" unless $opts[:no_comment] issue.claim config.user, comment, opts[:force] puts "Issue #{issue.name} marked as claimed by #{config.user}" end |
#claimed(project, config, opts, releases) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 132 def claimed project, config, opts, releases releases ||= project.unreleased_releases + [:unassigned] releases = [*releases] issues = project.issues.inject({}) do |h, i| r = project.release_for(i.release) || :unassigned if i.claimed? && (opts[:all] || i.open?) && releases.member?(r) (h[i.claimer] ||= []) << i end h end if issues.empty? puts "No issues." else issues.keys.sort.each do |c| puts "#{c}:" puts todo_list_for(issues[c], :show_release => true) puts end end end |
#close(project, config, opts, issue) ⇒ Object
380 381 382 383 384 385 |
# File 'lib/ditz/operator.rb', line 380 def close project, config, opts, issue puts "Closing issue #{issue.name}: #{issue.title}." disp = ask_for_selection Issue::DISPOSITIONS, "disposition", lambda { |x| Issue::DISPOSITION_STRINGS[x] || x.to_s } issue.close disp, config.user, get_comment(opts) puts "Closed issue #{issue.name} with disposition #{issue.disposition_string}." end |
#comment(project, config, opts, issue) ⇒ Object
460 461 462 463 464 465 466 467 468 469 |
# File 'lib/ditz/operator.rb', line 460 def comment project, config, opts, issue puts "Commenting on issue #{issue.name}: #{issue.title}." comment = get_comment opts if comment.blank? puts "Empty comment, aborted." else issue.log "commented", config.user, comment puts "Comments recorded for #{issue.name}." end end |
#commit(project, config, opts, issue) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/ditz/plugins/git.rb', line 129 def commit project, config, opts, issue opts[:edit] = true if opts[:message].nil? args = { :verbose => "--verbose", :all => "--all", :edit => "--edit", }.map { |k, v| opts[k] ? v : "" }.join(" ") comment = "# #{issue.name}: #{issue.title}" tag = "Ditz-issue: #{issue.id}" = if opts[:message] && !opts[:edit] "#{opts[:message]}\n\n#{tag}" elsif opts[:message] && opts[:edit] "#{opts[:message]}\n\n#{comment}\n#{tag}" else "#{comment}\n#{tag}" end = .gsub("\"", "\\\"") exec "git commit #{args} --message=\"#{}\"" end |
#do(op, project, config, args) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ditz/operator.rb', line 109 def do op, project, config, args meth = self.class.op_to_method(op) # Parse options, removing them from args opts = self.class.build_opts meth, args built_args = self.class.build_args project, meth, args built_args.unshift opts if opts send meth, project, config, *built_args end |
#drop(project, config, issue) ⇒ Object
206 207 208 209 |
# File 'lib/ditz/operator.rb', line 206 def drop project, config, issue project.drop_issue issue puts "Dropped #{issue.name}. Note that other issue names may have changed." end |
#edit(project, config, opts, issue) ⇒ Object
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'lib/ditz/operator.rb', line 581 def edit project, config, opts, issue data = { :title => issue.title, :description => issue.desc, :reporter => issue.reporter } fn = run_editor { |f| f.puts data.to_yaml } unless fn puts "Aborted." return end begin edits = YAML.load_file fn comment = opts[:silent] ? nil : get_comment(opts) if issue.change edits, config.user, comment, opts[:silent] puts "Change recorded." else puts "No changes." end end end |
#grep(project, config, opts, match) ⇒ Object
520 521 522 523 524 525 526 527 528 |
# File 'lib/ditz/operator.rb', line 520 def grep project, config, opts, match run_pager re = Regexp.new match, opts[:ignore_case] issues = project.issues.select do |i| i.title =~ re || i.desc =~ re || i.log_events.map { |time, who, what, comments| comments }.join(" ") =~ re end puts(todo_list_for(issues) || "No matching issues.") end |
#help(project, config, opts, command) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ditz/operator.rb', line 133 def help project, config, opts, command if opts[:cow] puts "MOO!" puts "All is well with the world now. A bit more methane though." return end run_pager return help_single(command) if command puts <<EOS Ditz commands: EOS ops = self.class.operations len = ops.map { |name, op| name.to_s.length }.max ops.each do |name, opts| printf " %#{len}s: %s\n", name, opts[:desc] end puts <<EOS Use 'ditz help <command>' for details. EOS end |
#help_single(command) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/ditz/operator.rb', line 156 def help_single command name, opts = self.class.operations.find { |name, spec| name == command } raise Error, "no such ditz command '#{command}'" unless name args = opts[:args_spec].map do |spec| case spec.to_s when /^maybe_(.*)$/ "[#{$1}]" else "<#{spec.to_s}>" end end.join(" ") puts <<EOS #{opts[:desc]}. Usage: ditz #{name} #{args} EOS end |
#html(project, config, dir) ⇒ Object
506 507 508 509 |
# File 'lib/ditz/operator.rb', line 506 def html project, config, dir dir ||= "html" HtmlView.new(project, config, dir).render_all end |
#init ⇒ Object
126 127 128 |
# File 'lib/ditz/operator.rb', line 126 def init Project.create_interactively end |
#label(project, config, issue, label_names) ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/ditz/plugins/issue-labeling.rb', line 109 def label project, config, issue, label_names labels = project.labels_for label_names puts "Adding labels #{label_names} to issue #{issue.name}: #{issue.title}." comment = ask_multiline "Comments" unless $opts[:no_comment] issue.apply_labels labels, config.user, comment show_labels issue end |
#labeled(project, config, opts, labels, releases) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/ditz/plugins/issue-labeling.rb', line 143 def labeled project, config, opts, labels, releases releases ||= project.unreleased_releases + [:unassigned] releases = [*releases] labels = project.labels_for labels issues = project.issues.select do |i| r = project.release_for(i.release) || :unassigned labels.all? { |l| i.labeled? l } && (opts[:all] || i.open?) && releases.member?(r) end if issues.empty? puts "No issues." else print_todo_list_by_release_for project, issues end end |
#log(project, config) ⇒ Object
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/ditz/operator.rb', line 531 def log project, config run_pager project.issues.map { |i| i.log_events.map { |e| [e, i] } }. flatten_one_level.sort_by { |e| e.first.first }.reverse. each do |(date, , what, comment), i| puts <<EOS date : #{date.localtime} (#{date.ago} ago) author: #{} issue: [#{i.name}] #{i.title} #{what} #{comment.gsub(/^/, " > ") unless comment =~ /^\A\s*\z/} EOS puts unless comment.blank? end end |
#mine(project, config, opts, releases) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 114 def mine project, config, opts, releases releases ||= project.unreleased_releases + [:unassigned] releases = [*releases] issues = project.issues.select do |i| r = project.release_for(i.release) || :unassigned releases.member?(r) && i.claimer == config.user && (opts[:all] || i.open?) end if issues.empty? puts "No issues." else print_todo_list_by_release_for project, issues end end |
#new_label(project, config, maybe_label) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/ditz/plugins/issue-labeling.rb', line 101 def new_label project, config, maybe_label puts "Adding label #{maybe_label}." if maybe_label label = Label.create_interactively(:args => [project, config], :with => { :name => maybe_label }) or return project.add_label label puts "Added label #{label.name}." end |
#print_todo_list_by_release_for(project, issues) ⇒ Object
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/ditz/operator.rb', line 315 def print_todo_list_by_release_for project, issues by_release = issues.inject({}) do |h, i| r = project.release_for(i.release) || :unassigned h[r] ||= [] h[r] << i h end (project.releases + [:unassigned]).each do |r| next unless by_release.member? r puts r == :unassigned ? "Unassigned:" : "#{r.name} (#{r.status}):" print todo_list_for(by_release[r]) puts end end |
#reconfigure(project, config) ⇒ Object
187 188 189 190 191 |
# File 'lib/ditz/operator.rb', line 187 def reconfigure project, config new_config = Config.create_interactively :defaults_from => config new_config.save! $opts[:config_file] puts "Configuration written." end |
#release(project, config, opts, release) ⇒ Object
485 486 487 488 |
# File 'lib/ditz/operator.rb', line 485 def release project, config, opts, release release.release! project, config.user, get_comment(opts) puts "Release #{release.name} released!" end |
#releases(project, config) ⇒ Object
472 473 474 475 476 477 478 479 |
# File 'lib/ditz/operator.rb', line 472 def releases project, config run_pager a, b = project.releases.partition { |r| r.released? } (b + a.sort_by { |r| r.release_time }).each do |r| status = r.released? ? "released #{r.release_time.pretty_date}" : r.status puts "#{r.name} (#{status})" end end |
#set_branch(project, config, issue, maybe_string) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ditz/plugins/git.rb', line 102 def set_branch project, config, issue, maybe_string puts "Issue #{issue.name} currently " + if issue.git_branch "assigned to git branch #{issue.git_branch.inspect}." else "not assigned to any git branch." end branch = maybe_string || ask("Git feature branch name:") return unless branch if branch == issue.git_branch raise Error, "issue #{issue.name} already assigned to branch #{issue.git_branch.inspect}" end puts "Assigning to branch #{branch.inspect}." issue.git_branch = branch end |
#set_component(project, config, opts, issue, maybe_component) ⇒ Object
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/ditz/operator.rb', line 421 def set_component project, config, opts, issue, maybe_component puts "Changing the component of issue #{issue.name}: #{issue.title}." if project.components.size == 1 raise Error, "this project does not use multiple components" end if maybe_component && maybe_component.name == issue.component raise Error, "issue #{issue.name} already assigned to component #{issue.component}" end component = maybe_component || begin components = project.components components -= [components.find { |r| r.name == issue.component }] if issue.component ask_for_selection(components, "component") { |r| r.name } end issue.assign_to_component component, config.user, get_comment(opts) oldname = issue.name project.assign_issue_names! puts <<EOS Issue #{oldname} is now #{issue.name}. Note that the names of other issues may have changed as well. EOS end |
#shortlog(project, config) ⇒ Object
549 550 551 552 553 554 555 556 557 558 559 560 561 562 |
# File 'lib/ditz/operator.rb', line 549 def shortlog project, config run_pager project.issues.map { |i| i.log_events.map { |e| [e, i] } }. flatten_one_level.sort_by { |e| e.first.first }.reverse. each do |(date, , what, comment), i| = if =~ /<(.*?)@/ $1 else end[0..15] printf "%13s|%13s|%13s|%s\n", date.ago, i.name, , what end end |
#show(project, config, issue) ⇒ Object
352 353 354 |
# File 'lib/ditz/operator.rb', line 352 def show project, config, issue ScreenView.new(project, config).render_issue issue end |
#start(project, config, opts, issue) ⇒ Object
360 361 362 363 364 |
# File 'lib/ditz/operator.rb', line 360 def start project, config, opts, issue puts "Starting work on issue #{issue.name}: #{issue.title}." issue.start_work config.user, get_comment(opts) puts "Recorded start of work for #{issue.name}." end |
#status(project, config, releases) ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/ditz/operator.rb', line 243 def status project, config, releases run_pager releases ||= project.unreleased_releases + [:unassigned] if releases.empty? puts "No releases." return end entries = releases.map do |r| title, issues = (r == :unassigned ? r.to_s : r.name), project.issues_for_release(r) middle = Issue::TYPES.map do |type| type_issues = issues.select { |i| i.type == type } num = type_issues.size nc = type_issues.count_of { |i| i.closed? } pc = 100.0 * (type_issues.empty? ? 1.0 : nc.to_f / num) "%2d/%2d %s" % [nc, num, type.to_s.pluralize(num, false)] end = if r == :unassigned "" elsif r.released? "(released)" elsif issues.empty? "(no issues)" elsif issues.all? { |i| i.closed? } "(ready for release)" else (issues) end [title, middle, ] end title_size = 0 middle_sizes = [] entries.each do |title, middle, | title_size = [title_size, title.length].max middle_sizes = middle.zip(middle_sizes).map do |e, s| [s || 0, e.length].max end end entries.each do |title, middle, | printf "%-#{title_size}s ", title middle.zip(middle_sizes).each_with_index do |(e, s), i| sep = i < middle.size - 1 ? "," : "" printf "%-#{s + sep.length}s ", e + sep end puts end end |
#status_bar_for(issues) ⇒ Object
298 299 300 301 302 303 |
# File 'lib/ditz/operator.rb', line 298 def issues Issue::STATUS_WIDGET. sort_by { |k, v| -Issue::STATUS_SORT_ORDER[k] }. map { |k, v| v * issues.count_of { |i| i.status == k } }. join end |
#stop(project, config, opts, issue) ⇒ Object
370 371 372 373 374 |
# File 'lib/ditz/operator.rb', line 370 def stop project, config, opts, issue puts "Stopping work on issue #{issue.name}: #{issue.title}." issue.stop_work config.user, get_comment(opts) puts "Recorded work stop for #{issue.name}." end |
#sync(project, config, opts) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ditz/plugins/git-sync.rb', line 55 def sync project, config, opts unless config.git_sync_local_branch $stderr.puts "Please run ditz reconfigure and set the local and remote branch names" return end Dir.chdir $project_root puts "[in #{$project_root}]" sh "git add *.yaml", :force => true, :fake => opts[:dry_run] sh "git commit -m 'issue updates'", :force => true, :fake => opts[:dry_run] sh "git pull", :fake => opts[:dry_run] sh "git push #{config.git_sync_remote_repo} #{config.git_sync_local_branch}:#{config.git_sync_remote_branch}", :fake => opts[:dry_run] puts puts "Ditz issue state synchronized." end |
#todo(project, config, opts, releases) ⇒ Object
334 335 336 |
# File 'lib/ditz/operator.rb', line 334 def todo project, config, opts, releases actually_do_todo project, config, releases, opts[:all] end |
#todo_list_for(issues, opts = {}) ⇒ Object
305 306 307 308 309 310 311 312 313 |
# File 'lib/ditz/operator.rb', line 305 def todo_list_for issues, opts={} return if issues.empty? name_len = issues.max_of { |i| i.name.length } issues.map do |i| s = sprintf "%s %#{name_len}s: %s", i., i.name, i.title s += " [#{i.release}]" if opts[:show_release] && i.release s + "\n" end.join end |
#unassign(project, config, opts, issue) ⇒ Object
450 451 452 453 454 |
# File 'lib/ditz/operator.rb', line 450 def unassign project, config, opts, issue puts "Unassigning issue #{issue.name}: #{issue.title}." issue.unassign config.user, get_comment(opts) puts "Unassigned #{issue.name}." end |
#unclaim(project, config, opts, issue) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 104 def unclaim project, config, opts, issue puts "Unclaiming issue #{issue.name}: #{issue.title}." comment = ask_multiline "Comments" unless $opts[:no_comment] issue.unclaim config.user, comment, opts[:force] puts "Issue #{issue.name} marked as unclaimed." end |
#unclaimed(project, config, opts, releases) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/ditz/plugins/issue-claiming.rb', line 158 def unclaimed project, config, opts, releases releases ||= project.unreleased_releases + [:unassigned] releases = [*releases] issues = project.issues.select do |i| r = project.release_for(i.release) || :unassigned releases.member?(r) && i.claimer.nil? && (opts[:all] || i.open?) end if issues.empty? puts "No issues." else print_todo_list_by_release_for project, issues end end |
#unlabel(project, config, issue, label_names) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ditz/plugins/issue-labeling.rb', line 118 def unlabel project, config, issue, label_names labels = if label_names puts "Removing #{label_names} labels from issue #{issue.name}: #{issue.title}." project.labels_for label_names else puts "Removing labels from issue #{issue.name}: #{issue.title}." nil end comment = ask_multiline "Comments" unless $opts[:no_comment] issue.remove_labels labels, config.user, comment show_labels issue end |
#validate(project, config) ⇒ Object
512 513 514 |
# File 'lib/ditz/operator.rb', line 512 def validate project, config ## a no-op end |