summary_judgement 1.3.6 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.6
1
+ 1.3.7
@@ -95,11 +95,27 @@ module SummaryJudgement
95
95
  when TrueClass
96
96
  options[:person] ||= :third
97
97
  end
98
- result << Verbs::Conjugator.conjugate(self.class.summary.predicate, options.slice(:person, :subject, :tense, :plurality)).to_s
99
- results = result.humanize unless options[:subject].is_a?(String)
100
- result << ' '
101
98
  end
102
- result << self.class.summary.class.render(self.class.summary.default, self).with_indefinite_article(!conjugation)
99
+ if placeholder = self.class.summary.default
100
+ if conjugation
101
+ result << Verbs::Conjugator.conjugate(self.class.summary.predicate, options.slice(:person, :subject, :tense, :plurality)).to_s
102
+ results = result.humanize unless options[:subject].is_a?(String)
103
+ result << ' '
104
+ end
105
+ result << self.class.summary.class.render(placeholder, self).with_indefinite_article(!conjugation)
106
+ elsif twigs = children.flatten.select(&:children)
107
+ if conjugation and options[:subject]
108
+ result << case options[:subject]
109
+ when String
110
+ options[:subject]
111
+ when Symbol, TrueClass
112
+ Verbs::Conjugator.subject(options.slice(:person, :plurality)).humanize
113
+ end
114
+ result << ' '
115
+ end
116
+ result << twigs.map { |t| t.summary options.merge(:subject => false, :conjugate => conjugation) }.to_sentence
117
+ end
118
+ result
103
119
  end
104
120
 
105
121
  def organize_leaves(*leaves)
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{summary_judgement}
8
- s.version = "1.3.6"
8
+ s.version = "1.3.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andy Rossmeissl"]
data/test/helper.rb CHANGED
@@ -85,6 +85,12 @@ class Shelf < Library
85
85
  end
86
86
  end
87
87
 
88
+ class Rack < Library
89
+ summarize do |has|
90
+ has.placeholder 'empty rack'
91
+ end
92
+ end
93
+
88
94
  class Catalog
89
95
  attr_reader :libraries
90
96
  def initialize(*libraries)
@@ -13,6 +13,8 @@ class TestSummaryJudgement < Test::Unit::TestCase
13
13
  @anne = Librarian.new
14
14
  @seamus = Enthusiast.new
15
15
  @new_releases = Shelf.new # empty!
16
+ @new_magazines = Rack.new # empty!
17
+ @browsing_section = Catalog.new @new_releases, @new_magazines
16
18
  end
17
19
 
18
20
  def test_setup
@@ -96,4 +98,8 @@ class TestSummaryJudgement < Test::Unit::TestCase
96
98
  assert_equal 'I have read 2 books and have skimmed 1 magazine', @catalog.summary(:conjugate => :first, :subject => true, :aspect => :perfect)
97
99
  assert_equal 'I have read a novel by William Gibson and an illustrated childrens book by Maurice Sendak and have skimmed a magazine issue from December 2009', @catalog.summary(:conjugate => :first, :subject => true, :aspect => :perfect, :verbose => true)
98
100
  end
101
+
102
+ def test_delegated_placeholders
103
+ assert_equal 'You have an empty shelf and have an empty rack', @browsing_section.summary(:conjugate => :second, :subject => true)
104
+ end
99
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: summary_judgement
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Rossmeissl