tracery 0.7.6 → 0.7.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc6be58e9cfc5484a72b215bb1b503c1a61f77fa
4
- data.tar.gz: 0e615f4130ccd03df0b33f87abeed9fb294feb2a
3
+ metadata.gz: 82d55b2e9461be2ad0f98538695e09e94362d57a
4
+ data.tar.gz: 645505f1d8075356c4dd107cd1c1d4e2de681e40
5
5
  SHA512:
6
- metadata.gz: ac5e3d659c35f1e313e305a86b87c9f2a403040e92656249209a1564700bf17cbf645b7d2ee374d5349617638e266740e7182fe94e0b225b8d5272b5e82a4ee4
7
- data.tar.gz: 43fafcfc0ba52adc1f69f62b03eeccaeed35d2ed9b2537bbba5f3522e10d8020e8e20e04ab58f3f52358b96fd029d1c09277f94f0245b82d735e2b7cf632089e
6
+ metadata.gz: 3b5be60323a1b3122199f80347cf6b6e2bf09f6212a2b5c601450096664764fc1069f195cb1e3bedbb21c9a1cec225f670a4cb32e936892713ad48ed26b40381
7
+ data.tar.gz: 898fa3176ac6e37c73ae568bfb8f0d99a6b0ba14100f93de15764369e0d36b66dfa0143719f59fde63a7eb6369b4ee2590e26bebcb144aaf7e65a28e4c0ff7c6
@@ -2,6 +2,10 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## 0.7.7 - 2016-07-02
6
+ ### Fixed
7
+ - [Capitalize downcases everything but first letter](https://github.com/elib/tracery/issues/20)
8
+
5
9
  ## 0.7.6 - 2016-04-29
6
10
  ### Added
7
11
  - This CHANGELOG.md file
@@ -21,6 +21,15 @@ module Modifiers
21
21
  return s + "s"
22
22
  end
23
23
  end
24
+
25
+ def self.capitalize(s)
26
+ head = s[0]
27
+ remainder = s[1..-1]
28
+ return s if(head.nil?)
29
+ head.upcase!
30
+ return head if remainder.nil?
31
+ return head + remainder
32
+ end
24
33
 
25
34
  def self.baseEngModifiers
26
35
  {
@@ -29,11 +38,11 @@ module Modifiers
29
38
  end,
30
39
 
31
40
  "capitalizeAll" => lambda do |s, parameters|
32
- return s.gsub(/\w+/) {|word| word.capitalize}
41
+ return s.gsub(/\w+/) {|word| capitalize word}
33
42
  end,
34
43
 
35
44
  "capitalize" => lambda do |s, parameters|
36
- return s.capitalize
45
+ return capitalize s
37
46
  end,
38
47
 
39
48
  "a" => lambda do |s, parameters|
@@ -1,3 +1,3 @@
1
1
  module Tracery
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
@@ -26,6 +26,10 @@ class TraceryTest < Test::Unit::TestCase
26
26
  "monster" => ["dragon", "ogre", "witch", "wizard", "goblin", "golem", "giant", "sphinx", "warlord"],
27
27
  "setPronouns" => ["[heroThey:they][heroThem:them][heroTheir:their][heroTheirs:theirs]", "[heroThey:she][heroThem:her][heroTheir:her][heroTheirs:hers]", "[heroThey:he][heroThem:him][heroTheir:his][heroTheirs:his]"],
28
28
  "setOccupation" => ["[occupation:baker][didStuff:baked bread,decorated cupcakes,folded dough,made croissants,iced a cake]", "[occupation:warrior][didStuff:fought #monster.a#,saved a village from #monster.a#,battled #monster.a#,defeated #monster.a#]"],
29
+ "capitalizeMe" => "SOME CAPITAL LETTERS",
30
+ "capitalizeMore" => "this sentence HAS CAPITALS IN IT",
31
+ "empty" => "",
32
+ "single" => "a",
29
33
  "origin" => ["#[#setPronouns#][#setOccupation#][hero:#name#]story#"]
30
34
  })
31
35
  @grammar.addModifiers(Modifiers.baseEngModifiers)
@@ -113,6 +117,31 @@ class TraceryTest < Test::Unit::TestCase
113
117
  src: "[pet:#animal#]#nonrecursiveStory# -> #nonrecursiveStory.replace(beach,mall)#"
114
118
  },
115
119
 
120
+ modifierCapitalize: {
121
+ src: "#capitalizeMe.capitalize#",
122
+ expected: "SOME CAPITAL LETTERS"
123
+ },
124
+
125
+ modifierCapitalizeMore: {
126
+ src: "#capitalizeMore.capitalize#",
127
+ expected: "This sentence HAS CAPITALS IN IT"
128
+ },
129
+
130
+ modifierCapitalizeMoreEach: {
131
+ src: "#capitalizeMore.capitalizeAll#",
132
+ expected: "This Sentence HAS CAPITALS IN IT"
133
+ },
134
+
135
+ modifierCapitalizeEmpty: {
136
+ src: "#empty.capitalize#",
137
+ expected: ""
138
+ },
139
+
140
+ modifierCapitalizeSingle: {
141
+ src: "#single.capitalize#",
142
+ expected: "A"
143
+ },
144
+
116
145
  recursivePush: {
117
146
  src: "[pet:#animal#]#recursiveStory#"
118
147
  },
@@ -148,7 +177,6 @@ class TraceryTest < Test::Unit::TestCase
148
177
  }
149
178
  }
150
179
 
151
- puts
152
180
  tests.each { |k,v|
153
181
  puts "#{k}: "
154
182
  @grammar.clearState
@@ -157,18 +185,19 @@ class TraceryTest < Test::Unit::TestCase
157
185
  root = @grammar.expand(source)
158
186
  all_errors = root.allErrors
159
187
 
160
- if(!v[:expected].nil?) then
161
- assert(root.finishedText == v[:expected], "\"#{root.finishedText}\" did not match \"#{v[:expected]}\"")
162
- else
163
- puts "\t#{root.finishedText}"
188
+ expected = v[:expected]
189
+
190
+ if(!expected.nil?) then
191
+ assert(root.finishedText == expected, "\"#{root.finishedText}\" did not match \"#{expected}\"")
164
192
  end
165
193
 
166
194
  if(is_error) then
167
- puts "\tErrors: #{all_errors}"
168
195
  refute(all_errors.empty?, "Expected errors.")
169
196
  else
170
197
  assert(all_errors.empty?, "Expected no errors.")
171
- refute(root.finishedText.empty?, "Expected non-empty output.")
198
+ if(!expected.nil? && !expected.empty?) then
199
+ refute(root.finishedText.empty?, "Expected non-empty output.")
200
+ end
172
201
  end
173
202
  }
174
203
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kate Compton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-29 00:00:00.000000000 Z
12
+ date: 2016-07-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |
15
15
  Tracery is a library for text generation.