profane 0.0.2 → 0.0.3

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.
data/README.md CHANGED
@@ -17,6 +17,20 @@ Or install it yourself as:
17
17
 
18
18
  $ gem install profane
19
19
 
20
+ ## Usage
21
+
22
+ Filter profanity from a bit of text:
23
+ ```
24
+ Profane::Filter.filter('Voldemort!')
25
+ => '*********!')
26
+ ```
27
+
28
+ Detect profanity in a bit of text:
29
+ ```
30
+ Profane::Filter.profane?('If you come to a fork in the road, take it.')
31
+ => false
32
+ ```
33
+
20
34
  ## Configuration
21
35
 
22
36
  You can include words from your own dictionary in a hash or a yaml file, where
@@ -40,28 +54,15 @@ Profane.configure(dictionary: { obscenity: 'obs******' }, use_internal_dictionar
40
54
  Profane.configure(dictionary_file: 'config/dictionary.yml', use_internal_dictionary: false)
41
55
  ```
42
56
 
43
- If you set a key to '' in the dictionary profane will use the default strategy
57
+ If you set a key to '' (blank string) in the dictionary profane will use the default strategy
44
58
  of overwriting the entire word (exempting punctuation) with '*'. You can pass an
45
59
  alternative character to use with the filter_character option.
46
60
  ```
47
61
  Profane.configure(filter_character: '&')
48
- ```
49
- Note that if you want to actually replace words with blank string you can use ''
50
- as your default character.
51
-
52
- ## Usage
53
-
54
- Filter profanity from a bit of text:
55
- ```
56
62
  Profane::Filter.filter('Voldemort!')
57
- => '*********!')
58
- ```
59
-
60
- Detect profanity in a bit of text:
61
- ```
62
- Profane::Filter.profane?('If you come to a fork in the road, take it.')
63
- => 'false'
63
+ => '&&&&&&&&&!')
64
64
  ```
65
+ Note that if you want to actually replace words with a blank string you can use '' as your default character.
65
66
 
66
67
  ## Thanks
67
68
 
@@ -16,6 +16,8 @@ module Profane
16
16
  end
17
17
 
18
18
  def profane?(phrase)
19
+ return false unless phrase
20
+
19
21
  phrase = phrase.downcase.split(/\s+/)
20
22
 
21
23
  dictionary.keys.each do |key|
@@ -1,3 +1,3 @@
1
1
  module Profane
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -73,6 +73,11 @@ describe 'Profane::Filter' do
73
73
  filter.profane?('this is not profane').should be_false
74
74
  end
75
75
 
76
+ it "returns false given nil" do
77
+ filter = Profane::Filter.new
78
+ filter.profane?(nil).should be_false
79
+ end
80
+
76
81
  it "detects the presence of words from the default dictionary" do
77
82
  filter = Profane::Filter.new
78
83
  filter.profane?('fuck').should be_true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-05-02 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler