saga 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.kick +2 -0
- data/VERSION +1 -1
- data/lib/saga/runner.rb +11 -1
- data/lib/saga/tokenizer.rb +15 -0
- data/saga.gemspec +1 -1
- data/templates/default/document.erb +1 -1
- data/templates/default/helpers.rb +15 -0
- data/templates/saga/document.erb +11 -6
- data/templates/saga/helpers.rb +14 -1
- data/test/cases/story_attributes.txt +13 -1
- data/test/saga_runner_spec.rb +1 -1
- metadata +1 -1
data/.kick
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/saga/runner.rb
CHANGED
@@ -27,8 +27,18 @@ module Saga
|
|
27
27
|
|
28
28
|
def new_file
|
29
29
|
document = Saga::Document.new
|
30
|
-
document.title = '
|
30
|
+
document.title = 'Title'
|
31
31
|
document.authors << self.class.author
|
32
|
+
document.stories[''] = [{
|
33
|
+
:description => 'As a writer I would like to write stories so developers can implement them.',
|
34
|
+
:id => 1,
|
35
|
+
:status => 'todo'
|
36
|
+
}]
|
37
|
+
document.definitions[''] = [{
|
38
|
+
:title => 'Writer',
|
39
|
+
:definition => 'Someone who is responsible for writing down requirements in the form of stories'
|
40
|
+
}]
|
41
|
+
|
32
42
|
Saga::Formatter.format(document, :template => 'saga')
|
33
43
|
end
|
34
44
|
|
data/lib/saga/tokenizer.rb
CHANGED
@@ -22,6 +22,17 @@ module Saga
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.interval(input)
|
26
|
+
case input.strip
|
27
|
+
when 'd'
|
28
|
+
:days
|
29
|
+
when 'w'
|
30
|
+
:weeks
|
31
|
+
else
|
32
|
+
:hours
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
def self.tokenize_story_attributes(input)
|
26
37
|
return {} if input.nil?
|
27
38
|
|
@@ -34,6 +45,10 @@ module Saga
|
|
34
45
|
next
|
35
46
|
elsif match = /\#(\d+)/.match(part)
|
36
47
|
attributes[:id] = match[1].to_i
|
48
|
+
elsif match = /i(\d+)/.match(part)
|
49
|
+
attributes[:iteration] = match[1].to_i
|
50
|
+
elsif match = /(\d+)(d|w|h|)/.match(part)
|
51
|
+
attributes[:estimate] = [match[1].to_i, interval(match[2])]
|
37
52
|
else
|
38
53
|
rest << part
|
39
54
|
end
|
data/saga.gemspec
CHANGED
@@ -47,7 +47,7 @@
|
|
47
47
|
<tr class="<%= story[:status] %>" id="story<%= story[:id] %>">
|
48
48
|
<td class="story"><%= story[:description] %></td>
|
49
49
|
<td class="meta id"><%= story[:id] %></td>
|
50
|
-
<td class="meta estimate"><%= story[:estimate] %></td>
|
50
|
+
<td class="meta estimate"><%= format_estimate(*story[:estimate]) if story[:estimate] %></td>
|
51
51
|
<td class="meta iteration"><%= story[:iteration] %></td>
|
52
52
|
<td class="meta status"><%= story[:status] %></td>
|
53
53
|
</tr>
|
@@ -14,4 +14,19 @@ module Helpers
|
|
14
14
|
def format_header(header)
|
15
15
|
"#{header[0,1].upcase}#{header[1..-1].downcase}"
|
16
16
|
end
|
17
|
+
|
18
|
+
def pluralize(cardinality, singular, plural)
|
19
|
+
[cardinality, cardinality == 1 ? singular : plural].join(' ')
|
20
|
+
end
|
21
|
+
|
22
|
+
def format_estimate(cardinality, interval)
|
23
|
+
case interval
|
24
|
+
when :days
|
25
|
+
pluralize(cardinality, 'day', 'days')
|
26
|
+
when :weeks
|
27
|
+
pluralize(cardinality, 'week', 'days')
|
28
|
+
else
|
29
|
+
cardinality.to_s
|
30
|
+
end
|
31
|
+
end
|
17
32
|
end
|
data/templates/saga/document.erb
CHANGED
@@ -8,18 +8,23 @@ Requirements <%= title %>
|
|
8
8
|
<% end -%>
|
9
9
|
|
10
10
|
USER STORIES
|
11
|
-
<% unless stories.keys.empty? -%>
|
12
|
-
|
13
11
|
<% stories.each do |header, stories| -%>
|
14
|
-
|
12
|
+
<% if header.strip == '' %>
|
13
|
+
|
14
|
+
<% else %>
|
15
|
+
<%= "\n#{header}\n\n" -%>
|
16
|
+
<% end %>
|
15
17
|
<% stories.each do |story| -%>
|
16
18
|
<%= format_story(story) %>
|
17
19
|
<% end -%>
|
18
20
|
<% end -%>
|
19
|
-
<% end -%>
|
20
21
|
<% definitions.each do |header, definitions| -%>
|
21
|
-
|
22
|
+
<% if header.strip == '' %>
|
23
|
+
|
24
|
+
<% else %>
|
25
|
+
<%= "\n#{header}\n\n" -%>
|
26
|
+
<% end %>
|
22
27
|
<% definitions.each do |definition| -%>
|
23
28
|
<%= format_definition(definition) %>
|
24
29
|
<% end %>
|
25
|
-
<% end %>
|
30
|
+
<% end %>
|
data/templates/saga/helpers.rb
CHANGED
@@ -5,10 +5,23 @@ module Helpers
|
|
5
5
|
end.compact.join(', ')
|
6
6
|
end
|
7
7
|
|
8
|
+
def format_estimate(cardinality, interval)
|
9
|
+
case interval
|
10
|
+
when :days
|
11
|
+
"#{cardinality}d"
|
12
|
+
when :weeks
|
13
|
+
"#{cardinality}w"
|
14
|
+
else
|
15
|
+
cardinality.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
8
19
|
def format_story(story)
|
9
20
|
story_attributes = []
|
10
21
|
story_attributes << "##{story[:id]}" if story[:id]
|
11
|
-
story_attributes <<
|
22
|
+
story_attributes << story[:status] if story[:status]
|
23
|
+
story_attributes << format_estimate(*story[:estimate]) if story[:estimate]
|
24
|
+
story_attributes << "i#{story[:iteration]}" if story[:iteration]
|
12
25
|
|
13
26
|
parts = [[story[:description], story_attributes.join(' ')].join(' - ')]
|
14
27
|
parts << " #{story[:notes]}" if story[:notes]
|
@@ -7,4 +7,16 @@
|
|
7
7
|
#12 todo
|
8
8
|
=> {:id => 12, :status => 'todo'}
|
9
9
|
#3 partially done
|
10
|
-
=> {:id => 3, :status => 'partially done'}
|
10
|
+
=> {:id => 3, :status => 'partially done'}
|
11
|
+
12
|
12
|
+
=> {:estimate => [12, :hours]}
|
13
|
+
1d
|
14
|
+
=> {:estimate => [1, :days]}
|
15
|
+
#1 1w partially done
|
16
|
+
=> {:id => 1, :estimate => [1, :weeks], :status => 'partially done'}
|
17
|
+
i12
|
18
|
+
=> {:iteration => 12}
|
19
|
+
#1 i1
|
20
|
+
=> {:id => 1, :iteration => 1}
|
21
|
+
#3 1 i2
|
22
|
+
=> {:id => 3, :iteration => 2, :estimate => [1, :hours]}
|
data/test/saga_runner_spec.rb
CHANGED