end.join " "
end
- def format_words(song)
- song.ruby.gsub("\n"){ "<br />" }.gsub("^( )+"){ " " * $1.length }
+ def format_words(str)
+ str.gsub("\n"){ "<br />" }.gsub("^( )+"){ " " * $1.length }
end
end
strip_ruby_base(words)
end
+ def kanji
+ strip_ruby_text(words)
+ end
+
def ruby
- markup_html_ruby_tag(words)
+ markup_html_ruby_tag(ERB::Util.h words)
end
# 慈(いつく)しみ
to_s.
gsub(RUBY_KANJI_HIRA) { ruby_tag_template($1, $2) }.
gsub(RUBY_ENGLISH_KANA){ ruby_tag_template($1, $2) }.
- gsub(RUBY_KANA_HIRA) { ruby_tag_template($1, $2) }
+ gsub(RUBY_KANA_HIRA) { ruby_tag_template($1, $2) }.
+ yourself
end
def ruby_tag_template(base, text)
end
def strip_ruby_base(str)
- str.gsub(RUBY_KANJI_HIRA){ $2 }.gsub(RUBY_ENGLISH_KANA){ $2 }.gsub(RUBY_KANA_HIRA){ $2 }
+ str.gsub(RUBY_KANJI_HIRA){ $2 }.
+ gsub(RUBY_ENGLISH_KANA){ $2 }.
+ gsub(RUBY_KANA_HIRA){ $2 }.
+ yourself
+ end
+
+ def strip_ruby_text(str)
+ str.gsub(RUBY_KANJI_HIRA){ $1 }.
+ gsub(RUBY_ENGLISH_KANA){ $1 }.
+ gsub(RUBY_KANA_HIRA){ $1 }.
+ yourself
end
end
[<%= link_to_function "リセット", "reset()" %>]
<hr />
-<div id="song_preview" style="font-size:18pt; width:20em;border:solid gray 1px">
-<%= format_words(@song) %>
+<div id="song_preview" style="font-size:18pt; width:20em; border:solid gray 1px">
+<%= format_words(@song.ruby) %>
</div>
</script>
<%- end -%>
<div id="fixed">
- <pre id="smallWindow"><%= render :partial => 'fixed' %></pre>
+ <pre id="smallWindow"><%= format_words(@song.kanji) %></pre>
<table id="panel">
<tr>
<th rowspan="2">文字の大きさの調整 </th>
</table>
</div>
<div id="scroll">
- <pre id="song"><%= render :partial => 'scroll' %></pre>
+ <pre id="song"><%= format_words(@song.ruby) %></pre>
</div>
# config.i18n.default_locale = :de
config.i18n.default_locale = :ja
end
+
+require 'object_ext'
subject { @song }
- its(:kana) {should == "いつくしみふかい ともなるイエスは"}
+ its(:kana) { should == "いつくしみふかい ともなるイエスは" }
+
+ its(:kanji) { should == "慈しみ深い 友なるイエスは" }
end
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+ config.before(:each) { Machinist.reset_before_test }
# == Fixtures
#
--- /dev/null
+require 'machinist/active_record'
+
+Program.blueprint do
+ name { "a program" }
+ note { "a note about this program..." }
+ play_on { Date.today }
+end
+
+Song.blueprint do
+ code { "C" }
+ title { "a title of song" }
+ copyright { "blah blah blah, ..." }
+ font_size { 2 }
+end