Permalink
Browse files

[BUGFIX] Concatenating documents containing strings across the border…

… inserts appropriate spacing


Fixes #21
  • Loading branch information...
1 parent 87cfac8 commit e00b0684956ea0728a5b0680fd8bbc2362ef7cf3 @benlangfeld benlangfeld committed Feb 24, 2014
Showing with 6 additions and 0 deletions.
  1. +1 −0 CHANGELOG.md
  2. +5 −0 lib/ruby_speech/generic_element.rb
View
@@ -1,5 +1,6 @@
# [develop](https://github.com/benlangfeld/ruby_speech)
* Bugfix: Phone number grammar should only allow a single instance of '*'/'x'
+ * Bugfix: Concatenating documents containing strings across the border inserts appropriate spacing (#21).
# [2.3.0](https://github.com/benlangfeld/ruby_speech/compare/v2.2.2...v2.3.0) - [2013-09-30](https://rubygems.org/gems/ruby_speech/versions/2.3.0)
* Feature: Allow generation of a boolean, date, digits, currency, number, phone or time grammar including from URIs
@@ -107,10 +107,15 @@ def +(other)
new_doc.root = new_element.node
if Nokogiri.jruby?
new_element.add_child self.clone.nokogiri_children
+ new_element << " "
new_element.add_child other.clone.nokogiri_children
else
# TODO: This is yucky because it requires serialization
new_element.add_child self.nokogiri_children.to_xml
+ string_types = [String, Nokogiri::XML::Text]
+ if string_types.include?(self.nokogiri_children.last.class) && string_types.include?(other.nokogiri_children.first.class)
+ new_element << " "
+ end
new_element.add_child other.nokogiri_children.to_xml
end
end

0 comments on commit e00b068

Please sign in to comment.