fandom-word 0.3.0 → 0.4.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
2
  SHA1:
3
- metadata.gz: bc6e3b9fe1ca4b079c06735e8adfb36ddcda87a0
4
- data.tar.gz: e39c700480ceb74bef8b65e61ee8897cdfcb4c50
3
+ metadata.gz: 8292d6e758a0580f52ed94dfa3ddca294ee6f5ed
4
+ data.tar.gz: f8458d92461eceb480f4b9cef2ab74845ad169f7
5
5
  SHA512:
6
- metadata.gz: 861407502f7998539124ff0ab5c98558d55a0e187b28622afd270e0a841189a7a49ba49f0c6217f5c062699cbf5e691919b79315669f68930c39168aedd7ee43
7
- data.tar.gz: 3c05280ae6b874129b6fe2cb28f38f46b635acffb86fc1d26edfa9c21eefc12b887e6ded35f992ad4645b828f08f768b558f0ff31e73c0474f769056372a8a1f
6
+ metadata.gz: 3612efa6c64bde71631e39858a7d1bd05c2853309afb9f0a7ccd1eb52b80d1b69e7760a23d8743c041ffa206daf27f04428f568369684fe6268afb4771f3d98b
7
+ data.tar.gz: edd8859f6b9e4fd2c5218eb13b1ec726896cfb6d01c4f6466fbeb6541dc73e3e0edf800a8313abc9724cdd8c9b0a7d031002e3d1de8e3592f598821797ce54de
@@ -0,0 +1,5 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=lf
3
+
4
+ # Known text files
5
+ *.sh text eol=lf
data/.gitignore CHANGED
@@ -3,4 +3,6 @@
3
3
 
4
4
  *.gem
5
5
 
6
- Gemfile.lock
6
+ Gemfile.lock
7
+
8
+ coverage/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require ./spec/spec_helper.rb
3
+ --format d
@@ -1,3 +1,18 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - lib/fandom-word.rb
3
+ - lib/fandom-word.rb
4
+
5
+ Layout/EndOfLine:
6
+ Exclude:
7
+ - fandom-word.gemspec
8
+ - Gemfile
9
+ - Rakefile
10
+ - lib/**/*
11
+ - spec/**/*
12
+
13
+ Metrics/BlockLength:
14
+ Exclude:
15
+ - spec/**/*
16
+
17
+ Metrics/LineLength:
18
+ Max: 120
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.1.0
5
+ - 2.1.2
6
+ - 2.2.2
7
+ - ruby-head
@@ -0,0 +1,5 @@
1
+ lib/fandoms.rb 04e6759e58e6b973fe0d3fa0382197356e2f5c93
2
+ lib/version.rb e943b10f8f7edb26682016a692305e251f5481b9
3
+ lib/fandom-word.rb 9e292912f4cce8af8b2ad6b655df6e73931a6cc8
4
+ lib/fandom_word.rb 0d0359cf3ced737a2d9a69b204c348ba5f7cb5d7
5
+ lib/fandom_word_catalog.rb 6a0254bf451a21cf7f94a12caa70133673515856
File without changes
Binary file
Binary file
Binary file
data/Gemfile CHANGED
@@ -2,5 +2,21 @@ source 'https://rubygems.org'
2
2
 
3
3
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- gem 'rake'
6
- gem 'rubocop'
5
+ group :build do
6
+ gem 'rake', '12.3.0'
7
+ gem 'yard', '0.9.9'
8
+ end
9
+
10
+ group :development do
11
+ gem 'pry', '0.10.4'
12
+ gem 'pry-nav', '0.2.4'
13
+ gem 'pry-stack_explorer', '0.4.9.2'
14
+ gem 'rubocop', '0.51.0'
15
+ end
16
+
17
+ group :test do
18
+ gem 'benchmark-ips', '2.7.2'
19
+ gem 'rspec', '3.7.0'
20
+ gem 'rspec-benchmark', '0.3.0'
21
+ gem 'simplecov', '0.15.1'
22
+ end
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  fandom-word
2
2
  ====
3
+ [![Gem Version](https://badge.fury.io/rb/fandom-word.svg)](https://badge.fury.io/rb/fandom-word)
4
+ [![Build Status](https://travis-ci.org/RaviN/fandom-word.svg?branch=master)](https://travis-ci.org/RaviN/fandom-word)
3
5
 
4
6
  A fandom word generator that returns random words from various fandoms.
5
7
 
@@ -10,11 +12,13 @@ fandom-word allows you to get a randomized word pertaining to any fandom.
10
12
  You can also use it to get a randomized word for a specific fandom.
11
13
 
12
14
  ```ruby
13
- FandomWord.get_word # returns a word from any fandom category
14
- FandomWord.get_word_by_fandom(fandom_name) # returns a word from a specific fandom
15
+ FandomWord.random_word # returns a word from any fandom category
16
+ FandomWord.random_word(fandom_name) # returns a word from a specific fandom
17
+ FandomWord.random_word([fandom_name_1, fandom_name_2]) # returns a word from one of the fandoms
18
+ FandomWord.fandoms # list fandoms
15
19
  ```
16
20
 
17
- To get a list of available fandoms use `Fandomword.available_fandoms`
21
+ Available fandoms are defined as constants in `FandomWord::Fandoms`
18
22
 
19
23
  Adding Fandoms
20
24
  ----
@@ -24,14 +28,14 @@ Adding Fandoms
24
28
  * When adding your word list use the following format
25
29
  ```yaml
26
30
  :categories:
27
- - list
28
- - of
29
- - applicable
30
- - categories
31
+ - list
32
+ - of
33
+ - applicable
34
+ - categories
31
35
  :words:
32
- - list
33
- - of
34
- - words
36
+ - list
37
+ - of
38
+ - words
35
39
  ```
36
- * Make sure all tests are still passing ( we will have tests, promise )
40
+ * Make sure all tests are still passing and there is 100% code coverage
37
41
  * Submit pull request
data/Rakefile CHANGED
@@ -1,17 +1,18 @@
1
1
  require 'ostruct'
2
- require_relative 'lib/fandom_word'
2
+
3
+ # Require relative all library files. No require relatives should be necessary below the next couple lines
4
+ source_files_to_require = Dir['lib/**/*.rb']
5
+ source_files_to_require.each { |file_path| require_relative file_path }
3
6
 
4
7
  task :default do
5
- puts "RANDOM MECHA WORD: #{FandomWord.random_word_from_fandom 'mecha'}"
6
- puts "RANDOM ANIME WORD: #{FandomWord.random_word_from_fandom 'anime'}"
7
- puts "RANDOM CATEGORY WORD: #{FandomWord.random_word}"
8
+ Rake::Task['pre_flight'].invoke
9
+ Rake::Task['demo'].invoke
8
10
  end
9
11
 
12
+ desc 'Collects all word lists and compiles into words.data'
10
13
  task :build_data do
11
14
  require 'erb'
12
-
13
15
  require 'yaml'
14
- require_relative 'lib/fandom_word_catalog'
15
16
 
16
17
  DATA_FILE = 'data/words.data'.freeze
17
18
  WORD_LIST_GLOB = 'word-lists/**/*.yml'.freeze
@@ -21,7 +22,7 @@ task :build_data do
21
22
  catalog = FandomWord::FandomWordCatalog.new
22
23
 
23
24
  Dir.glob(WORD_LIST_GLOB) do |file_path|
24
- puts "Processing: #{file_path}"
25
+ puts "Adding to words.data: #{file_path}"
25
26
  word_list = YAML.load_file(file_path)
26
27
  word_list[:words].each do |word|
27
28
  catalog.add_word(word, word_list[:categories])
@@ -42,3 +43,56 @@ task :build_data do
42
43
  erb = Dummy.new(fandoms: catalog.fandoms)
43
44
  File.write('lib/fandoms.rb', erb.render(File.read('build/fandoms.rb.erb')))
44
45
  end
46
+
47
+ desc 'Perform a couple demonstrations of FandomWord'
48
+ task :demo do
49
+ puts "RANDOM MECHA WORD: #{FandomWord.random_word 'mecha'}"
50
+ puts "RANDOM ANIME WORD: #{FandomWord.random_word 'anime'}"
51
+ puts "RANDOM ANIME OR MECHA WORD: #{FandomWord.random_word %w[anime mecha]}"
52
+ puts "RANDOM WORD: #{FandomWord.random_word}"
53
+ end
54
+
55
+ desc 'Performs common checks / house keeping as a prerequisite before submitting a pull request'
56
+ task :pre_flight do
57
+ def system_helper(command)
58
+ raise "One of the pre flight steps failed! #{command}" unless system command
59
+ end
60
+
61
+ # Validate style is up to standards
62
+ system_helper 'bundle exec rubocop -DES'
63
+
64
+ # Validate all tests pass
65
+ system 'bundle exec rspec'
66
+
67
+ # Sort original word list alphabetically
68
+ Rake::Task['sort_word_lists'].invoke
69
+
70
+ # Build word data
71
+ Rake::Task['build_data'].invoke
72
+
73
+ # Document code
74
+ system 'bundle exec yard'
75
+ end
76
+
77
+ desc 'Get benchmark'
78
+ task :determine_benchmark_ips do
79
+ require 'benchmark/ips'
80
+
81
+ Benchmark.ips do |x|
82
+ x.config time: 5, warmup: 2
83
+ x.report('Get Random Word') { FandomWord.random_word }
84
+ x.compare!
85
+ end
86
+ end
87
+
88
+ desc 'Sort word list fandoms and words in alphabetical order'
89
+ task :sort_word_lists do
90
+ require 'yaml'
91
+ WORD_LIST_GLOB = 'word-lists/**/*.yml'.freeze
92
+ Dir.glob(WORD_LIST_GLOB) do |file_path|
93
+ puts "Sorting word list alphabetically: #{file_path}"
94
+ word_list = YAML.load_file file_path
95
+ word_list.each_value(&:sort!)
96
+ File.open(file_path, 'w') { |file| file.write word_list.to_yaml }
97
+ end
98
+ end
Binary file
@@ -0,0 +1,347 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: FandomWord
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "FandomWord";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (F)</a> &raquo;
40
+
41
+
42
+ <span class="title">FandomWord</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: FandomWord
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/fandom_word.rb<span class="defines">,<br />
82
+ lib/fandoms.rb,<br /> lib/version.rb,<br /> lib/fandom_word_catalog.rb</span>
83
+ </dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Overview</h2><div class="docstring">
89
+ <div class="discussion">
90
+
91
+ <p>Holds all classes and methods for Fandom Word</p>
92
+
93
+
94
+ </div>
95
+ </div>
96
+ <div class="tags">
97
+
98
+
99
+ </div><h2>Defined Under Namespace</h2>
100
+ <p class="children">
101
+
102
+
103
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="FandomWord/Fandoms.html" title="FandomWord::Fandoms (module)">Fandoms</a></span>
104
+
105
+
106
+
107
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="FandomWord/FandomRandomizer.html" title="FandomWord::FandomRandomizer (class)">FandomRandomizer</a></span>, <span class='object_link'><a href="FandomWord/FandomWordCatalog.html" title="FandomWord::FandomWordCatalog (class)">FandomWordCatalog</a></span>
108
+
109
+
110
+ </p>
111
+
112
+ <h2>Constant Summary</h2>
113
+ <dl class="constants">
114
+
115
+ <dt id="VERSION-constant" class="">VERSION =
116
+ <div class="docstring">
117
+ <div class="discussion">
118
+
119
+ <p>Version of this gem</p>
120
+
121
+
122
+ </div>
123
+ </div>
124
+ <div class="tags">
125
+
126
+
127
+ </div>
128
+ </dt>
129
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.4.0</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
130
+
131
+ </dl>
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+ <h2>
141
+ Class Method Summary
142
+ <small><a href="#" class="summary_toggle">collapse</a></small>
143
+ </h2>
144
+
145
+ <ul class="summary">
146
+
147
+ <li class="public ">
148
+ <span class="summary_signature">
149
+
150
+ <a href="#fandoms-class_method" title="fandoms (class method)">.<strong>fandoms</strong> &#x21d2; Object </a>
151
+
152
+
153
+
154
+ </span>
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+ <span class="summary_desc"><div class='inline'>
165
+ <p>Returns the list of fandoms (categories).</p>
166
+ </div></span>
167
+
168
+ </li>
169
+
170
+
171
+ <li class="public ">
172
+ <span class="summary_signature">
173
+
174
+ <a href="#random_word-class_method" title="random_word (class method)">.<strong>random_word</strong>(fandom_name_or_names = nil) &#x21d2; String </a>
175
+
176
+
177
+
178
+ </span>
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+ <span class="summary_desc"><div class='inline'>
189
+ <p>Returns random word from any fandom in catalog.</p>
190
+ </div></span>
191
+
192
+ </li>
193
+
194
+
195
+ </ul>
196
+
197
+
198
+
199
+
200
+ <div id="class_method_details" class="method_details_list">
201
+ <h2>Class Method Details</h2>
202
+
203
+
204
+ <div class="method_details first">
205
+ <h3 class="signature first" id="fandoms-class_method">
206
+
207
+ .<strong>fandoms</strong> &#x21d2; <tt>Object</tt>
208
+
209
+
210
+
211
+
212
+
213
+ </h3><div class="docstring">
214
+ <div class="discussion">
215
+
216
+ <p>Returns the list of fandoms (categories)</p>
217
+
218
+
219
+ </div>
220
+ </div>
221
+ <div class="tags">
222
+
223
+
224
+ </div><table class="source_code">
225
+ <tr>
226
+ <td>
227
+ <pre class="lines">
228
+
229
+
230
+ 19
231
+ 20
232
+ 21</pre>
233
+ </td>
234
+ <td>
235
+ <pre class="code"><span class="info file"># File 'lib/fandom_word.rb', line 19</span>
236
+
237
+ <span class='kw'>def</span> <span class='id identifier rubyid_fandoms'>fandoms</span>
238
+ <span class='const'><span class='object_link'><a href="FandomWord/FandomRandomizer.html" title="FandomWord::FandomRandomizer (class)">FandomRandomizer</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_available_fandoms'>available_fandoms</span>
239
+ <span class='kw'>end</span></pre>
240
+ </td>
241
+ </tr>
242
+ </table>
243
+ </div>
244
+
245
+ <div class="method_details ">
246
+ <h3 class="signature " id="random_word-class_method">
247
+
248
+ .<strong>random_word</strong>(fandom_name_or_names = nil) &#x21d2; <tt>String</tt>
249
+
250
+
251
+
252
+
253
+
254
+ </h3><div class="docstring">
255
+ <div class="discussion">
256
+
257
+ <p>Returns random word from any fandom in catalog. Fandom category can be
258
+ specified.</p>
259
+
260
+
261
+ </div>
262
+ </div>
263
+ <div class="tags">
264
+ <p class="tag_title">Parameters:</p>
265
+ <ul class="param">
266
+
267
+ <li>
268
+
269
+ <span class='name'>fandom_name_or_names</span>
270
+
271
+
272
+ <span class='type'>(<tt>String</tt>, <tt>Array</tt>)</span>
273
+
274
+
275
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
276
+
277
+
278
+ &mdash;
279
+ <div class='inline'>
280
+ <p>Fandom category or array of categories</p>
281
+ </div>
282
+
283
+ </li>
284
+
285
+ </ul>
286
+
287
+ <p class="tag_title">Returns:</p>
288
+ <ul class="return">
289
+
290
+ <li>
291
+
292
+
293
+ <span class='type'>(<tt>String</tt>)</span>
294
+
295
+
296
+
297
+ &mdash;
298
+ <div class='inline'>
299
+ <p>Random word</p>
300
+ </div>
301
+
302
+ </li>
303
+
304
+ </ul>
305
+
306
+ </div><table class="source_code">
307
+ <tr>
308
+ <td>
309
+ <pre class="lines">
310
+
311
+
312
+ 10
313
+ 11
314
+ 12
315
+ 13
316
+ 14
317
+ 15
318
+ 16</pre>
319
+ </td>
320
+ <td>
321
+ <pre class="code"><span class="info file"># File 'lib/fandom_word.rb', line 10</span>
322
+
323
+ <span class='kw'>def</span> <span class='id identifier rubyid_random_word'>random_word</span><span class='lparen'>(</span><span class='id identifier rubyid_fandom_name_or_names'>fandom_name_or_names</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
324
+ <span class='kw'>if</span> <span class='id identifier rubyid_fandom_name_or_names'>fandom_name_or_names</span>
325
+ <span class='const'><span class='object_link'><a href="FandomWord/FandomRandomizer.html" title="FandomWord::FandomRandomizer (class)">FandomRandomizer</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_random_word'>random_word</span> <span class='id identifier rubyid_fandom_name_or_names'>fandom_name_or_names</span>
326
+ <span class='kw'>else</span>
327
+ <span class='const'><span class='object_link'><a href="FandomWord/FandomRandomizer.html" title="FandomWord::FandomRandomizer (class)">FandomRandomizer</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_random_word'>random_word</span>
328
+ <span class='kw'>end</span>
329
+ <span class='kw'>end</span></pre>
330
+ </td>
331
+ </tr>
332
+ </table>
333
+ </div>
334
+
335
+ </div>
336
+
337
+ </div>
338
+
339
+ <div id="footer">
340
+ Generated on Sun Nov 19 16:39:22 2017 by
341
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
342
+ 0.9.9 (ruby-2.3.3).
343
+ </div>
344
+
345
+ </div>
346
+ </body>
347
+ </html>