saga 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.kick CHANGED
@@ -9,6 +9,8 @@ process do |files|
9
9
  "test/#{$1.gsub('/', '_')}_spec.rb"
10
10
  when %r{^test/(.+)_spec\.rb$}
11
11
  file
12
+ when %r{^test/cases}
13
+ "test/saga_tokenizer_spec.rb"
12
14
  end
13
15
  end)
14
16
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.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 = '(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
 
@@ -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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{saga}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Manfred Stienstra"]
@@ -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
@@ -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
- <%= "\n#{header}\n\n" unless header.strip == '' -%>
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
- <%= "\n#{header}\n\n" unless header.strip == '' -%>
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 %>
@@ -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 << "##{story[:status]}" if story[:status]
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]}
@@ -50,7 +50,7 @@ describe "A Runner" do
50
50
  output = collect_stdout do
51
51
  runner.run
52
52
  end
53
- output.should.include('Requirements (Title)')
53
+ output.should.include('Requirements Title')
54
54
  output.should.include('- Manfred Stienstra')
55
55
  end
56
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra