antivirus 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc1d30d434238df7de4e8f2ec33236e05c70873c
4
- data.tar.gz: 1d291ce3febb2a348a39a7eb744e46527802254e
3
+ metadata.gz: 68506dbc5c0ffff2c0c4fa00bd5e72c2c2935d2b
4
+ data.tar.gz: e36724195f987c2436630fe57c16ef9a23d69f60
5
5
  SHA512:
6
- metadata.gz: 1bcc885a639317821344ef7d58328a067dc581e4d56e0b59972593d91c9dd1941ac1b1778106a7104913023a8446eea077efb065c2dd4d2fb94209a101a9a11a
7
- data.tar.gz: 4da1eb5c489bf657e803ca64dc0f8e541b0dcf90f9bc73cece0cb606d9b33d2e4c0aa0fd0140fcdf18b332365e1b7d1a638a1cd8655d144130916b4f012d74eb
6
+ metadata.gz: f1e694e6360c17a7d5e57c7c088eb93048e4f649ad759fd0e2cf7fc0409c54729631214086c095517a7a3bb1d3828f027ce783cc6c12732653fd1ffba3846c61
7
+ data.tar.gz: de98b2cc523f516160258afc0e1ec089456f0a4faef505146426042f69d34c98474160e6f0f72534c1c1cab5e06353eb21a464fb64d81c71505a5e0653510f78
@@ -0,0 +1,4 @@
1
+ .bundle/
2
+ pkg/
3
+ spec/dummy/log/*.log
4
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md CHANGED
@@ -21,10 +21,9 @@ $ bundle
21
21
 
22
22
  ## Usage
23
23
 
24
- Profane words define as array in `config/locales/*.yml`.
25
- You can define profane words in `antivirus.profane_words`.
24
+ Define profane words as array in `config/locales/*.yml` with `antivirus.profane_words` key.
26
25
 
27
- `antivirus.message` is an error message when target includes profane words.
26
+ `antivirus.message` key is an error message when value includes profane words.
28
27
 
29
28
  ```yml
30
29
  en:
@@ -0,0 +1,21 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ require 'antivirus/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'antivirus'
7
+ s.version = Antivirus::VERSION
8
+ s.authors = 'kami'
9
+ s.email = 'kami30k@gmail.com'
10
+ s.homepage = 'https://github.com/kami30k/antivirus'
11
+ s.summary = 'Profanity filter for Rails application.'
12
+ s.description = 'Profanity filter for Rails application.'
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files -z`.split("\x0")
16
+
17
+ s.add_dependency 'rails'
18
+
19
+ s.add_development_dependency 'sqlite3'
20
+ s.add_development_dependency 'rspec-rails'
21
+ end
@@ -1,3 +1,4 @@
1
+ require 'antivirus/version'
1
2
  require 'antivirus/railtie' if defined?(Rails)
2
3
 
3
4
  module Antivirus
@@ -1,7 +1,5 @@
1
- require 'rails'
2
-
3
1
  module Antivirus
4
- class Railtie < ::Rails::Railtie
2
+ class Railtie < Rails::Railtie
5
3
  initializer 'antivirus' do
6
4
  ActiveSupport.on_load :active_record do
7
5
  ActiveRecord::Base.send :include, Validator
@@ -21,7 +21,7 @@ module Antivirus
21
21
 
22
22
  def t(key, default)
23
23
  value = I18n.t(key, default: '')
24
- value.present? ? value : default
24
+ value.presence || default
25
25
  end
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module Antivirus
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,36 @@
1
+ $:.unshift File.expand_path('../../../lib', __FILE__)
2
+
3
+ require 'action_controller/railtie'
4
+ require 'active_record'
5
+
6
+ require 'antivirus'
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ config.secret_token = 'abcdefghijklmnopqrstuvwxyz0123456789'
11
+ config.session_store :cookie_store, key: '_dummy_session'
12
+ config.eager_load = false
13
+ config.active_support.deprecation = :log
14
+ config.i18n.load_path += Dir[Rails.root.join('spec/dummy/config/locales/*.yml')]
15
+ end
16
+ end
17
+
18
+ Dummy::Application.initialize!
19
+
20
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
21
+
22
+ class Post < ActiveRecord::Base
23
+ validates :content, profanity_filter: true
24
+ end
25
+
26
+ class CreatePosts < ActiveRecord::Migration
27
+ def change
28
+ create_table :posts do |t|
29
+ t.text :content
30
+
31
+ t.timestamps null: true
32
+ end
33
+ end
34
+ end
35
+
36
+ CreatePosts.new.change
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ APP_PATH = File.expand_path('../../application', __FILE__)
4
+
5
+ require 'rails/commands'
@@ -0,0 +1 @@
1
+ run Rails.application
@@ -0,0 +1,6 @@
1
+ en:
2
+ antivirus:
3
+ profane_words:
4
+ - foo
5
+ - bar
6
+ - baz
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Post do
4
+ context 'when content is valid' do
5
+ let(:post) { Post.new(content: 'valid content') }
6
+
7
+ it 'should be valid' do
8
+ expect(post).to be_valid
9
+ end
10
+ end
11
+
12
+ context 'when content equals profane word' do
13
+ let(:post) { Post.new(content: 'foo') }
14
+
15
+ it 'should not be valid' do
16
+ expect(post).not_to be_valid
17
+ end
18
+ end
19
+
20
+ context 'when content includes profane word' do
21
+ let(:post) { Post.new(content: 'foobarbaz') }
22
+
23
+ it 'should not be valid' do
24
+ expect(post).not_to be_valid
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'dummy/application'
2
+
3
+ RSpec.configure do |config|
4
+ config.before :each do
5
+ Post.delete_all
6
+ end
7
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: antivirus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-27 00:00:00.000000000 Z
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,19 +53,28 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Profanity filter for Rails application.
56
- email:
57
- - kami30k@gmail.com
56
+ email: kami30k@gmail.com
58
57
  executables: []
59
58
  extensions: []
60
59
  extra_rdoc_files: []
61
60
  files:
61
+ - ".gitignore"
62
+ - ".rspec"
63
+ - Gemfile
62
64
  - MIT-LICENSE
63
65
  - README.md
64
66
  - Rakefile
67
+ - antivirus.gemspec
65
68
  - lib/antivirus.rb
66
69
  - lib/antivirus/railtie.rb
67
70
  - lib/antivirus/validator.rb
68
71
  - lib/antivirus/version.rb
72
+ - spec/dummy/application.rb
73
+ - spec/dummy/bin/rails
74
+ - spec/dummy/config.ru
75
+ - spec/dummy/config/locales/en.yml
76
+ - spec/models/post_spec.rb
77
+ - spec/spec_helper.rb
69
78
  homepage: https://github.com/kami30k/antivirus
70
79
  licenses:
71
80
  - MIT
@@ -86,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
95
  version: '0'
87
96
  requirements: []
88
97
  rubyforge_project:
89
- rubygems_version: 2.2.2
98
+ rubygems_version: 2.4.5
90
99
  signing_key:
91
100
  specification_version: 4
92
101
  summary: Profanity filter for Rails application.