acts_as_commentable_more 1.0.0

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.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +48 -0
  4. data/.travis.yml +23 -0
  5. data/CHANGELOG.rdoc +5 -0
  6. data/Gemfile +40 -0
  7. data/Gemfile.lock +212 -0
  8. data/LICENSE +22 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.rdoc +16 -0
  11. data/Rakefile +32 -0
  12. data/acts_as_commentable_more.gemspec +36 -0
  13. data/lib/acts_as_commentable_more/version.rb +3 -0
  14. data/lib/acts_as_commentable_more.rb +4 -0
  15. data/lib/comment_methods.rb +19 -0
  16. data/lib/commentable_methods.rb +68 -0
  17. data/lib/generators/commentable/USAGE +11 -0
  18. data/lib/generators/commentable/commentable_generator.rb +18 -0
  19. data/lib/generators/commentable/templates/comment.rb +17 -0
  20. data/lib/generators/commentable/templates/create_comments.rb +18 -0
  21. data/lib/tasks/acts_as_commentable_more_tasks.rake +4 -0
  22. data/test/acts_as_commentable_more_test.rb +7 -0
  23. data/test/dummy/README.rdoc +28 -0
  24. data/test/dummy/Rakefile +17 -0
  25. data/test/dummy/app/assets/images/.keep +0 -0
  26. data/test/dummy/app/assets/javascripts/application.js +13 -0
  27. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  28. data/test/dummy/app/controllers/application_controller.rb +5 -0
  29. data/test/dummy/app/controllers/concerns/.keep +0 -0
  30. data/test/dummy/app/helpers/application_helper.rb +2 -0
  31. data/test/dummy/app/mailers/.keep +0 -0
  32. data/test/dummy/app/models/.keep +0 -0
  33. data/test/dummy/app/models/admin.rb +2 -0
  34. data/test/dummy/app/models/comment.rb +17 -0
  35. data/test/dummy/app/models/concerns/.keep +0 -0
  36. data/test/dummy/app/models/custom_comment.rb +17 -0
  37. data/test/dummy/app/models/letter.rb +3 -0
  38. data/test/dummy/app/models/note.rb +3 -0
  39. data/test/dummy/app/models/post.rb +4 -0
  40. data/test/dummy/app/models/topic.rb +3 -0
  41. data/test/dummy/app/models/user.rb +2 -0
  42. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  43. data/test/dummy/bin/bundle +3 -0
  44. data/test/dummy/bin/rails +4 -0
  45. data/test/dummy/bin/rake +4 -0
  46. data/test/dummy/config/application.rb +35 -0
  47. data/test/dummy/config/boot.rb +5 -0
  48. data/test/dummy/config/database.travis.yml +18 -0
  49. data/test/dummy/config/environment.rb +5 -0
  50. data/test/dummy/config/environments/development.rb +37 -0
  51. data/test/dummy/config/environments/production.rb +78 -0
  52. data/test/dummy/config/environments/test.rb +39 -0
  53. data/test/dummy/config/initializers/assets.rb +8 -0
  54. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  55. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  56. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  57. data/test/dummy/config/initializers/inflections.rb +16 -0
  58. data/test/dummy/config/initializers/mime_types.rb +4 -0
  59. data/test/dummy/config/initializers/session_store.rb +3 -0
  60. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  61. data/test/dummy/config/locales/en.yml +23 -0
  62. data/test/dummy/config/routes.rb +56 -0
  63. data/test/dummy/config/secrets.yml +22 -0
  64. data/test/dummy/config.ru +4 -0
  65. data/test/dummy/db/migrate/20150113045806_create_posts.rb +9 -0
  66. data/test/dummy/db/migrate/20150113045817_create_admins.rb +9 -0
  67. data/test/dummy/db/migrate/20150113045831_create_users.rb +9 -0
  68. data/test/dummy/db/migrate/20150113065948_create_notes.rb +9 -0
  69. data/test/dummy/db/migrate/20150113074249_create_topics.rb +9 -0
  70. data/test/dummy/db/migrate/20150114052120_create_letters.rb +9 -0
  71. data/test/dummy/db/migrate/20150114100411_create_comments.rb +18 -0
  72. data/test/dummy/db/migrate/20150114100422_create_custom_comments.rb +18 -0
  73. data/test/dummy/db/schema.rb +86 -0
  74. data/test/dummy/lib/assets/.keep +0 -0
  75. data/test/dummy/log/.keep +0 -0
  76. data/test/dummy/public/404.html +67 -0
  77. data/test/dummy/public/422.html +67 -0
  78. data/test/dummy/public/500.html +66 -0
  79. data/test/dummy/public/favicon.ico +0 -0
  80. data/test/dummy/spec/acts_as_commentable_more_spec.rb +205 -0
  81. data/test/dummy/spec/factories/admins.rb +7 -0
  82. data/test/dummy/spec/factories/comments.rb +7 -0
  83. data/test/dummy/spec/factories/custom_comments.rb +7 -0
  84. data/test/dummy/spec/factories/letters.rb +7 -0
  85. data/test/dummy/spec/factories/notes.rb +7 -0
  86. data/test/dummy/spec/factories/posts.rb +7 -0
  87. data/test/dummy/spec/factories/topics.rb +7 -0
  88. data/test/dummy/spec/factories/users.rb +7 -0
  89. data/test/dummy/spec/models/admin_spec.rb +5 -0
  90. data/test/dummy/spec/models/custom_comment_spec.rb +5 -0
  91. data/test/dummy/spec/models/letter_spec.rb +5 -0
  92. data/test/dummy/spec/models/note_spec.rb +5 -0
  93. data/test/dummy/spec/models/post_spec.rb +5 -0
  94. data/test/dummy/spec/models/topic_spec.rb +5 -0
  95. data/test/dummy/spec/models/user_spec.rb +5 -0
  96. data/test/dummy/spec/rails_helper.rb +61 -0
  97. data/test/dummy/spec/spec_helper.rb +85 -0
  98. data/test/test_helper.rb +16 -0
  99. metadata +197 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1a78b63f0d3bf01af29ca0f946959b6254009d1
4
+ data.tar.gz: d6a5ac305abb6f3bb43091de280da094f14d0774
5
+ SHA512:
6
+ metadata.gz: 2a93ba75df227b8cc5dc8e9988404b2d7830abe8a4c2cdf3702950ba06fed9c2e432d6eb4cbeee0d42242dcd91cae765f52a71f10c5134eef8a0d09b9e7a3563
7
+ data.tar.gz: a2b458ec39cd795fd46b69ad3e87739e0038c82e47b4854e370c3d3090b10c8522051054c770a3b72e35cd49a78e82327a2eae817c9df02659ef309ec626339e
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: UcUDq2TUR052ZfBRowsdMHTo1n4pF1uZ7
data/.gitignore ADDED
@@ -0,0 +1,48 @@
1
+
2
+ .bundle/
3
+ log/*.log
4
+ pkg/
5
+ test/dummy/db/*.sqlite3
6
+ test/dummy/db/*.sqlite3-journal
7
+ test/dummy/log/*.log
8
+ test/dummy/tmp/
9
+ test/dummy/.sass-cache
10
+ test/dummy/config/database.yml
11
+ test/dummy/db/schema.rb
12
+
13
+ test/dummy/coverage
14
+
15
+ *.rbc
16
+ capybara-*.html
17
+ .rspec
18
+ /log
19
+ /tmp
20
+ /db/*.sqlite3
21
+ /public/system
22
+ /coverage/
23
+ /spec/tmp
24
+ **.orig
25
+ rerun.txt
26
+ pickle-email-*.html
27
+
28
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
29
+ test/dummy/config/initializers/secret_token.rb
30
+ ctest/dummy/onfig/secrets.yml
31
+
32
+ ## Environment normalisation:
33
+ /.bundle
34
+ /vendor/bundle
35
+
36
+ # these should all be checked in to normalise the environment:
37
+ # Gemfile.lock, .ruby-version, .ruby-gemset
38
+
39
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
40
+ .rvmrc
41
+
42
+ # if using bower-rails ignore default bower_components path bower.json files
43
+ /vendor/assets/bower_components
44
+ *.bowerrc
45
+ bower.json
46
+
47
+ # ignore coverage result file
48
+ test/dummy/coverage/.resultset.json
data/.travis.yml ADDED
@@ -0,0 +1,23 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ env: DB=postgres
5
+
6
+ sudo: true
7
+
8
+ gemfile: Gemfile
9
+
10
+ env: DB=postgresql
11
+
12
+ before_script:
13
+ - cd test/dummy
14
+ - cp config/database.travis.yml config/database.yml
15
+ - bundle install
16
+ - psql -c 'create database strano_test' -U postgres
17
+ - bundle exec rake db:create RAILS_ENV=test
18
+ - bundle exec rake db:migrate RAILS_ENV=test
19
+ - bundle exec rake db:test:prepare
20
+
21
+ script: bundle exec rspec
22
+
23
+ travis encrypt "happio:PFNa84fG9iz9hVr5Q22UNUMo" --add notifications.slack
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ === Change Log
2
+
3
+ * v.1.0.0
4
+ - can set comment's types
5
+ - can set association options
data/Gemfile ADDED
@@ -0,0 +1,40 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in acts_as_commentable_more.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use debugger
14
+ # gem 'debugger'
15
+
16
+ gem "codeclimate-test-reporter", group: :test, require: nil
17
+
18
+ group :development do
19
+ gem 'bullet', '4.13.2'
20
+ gem 'spring', '1.1.3'
21
+ gem 'mina', '0.3.0'
22
+ gem 'hirb', '0.7.2'
23
+ gem 'better_errors', '2.0.0'
24
+ # gem 'debugger'
25
+ end
26
+
27
+ group :development, :test do
28
+ gem 'rspec-rails', '3.1.0'
29
+ gem 'capybara', '2.4.3'
30
+ gem 'shoulda-matchers', '2.7.0', require: false
31
+ gem 'guard-rspec', '4.3.1'
32
+ gem 'simplecov', '0.9.0', require: false
33
+ gem 'spring-commands-rspec', '1.0.2'
34
+ gem 'factory_girl_rails', '4.4.1'
35
+ gem 'coveralls', require: false
36
+ end
37
+
38
+ group :test do
39
+ # gem 'rspec-sidekiq'
40
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,212 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ acts_as_commentable_more (1.0.0)
5
+ rails (~> 4.1.8)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.1.9)
11
+ actionpack (= 4.1.9)
12
+ actionview (= 4.1.9)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ actionpack (4.1.9)
15
+ actionview (= 4.1.9)
16
+ activesupport (= 4.1.9)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ actionview (4.1.9)
20
+ activesupport (= 4.1.9)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ activemodel (4.1.9)
24
+ activesupport (= 4.1.9)
25
+ builder (~> 3.1)
26
+ activerecord (4.1.9)
27
+ activemodel (= 4.1.9)
28
+ activesupport (= 4.1.9)
29
+ arel (~> 5.0.0)
30
+ activesupport (4.1.9)
31
+ i18n (~> 0.6, >= 0.6.9)
32
+ json (~> 1.7, >= 1.7.7)
33
+ minitest (~> 5.1)
34
+ thread_safe (~> 0.1)
35
+ tzinfo (~> 1.1)
36
+ arel (5.0.1.20140414130214)
37
+ better_errors (2.0.0)
38
+ coderay (>= 1.0.0)
39
+ erubis (>= 2.6.6)
40
+ rack (>= 0.9.0)
41
+ builder (3.2.2)
42
+ bullet (4.13.2)
43
+ activesupport (>= 3.0.0)
44
+ uniform_notifier (>= 1.6.0)
45
+ capybara (2.4.3)
46
+ mime-types (>= 1.16)
47
+ nokogiri (>= 1.3.3)
48
+ rack (>= 1.0.0)
49
+ rack-test (>= 0.5.4)
50
+ xpath (~> 2.0)
51
+ celluloid (0.16.0)
52
+ timers (~> 4.0.0)
53
+ codeclimate-test-reporter (0.4.5)
54
+ simplecov (>= 0.7.1, < 1.0.0)
55
+ coderay (1.1.0)
56
+ coveralls (0.7.1)
57
+ multi_json (~> 1.3)
58
+ rest-client
59
+ simplecov (>= 0.7)
60
+ term-ansicolor
61
+ thor
62
+ diff-lcs (1.2.5)
63
+ docile (1.1.5)
64
+ erubis (2.7.0)
65
+ factory_girl (4.4.0)
66
+ activesupport (>= 3.0.0)
67
+ factory_girl_rails (4.4.1)
68
+ factory_girl (~> 4.4.0)
69
+ railties (>= 3.0.0)
70
+ ffi (1.9.6)
71
+ formatador (0.2.5)
72
+ guard (2.10.5)
73
+ formatador (>= 0.2.4)
74
+ listen (~> 2.7)
75
+ lumberjack (~> 1.0)
76
+ nenv (~> 0.1)
77
+ pry (>= 0.9.12)
78
+ thor (>= 0.18.1)
79
+ guard-rspec (4.3.1)
80
+ guard (~> 2.1)
81
+ rspec (>= 2.14, < 4.0)
82
+ hike (1.2.3)
83
+ hirb (0.7.2)
84
+ hitimes (1.2.2)
85
+ i18n (0.7.0)
86
+ json (1.8.2)
87
+ listen (2.8.4)
88
+ celluloid (>= 0.15.2)
89
+ rb-fsevent (>= 0.9.3)
90
+ rb-inotify (>= 0.9)
91
+ lumberjack (1.0.9)
92
+ mail (2.6.3)
93
+ mime-types (>= 1.16, < 3)
94
+ method_source (0.8.2)
95
+ mime-types (2.4.3)
96
+ mina (0.3.0)
97
+ open4
98
+ rake
99
+ mini_portile (0.6.1)
100
+ minitest (5.5.1)
101
+ multi_json (1.10.1)
102
+ nenv (0.1.1)
103
+ netrc (0.10.2)
104
+ nokogiri (1.6.5)
105
+ mini_portile (~> 0.6.0)
106
+ open4 (1.3.4)
107
+ pg (0.18.1)
108
+ pry (0.10.1)
109
+ coderay (~> 1.1.0)
110
+ method_source (~> 0.8.1)
111
+ slop (~> 3.4)
112
+ rack (1.5.2)
113
+ rack-test (0.6.3)
114
+ rack (>= 1.0)
115
+ rails (4.1.9)
116
+ actionmailer (= 4.1.9)
117
+ actionpack (= 4.1.9)
118
+ actionview (= 4.1.9)
119
+ activemodel (= 4.1.9)
120
+ activerecord (= 4.1.9)
121
+ activesupport (= 4.1.9)
122
+ bundler (>= 1.3.0, < 2.0)
123
+ railties (= 4.1.9)
124
+ sprockets-rails (~> 2.0)
125
+ railties (4.1.9)
126
+ actionpack (= 4.1.9)
127
+ activesupport (= 4.1.9)
128
+ rake (>= 0.8.7)
129
+ thor (>= 0.18.1, < 2.0)
130
+ rake (10.4.2)
131
+ rb-fsevent (0.9.4)
132
+ rb-inotify (0.9.5)
133
+ ffi (>= 0.5.0)
134
+ rest-client (1.7.2)
135
+ mime-types (>= 1.16, < 3.0)
136
+ netrc (~> 0.7)
137
+ rspec (3.1.0)
138
+ rspec-core (~> 3.1.0)
139
+ rspec-expectations (~> 3.1.0)
140
+ rspec-mocks (~> 3.1.0)
141
+ rspec-core (3.1.7)
142
+ rspec-support (~> 3.1.0)
143
+ rspec-expectations (3.1.2)
144
+ diff-lcs (>= 1.2.0, < 2.0)
145
+ rspec-support (~> 3.1.0)
146
+ rspec-mocks (3.1.3)
147
+ rspec-support (~> 3.1.0)
148
+ rspec-rails (3.1.0)
149
+ actionpack (>= 3.0)
150
+ activesupport (>= 3.0)
151
+ railties (>= 3.0)
152
+ rspec-core (~> 3.1.0)
153
+ rspec-expectations (~> 3.1.0)
154
+ rspec-mocks (~> 3.1.0)
155
+ rspec-support (~> 3.1.0)
156
+ rspec-support (3.1.2)
157
+ shoulda-matchers (2.7.0)
158
+ activesupport (>= 3.0.0)
159
+ simplecov (0.9.0)
160
+ docile (~> 1.1.0)
161
+ multi_json
162
+ simplecov-html (~> 0.8.0)
163
+ simplecov-html (0.8.0)
164
+ slop (3.6.0)
165
+ spring (1.1.3)
166
+ spring-commands-rspec (1.0.2)
167
+ spring (>= 0.9.1)
168
+ sprockets (2.12.3)
169
+ hike (~> 1.2)
170
+ multi_json (~> 1.0)
171
+ rack (~> 1.0)
172
+ tilt (~> 1.1, != 1.3.0)
173
+ sprockets-rails (2.2.2)
174
+ actionpack (>= 3.0)
175
+ activesupport (>= 3.0)
176
+ sprockets (>= 2.8, < 4.0)
177
+ term-ansicolor (1.3.0)
178
+ tins (~> 1.0)
179
+ thor (0.19.1)
180
+ thread_safe (0.3.4)
181
+ tilt (1.4.1)
182
+ timers (4.0.1)
183
+ hitimes
184
+ tins (1.3.3)
185
+ tzinfo (1.2.2)
186
+ thread_safe (~> 0.1)
187
+ uniform_notifier (1.6.2)
188
+ xpath (2.0.0)
189
+ nokogiri (~> 1.3)
190
+
191
+ PLATFORMS
192
+ ruby
193
+
194
+ DEPENDENCIES
195
+ acts_as_commentable_more!
196
+ better_errors (= 2.0.0)
197
+ bullet (= 4.13.2)
198
+ capybara (= 2.4.3)
199
+ codeclimate-test-reporter
200
+ coveralls
201
+ factory_girl_rails (= 4.4.1)
202
+ guard-rspec (= 4.3.1)
203
+ hirb (= 0.7.2)
204
+ mina (= 0.3.0)
205
+ pg
206
+ rake
207
+ rspec
208
+ rspec-rails (= 3.1.0)
209
+ shoulda-matchers (= 2.7.0)
210
+ simplecov (= 0.9.0)
211
+ spring (= 1.1.3)
212
+ spring-commands-rspec (= 1.0.2)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 PiYa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ = ActsAsCommentableMore
2
+
3
+ {<img src="https://gemnasium.com/piya23300/acts_as_commentable_more.svg" alt="Dependency Status" />}[https://gemnasium.com/piya23300/acts_as_commentable_more]
4
+ {<img src="https://coveralls.io/repos/piya23300/acts_as_commentable_more/badge.png" alt="Coverage Status" />}[https://coveralls.io/r/piya23300/acts_as_commentable_more]
5
+
6
+ ---
7
+
8
+ == Generate
9
+
10
+ rails generate commentable your_model_name
11
+ or
12
+ {read more about generate}[https://github.com/piya23300/acts_as_commentable_more/tree/develop/lib/generators/commentable/USAGE]
13
+
14
+ ---
15
+
16
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ActsAsCommentableMore'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,36 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "acts_as_commentable_more/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "acts_as_commentable_more"
9
+ s.version = ActsAsCommentableMore::VERSION
10
+ s.authors = ["piya23300"]
11
+ s.email = ["piya23300@gmail.com"]
12
+ s.homepage = "https://github.com/piya23300/acts_as_commentable_more"
13
+ s.summary = "gem that provides comment functionality."
14
+ s.description = "gem that provides comment functionality."
15
+ s.license = "MIT"
16
+
17
+ s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
18
+ s.test_files = Dir["test/**/*"]
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+
25
+ s.autorequire = %q{acts_as_commentable_more}
26
+
27
+ s.add_development_dependency 'rake'
28
+ s.add_development_dependency 'rspec'
29
+
30
+
31
+ s.add_dependency "rails", "~> 4.1.8"
32
+
33
+ s.add_development_dependency "pg"
34
+ # s.add_development_dependency "acts_as_commentable"
35
+
36
+ end
@@ -0,0 +1,3 @@
1
+ module ActsAsCommentableMore
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ module ActsAsCommentableMore
2
+ require 'commentable_methods'
3
+ require 'comment_methods'
4
+ end
@@ -0,0 +1,19 @@
1
+ module ActsAsCommentableMore::Finders
2
+ extend ActiveSupport::Concern
3
+
4
+ def related_attributes
5
+ read_attribute(:related_attributes).symbolize_keys
6
+ end
7
+
8
+ module ClassMethods
9
+
10
+ def find_comments_by_user(user, role = nil)
11
+ attr_finder = { user: user }
12
+ attr_finder.merge!(role: role.to_s) if role.present?
13
+ where(attr_finder).order("created_at DESC")
14
+ end
15
+
16
+ end
17
+
18
+
19
+ end
@@ -0,0 +1,68 @@
1
+ # ActsAsCommentable
2
+ module Happio
3
+ module Acts #:nodoc:
4
+ module Commentable #:nodoc:
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ mattr_accessor :comment_roles
9
+ end
10
+
11
+ module HelperMethods
12
+ private
13
+ def define_role_based_inflection(role, join_options)
14
+ send("define_role_based_inflection_#{Rails.version.first}", role, join_options)
15
+ end
16
+
17
+ def define_role_based_inflection_3(role, options)
18
+ has_many "#{role.to_s}_comments".to_sym,
19
+ has_many_options(role, join_options).merge(:conditions => { role: role.to_s })
20
+ end
21
+
22
+ def define_role_based_inflection_4(role, join_options)
23
+ has_many "#{role.to_s}_comments".to_sym,
24
+ -> { where(role: role.to_s) },
25
+ has_many_options(role, join_options)
26
+ end
27
+
28
+ def has_many_options(role, join_options)
29
+ { :before_add => Proc.new { |x, c| c.role = role.to_s } }.merge(join_options)
30
+ end
31
+ end
32
+
33
+ module ClassMethods
34
+ include HelperMethods
35
+
36
+ def acts_as_commentable(types: [], options: {})
37
+ default_options = {as: :commentable, dependent: :destroy, class_name: 'Comment'}
38
+ default_roles = [:comment]
39
+
40
+ association_options = default_options.merge(options.compact)
41
+ self.comment_roles = (default_roles + types.flatten.compact.map(&:to_sym)).uniq
42
+
43
+ if comment_roles == [:comment]
44
+ has_many :comments, has_many_options(:comment, association_options)
45
+ else
46
+ comment_roles.each do |role|
47
+ define_role_based_inflection(role, association_options)
48
+ end
49
+ class_eval %{
50
+ def all_comments
51
+ #{association_options[:class_name].classify.constantize}
52
+ .where(
53
+ #{association_options[:as].to_s + '_id'}: self.id,
54
+ #{association_options[:as].to_s + '_type'}: self.class.base_class.name
55
+ ).order(created_at: :desc)
56
+ end
57
+ }
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+ end
66
+ end
67
+
68
+ ActiveRecord::Base.send(:include, Happio::Acts::Commentable)
@@ -0,0 +1,11 @@
1
+ Description:
2
+ Create <model_name>.rb to app/models/ by using comment.rb template.
3
+ Create create_<model_name>s.rb to db/migrate by using create_comments.rb template.
4
+
5
+ Example:
6
+ rails generate commentable <model_name>
7
+
8
+ This will create:
9
+ app/models/<model_name>.rb
10
+ db/migrate/<time_stamp>_create_<model_name>s.rb
11
+
@@ -0,0 +1,18 @@
1
+ class CommentableGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ include Rails::Generators::Migration
4
+
5
+ def self.source_root
6
+ @_acts_as_commentable_source_root ||= File.expand_path("../templates", __FILE__)
7
+ end
8
+
9
+ def self.next_migration_number(path)
10
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
11
+ end
12
+
13
+ def create_model_file
14
+ template "comment.rb", "app/models/#{file_path}.rb"
15
+ migration_template "create_comments.rb", "db/migrate/create_#{plural_table_name}.rb"
16
+ end
17
+
18
+ end
@@ -0,0 +1,17 @@
1
+
2
+ class <%= class_name %> < ActiveRecord::Base
3
+ ###################################################################
4
+ ### To implement commentable add the following line to your model
5
+ ### acts_as_commentable types: [:hide, :show], options: { class_name: '<%= class_name %>', as: :<%= class_name.demodulize.underscore + "able" %> }
6
+
7
+ ### types is an array of possible comment type
8
+ ### for example if you have public and private comment
9
+ ### your types would be [:public, :private]
10
+
11
+ include ActsAsCommentableMore::Finders
12
+
13
+ belongs_to :<%= class_name.demodulize.underscore + "able" %>, :polymorphic => true
14
+ belongs_to :user, polymorphic: true
15
+
16
+ ###################################################################
17
+ end
@@ -0,0 +1,18 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration
2
+ def change
3
+ enable_extension 'hstore'
4
+
5
+ create_table :<%= table_name %> do |t|
6
+ # t.string :title, :limit => 50, :default => ""
7
+ t.text :message
8
+ t.references :<%= class_name.demodulize.underscore + "able" %>, polymorphic: true
9
+ t.references :user, polymorphic: true, index: true
10
+ t.string :role, default: nil
11
+ t.hstore :related_attributes
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :<%= table_name %>, [:<%= class_name.demodulize.underscore + "able" %>_type, :<%= class_name.demodulize.underscore + "able" %>_id],
16
+ name: :index_<%= plural_name %>_on_<%= class_name.demodulize.underscore %>able_type_and_<%= class_name.demodulize.underscore %>able_id
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :acts_as_commentable_more do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ActsAsCommentableMoreTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, ActsAsCommentableMore
6
+ end
7
+ end