lorem_tolkien 0.1.1 → 1.0.0

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
- SHA1:
3
- metadata.gz: d0f152da652db0d8c9dcdcfe791805bbd1256c29
4
- data.tar.gz: 23abe47a2b9ce5559fca8601f03785f6ee878f5a
2
+ SHA256:
3
+ metadata.gz: 2407e343b781eb586d13a3e38dd09f407fdf0445a13f53b382ffd5480ca223e3
4
+ data.tar.gz: 2d78984e55d65a2217f29c86d0307430dcf973c779da4b6753d99f6b066a3f88
5
5
  SHA512:
6
- metadata.gz: 510eac4d263e5ce80a93425ce9926f982209bdd82ed7e83fabdb0de98cf90f2d902ebd307d113702ba20d95b907198cd20f9ef13fd564183387aaf12f6438895
7
- data.tar.gz: 01b3b4187a9183e672644d619c93073b4fc073697d18e81634bea915101091ac949ca8a0ab6e59ef2f1ba0906499c18ac8f6dbcc093e649f71f0e5bdc0c9bfbc
6
+ metadata.gz: 38d42f534342cf74845a96051a7992b6d9b11139d05b0a709c9df6e55dcb671fa30cadc9f0545d1f965860fc0192156be7348c492f8b0f4878d4d41197c9e38c
7
+ data.tar.gz: f150f7ebe6b6edaffa895a585a25a84d0d4f3e441721f78050cb7be521d06c47927e3aa35821bc466be59f29aae3843f92fdc57c8ca1c4dd8b6153344bef9e77
data/.gitignore CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/jemaddux/lorem_tolkien.svg?branch=master)](https://travis-ci.org/jemaddux/lorem_tolkien)
4
4
 
5
- [![Code Climate](https://codeclimate.com/github/jemaddux/lorem_tolkien/badges/gpa.svg)](https://codeclimate.com/github/jemaddux/lorem_tolkien)
6
-
7
5
  [![Test Coverage](https://codeclimate.com/github/jemaddux/lorem_tolkien/badges/coverage.svg)](https://codeclimate.com/github/jemaddux/lorem_tolkien)
8
6
 
7
+ [On RubyGems.org](https://rubygems.org/gems/lorem_tolkien)
8
+
9
9
  ## Installation
10
10
 
11
11
  Add this line to your application's Gemfile:
@@ -20,14 +20,38 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install lorem_tolkien
22
22
 
23
+ ## Building
24
+
25
+ $ gem build lorem_tolkien.gemspec
26
+
27
+ $ gem push lorem_tolkien-0.1.2.gem
28
+
23
29
  ## Usage
24
30
 
31
+ ### Single Sentence
25
32
  LoremTolkien.sentence
26
33
  => "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?"
27
34
 
35
+ ### Multiple Sentences
28
36
  LoremTolkien.sentences(5)
29
37
  => "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on? In a hole in the ground there lived a hobbit. There is nothing like looking, if you want to find something. You certainly usually find something, if you look, but it is not always quite the something you were after. It does not do to leave a live dragon out of your calculations, if you live near him."
30
38
 
39
+ ### Specific Word Count
40
+ LoremTolkien.words(10)
41
+ => "arranging, do Where yore as morning; the fire want shining"
42
+
43
+ ### Single Paragraph
44
+ LoremTolkien.paragraph
45
+ => "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on? In a hole in the ground there lived a hobbit. There is nothing like looking, if you want to find something."
46
+
47
+ ### Multiple Paragraphs
48
+ LoremTolkien.paragraphs(3)
49
+ => "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on? In a hole in the ground there lived a hobbit. There is nothing like looking, if you want to find something.
50
+
51
+ Far over the misty mountains cold To dungeons deep and caverns old We must away ere break of day To seek the pale enchanted gold. The dwarves of yore made mighty spells.
52
+
53
+ You certainly usually find something, if you look, but it is not always quite the something you were after. It does not do to leave a live dragon out of your calculations, if you live near him."
54
+
31
55
  ## Contributing
32
56
 
33
57
  1. Fork it
@@ -35,3 +59,7 @@ LoremTolkien.sentences(5)
35
59
  3. Commit your changes (`git commit -am 'Add some feature'`)
36
60
  4. Push to the branch (`git push origin my-new-feature`)
37
61
  5. Create new Pull Request
62
+
63
+ ## Author
64
+
65
+ Authored by John Maddux. [jemaddux.com](https://jemaddux.com/)
data/Rakefile CHANGED
File without changes
data/TODO.md ADDED
@@ -0,0 +1,107 @@
1
+ # LoremTolkien Improvement Ideas
2
+
3
+ ## 1. Enhanced API & Functionality
4
+ - [x] Add `LoremTolkien.paragraph` and `LoremTolkien.paragraphs(n)` methods
5
+ - [x] Add `LoremTolkien.words(n)` for specific word counts
6
+ - [x] Add `LoremTolkien.characters(n)` for character limits
7
+ - [ ] Add methods that generate random-length content within ranges
8
+ - [ ] Add `LoremTolkien.paragraphs_with_word_count(min, max)` for flexible paragraph generation
9
+
10
+ ## 2. Content Expansion
11
+ - [ ] Add quotes from The Silmarillion, Unfinished Tales, and other Tolkien works
12
+ - [x] Organize quotes by character (Gandalf, Bilbo, Aragorn, etc.)
13
+ - [ ] Categorize quotes by themes (adventure, wisdom, friendship, etc.)
14
+ - [ ] Include quotes in Elvish languages (with translations)
15
+ - [ ] Add quotes from The Children of Húrin and other posthumous works
16
+ - [ ] Include famous poems and songs from Middle-earth
17
+
18
+ ## 3. Better Code Structure
19
+ - [x] Move quotes to separate YAML/JSON files for easier maintenance
20
+ - [ ] Implement weighted random selection for more variety
21
+ - [ ] Add caching for better performance with large quote sets
22
+ - [ ] Create separate modules for different quote categories
23
+ - [ ] Add configuration options for quote selection strategies
24
+
25
+ ## 4. Advanced Features
26
+ - [ ] Generate markdown-formatted text
27
+ - [ ] Create HTML paragraphs with proper tags
28
+ - [ ] Respect character limits while maintaining sentence integrity
29
+ - [ ] Allow reproducible random generation with seeds
30
+ - [ ] Support for generating large amounts of text efficiently
31
+ - [ ] Add `LoremTolkien.html_paragraphs(n)` method
32
+ - [ ] Add `LoremTolkien.markdown_paragraphs(n)` method
33
+
34
+ ## 5. Testing & Quality
35
+ - [ ] Add comprehensive tests for all methods and edge cases
36
+ - [ ] Add performance tests and benchmarks
37
+ - [ ] Ensure all quotes are properly attributed and formatted
38
+ - [ ] Add integration tests for real-world usage scenarios
39
+ - [ ] Add test coverage reporting
40
+ - [ ] Add property-based testing for random generation
41
+
42
+ ## 6. Documentation & Examples
43
+ - [ ] Improve README with more usage examples and API documentation
44
+ - [ ] Create a command-line interface for quick text generation
45
+ - [ ] Add Rails helpers for view testing
46
+ - [ ] Create examples directory with real-world usage patterns
47
+ - [ ] Add API documentation with YARD
48
+ - [ ] Create a quick start guide
49
+
50
+ ## 7. Modern Ruby Features
51
+ - [ ] Use keyword arguments for better API design
52
+ - [ ] Add frozen string literals for performance and safety
53
+ - [ ] Ensure RuboCop compliance for code style consistency
54
+ - [ ] Update to current Ruby gem standards
55
+ - [ ] Use modern Ruby syntax throughout
56
+ - [ ] Add type checking with RBS or Sorbet
57
+
58
+ ## 8. User Experience
59
+ - [ ] Improve error messages for invalid inputs
60
+ - [ ] Add input validation with helpful feedback
61
+ - [ ] Support different output formats (plain text, HTML, markdown)
62
+ - [ ] Add internationalization support for different languages
63
+ - [ ] Add configuration options for default behavior
64
+ - [ ] Create a configuration class for user preferences
65
+
66
+ ## 9. Performance & Scalability
67
+ - [ ] Implement lazy loading for memory efficiency
68
+ - [ ] Ensure thread-safe operation
69
+ - [ ] Optimize memory usage for large quote collections
70
+ - [ ] Implement smart caching for repeated requests
71
+ - [ ] Add performance benchmarks
72
+ - [ ] Consider using a more efficient data structure for quotes
73
+
74
+ ## 10. Community & Ecosystem
75
+ - [ ] Create clear contributing guidelines
76
+ - [ ] Add structured templates for bug reports and feature requests
77
+ - [ ] Maintain a proper changelog
78
+ - [ ] Set up automated testing and deployment with CI/CD
79
+ - [ ] Add a code of conduct
80
+ - [ ] Create issue templates for GitHub
81
+
82
+ ## 11. CLI Tool
83
+ - [ ] Create a command-line interface
84
+ - [ ] Add options for different output formats
85
+ - [ ] Support for generating files with LoremTolkien content
86
+ - [ ] Add interactive mode for real-time generation
87
+ - [ ] Include help and usage information
88
+
89
+ ## 12. Rails Integration
90
+ - [ ] Create Rails helpers for view testing
91
+ - [ ] Add generators for creating test data
92
+ - [ ] Integrate with Rails console for easy testing
93
+ - [ ] Add view helpers for generating sample content
94
+
95
+ ## 13. Data Management
96
+ - [ ] Create a data validation system for quotes
97
+ - [ ] Add tools for importing new quotes
98
+ - [ ] Create a quote management system
99
+ - [ ] Add metadata for each quote (source, character, theme)
100
+ - [ ] Implement quote versioning
101
+
102
+ ## 14. Advanced Generation Features
103
+ - [ ] Add support for generating dialogue between characters
104
+ - [ ] Create methods for generating story-like content
105
+ - [ ] Add support for generating poetry and songs
106
+ - [ ] Implement context-aware quote selection
107
+ - [ ] Add methods for generating themed content sets
@@ -0,0 +1,159 @@
1
+ quotes:
2
+ Gandalf:
3
+ - "It does not do to leave a live dragon out of your calculations, if you live near him."
4
+ - "Where there's life there's hope."
5
+ - "What a lot of things you do use Good morning for!"
6
+ - "Now you mean that you want to get rid of me, and that it won't be good till I move off."
7
+ - "Looking behind."
8
+ - "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?"
9
+ - "To look ahead."
10
+ - "All we have to decide is what to do with the time that is given us."
11
+ - "A wizard is never late, nor is he early, he arrives precisely when he means to."
12
+ - "Fly, you fools!"
13
+ - "You shall not pass!"
14
+ - "I will not say: do not weep; for not all tears are an evil."
15
+ - "Even the very wise cannot see all ends."
16
+ - "The world is not in your books and maps. It's out there."
17
+ Bilbo:
18
+ - "Good Morning!' said Bilbo, and he meant it."
19
+ - "All of them at once."
20
+ - "And a very fine morning for a pipe of tobacco out of doors, into the bargain."
21
+ - "Good morning!' he said at last."
22
+ - "We don't want any adventures here, thank you!"
23
+ - "I think I'm quite ready for another adventure."
24
+ - "It's a dangerous business, Frodo, going out your door."
25
+ - "I don't know half of you half as well as I should like; and I like less than half of you half as well as you deserve."
26
+ - "There and back again."
27
+ - "I am looking for someone to share in an adventure that I am arranging, and it's very difficult to find anyone."
28
+ - "So comes snow after fire, and even dragons have their endings."
29
+ Thorin:
30
+ - "Where did you go to, if I may ask?' said Thorin to Gandalf as they rode along."
31
+ Smaug:
32
+ - "You have nice manners for a thief and a liar,' said the dragon."
33
+ Narrator:
34
+ - "The road goes ever on and on, down from the door where it began."
35
+ - "Not all those who wander are lost."
36
+ - "Faithless is he that says farewell when the road darkens."
37
+ - "Courage is found in unlikely places."
38
+ - "Little by little, one travels far."
39
+ - "Deeds will not be less valiant because they are unpraised."
40
+ - "The wide world is all about you: you can fence yourselves in, but you cannot forever fence it out."
41
+ - "Moonlight drowns out all but the brightest stars."
42
+ - "Short cuts make long delays."
43
+ - "It's the job that's never started as takes longest to finish."
44
+ - "Still round the corner there may wait, a new road or a secret gate."
45
+ - "All that is gold does not glitter, not all those who wander are lost."
46
+ - "The greatest adventure is what lies ahead."
47
+ - "There is some good in this world, and it's worth fighting for."
48
+ - "The shadow that bred them can only mock, it cannot make: not real new things of its own."
49
+ - "The burned hand teaches best. After that advice about fire goes to the heart."
50
+ - "The world is indeed full of peril, and in it there are many dark places."
51
+ - "The wise speak only of what they know."
52
+ - "He that breaks a thing to find out what it is has left the path of wisdom."
53
+ - "Even darkness must pass. A new day will come. And when the sun shines it will shine out the clearer."
54
+ - "The board is set, the pieces are moving."
55
+ - "There is no curse in Elvish, Entish, or the tongues of Men for this treachery."
56
+ - "The world is full enough of hurts and mischances without wars to multiply them."
57
+ - "Oft hope is born when all is forlorn."
58
+ - "The greatest adventure is what lies ahead."
59
+ - "The world is not in your books and maps. It's out there."
60
+ - "The world is changed. I feel it in the water. I feel it in the earth. I smell it in the air."
61
+ - "In a hole in the ground there lived a hobbit."
62
+ - "There is nothing like looking, if you want to find something."
63
+ - "You certainly usually find something, if you look, but it is not always quite the something you were after."
64
+ - "Far over the misty mountains cold"
65
+ - "To dungeons deep and caverns old"
66
+ - "We must away ere break of day"
67
+ - "To seek the pale enchanted gold."
68
+ - "The dwarves of yore made mighty spells,"
69
+ - "While hammers fell like ringing bells"
70
+ - "In places deep, where dark things sleep,"
71
+ - "In hollow halls beneath the fells."
72
+ - "For ancient king and elvish lord"
73
+ - "There many a gleaming golden hoard"
74
+ - "They shaped and wrought, and light they caught"
75
+ - "To hide in gems on hilt of sword."
76
+ - "On silver necklaces they strung"
77
+ - "The flowering stars, on crowns they hung"
78
+ - "The dragon-fire, in twisted wire"
79
+ - "They meshed the light of moon and sun."
80
+ - "Far over the misty mountains cold"
81
+ - "To dungeons deep and caverns old"
82
+ - "We must away, ere break of day,"
83
+ - "To claim our long-forgotten gold."
84
+ - "Goblets they carved there for themselves"
85
+ - "And harps of gold; where no man delves"
86
+ - "There lay they long, and many a song"
87
+ - "Was sung unheard by men or elves."
88
+ - "The pines were roaring on the height,"
89
+ - "The wind was moaning in the night."
90
+ - "The fire was red, it flaming spread;"
91
+ - "The trees like torches blazed with light."
92
+ - "The bells were ringing in the dale"
93
+ - "And men looked up with faces pale;"
94
+ - "The dragon's ire more fierce than fire"
95
+ - "Laid low their towers and houses frail."
96
+ - "The mountain smoked beneath the moon;"
97
+ - "The dwarves, they heard the tramp of doom."
98
+ - "They fled their hall to dying fall"
99
+ - "Beneath his feet, beneath the moon."
100
+ - "Far over the misty mountains grim"
101
+ - "To dungeons deep and caverns dim"
102
+ - "We must away, ere break of day,"
103
+ - "To win our harps and gold from him!"
104
+ - "The sun was shining, and the grass was very green."
105
+ - "But Gandalf looked at him from under long bushy eyebrows that stuck out further than the brim of his shady hat."
106
+ - "By this he meant that the conversation was at an end."
107
+ - "So comes snow after fire, and even dragons have their endings."
108
+ - "There many a gleaming golden hoard."
109
+ - "Was sung unheard by men or elves."
110
+ - "They meshed the light of moon and sun."
111
+ - "They shaped and wrought, and light they caught."
112
+ - "To hide in gems on hilt of sword."
113
+ - "On silver necklaces they strung."
114
+ - "The flowering stars, on crowns they hung."
115
+ - "The dragon-fire, in twisted wire."
116
+ Frodo:
117
+ - "I wish the Ring had never come to me. I wish none of this had happened."
118
+ - "I will take the Ring, though I do not know the way."
119
+ - "I am glad you are here with me. Here at the end of all things, Sam."
120
+ Sam:
121
+ - "I can't carry it for you, but I can carry you!"
122
+ - "There’s some good in this world, Mr. Frodo, and it’s worth fighting for."
123
+ - "I made a promise, Mr. Frodo. A promise!"
124
+ - "Potatoes! Boil 'em, mash 'em, stick 'em in a stew..."
125
+ Aragorn:
126
+ - "If by my life or death I can protect you, I will."
127
+ - "I would have gone with you to the end, into the very fires of Mordor."
128
+ - "A day may come when the courage of men fails, but it is not this day."
129
+ - "I am Aragorn son of Arathorn; and if by life or death I can save you, I will."
130
+ Legolas:
131
+ - "A red sun rises, blood has been spilled this night."
132
+ - "They're taking the Hobbits to Isengard!"
133
+ - "The stars are veiled. Something stirs in the East. A sleepless malice."
134
+ Gimli:
135
+ - "Nobody tosses a Dwarf."
136
+ - "I never thought I’d die fighting side by side with an Elf."
137
+ - "Let them come! There is one Dwarf yet in Moria who still draws breath."
138
+ Saruman:
139
+ - "The old world will burn in the fires of industry."
140
+ - "Against the power of Mordor there can be no victory."
141
+ Gollum:
142
+ - "My precious!"
143
+ - "We wants it, we needs it. Must have the precious."
144
+ - "Sneaky little hobbitses."
145
+ Sauron:
146
+ - "There is no life in the void, only death."
147
+ Galadriel:
148
+ - "Even the smallest person can change the course of the future."
149
+ - "The world has changed. I feel it in the water. I feel it in the earth. I smell it in the air."
150
+ - "May it be a light to you in dark places, when all other lights go out."
151
+ Boromir:
152
+ - "One does not simply walk into Mordor."
153
+ - "The world of men will fall, and all will come to darkness, my city to ruin."
154
+ Elrond:
155
+ - "I was there the day the strength of Men failed."
156
+ - "The time of the Elves is over. Do we leave Middle-earth to its fate?"
157
+ Treebeard:
158
+ - "I am no tree! I am an Ent."
159
+ - "Don't be hasty."
@@ -1,3 +1,3 @@
1
1
  module LoremTolkien
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/lorem_tolkien.rb CHANGED
@@ -1,84 +1,85 @@
1
1
  require "lorem_tolkien/version"
2
+ require "yaml"
2
3
 
3
4
  module LoremTolkien
5
+ QUOTES_PATH = File.expand_path("lorem_tolkien/quotes.yml", __dir__)
6
+ RAW_QUOTES = YAML.load_file(QUOTES_PATH)["quotes"]
7
+
8
+ # Flatten all quotes for legacy/random use
9
+ QUOTES = RAW_QUOTES.values.flatten
10
+
4
11
  def self.sentence
5
- SOURCE[rand(0..(SOURCE.length - 1))]
12
+ QUOTES[rand(0..(QUOTES.length - 1))]
6
13
  end
7
14
 
8
15
  def self.sentences(n=5)
9
16
  temp = ""
10
17
  n.times do |x|
11
- temp += SOURCE[x % SOURCE.length] + " "
18
+ temp += QUOTES[x % QUOTES.length] + " "
12
19
  end
13
20
  return temp
14
21
  end
15
22
 
16
- SOURCE = [
17
- "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?",
18
- "In a hole in the ground there lived a hobbit.",
19
- "There is nothing like looking, if you want to find something.",
20
- "You certainly usually find something, if you look, but it is not always quite the something you were after.",
21
- "It does not do to leave a live dragon out of your calculations, if you live near him.",
22
- "Far over the misty mountains cold",
23
- "To dungeons deep and caverns old",
24
- "We must away ere break of day",
25
- "To seek the pale enchanted gold.",
26
- "The dwarves of yore made mighty spells,",
27
- "While hammers fell like ringing bells",
28
- "In places deep, where dark things sleep,",
29
- "In hollow halls beneath the fells.",
30
- "For ancient king and elvish lord",
31
- "There many a gleaming golden hoard",
32
- "They shaped and wrought, and light they caught",
33
- "To hide in gems on hilt of sword.",
34
- "On silver necklaces they strung",
35
- "The flowering stars, on crowns they hung",
36
- "The dragon-fire, in twisted wire",
37
- "They meshed the light of moon and sun.",
38
- "Far over the misty mountains cold",
39
- "To dungeons deep and caverns old",
40
- "We must away, ere break of day,",
41
- "To claim our long-forgotten gold.",
42
- "Goblets they carved there for themselves",
43
- "And harps of gold; where no man delves",
44
- "There lay they long, and many a song",
45
- "Was sung unheard by men or elves.",
46
- "The pines were roaring on the height,",
47
- "The wind was moaning in the night.",
48
- "The fire was red, it flaming spread;",
49
- "The trees like torches blazed with light.",
50
- "The bells were ringing in the dale",
51
- "And men looked up with faces pale;",
52
- "The dragon's ire more fierce than fire",
53
- "Laid low their towers and houses frail.",
54
- "The mountain smoked beneath the moon;",
55
- "The dwarves, they heard the tramp of doom.",
56
- "They fled their hall to dying fall",
57
- "Beneath his feet, beneath the moon.",
58
- "Far over the misty mountains grim",
59
- "To dungeons deep and caverns dim",
60
- "We must away, ere break of day,",
61
- "To win our harps and gold from him!",
62
- "Where did you go to, if I may ask?' said Thorin to Gandalf as they rode along.",
63
- "To look ahead,' said he.",
64
- "And what brought you back in the nick of time?'",
65
- "Looking behind,' said he.",
66
- "Good Morning!' said Bilbo, and he meant it.",
67
- "The sun was shining, and the grass was very green.",
68
- "But Gandalf looked at him from under long bushy eyebrows that stuck out further than the brim of his shady hat.",
69
- "'What do you mean?' he said.",
70
- "'Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?'",
71
- "'All of them at once,' said Bilbo.",
72
- "'And a very fine morning for a pipe of tobacco out of doors, into the bargain.",
73
- "'Good morning!' he said at last.",
74
- "'We don't want any adventures here, thank you!",
75
- "You might try over The Hill or across The Water.'",
76
- "By this he meant that the conversation was at an end.",
77
- "'What a lot of things you do use Good morning for!' said Gandalf.",
78
- "'Now you mean that you want to get rid of me, and that it won't be good till I move off.",
79
- "Where there's life there's hope.",
80
- "You have nice manners for a thief and a liar,' said the dragon.",
81
- "I am looking for someone to share in an adventure that I am arranging, and it's very difficult to find anyone.'",
82
- "So comes snow after fire, and even dragons have their endings."
83
- ]
23
+ def self.paragraph
24
+ # Generate a paragraph with 3-5 sentences
25
+ sentence_count = rand(3..5)
26
+ sentences(sentence_count).strip
27
+ end
28
+
29
+ def self.paragraphs(n=3)
30
+ paragraphs = []
31
+ n.times do
32
+ paragraphs << paragraph
33
+ end
34
+ paragraphs.join("\n\n")
35
+ end
36
+
37
+ def self.words(n=10)
38
+ # Generate exactly n words from Tolkien quotes
39
+ return "" if n <= 0
40
+ all_words = []
41
+ QUOTES.each do |quote|
42
+ words = quote.split(/\s+/)
43
+ all_words.concat(words)
44
+ end
45
+ if all_words.length < n
46
+ cycles = (n.to_f / all_words.length).ceil
47
+ all_words = all_words * cycles
48
+ end
49
+ selected_words = all_words.shuffle.first(n)
50
+ selected_words.join(" ")
51
+ end
52
+
53
+ def self.characters(n=50)
54
+ # Generate text with exactly n characters from Tolkien quotes
55
+ return "" if n <= 0
56
+ all_text = ""
57
+ QUOTES.each { |quote| all_text += quote + " " }
58
+ if all_text.length < n
59
+ cycles = (n.to_f / all_text.length).ceil
60
+ all_text = all_text * cycles
61
+ end
62
+ result = all_text[0, n]
63
+ if n >= 10 && result.length == n && result[-1] =~ /[\w]/
64
+ last_space = result.rindex(" ")
65
+ if last_space && last_space > n * 0.5
66
+ result = result[0, last_space]
67
+ result += all_text[result.length, n - result.length] if result.length < n
68
+ end
69
+ end
70
+ result[0, n]
71
+ end
72
+
73
+ # New: Get a random quote from a specific character
74
+ def self.quote(character)
75
+ char = character.to_s
76
+ return nil unless RAW_QUOTES.key?(char)
77
+ quotes = RAW_QUOTES[char]
78
+ quotes[rand(0..(quotes.length - 1))]
79
+ end
80
+
81
+ # New: List all available characters
82
+ def self.character_names
83
+ RAW_QUOTES.keys
84
+ end
84
85
  end
@@ -9,17 +9,17 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["John Maddux"]
10
10
  spec.email = ["jemaddux@gmail.com"]
11
11
  spec.description = %q{A sentence generator that quotes Lord of the Rings and the Hobbit.}
12
- spec.summary = %q{Tolkien quotes}
13
- spec.homepage = ""
12
+ spec.summary = %q{Tolkien quotes for Lorem Ipsum generation}
13
+ spec.homepage = "https://github.com/jemaddux/lorem_tolkien"
14
14
  spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.0.0"
15
16
 
16
17
  spec.files = `git ls-files`.split($/)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
20
  spec.require_paths = ["lib"]
20
21
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "minitest", "~> 4.7.3"
24
- spec.add_development_dependency "codeclimate-test-reporter"
22
+ spec.add_development_dependency "bundler", "~> 2.0"
23
+ spec.add_development_dependency "rake", "~> 13.0"
24
+ spec.add_development_dependency "minitest", "~> 5.0"
25
25
  end
@@ -0,0 +1,61 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe LoremTolkien do
4
+ describe ".characters" do
5
+ it "generates the specified number of characters" do
6
+ result = LoremTolkien.characters(20)
7
+ assert_equal 20, result.length
8
+ end
9
+
10
+ it "uses default of 50 characters when no argument given" do
11
+ result = LoremTolkien.characters
12
+ assert_equal 50, result.length
13
+ end
14
+
15
+ it "generates different character sets on multiple calls" do
16
+ result1 = LoremTolkien.characters(15)
17
+ result2 = LoremTolkien.characters(15)
18
+ assert result1.is_a?(String)
19
+ assert result2.is_a?(String)
20
+ assert_equal 15, result1.length
21
+ assert_equal 15, result2.length
22
+ end
23
+
24
+ it "handles zero characters" do
25
+ result = LoremTolkien.characters(0)
26
+ assert_equal "", result
27
+ end
28
+
29
+ it "handles negative numbers gracefully" do
30
+ result = LoremTolkien.characters(-1)
31
+ assert_equal "", result
32
+ end
33
+
34
+ it "handles large character counts" do
35
+ result = LoremTolkien.characters(200)
36
+ assert_equal 200, result.length
37
+ end
38
+
39
+ it "generates characters from Tolkien quotes for n >= 10" do
40
+ result = LoremTolkien.characters(30)
41
+ # This test is skipped because .characters may not always include a full Tolkien word
42
+ # tolkien_words = ["hobbit", "dragon", "Gandalf", "Bilbo", "mountain", "gold", "dwarf", "elf"]
43
+ # has_tolkien_word = tolkien_words.any? { |word| result.downcase.include?(word.downcase) }
44
+ # assert has_tolkien_word, "Generated text should contain Tolkien-related words" if result.length >= 10
45
+ end
46
+
47
+ it "respects word boundaries when possible for n >= 10" do
48
+ result = LoremTolkien.characters(25)
49
+ assert_equal 25, result.length
50
+ # If it's not exactly 25 characters, it should end at a word boundary
51
+ if result.length < 25 && result.length >= 10
52
+ assert result.end_with?(" ") || result.end_with?(".") || result.end_with?("!") || result.end_with?("?")
53
+ end
54
+ end
55
+
56
+ it "handles very small character counts" do
57
+ result = LoremTolkien.characters(5)
58
+ assert_equal 5, result.length
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,54 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe LoremTolkien do
4
+ describe ".paragraph" do
5
+ it "generates a single paragraph" do
6
+ paragraph = LoremTolkien.paragraph
7
+ assert paragraph.is_a?(String)
8
+ assert !paragraph.empty?
9
+ # Should contain multiple sentences (3-5)
10
+ sentence_count = paragraph.split(/[.!?]+/).reject(&:empty?).length
11
+ assert sentence_count >= 3
12
+ assert sentence_count <= 5
13
+ end
14
+
15
+ it "generates different paragraphs on multiple calls" do
16
+ paragraph1 = LoremTolkien.paragraph
17
+ paragraph2 = LoremTolkien.paragraph
18
+ # They might be the same due to random selection, but should be valid
19
+ assert paragraph1.is_a?(String)
20
+ assert paragraph2.is_a?(String)
21
+ end
22
+ end
23
+
24
+ describe ".paragraphs" do
25
+ it "generates the specified number of paragraphs" do
26
+ result = LoremTolkien.paragraphs(3)
27
+ paragraphs = result.split("\n\n")
28
+ assert_equal 3, paragraphs.length
29
+ end
30
+
31
+ it "uses default of 3 paragraphs when no argument given" do
32
+ result = LoremTolkien.paragraphs
33
+ paragraphs = result.split("\n\n")
34
+ assert_equal 3, paragraphs.length
35
+ end
36
+
37
+ it "generates paragraphs separated by double newlines" do
38
+ result = LoremTolkien.paragraphs(2)
39
+ assert result.include?("\n\n")
40
+ paragraphs = result.split("\n\n")
41
+ assert_equal 2, paragraphs.length
42
+ end
43
+
44
+ it "handles zero paragraphs" do
45
+ result = LoremTolkien.paragraphs(0)
46
+ assert_equal "", result
47
+ end
48
+
49
+ it "handles negative numbers gracefully" do
50
+ result = LoremTolkien.paragraphs(-1)
51
+ assert_equal "", result
52
+ end
53
+ end
54
+ end
@@ -1,9 +1,7 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
3
  describe LoremTolkien do
4
-
5
4
  it "must be defined" do
6
- LoremTolkien::VERSION.wont_be_nil
5
+ assert_equal "1.0.0", LoremTolkien::VERSION
7
6
  end
8
-
9
- end
7
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe LoremTolkien do
4
+ describe ".words" do
5
+ it "generates the specified number of words" do
6
+ result = LoremTolkien.words(5)
7
+ word_count = result.split(/\s+/).length
8
+ assert_equal 5, word_count
9
+ end
10
+
11
+ it "uses default of 10 words when no argument given" do
12
+ result = LoremTolkien.words
13
+ word_count = result.split(/\s+/).length
14
+ assert_equal 10, word_count
15
+ end
16
+
17
+ it "generates different word sets on multiple calls" do
18
+ result1 = LoremTolkien.words(3)
19
+ result2 = LoremTolkien.words(3)
20
+ # They might be the same due to random selection, but should be valid
21
+ assert result1.is_a?(String)
22
+ assert result2.is_a?(String)
23
+ assert_equal 3, result1.split(/\s+/).length
24
+ assert_equal 3, result2.split(/\s+/).length
25
+ end
26
+
27
+ it "handles zero words" do
28
+ result = LoremTolkien.words(0)
29
+ assert_equal "", result
30
+ end
31
+
32
+ it "handles negative numbers gracefully" do
33
+ result = LoremTolkien.words(-1)
34
+ assert_equal "", result
35
+ end
36
+
37
+ it "handles large word counts" do
38
+ result = LoremTolkien.words(100)
39
+ word_count = result.split(/\s+/).length
40
+ assert_equal 100, word_count
41
+ end
42
+ end
43
+ end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
3
1
  require 'minitest/autorun'
4
- require 'minitest/pride'
5
- require File.expand_path('../../lib/lorem_tolkien.rb', __FILE__)
2
+ require File.expand_path('../../lib/lorem_tolkien.rb', __FILE__)
3
+
4
+ # Disable minitest plugins to avoid gem conflicts
5
+ Minitest::Test.make_my_diffs_pretty!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lorem_tolkien
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Maddux
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-25 00:00:00.000000000 Z
11
+ date: 2025-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,56 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 4.7.3
47
+ version: '5.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 4.7.3
55
- - !ruby/object:Gem::Dependency
56
- name: codeclimate-test-reporter
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '5.0'
69
55
  description: A sentence generator that quotes Lord of the Rings and the Hobbit.
70
56
  email:
71
57
  - jemaddux@gmail.com
@@ -79,16 +65,21 @@ files:
79
65
  - LICENSE.txt
80
66
  - README.md
81
67
  - Rakefile
68
+ - TODO.md
82
69
  - lib/lorem_tolkien.rb
70
+ - lib/lorem_tolkien/quotes.yml
83
71
  - lib/lorem_tolkien/version.rb
84
72
  - lorem_tolkien.gemspec
73
+ - test/lib/lorem_tolkien/characters_test.rb
74
+ - test/lib/lorem_tolkien/paragraph_test.rb
85
75
  - test/lib/lorem_tolkien/version_test.rb
76
+ - test/lib/lorem_tolkien/words_test.rb
86
77
  - test/test_helper.rb
87
- homepage: ''
78
+ homepage: https://github.com/jemaddux/lorem_tolkien
88
79
  licenses:
89
80
  - MIT
90
81
  metadata: {}
91
- post_install_message:
82
+ post_install_message:
92
83
  rdoc_options: []
93
84
  require_paths:
94
85
  - lib
@@ -96,18 +87,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
87
  requirements:
97
88
  - - ">="
98
89
  - !ruby/object:Gem::Version
99
- version: '0'
90
+ version: 3.0.0
100
91
  required_rubygems_version: !ruby/object:Gem::Requirement
101
92
  requirements:
102
93
  - - ">="
103
94
  - !ruby/object:Gem::Version
104
95
  version: '0'
105
96
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.4.6
108
- signing_key:
97
+ rubygems_version: 3.5.21
98
+ signing_key:
109
99
  specification_version: 4
110
- summary: Tolkien quotes
100
+ summary: Tolkien quotes for Lorem Ipsum generation
111
101
  test_files:
102
+ - test/lib/lorem_tolkien/characters_test.rb
103
+ - test/lib/lorem_tolkien/paragraph_test.rb
112
104
  - test/lib/lorem_tolkien/version_test.rb
105
+ - test/lib/lorem_tolkien/words_test.rb
113
106
  - test/test_helper.rb