ru_bee 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjE4ZTQ0YmJhOGY2MWE4NGM5ZGU2ZDRmMzQ1ZjYwMGM1NWJiYWI3OA==
4
+ NGIyZDUwMDRjNjA4ZDYwYmZlNjBmNDU5NjY5YWQzMWJmZGE1ZGI3Yg==
5
5
  data.tar.gz: !binary |-
6
- ODA3NTNhYmU3ZTM4YjAyYmFjZDZhN2M1Nzg1MzU2NzM3MjlkODRlNg==
6
+ NWI5MWVjYTA3ODBjNWMyYTIwYjEwNDYwNWYxYzQyYjY1MzI4ZTM0Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmM0YTEzYjFmMWNjZjcxYTYyODU1NDQzMGZkNGZmYWFiODliMGU3OTA5MTBh
10
- Njg4ZDlhNmZmM2E5NzIzZTRmNzAwYjU3N2JjNGZiYjhjNjhkYjdlN2Q1ZDFj
11
- ZTRkYmY5MmIwZWE0ZWVkMzIwYTc1ODNkNWE5ZDE0YTZjYTFkNjI=
9
+ YTkwOTFjYjZjNjI1MGUwMWQ1MzcwZmQ2OTQ3Yjg3OGJhZTQ4MTNhOTFlODY2
10
+ MTIyOWI1NzY1NjIxYThkOWRkNjgzMzBiNDQyOWNiMDg0NTY2OTRlOTkyMWE4
11
+ ZjhjNzUzMzcyZjQzMmQzZGMwOGZjYTcwMWRlZDJhZTFiZmQ2MGM=
12
12
  data.tar.gz: !binary |-
13
- YzgzYTMxODcxM2NjOGQwZTExYzk3ZWM2MDYxZjA0ZmNmMDZkOWM0NGRmNTJk
14
- ZGFkNWYxYzhlYjEwMjEyMmE2YTAxZWE3NzEzYzE5OGMwNDBkYWVjYTdhYjU4
15
- OGNiYjI0NjBlYjhkMzgyYjU3NmI0M2ZiZDQ4ZjFmNzE4YTNkY2M=
13
+ MmYxODVjYzFiZGM2NWFjYzI5ZmM4NTk1ZGRhYmE5Nzk0YzNiMGM0NDVkNjdh
14
+ NzZmNDljMTllOGQzN2U3NzJkOWI1MjRmNTFhNTMxMWEyOWMxYWQ3OWZiNjc5
15
+ OTgzYjIxM2EzYjY2ZDI1ZmMxODg1Yzc4ZjVlMmY5MDBiMjA5ODM=
@@ -1,3 +1,3 @@
1
1
  module RuBee
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/scanner.rb CHANGED
@@ -1,36 +1,31 @@
1
1
  class String
2
2
 
3
- @dictionary = []
4
- @options = {}
5
-
6
3
  def correct? options={}
7
4
  @options = options
8
- get_parts
9
- load_dictionary
10
5
  check
11
6
  end
12
7
 
13
8
  def misspellings options={}
14
9
  @options = options
15
- get_parts
16
- load_dictionary
17
10
  check true
18
11
  @bad_words
19
12
  end
20
13
 
21
14
  private
22
15
 
23
- def get_parts
24
- @parts = self.downcase.gsub(/[\'\"]/, '').scan(/[a-z]+/)
16
+ def words
17
+ @words ||= self.downcase.gsub(/[\'\"]/, '').scan(/[a-z]+/)
25
18
  end
26
19
 
27
- def load_dictionary
28
- filename = @options[:language] || 'english'
29
- path = File.dirname(__FILE__)
30
- file = File.open("#{path}/dictionaries/#{filename}", "r")
31
- @dictionary = file.read.downcase.split(/\n/)
32
- file.close
33
- @dictionary
20
+ def dictionary
21
+ @dictionary ||= begin
22
+ filename = @options[:language] || 'english'
23
+ path = File.dirname(__FILE__)
24
+ file = File.open("#{path}/dictionaries/#{filename}", "r")
25
+ contents = file.read.downcase.split(/\n/)
26
+ file.close
27
+ contents || []
28
+ end
34
29
  end
35
30
 
36
31
  def remove_s word
@@ -63,16 +58,16 @@ class String
63
58
 
64
59
  def check collect=false
65
60
  @bad_words = []
66
- @parts.each do |word|
67
- unless @dictionary.include?("#{word}") or
68
- @dictionary.include?("#{remove_s(word)}") or
69
- @dictionary.include?("#{remove_ed(word)}") or
70
- @dictionary.include?("#{remove_ing(word)}") or
71
- @dictionary.include?("#{remove_es(word)}")
61
+ words.each do |word|
62
+ unless dictionary.include?("#{word}") or
63
+ dictionary.include?("#{remove_s(word)}") or
64
+ dictionary.include?("#{remove_ed(word)}") or
65
+ dictionary.include?("#{remove_ing(word)}") or
66
+ dictionary.include?("#{remove_es(word)}")
72
67
  @bad_words << word
73
68
  return false unless collect
74
69
  end
75
- end
70
+ end
76
71
  true
77
72
  end
78
73
 
data/spec/scanner_spec.rb CHANGED
@@ -35,10 +35,10 @@ describe String do
35
35
  end
36
36
 
37
37
 
38
- describe '#get_parts' do
38
+ describe '#words' do
39
39
 
40
40
  it 'should break string into word parts' do
41
- expect(test_string_good.send('get_parts').count).to eq(10)
41
+ expect(test_string_good.send('words').count).to eq(10)
42
42
  end
43
43
 
44
44
  end
@@ -47,7 +47,7 @@ describe String do
47
47
 
48
48
  it 'should set DICTIONARY to' do
49
49
  test_string_good.correct?
50
- expect(test_string_good.send('load_dictionary').count).to eq(235887)
50
+ expect(test_string_good.send('dictionary').count).to eq(235887)
51
51
  end
52
52
 
53
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ru_bee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - dan