Class: DitzStr::Project
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
Class Method 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, inherited, #initialize, #inspect, #log, #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/ditzstr/model-objects.rb', line 47
def issues
@issues
end
|
Returns the value of attribute pathname.
44
45
46
|
# File 'lib/ditzstr/model-objects.rb', line 44
def pathname
@pathname
end
|
Class Method Details
131
132
133
134
135
|
# File 'lib/ditzstr/model-objects.rb', line 131
def self.from *a
p = super(*a)
p.validate!
p
end
|
Instance Method Details
#add_issue(issue) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/ditzstr/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
70
|
# File 'lib/ditzstr/model-objects.rb', line 70
def added_issues; @added_issues ||= [] end
|
#assign_issue_names! ⇒ Object
115
116
117
118
119
120
121
|
# File 'lib/ditzstr/model-objects.rb', line 115
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 = "#{prefixes[i.component]}-#{ids[i.component] += 1}"
end
end
|
#component_for(component_name) ⇒ Object
89
90
91
|
# File 'lib/ditzstr/model-objects.rb', line 89
def component_for component_name
components.find { |i| i.name == component_name }
end
|
#deleted_issues ⇒ Object
71
|
# File 'lib/ditzstr/model-objects.rb', line 71
def deleted_issues; @deleted_issues ||= [] end
|
#drop_issue(issue) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/ditzstr/model-objects.rb', line 63
def drop_issue issue
if issues.delete issue
deleted_issues << issue
assign_issue_names!
end
end
|
#get_components ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/ditzstr/model-objects.rb', line 73
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
|
#group_issues(these_issues = issues) ⇒ Object
111
112
113
|
# File 'lib/ditzstr/model-objects.rb', line 111
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
84
85
86
87
|
# File 'lib/ditzstr/model-objects.rb', line 84
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
103
104
105
|
# File 'lib/ditzstr/model-objects.rb', line 103
def issues_for_component component
issues.select { |i| i.component == component.name }
end
|
#issues_for_release(release) ⇒ Object
99
100
101
|
# File 'lib/ditzstr/model-objects.rb', line 99
def issues_for_release release
release == :unassigned ? unassigned_issues : issues.select { |i| i.release == release.name }
end
|
#release_for(release_name) ⇒ Object
93
94
95
|
# File 'lib/ditzstr/model-objects.rb', line 93
def release_for release_name
releases.find { |i| i.name == release_name }
end
|
#unassigned_issues ⇒ Object
107
108
109
|
# File 'lib/ditzstr/model-objects.rb', line 107
def unassigned_issues
issues.select { |i| i.release.nil? }
end
|
#unreleased_releases ⇒ Object
97
|
# File 'lib/ditzstr/model-objects.rb', line 97
def unreleased_releases; releases.select { |r| r.unreleased? } end
|
#validate! ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/ditzstr/model-objects.rb', line 123
def validate!
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
|