aozora 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,85 @@
1
+ High above the city, on a tall column, stood the statue of the Happy Prince.He was gilded all over with thin leaves of fine gold, for eyes he had two bright sapphires, and a large red ruby glowed on his sword-hilt.
2
+ He was very much admired indeed."He is as beautiful as a weathercock," remarked one of the Town Councillors who wished to gain a reputation for having artistic tastes; "only not quite so useful," he added, fearing lest people should think him unpractical, which he really was not.
3
+ "Why can't you be like the Happy Prince?" asked a sensible mother of her little boy who was crying for the moon."The Happy Prince never dreams of crying for anything."
4
+ "I am glad there is some one in the world who is quite happy," muttered a disappointed man as he gazed at the wonderful statue.
5
+ "He looks just like an angel," said the Charity Children as they came out of the cathedral in their bright scarlet cloaks and their clean white pinafores.
6
+ "How do you know?" said the Mathematical Master, "you have never seen one."
7
+ "Ah! but we have, in our dreams," answered the children; and the Mathematical Master frowned and looked very severe, for he did not approve of children dreaming.
8
+ One night there flew over the city a little Swallow.His friends had gone away to Egypt six weeks before, but he had stayed behind, for he was in love with the most beautiful Reed.He had met her early in the spring as he was flying down the river after a big yellow moth, and had been so attracted by her slender waist that he had stopped to talk to her.
9
+ "Shall I love you?" said the Swallow, who liked to come to the point at once, and the Reed made him a low bow.So he flew round and round her, touching the water with his wings, and making silver ripples.This was his courtship, and it lasted all through the summer.
10
+ "It is a ridiculous attachment," twittered the other Swallows; "she has no money, and far too many relations"; and indeed the river was quite full of Reeds.Then, when the autumn came they all flew away.
11
+ After they had gone he felt lonely, and began to tire of his lady- love."She has no conversation," he said, "and I am afraid that she is a coquette, for she is always flirting with the wind."And certainly, whenever the wind blew, the Reed made the most graceful curtseys."I admit that she is domestic," he continued, "but I love travelling, and my wife, consequently, should love travelling also."
12
+ "Will you come away with me?" he said finally to her; but the Reed shook her head, she was so attached to her home.
13
+ "You have been trifling with me," he cried."I am off to the Pyramids.Good-bye!" and he flew away.
14
+ All day long he flew, and at night-time he arrived at the city. "Where shall I put up?" he said; "I hope the town has made preparations."
15
+ Then he saw the statue on the tall column.
16
+ "I will put up there," he cried; "it is a fine position, with plenty of fresh air."So he alighted just between the feet of the Happy Prince.
17
+ "I have a golden bedroom," he said softly to himself as he looked round, and he prepared to go to sleep; but just as he was putting his head under his wing a large drop of water fell on him."What a curious thing!" he cried; "there is not a single cloud in the sky, the stars are quite clear and bright, and yet it is raining.The climate in the north of Europe is really dreadful.The Reed used to like the rain, but that was merely her selfishness."
18
+ Then another drop fell.
19
+ "What is the use of a statue if it cannot keep the rain off?" he said; "I must look for a good chimney-pot," and he determined to fly away.
20
+ But before he had opened his wings, a third drop fell, and he looked up, and saw--Ah! what did he see?
21
+ The eyes of the Happy Prince were filled with tears, and tears were running down his golden cheeks.His face was so beautiful in the moonlight that the little Swallow was filled with pity.
22
+ "Who are you?" he said.
23
+ "I am the Happy Prince."
24
+ "Why are you weeping then?" asked the Swallow; "you have quite drenched me."
25
+ "When I was alive and had a human heart," answered the statue, "I did not know what tears were, for I lived in the Palace of Sans- Souci, where sorrow is not allowed to enter.In the daytime I played with my companions in the garden, and in the evening I led the dance in the Great Hall.Round the garden ran a very lofty wall, but I never cared to ask what lay beyond it, everything about me was so beautiful.My courtiers called me the Happy Prince, and happy indeed I was, if pleasure be happiness.So I lived, and so I died.And now that I am dead they have set me up here so high that I can see all the ugliness and all the misery of my city, and though my heart is made of lead yet I cannot chose but weep."
26
+ "What! is he not solid gold?" said the Swallow to himself.He was too polite to make any personal remarks out loud.
27
+ "Far away," continued the statue in a low musical voice, "far away in a little street there is a poor house.One of the windows is open, and through it I can see a woman seated at a table.Her face is thin and worn, and she has coarse, red hands, all pricked by the needle, for she is a seamstress.She is embroidering passion- flowers on a satin gown for the loveliest of the Queen's maids-of- honour to wear at the next Court-ball.In a bed in the corner of the room her little boy is lying ill.He has a fever, and is asking for oranges.His mother has nothing to give him but river water, so he is crying.Swallow, Swallow, little Swallow, will you not bring her the ruby out of my sword-hilt?My feet are fastened to this pedestal and I cannot move."
28
+ "I am waited for in Egypt," said the Swallow."My friends are flying up and down the Nile, and talking to the large lotus- flowers.Soon they will go to sleep in the tomb of the great King. The King is there himself in his painted coffin.He is wrapped in yellow linen, and embalmed with spices.Round his neck is a chain of pale green jade, and his hands are like withered leaves."
29
+ "Swallow, Swallow, little Swallow," said the Prince, "will you not stay with me for one night, and be my messenger?The boy is so thirsty, and the mother so sad."
30
+ "I don't think I like boys," answered the Swallow."Last summer, when I was staying on the river, there were two rude boys, the miller's sons, who were always throwing stones at me.They never hit me, of course; we swallows fly far too well for that, and besides, I come of a family famous for its agility; but still, it was a mark of disrespect."
31
+ But the Happy Prince looked so sad that the little Swallow was sorry."It is very cold here," he said; "but I will stay with you for one night, and be your messenger."
32
+ "Thank you, little Swallow," said the Prince.
33
+ So the Swallow picked out the great ruby from the Prince's sword, and flew away with it in his beak over the roofs of the town.
34
+ He passed by the cathedral tower, where the white marble angels were sculptured.He passed by the palace and heard the sound of dancing.A beautiful girl came out on the balcony with her lover. "How wonderful the stars are," he said to her, "and how wonderful is the power of love!"
35
+ "I hope my dress will be ready in time for the State-ball," she answered; "I have ordered passion-flowers to be embroidered on it; but the seamstresses are so lazy."
36
+ He passed over the river, and saw the lanterns hanging to the masts of the ships.He passed over the Ghetto, and saw the old Jews bargaining with each other, and weighing out money in copper scales.At last he came to the poor house and looked in.The boy was tossing feverishly on his bed, and the mother had fallen asleep, she was so tired.In he hopped, and laid the great ruby on the table beside the woman's thimble.Then he flew gently round the bed, fanning the boy's forehead with his wings."How cool I feel," said the boy, "I must be getting better"; and he sank into a delicious slumber.
37
+ Then the Swallow flew back to the Happy Prince, and told him what he had done."It is curious," he remarked, "but I feel quite warm now, although it is so cold."
38
+ "That is because you have done a good action," said the Prince. And the little Swallow began to think, and then he fell asleep. Thinking always made him sleepy.
39
+ When day broke he flew down to the river and had a bath."What a remarkable phenomenon," said the Professor of Ornithology as he was passing over the bridge."A swallow in winter!"And he wrote a long letter about it to the local newspaper.Every one quoted it, it was full of so many words that they could not understand.
40
+ "To-night I go to Egypt," said the Swallow, and he was in high spirits at the prospect.He visited all the public monuments, and sat a long time on top of the church steeple.Wherever he went the Sparrows chirruped, and said to each other, "What a distinguished stranger!" so he enjoyed himself very much.
41
+ When the moon rose he flew back to the Happy Prince."Have you any commissions for Egypt?" he cried; "I am just starting."
42
+ "Swallow, Swallow, little Swallow," said the Prince, "will you not stay with me one night longer?"
43
+ "I am waited for in Egypt," answered the Swallow."To-morrow my friends will fly up to the Second Cataract.The river-horse couches there among the bulrushes, and on a great granite throne sits the God Memnon.All night long he watches the stars, and when the morning star shines he utters one cry of joy, and then he is silent.At noon the yellow lions come down to the water's edge to drink.They have eyes like green beryls, and their roar is louder than the roar of the cataract.
44
+ "Swallow, Swallow, little Swallow," said the Prince, "far away across the city I see a young man in a garret.He is leaning over a desk covered with papers, and in a tumbler by his side there is a bunch of withered violets.His hair is brown and crisp, and his lips are red as a pomegranate, and he has large and dreamy eyes. He is trying to finish a play for the Director of the Theatre, but he is too cold to write any more.There is no fire in the grate, and hunger has made him faint."
45
+ "I will wait with you one night longer," said the Swallow, who really had a good heart."Shall I take him another ruby?"
46
+ "Alas!I have no ruby now," said the Prince; "my eyes are all that I have left.They are made of rare sapphires, which were brought out of India a thousand years ago.Pluck out one of them and take it to him.He will sell it to the jeweller, and buy food and firewood, and finish his play."
47
+ "Dear Prince," said the Swallow, "I cannot do that"; and he began to weep.
48
+ "Swallow, Swallow, little Swallow," said the Prince, "do as I command you."
49
+ So the Swallow plucked out the Prince's eye, and flew away to the student's garret.It was easy enough to get in, as there was a hole in the roof.Through this he darted, and came into the room. The young man had his head buried in his hands, so he did not hear the flutter of the bird's wings, and when he looked up he found the beautiful sapphire lying on the withered violets.
50
+ "I am beginning to be appreciated," he cried; "this is from some great admirer.Now I can finish my play," and he looked quite happy.
51
+ The next day the Swallow flew down to the harbour.He sat on the mast of a large vessel and watched the sailors hauling big chests out of the hold with ropes."Heave a-hoy!" they shouted as each chest came up."I am going to Egypt"! cried the Swallow, but nobody minded, and when the moon rose he flew back to the Happy Prince.
52
+ "I am come to bid you good-bye," he cried.
53
+ "Swallow, Swallow, little Swallow," said the Prince, "will you not stay with me one night longer?"
54
+ "It is winter," answered the Swallow, "and the chill snow will soon be here.In Egypt the sun is warm on the green palm-trees, and the crocodiles lie in the mud and look lazily about them.My companions are building a nest in the Temple of Baalbec, and the pink and white doves are watching them, and cooing to each other. Dear Prince, I must leave you, but I will never forget you, and next spring I will bring you back two beautiful jewels in place of those you have given away.The ruby shall be redder than a red rose, and the sapphire shall be as blue as the great sea."
55
+ "In the square below," said the Happy Prince, "there stands a little match-girl.She has let her matches fall in the gutter, and they are all spoiled.Her father will beat her if she does not bring home some money, and she is crying.She has no shoes or stockings, and her little head is bare.Pluck out my other eye, and give it to her, and her father will not beat her."
56
+ "I will stay with you one night longer," said the Swallow, "but I cannot pluck out your eye.You would be quite blind then."
57
+ "Swallow, Swallow, little Swallow," said the Prince, "do as I command you."
58
+ So he plucked out the Prince's other eye, and darted down with it. He swooped past the match-girl, and slipped the jewel into the palm of her hand."What a lovely bit of glass," cried the little girl; and she ran home, laughing.
59
+ Then the Swallow came back to the Prince."You are blind now," he said, "so I will stay with you always."
60
+ "No, little Swallow," said the poor Prince, "you must go away to Egypt."
61
+ "I will stay with you always," said the Swallow, and he slept at the Prince's feet.
62
+ All the next day he sat on the Prince's shoulder, and told him stories of what he had seen in strange lands.He told him of the red ibises, who stand in long rows on the banks of the Nile, and catch gold-fish in their beaks; of the Sphinx, who is as old as the world itself, and lives in the desert, and knows everything; of the merchants, who walk slowly by the side of their camels, and carry amber beads in their hands; of the King of the Mountains of the Moon, who is as black as ebony, and worships a large crystal; of the great green snake that sleeps in a palm-tree, and has twenty priests to feed it with honey-cakes; and of the pygmies who sail over a big lake on large flat leaves, and are always at war with the butterflies.
63
+ "Dear little Swallow," said the Prince, "you tell me of marvellous things, but more marvellous than anything is the suffering of men and of women.There is no Mystery so great as Misery.Fly over my city, little Swallow, and tell me what you see there."
64
+ So the Swallow flew over the great city, and saw the rich making merry in their beautiful houses, while the beggars were sitting at the gates.He flew into dark lanes, and saw the white faces of starving children looking out listlessly at the black streets. Under the archway of a bridge two little boys were lying in one another's arms to try and keep themselves warm."How hungry we are!" they said."You must not lie here," shouted the Watchman, and they wandered out into the rain.
65
+ Then he flew back and told the Prince what he had seen.
66
+ "I am covered with fine gold," said the Prince, "you must take it off, leaf by leaf, and give it to my poor; the living always think that gold can make them happy."
67
+ Leaf after leaf of the fine gold the Swallow picked off, till the Happy Prince looked quite dull and grey.Leaf after leaf of the fine gold he brought to the poor, and the children's faces grew rosier, and they laughed and played games in the street."We have bread now!" they cried.
68
+ Then the snow came, and after the snow came the frost.The streets looked as if they were made of silver, they were so bright and glistening; long icicles like crystal daggers hung down from the eaves of the houses, everybody went about in furs, and the little boys wore scarlet caps and skated on the ice.
69
+ The poor little Swallow grew colder and colder, but he would not leave the Prince, he loved him too well.He picked up crumbs outside the baker's door when the baker was not looking and tried to keep himself warm by flapping his wings.
70
+ But at last he knew that he was going to die.He had just strength to fly up to the Prince's shoulder once more."Good-bye, dear Prince!" he murmured, "will you let me kiss your hand?"
71
+ "I am glad that you are going to Egypt at last, little Swallow," said the Prince, "you have stayed too long here; but you must kiss me on the lips, for I love you."
72
+ "It is not to Egypt that I am going," said the Swallow."I am going to the House of Death.Death is the brother of Sleep, is he not?"
73
+ And he kissed the Happy Prince on the lips, and fell down dead at his feet.
74
+ At that moment a curious crack sounded inside the statue, as if something had broken.The fact is that the leaden heart had snapped right in two.It certainly was a dreadfully hard frost.
75
+ Early the next morning the Mayor was walking in the square below in company with the Town Councillors.As they passed the column he looked up at the statue:"Dear me! how shabby the Happy Prince looks!" he said.
76
+ "How shabby indeed!" cried the Town Councillors, who always agreed with the Mayor; and they went up to look at it.
77
+ "The ruby has fallen out of his sword, his eyes are gone, and he is golden no longer," said the Mayor in fact, "he is litttle beter than a beggar!"
78
+ "Little better than a beggar," said the Town Councillors.
79
+ "And here is actually a dead bird at his feet!" continued the Mayor."We must really issue a proclamation that birds are not to be allowed to die here."And the Town Clerk made a note of the suggestion.
80
+ So they pulled down the statue of the Happy Prince."As he is no longer beautiful he is no longer useful," said the Art Professor at the University.
81
+ Then they melted the statue in a furnace, and the Mayor held a meeting of the Corporation to decide what was to be done with the metal."We must have another statue, of course," he said, "and it shall be a statue of myself."
82
+ "Of myself," said each of the Town Councillors, and they quarrelled.When I last heard of them they were quarrelling still.
83
+ "What a strange thing!" said the overseer of the workmen at the foundry."This broken lead heart will not melt in the furnace.We must throw it away."So they threw it on a dust-heap where the dead Swallow was also lying.
84
+ "Bring me the two most precious things in the city," said God to one of His Angels; and the Angel brought Him the leaden heart and the dead bird.
85
+ "You have rightly chosen," said God, "for in my garden of Paradise this little bird shall sing for evermore, and in my city of gold the Happy Prince shall praise me."
@@ -0,0 +1,3 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
2
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
3
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -12,7 +12,7 @@
12
12
  class Aozora
13
13
 
14
14
  # テキストの種類として指定できるSymbolのリスト
15
- Titles = lambda {
15
+ TITLES = lambda {
16
16
  titles = Array.new
17
17
  titles.push :kokoro
18
18
  titles.push :bocchan
@@ -27,10 +27,22 @@ class Aozora
27
27
  titles.push :sangetsuki
28
28
  titles.push :watashino_kojinshugi
29
29
  titles.push :london
30
+ titles.push :lorem_ipsum
31
+ titles.push :happy_prince
32
+ titles.push :christmas_carol
30
33
  titles.push :__TEST_DATA__ # for test only
31
34
  return titles
32
35
  }.call
33
36
 
37
+ # 英文のテキストのリスト
38
+ EN_TITLES = lambda {
39
+ en_titles = Array.new
40
+ en_titles.push :lorem_ipsum
41
+ en_titles.push :happy_prince
42
+ en_titles.push :christmas_carol
43
+ return en_titles
44
+ }.call
45
+
34
46
  #
35
47
  # Aozoraクラスのインスタンスを生成する。
36
48
  #
@@ -42,9 +54,15 @@ class Aozora
42
54
  validate_length(length)
43
55
 
44
56
  if title.kind_of? Numeric
45
- title = Titles[title]
57
+ title = TITLES[title]
46
58
  end
47
59
  @text = read_file(title, length)
60
+ @toggles = {:dots => false, :paragraph => false}
61
+ if EN_TITLES.include? title
62
+ @lang = :en
63
+ else
64
+ @lang = :ja
65
+ end
48
66
  return self
49
67
  end
50
68
 
@@ -58,7 +76,20 @@ class Aozora
58
76
  # テキストの種類として指定できるSymbolおよび番号の
59
77
  # 対応表を標準出力に表示します。
60
78
  #
61
- def self.titles; print self._titles end
79
+ def self.titles
80
+ titles = String.new
81
+ titles += "+--+-------------------------+\n"
82
+ titles += "| n| symbol |\n"
83
+ titles += "+--+-------------------------+\n"
84
+ # __TEST_DATA__.txtを含めない
85
+ (0..(TITLES.size-2)).each do |i|
86
+ num_s = sprintf("%2d",i)
87
+ sym_s = sprintf("%-25s",TITLES[i].inspect)
88
+ titles += "|#{num_s}|#{sym_s}|\n"
89
+ end
90
+ titles += "+--+-------------------------+\n"
91
+ print titles
92
+ end
62
93
 
63
94
  #
64
95
  # テキストに含まれるアルファベットを半角や全角に変換します。
@@ -130,11 +161,20 @@ class Aozora
130
161
  # {:_head => true} を渡された場合、パラグラフの冒頭にスペースが入ります。
131
162
  #
132
163
  def paragraph(p_length=40, options={})
164
+ # 既にparagraphが実行済みだった場合は何もしない
165
+ return self if @toggles[:paragraph]
166
+ @toggles[:paragraph] = true
167
+
133
168
  div_paragraph(p_length)
134
169
 
135
170
  if options[:space_head]
136
- @text = " "+@text
137
- @text.gsub!(/\n/,"\n ")
171
+ if @lang == :en
172
+ @text = " "+@text
173
+ @text.gsub!(/\n/,"\n ")
174
+ else
175
+ @text = " "+@text
176
+ @text.gsub!(/\n/,"\n ")
177
+ end
138
178
  end
139
179
 
140
180
  if options[:blank_line]
@@ -148,7 +188,11 @@ class Aozora
148
188
  # ダミーテキストの末尾に、文章の途中であることを示す「…」を付します。
149
189
  #
150
190
  def dots
191
+ # 既にdotsが実行済みだった場合は何もしない
192
+ return self if @toggles[:dots]
193
+
151
194
  @text += "…"
195
+ @toggles[:dots] = true
152
196
  return self
153
197
  end
154
198
 
@@ -175,21 +219,6 @@ class Aozora
175
219
  end
176
220
  end
177
221
 
178
- def self._titles
179
- titles = String.new
180
- titles += "+--+-------------------------+\n"
181
- titles += "| n| symbol |\n"
182
- titles += "+--+-------------------------+\n"
183
- # __TEST_DATA__.txtを含めない
184
- (0..(Titles.size-2)).each do |i|
185
- num_s = sprintf("%2d",i)
186
- sym_s = sprintf("%-25s",Titles[i].inspect)
187
- titles += "|#{num_s}|#{sym_s}|\n"
188
- end
189
- titles += "+--+-------------------------+\n"
190
- return titles
191
- end
192
-
193
222
  def div_paragraph(p_length)
194
223
  if not p_length.kind_of? Numeric
195
224
  raise "invalid argmument: p_length = #{p_length}"
@@ -197,10 +226,19 @@ class Aozora
197
226
  if (p_length <= 0) or (p_length >= @text.size)
198
227
  raise "invalid argmument: p_length = #{p_length}"
199
228
  end
229
+ if @lang == :en
230
+ en_div_paragraph(p_length)
231
+ else
232
+ ja_div_paragraph(p_length)
233
+ end
234
+ return nil
235
+ end
200
236
 
237
+ def ja_div_paragraph(p_length)
201
238
  offset = 0; ptr = 0; prev = 0
239
+ comma = "。"
202
240
  loop do
203
- ptr = @text.index("。", offset)
241
+ ptr = @text.index(comma, offset)
204
242
  # 一度目の探索で終端に辿り着いた場合
205
243
  return if not ptr
206
244
  # 一度目の探索でp_lengthを超えた場合
@@ -212,7 +250,7 @@ class Aozora
212
250
 
213
251
  loop do
214
252
  prev = ptr
215
- ptr = @text.index("。", (prev+1))
253
+ ptr = @text.index(comma, (prev+1))
216
254
  return if not ptr
217
255
 
218
256
  # offsetからの距離
@@ -235,20 +273,59 @@ class Aozora
235
273
  end
236
274
  end
237
275
 
276
+ def en_div_paragraph(p_length)
277
+ offset = 0; ptr = 0; prev = 0
278
+ comma = "."
279
+ loop do
280
+ ptr = @text.index(comma, offset)
281
+ # 一度目の探索で終端に辿り着いた場合
282
+ return if not ptr
283
+ # 一度目の探索でp_lengthを超えた場合
284
+ if p_length <= (ptr - offset)
285
+ @text = @text[0..ptr] + "\n" + @text[(ptr+1)..(-1)].strip
286
+ offset = ptr+2
287
+ next
288
+ end
289
+
290
+ loop do
291
+ prev = ptr
292
+ ptr = @text.index(comma, (prev+1))
293
+ return if not ptr
294
+
295
+ # offsetからの距離
296
+ ptr_rel = ptr - offset
297
+ prev_rel = prev - offset
298
+
299
+ if ptr_rel >= p_length
300
+ if (p_length - prev_rel) < (ptr_rel - p_length)
301
+ # prevの直後に改行を入れてoffsetを更新
302
+ @text = @text[0..prev] + "\n" + @text[(prev+1)..(-1)].strip
303
+ offset = prev+2
304
+ else
305
+ # ptrの直後に改行を入れてoffsetを更新
306
+ @text = @text[0..ptr] + "\n" + @text[(ptr+1)..(-1)].strip
307
+ offset = ptr+2
308
+ end
309
+ break
310
+ end
311
+ end
312
+ end
313
+ end
314
+
238
315
  def validate_tilte(title)
239
316
  if title == nil
240
317
  raise "invalid argmument: title = nil"
241
318
  end
242
319
 
243
320
  if title.kind_of? Numeric
244
- if (title > (Titles.size - 1)) or (title < 0)
321
+ if (title > (TITLES.size - 1)) or (title < 0)
245
322
  raise "invalid argmument: title = #{title}"
246
323
  end
247
324
  return nil
248
325
  end
249
326
 
250
327
  if title.kind_of? Symbol
251
- Titles.each do |t|
328
+ TITLES.each do |t|
252
329
  return nil if t == title
253
330
  end
254
331
  raise "invalid argmument: title = #{title}"
@@ -1,3 +1,3 @@
1
1
  class Aozora
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -189,4 +189,42 @@ class AozoraTest < Test::Unit::TestCase
189
189
  "三日と経たないうちに、私を呼び寄せた友達は、"
190
190
  assert_equal(expected, actual)
191
191
  end
192
+
193
+ # fixes #1
194
+ def test_dots_twice_time
195
+ expected = Aozora.new.dots.to_s
196
+ actual = Aozora.new.dots.dots.to_s
197
+ assert_equal(expected, actual)
198
+ end
199
+
200
+ # fixes #1
201
+ def test_paragraph_twice_time
202
+ expected = Aozora.new.paragraph.to_s
203
+ actual = Aozora.new.paragraph.paragraph(1).to_s
204
+ assert_equal(expected, actual)
205
+ end
206
+
207
+ # fixes #2
208
+ def test_english_text_no_13
209
+ tmp = Aozora.new(13, 300)
210
+ actual = tmp.paragraph(100, {:space_head=>true, :blank_line=>true}).to_s
211
+ expected = " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\n Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n\n Duis aute irure dolor in reprehenderit in voluptate velit esse cill"
212
+ assert_equal(expected, actual)
213
+ end
214
+
215
+ # fixes #2
216
+ def test_english_text_no_14
217
+ tmp = Aozora.new(14, 300)
218
+ actual = tmp.paragraph(100, {:space_head=>true, :blank_line=>true}).to_s
219
+ expected = " High above the city, on a tall column, stood the statue of the Happy Prince.\n\n He was gilded all over with thin leaves of fine gold, for eyes he had two bright sapphires, and a large red ruby glowed on his sword-hilt.\n\n He was very much admired indeed.\"He is as beautiful as a weathercock,\" remarked one of"
220
+ assert_equal(expected, actual)
221
+ end
222
+
223
+ # fixes #2
224
+ def test_english_text_no_15
225
+ tmp = Aozora.new(15, 300)
226
+ actual = tmp.paragraph(100, {:space_head=>true, :blank_line=>true}).to_s
227
+ expected = " MARLEY was dead: to begin with. There is no doubt whatever about that.\n\n The register of his burial was signed by the clergyman, the clerk, the undertaker, and the chief mourner.\n\n Scrooge signed it: and Scrooge's name was good upon 'Change, for anything he chose to put his hand to.\n\n Old Marley was as de"
228
+ assert_equal(expected, actual)
229
+ end
192
230
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aozora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-18 00:00:00.000000000 Z
12
+ date: 2013-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -43,7 +43,7 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- description: aozoraはダミーテキストを生成するライブラリです。
46
+ description: ダミーテキストを生成するライブラリです。
47
47
  email:
48
48
  - tkr.tnmc@gmail.com
49
49
  executables: []
@@ -58,11 +58,14 @@ files:
58
58
  - aozora.gemspec
59
59
  - data/__TEST_DATA__.txt
60
60
  - data/bocchan.txt
61
+ - data/christmas_carol.txt
62
+ - data/happy_prince.txt
61
63
  - data/hashire_merosu.txt
62
64
  - data/joseito.txt
63
65
  - data/kokoro.txt
64
66
  - data/lemon.txt
65
67
  - data/london.txt
68
+ - data/lorem_ipsum.txt
66
69
  - data/ningen_shikkaku.txt
67
70
  - data/pandorano_hako.txt
68
71
  - data/sangetsuki.txt
@@ -98,6 +101,6 @@ rubyforge_project:
98
101
  rubygems_version: 1.8.23
99
102
  signing_key:
100
103
  specification_version: 3
101
- summary: Japanese lorem ipsum generator
104
+ summary: Lipsum generator for Japanese
102
105
  test_files:
103
106
  - test/aozora_test.rb