inkcite 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e391fed5c45670dba9e4bb01afdec27bb9ce9a8
4
- data.tar.gz: 07dded169cb4a67d56cad26c7f39ead9c3118dfa
3
+ metadata.gz: 8b4814acacbf7cdc4b0b6c9ff9e124094ca1b08c
4
+ data.tar.gz: 276345f2b8b0205675c97734b2f297d6a15334ad
5
5
  SHA512:
6
- metadata.gz: 541565fcca55aaa6253a29bc437f3350ea4376514da88c13ae1efad1ed2c5d8eff7449949136d406a336d3ee0d36b9c7468e21d63044f6f83bc0af38018153a4
7
- data.tar.gz: 31fb64ab71c6973d79a92d706ce2328016db9e9f36c9364eba715838088a0f3e631c6ba6a4624c68c04b9d31db6977d03cbfeb778eee8f74da8e8e48f2a7b83c
6
+ metadata.gz: 40d16b2fc96750094b4b59f7ae3d6096fdcf03fcc9f77848dfb111291c9c748e7ff49f5fb0501d0ce02789206eeefcfc024439dbb6b4f2a097518bfc4409a7c4
7
+ data.tar.gz: 37e96c39c9856b921a2432047cfa3a59853ad7b1ee2e7e20f13a381697a336be1d506cea74e1c64e5429cc16350e96f3df7def95bb2dfff10863729f8fa27da8
@@ -33,6 +33,10 @@ module Inkcite
33
33
  @symbol == @symbol.to_i.to_s
34
34
  end
35
35
 
36
+ def symbol?
37
+ !numeric?
38
+ end
39
+
36
40
  def to_s
37
41
  "#{symbol} #{text}"
38
42
  end
@@ -61,7 +65,7 @@ module Inkcite
61
65
  # there is one, increment the count. Otherwise, start the count
62
66
  # off at one.
63
67
  last_instance = ctx.footnotes.select(&:numeric?).last
64
- symbol = last_instance.nil?? 1 : last_instance.symbol.to_i + 1
68
+ symbol = last_instance.nil? ? 1 : last_instance.symbol.to_i + 1
65
69
 
66
70
  end
67
71
 
@@ -94,7 +98,7 @@ module Inkcite
94
98
  # on the format of the email.
95
99
  tmpl = opt[:tmpl] || opt[:template]
96
100
  if tmpl.blank?
97
- tmpl = ctx.text?? "($symbol$) $text$\n\n" : "<sup>$symbol$</sup> $text$<br><br>"
101
+ tmpl = ctx.text? ? "($symbol$) $text$\n\n" : "<sup>$symbol$</sup> $text$<br><br>"
98
102
 
99
103
  elsif ctx.text?
100
104
 
@@ -104,23 +108,19 @@ module Inkcite
104
108
 
105
109
  end
106
110
 
111
+ # First, collect all symbols in the natural order they are defined
112
+ # in the email.
113
+ footnotes = ctx.footnotes.select(&:symbol?)
107
114
 
108
- # Symbolic footnotes (e.g. daggers) always go ahead of
109
- # the numeric footnotes - cause that's the way I like it
110
- # uh huh, uh huh.
111
- ctx.footnotes.sort! do |f1, f2|
112
-
113
- next 1 if f1.numeric? && !f2.numeric?
114
- next -1 if !f1.numeric? && f2.numeric?
115
- f1.number <=> f2.number
116
-
117
- end
115
+ # Now add to the list all numeric footnotes ordered naturally
116
+ # regardless of how they were ordered in the email.
117
+ footnotes += ctx.footnotes.select(&:numeric?).sort { |f1, f2| f1.number <=> f2.number }
118
118
 
119
119
  html = ''
120
120
 
121
121
  # Iterate through each of the footnotes and render them based on the
122
122
  # template that was provided.
123
- ctx.footnotes.collect do |f|
123
+ footnotes.each do |f|
124
124
  html << tmpl.gsub('$symbol$', f.symbol).gsub('$text$', f.text)
125
125
  end
126
126
 
@@ -1,3 +1,3 @@
1
1
  module Inkcite
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -37,6 +37,10 @@ describe Inkcite::Renderer::Footnote do
37
37
  Inkcite::Renderer.render('({footnote text="EPA-estimated fuel economy."})({footnote symbol="†" text="See Blackmur, especially chapters 3 and 4, for an insightful analysis of this trend."})({footnote text="Actual mileage may vary."})<br><br>{footnotes}', @view).must_equal("(1)(†)(2)<br><br><sup>†</sup> See Blackmur, especially chapters 3 and 4, for an insightful analysis of this trend.<br><br><sup>1</sup> EPA-estimated fuel economy.<br><br><sup>2</sup> Actual mileage may vary.<br><br>")
38
38
  end
39
39
 
40
+ it 'sorts symbols in the order they are defined' do
41
+ Inkcite::Renderer.render('({footnote text="EPA-estimated fuel economy."})({footnote symbol="†" text="See Blackmur, especially chapters 3 and 4, for an insightful analysis of this trend."})({footnote symbol="*" text="Actual mileage may vary."})<br><br>{footnotes}', @view).must_equal("(1)(†)(*)<br><br><sup>†</sup> See Blackmur, especially chapters 3 and 4, for an insightful analysis of this trend.<br><br><sup>*</sup> Actual mileage may vary.<br><br><sup>1</sup> EPA-estimated fuel economy.<br><br>")
42
+ end
43
+
40
44
  it 'can have a reusable, readable ID assigned to it' do
41
45
  Inkcite::Renderer.render('({footnote id="epa" text="EPA-estimated fuel economy."})({footnote id="epa"})', @view).must_equal("(1)(1)")
42
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inkcite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey D. Hoffman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-30 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport