the_comments 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -134,6 +134,9 @@ bundle exec rails g the_comments install
134
134
  ```ruby
135
135
  config/initializers/the_comments.rb
136
136
 
137
+ app/models/ip_black_list.rb
138
+ app/models/user_agent_black_list.rb
139
+
137
140
  app/controllers/comments_controller.rb
138
141
  app/controllers/ip_black_lists_controller.rb
139
142
  app/controllers/user_agent_black_lists_controller.rb
@@ -351,7 +354,7 @@ I use denormalization of commentable objects to solve this problem.
351
354
 
352
355
  My practice shows - We need 3 denormalized fields into comment for (request-free) building of recent comments list:
353
356
 
354
- <img src="https://raw.github.com/open-cook/the-teacher/master/docs/the_comments_view_5.gif" alt="the_comments">
357
+ <img src="https://raw.github.com/the-teacher/the_comments/master/docs/the_comments_view_5.gif" alt="the_comments">
355
358
 
356
359
  * **Comment#commentable_title** - for example: "My first post about Ruby On Rails"
357
360
  * **Comment#commentable_url** - for example: "/posts/1-my-first-post-about-ruby-on-rails"
@@ -2,8 +2,11 @@ module TheCommentsBase
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
+ # attr_accessible :parent_id
6
+ # attr_accessible :ip, :referer, :user_agent, :tolerance_time
7
+ # attr_accessible :user, :title, :contacts, :raw_content, :view_token, :state
8
+
5
9
  # Nested Set
6
- attr_accessible :parent_id
7
10
  acts_as_nested_set scope: [:commentable_type, :commentable_id]
8
11
 
9
12
  # Comments State Machine
@@ -12,9 +15,6 @@ module TheCommentsBase
12
15
  # TheSortableTree
13
16
  include TheSortableTree::Scopes
14
17
 
15
- attr_accessible :user, :title, :contacts, :raw_content, :view_token, :state
16
- attr_accessible :ip, :referer, :user_agent, :tolerance_time
17
-
18
18
  validates :raw_content, presence: true
19
19
 
20
20
  # relations
@@ -2,8 +2,7 @@ module TheCommentsBlackIp
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- attr_accessible :ip, :state
6
-
5
+ # attr_accessible :ip, :state
7
6
  validates :ip, presence: true
8
7
  validates :ip, uniqueness: true
9
8
  end
@@ -2,8 +2,7 @@ module TheCommentsBlackUserAgent
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- attr_accessible :ip, :state
6
-
5
+ # attr_accessible :ip, :state
7
6
  validates :user_agent, presence: true
8
7
  validates :user_agent, uniqueness: true
9
8
  end
@@ -9,6 +9,10 @@ Generators:
9
9
 
10
10
  This will create:
11
11
  config/initializers/the_comments.rb
12
+
13
+ app/models/ip_black_list.rb
14
+ app/models/user_agent_black_list.rb
15
+
12
16
  app/controllers/comments_controller.rb
13
17
  app/controllers/ip_black_lists_controller.rb
14
18
  app/controllers/user_agent_black_lists_controller.rb
@@ -0,0 +1,3 @@
1
+ class IpBlackList < ActiveRecord::Base
2
+ include TheCommentsBlackIp
3
+ end
@@ -0,0 +1,9 @@
1
+ module TheCommentsBlackIp
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # attr_accessible :ip, :state
6
+ validates :ip, presence: true
7
+ validates :ip, uniqueness: true
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module TheCommentsBlackUserAgent
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # attr_accessible :ip, :state
6
+ validates :user_agent, presence: true
7
+ validates :user_agent, uniqueness: true
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ class UserAgentBlackList < ActiveRecord::Base
2
+ include TheCommentsBlackUserAgent
3
+ end
@@ -8,6 +8,8 @@ class TheCommentsGenerator < Rails::Generators::NamedBase
8
8
  cp_controllers
9
9
  elsif gen_name == 'controllers'
10
10
  cp_controllers
11
+ elsif gen_name == 'models'
12
+ cp_models
11
13
  else
12
14
  puts 'TheComments Generator - wrong Name'
13
15
  puts 'Try to use [install|controllers]'
@@ -24,6 +26,11 @@ class TheCommentsGenerator < Rails::Generators::NamedBase
24
26
  copy_file 'the_comments.rb', 'config/initializers/the_comments.rb'
25
27
  end
26
28
 
29
+ def cp_models
30
+ copy_file 'ip_black_list.rb', 'app/models/ip_black_list.rb'
31
+ copy_file 'user_agent_black_list.rb', 'app/models/user_agent_black_list.rb'
32
+ end
33
+
27
34
  def cp_controllers
28
35
  copy_file 'comments_controller.rb', 'app/controllers/comments_controller.rb'
29
36
  copy_file 'ip_black_lists_controller.rb', 'app/controllers/ip_black_lists_controller.rb'
@@ -1,3 +1,3 @@
1
1
  module TheComments
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-07 00:00:00.000000000 Z
12
+ date: 2013-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: state_machine
16
- requirement: &78157620 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *78157620
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: the_sortable_tree
27
- requirement: &78157410 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *78157410
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: ! ' Comments with threading for Rails 4 '
37
47
  email:
38
48
  - zykin-ilya@ya.ru
@@ -78,8 +88,12 @@ files:
78
88
  - docs/the_comments_view_5.gif
79
89
  - lib/generators/the_comments/USAGE
80
90
  - lib/generators/the_comments/templates/comments_controller.rb
91
+ - lib/generators/the_comments/templates/ip_black_list.rb
81
92
  - lib/generators/the_comments/templates/ip_black_lists_controller.rb
82
93
  - lib/generators/the_comments/templates/the_comments.rb
94
+ - lib/generators/the_comments/templates/the_comments_black_ip.rb
95
+ - lib/generators/the_comments/templates/the_comments_black_user_agent.rb
96
+ - lib/generators/the_comments/templates/user_agent_black_list.rb
83
97
  - lib/generators/the_comments/templates/user_agent_black_lists_controller.rb
84
98
  - lib/generators/the_comments/the_comments_generator.rb
85
99
  - lib/generators/the_comments/views_generator.rb
@@ -107,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
121
  version: '0'
108
122
  requirements: []
109
123
  rubyforge_project:
110
- rubygems_version: 1.8.15
124
+ rubygems_version: 1.8.25
111
125
  signing_key:
112
126
  specification_version: 3
113
127
  summary: the_comments by the-teacher