Class: Ditz::Project
- Inherits:
-
ModelObject
show all
- Defined in:
- lib/ditz/plugins/issue-labeling.rb,
lib/ditz/model-objects.rb,
lib/ditz/plugins/sha-names.rb,
lib/ditz/plugins/issue-claiming.rb
Overview
Defined Under Namespace
Classes: Error
Constant Summary
collapse
- SHA_NAME_LENGTH =
5
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from ModelObject
#changed!, #changed?, changes_are_logged, create, create_interactively, #deserialized_form_of, #each_modelobject, field, field_names, from, inherited, #initialize, #inspect, #save!, #serialized_form_of, #to_s, #to_yaml, #to_yaml_type, #unchanged!, yaml_domain, yaml_other_thing
Instance Attribute Details
issues are not model fields proper, so we build up their interface here.
47
48
49
|
# File 'lib/ditz/model-objects.rb', line 47
def issues
@issues
end
|
Returns the value of attribute pathname.
44
45
46
|
# File 'lib/ditz/model-objects.rb', line 44
def pathname
@pathname
end
|
Instance Method Details
#__old_drop_release ⇒ Object
70
|
# File 'lib/ditz/model-objects.rb', line 70
alias :__old_drop_release :drop_release
|
#add_issue(issue) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/ditz/model-objects.rb', line 55
def add_issue issue
added_issues << issue
issues << issue
issue.project = self
assign_issue_names!
issue
end
|
#added_issues ⇒ Object
76
|
# File 'lib/ditz/model-objects.rb', line 76
def added_issues; @added_issues ||= [] end
|
#assign_issue_names! ⇒ Object
121
122
123
124
125
126
127
|
# File 'lib/ditz/model-objects.rb', line 121
def assign_issue_names!
prefixes = components.map { |c| [c.name, c.name.gsub(/^\s+/, "-").downcase] }.to_h
ids = components.map { |c| [c.name, 0] }.to_h
issues.sort_by { |i| i.creation_time }.each do |i|
i.name = components.length > 1 ? "#{prefixes[i.component]}-#{ids[i.component] += 1}" : "##{ids[i.component] += 1}"
end
end
|
#component_for(component_name) ⇒ Object
95
96
97
|
# File 'lib/ditz/model-objects.rb', line 95
def component_for component_name
components.find { |i| i.name == component_name }
end
|
#deleted_issues ⇒ Object
77
|
# File 'lib/ditz/model-objects.rb', line 77
def deleted_issues; @deleted_issues ||= [] end
|
#drop_issue(issue) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/ditz/model-objects.rb', line 63
def drop_issue issue
if issues.delete issue
deleted_issues << issue
assign_issue_names!
end
end
|
#drop_release(release) ⇒ Object
71
72
73
74
|
# File 'lib/ditz/model-objects.rb', line 71
def drop_release release
raise Error, "only can drop releases without issues" unless issues_for_release(release).empty?
__old_drop_release release
end
|
#get_components ⇒ Object
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/ditz/model-objects.rb', line 79
def get_components
puts <<EOS
Issues can be tracked across the project as a whole, or the project can be
split into components, and issues tracked separately for each component.
EOS
use_components = ask_yon "Track issues separately for different components?"
comp_names = use_components ? ask_for_many("components") : []
([name] + comp_names).uniq.map { |n| Component.create_interactively :with => { :name => n } }
end
|
#get_labels ⇒ Object
38
39
40
41
|
# File 'lib/ditz/plugins/issue-labeling.rb', line 38
def get_labels
lab_names = ask_for_many("labels")
([name] + lab_names).uniq.map { |n| Label.create_interactively :with => { :name => n } }
end
|
#group_issues(these_issues = issues) ⇒ Object
117
118
119
|
# File 'lib/ditz/model-objects.rb', line 117
def group_issues these_issues=issues
these_issues.group_by { |i| i.type }.sort_by { |(t,g)| Issue::TYPE_ORDER[t] }
end
|
#issues_for(ident) ⇒ Object
90
91
92
93
|
# File 'lib/ditz/model-objects.rb', line 90
def issues_for ident
by_name = issues.find { |i| i.name == ident }
by_name ? [by_name] : issues.select { |i| i.id =~ /^#{Regexp::escape ident}/ }
end
|
#issues_for_component(component) ⇒ Object
109
110
111
|
# File 'lib/ditz/model-objects.rb', line 109
def issues_for_component component
issues.select { |i| i.component == component.name }
end
|
#issues_for_release(release) ⇒ Object
105
106
107
|
# File 'lib/ditz/model-objects.rb', line 105
def issues_for_release release
release == :unassigned ? unassigned_issues : issues.select { |i| i.release == release.name }
end
|
#label_for(label_name) ⇒ Object
43
44
45
|
# File 'lib/ditz/plugins/issue-labeling.rb', line 43
def label_for label_name
labels.find { |i| i.name == label_name }
end
|
#labels_for(label_names) ⇒ Object
47
48
49
50
51
|
# File 'lib/ditz/plugins/issue-labeling.rb', line 47
def labels_for label_names
label_names.split(/\s*,\s*/).map do |val|
label_for(val) or raise Error, "no label with name #{val}"
end
end
|
#release_for(release_name) ⇒ Object
99
100
101
|
# File 'lib/ditz/model-objects.rb', line 99
def release_for release_name
releases.find { |i| i.name == release_name }
end
|
#unassigned_issues ⇒ Object
113
114
115
|
# File 'lib/ditz/model-objects.rb', line 113
def unassigned_issues
issues.select { |i| i.release.nil? }
end
|
#unreleased_releases ⇒ Object
103
|
# File 'lib/ditz/model-objects.rb', line 103
def unreleased_releases; releases.select { |r| r.unreleased? } end
|
#validate!(whence, context) ⇒ Object
129
130
131
132
133
134
135
136
|
# File 'lib/ditz/model-objects.rb', line 129
def validate! whence, context
config, project = context
if(dup = components.map { |c| c.name }.first_duplicate)
raise Error, "more than one component named #{dup.inspect}: #{components.inspect}"
elsif(dup = releases.map { |r| r.name }.first_duplicate)
raise Error, "more than one release named #{dup.inspect}"
end
end
|