frosty_meadow 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/frosty_meadow.rb +16 -8
  2. metadata +1 -1
data/lib/frosty_meadow.rb CHANGED
@@ -3,7 +3,7 @@ require 'json'
3
3
  module FrostyMeadow
4
4
  module Version
5
5
  MAJOR = 2
6
- MINOR = 0
6
+ MINOR = 1
7
7
  PATCH = 0
8
8
 
9
9
  FULL = [MAJOR, MINOR, PATCH].join('.')
@@ -24,6 +24,8 @@ module FrostyMeadow
24
24
  end
25
25
 
26
26
  class << self
27
+ @@words = []
28
+
27
29
  def generate params = {}
28
30
  words = get_words params
29
31
 
@@ -40,15 +42,21 @@ module FrostyMeadow
40
42
  end
41
43
 
42
44
  def get_words params = {}
43
- file_path = File.join(File.dirname(__FILE__), 'data/words.json')
44
- file = File.new file_path, "r"
45
45
 
46
- file_contents = ""
47
- while line = file.gets
48
- file_contents << line
49
- end
46
+ if @@words.empty?
47
+ file_path = File.join(File.dirname(__FILE__), 'data/words.json')
48
+ file = File.new file_path, "r"
50
49
 
51
- words = JSON.parse(file_contents)
50
+ file_contents = ""
51
+ while line = file.gets
52
+ file_contents << line
53
+ end
54
+
55
+ words = JSON.parse(file_contents)
56
+ @@words = words
57
+ else
58
+ words = @@words
59
+ end
52
60
 
53
61
  words['adjectives'] = params[:adjectives] unless params[:adjectives].nil?
54
62
  words['nouns'] = params[:nouns] unless params[:nouns].nil?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frosty_meadow
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: