Skip to content

Commit

Permalink
Allow setting the language and base URI on an SSML <speak/>
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Jun 21, 2011
1 parent 6f4bd92 commit e8ea671
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/ruby_speech.rb
Expand Up @@ -7,6 +7,8 @@
module RubySpeech
extend ActiveSupport::Autoload

autoload :SSML
autoload :Version

autoload :SSML
autoload :XML
end
16 changes: 13 additions & 3 deletions lib/ruby_speech/ssml/speak.rb
@@ -1,13 +1,23 @@
module RubySpeech
module SSML
class Speak < Niceogiri::XML::Node
include XML::Language

def self.new
super('speak').tap do |new_doc|
new_doc.namespace = 'http://www.w3.org/2001/10/synthesis'
new_doc[:version] = '1.0'
new_doc['xml:lang'] = "en-US"
new_doc[:version] = '1.0'
new_doc.namespace = 'http://www.w3.org/2001/10/synthesis'
new_doc.language = "en-US"
end
end

def base_uri
read_attr :base
end

def base_uri=(uri)
write_attr 'xml:base', uri
end
end # Document
end # SSML
end # RubySpeech
7 changes: 7 additions & 0 deletions lib/ruby_speech/xml.rb
@@ -0,0 +1,7 @@
module RubySpeech
module XML
extend ActiveSupport::Autoload

autoload :Language
end # XML
end # RubySpeech
13 changes: 13 additions & 0 deletions lib/ruby_speech/xml/language.rb
@@ -0,0 +1,13 @@
module RubySpeech
module XML
module Language
def language
read_attr :lang
end

def language=(l)
write_attr 'xml:lang', l
end
end # Language
end # XML
end # RubySpeech
13 changes: 13 additions & 0 deletions spec/ruby_speech/ssml/speak_spec.rb
Expand Up @@ -6,6 +6,19 @@ module SSML
it { should be_a_valid_ssml_document }

its(:name) { should == 'speak' }
its(:language) { should == 'en-US' }

describe "#language" do
before { subject.language = 'jp' }

its(:language) { should == 'jp' }
end

describe "#base_uri" do
before { subject.base_uri = 'blah' }

its(:base_uri) { should == 'blah' }
end
end # Document
end # SSML
end # RubySpeech

0 comments on commit e8ea671

Please sign in to comment.