Module: Profane
- Defined in:
- lib/profane.rb,
lib/profane/filter.rb,
lib/profane/version.rb
Defined Under Namespace
Classes: Filter
Constant Summary collapse
- DICTIONARY_PATH =
File.('../../config/dictionary.yml', __FILE__)
- VERSION =
"0.0.4"
Class Method Summary collapse
- .character ⇒ Object
- .config ⇒ Object
- .configure(options) ⇒ Object
- .dictionary ⇒ Object
- .load_custom_yaml_dictionary ⇒ Object
- .load_dictionary ⇒ Object
- .load_internal_yaml_dictionary ⇒ Object
- .load_yaml_dictionary ⇒ Object
- .set_default_config ⇒ Object
- .stringify_keys(hash) ⇒ Object
Class Method Details
.character ⇒ Object
32 33 34 |
# File 'lib/profane.rb', line 32 def self.character config[:filter_character] || '*' end |
.config ⇒ Object
12 13 14 |
# File 'lib/profane.rb', line 12 def self.config @config ||= set_default_config end |
.configure(options) ⇒ Object
8 9 10 |
# File 'lib/profane.rb', line 8 def self.configure() config.merge!() end |
.dictionary ⇒ Object
20 21 22 |
# File 'lib/profane.rb', line 20 def self.dictionary stringify_keys(load_dictionary) end |
.load_custom_yaml_dictionary ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/profane.rb', line 60 def self.load_custom_yaml_dictionary path = config[:dictionary_file] if path && File.exist?(path) YAML.load(File.read(config[:dictionary_file])) else {} end end |
.load_dictionary ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/profane.rb', line 36 def self.load_dictionary yaml_dictionary = load_yaml_dictionary if config[:use_internal_dictionary] yaml_dictionary.merge (config[:dictionary] || {}) else config[:dictionary] end end |
.load_internal_yaml_dictionary ⇒ Object
56 57 58 |
# File 'lib/profane.rb', line 56 def self.load_internal_yaml_dictionary internal_dictionary = YAML.load(File.read(DICTIONARY_PATH)) end |
.load_yaml_dictionary ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/profane.rb', line 46 def self.load_yaml_dictionary custom_dictionary = load_custom_yaml_dictionary if config[:use_internal_dictionary] load_internal_yaml_dictionary.merge custom_dictionary else custom_dictionary end end |
.set_default_config ⇒ Object
16 17 18 |
# File 'lib/profane.rb', line 16 def self.set_default_config @config = { use_internal_dictionary: true } end |
.stringify_keys(hash) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/profane.rb', line 24 def self.stringify_keys(hash) hash.keys.each do |key| hash[key.to_s] = hash.delete(key) end hash end |