acts_as_commentable_more 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- data/lib/acts_as_commentable_more.rb +5 -2
- data/lib/{comment_methods.rb → acts_as_commentable_more/comment_methods.rb} +0 -0
- data/lib/acts_as_commentable_more/commentable_methods.rb +64 -0
- data/lib/acts_as_commentable_more/helpers/comment/callbacks_helper.rb +59 -0
- data/lib/acts_as_commentable_more/helpers/comment/methods_helper.rb +44 -0
- data/lib/acts_as_commentable_more/helpers/post/associations_helper.rb +30 -0
- data/lib/acts_as_commentable_more/helpers/post/methods_helper.rb +18 -0
- data/lib/acts_as_commentable_more/helpers/post/scopes_helper.rb +19 -0
- data/lib/acts_as_commentable_more/version.rb +1 -1
- data/lib/generators/commentable/templates/comment.rb +1 -1
- data/test/dummy/spec/models/letter_spec.rb +2 -1
- data/test/dummy/spec/models/main_model_spec.rb +5 -0
- data/test/dummy/spec/models/note_custom_asso_name_spec.rb +2 -1
- data/test/dummy/spec/models/note_spec.rb +2 -1
- data/test/dummy/spec/models/post_custom_asso_name_spec.rb +1 -1
- data/test/dummy/spec/models/post_disable_cache_spec.rb +5 -0
- data/test/dummy/spec/models/post_spec.rb +2 -1
- data/test/dummy/spec/models/topic_spec.rb +1 -1
- metadata +13 -165
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -48
- data/.travis.yml +0 -22
- data/CHANGELOG.md +0 -12
- data/Gemfile +0 -40
- data/Gemfile.lock +0 -212
- data/LICENSE +0 -22
- data/README.md +0 -125
- data/acts_as_commentable_more.gemspec +0 -36
- data/lib/commentable_methods.rb +0 -118
- data/test/acts_as_commentable_more_test.rb +0 -7
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -17
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/admin.rb +0 -2
- data/test/dummy/app/models/comment.rb +0 -17
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/custom_comment.rb +0 -17
- data/test/dummy/app/models/letter.rb +0 -3
- data/test/dummy/app/models/note.rb +0 -3
- data/test/dummy/app/models/note_custom_asso_name.rb +0 -3
- data/test/dummy/app/models/post.rb +0 -4
- data/test/dummy/app/models/post_custom_asso_name.rb +0 -5
- data/test/dummy/app/models/topic.rb +0 -3
- data/test/dummy/app/models/user.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -35
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.travis.yml +0 -18
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -78
- data/test/dummy/config/environments/test.rb +0 -39
- data/test/dummy/config/initializers/assets.rb +0 -8
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/migrate/20150113045806_create_posts.rb +0 -9
- data/test/dummy/db/migrate/20150113045817_create_admins.rb +0 -9
- data/test/dummy/db/migrate/20150113045831_create_users.rb +0 -9
- data/test/dummy/db/migrate/20150113065948_create_notes.rb +0 -9
- data/test/dummy/db/migrate/20150113074249_create_topics.rb +0 -9
- data/test/dummy/db/migrate/20150114052120_create_letters.rb +0 -9
- data/test/dummy/db/migrate/20150114100411_create_comments.rb +0 -18
- data/test/dummy/db/migrate/20150114100422_create_custom_comments.rb +0 -18
- data/test/dummy/db/migrate/20150115094241_create_post_custom_asso_names.rb +0 -9
- data/test/dummy/db/migrate/20150115100013_create_note_custom_asso_names.rb +0 -9
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/spec/acts_as_commentable_more_spec.rb +0 -275
- data/test/dummy/spec/factories/admins.rb +0 -7
- data/test/dummy/spec/factories/comments.rb +0 -7
- data/test/dummy/spec/factories/custom_comments.rb +0 -7
- data/test/dummy/spec/factories/letters.rb +0 -7
- data/test/dummy/spec/factories/note_custom_asso_names.rb +0 -7
- data/test/dummy/spec/factories/notes.rb +0 -7
- data/test/dummy/spec/factories/post_custom_asso_names.rb +0 -7
- data/test/dummy/spec/factories/posts.rb +0 -7
- data/test/dummy/spec/factories/topics.rb +0 -7
- data/test/dummy/spec/factories/users.rb +0 -7
- data/test/dummy/spec/rails_helper.rb +0 -61
- data/test/dummy/spec/spec_helper.rb +0 -85
- data/test/test_helper.rb +0 -16
@@ -1,36 +0,0 @@
|
|
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
|
data/lib/commentable_methods.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
# ActsAsCommentable
|
2
|
-
module Happio
|
3
|
-
module Acts #:nodoc:
|
4
|
-
module Commentable #:nodoc:
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
module HelperMethods
|
8
|
-
private
|
9
|
-
def define_role_based_inflection(role, association_base_name, join_options)
|
10
|
-
association_name = "#{role.to_s}_#{association_base_name.to_s}"
|
11
|
-
send("define_role_based_inflection_#{Rails.version.first}", role, association_name,join_options)
|
12
|
-
end
|
13
|
-
|
14
|
-
def define_role_based_inflection_3(role, association_name, join_options)
|
15
|
-
has_many "#{association_name.to_s}".to_sym,
|
16
|
-
has_many_options(role, join_options).merge(:conditions => { role: role.to_s })
|
17
|
-
end
|
18
|
-
|
19
|
-
def define_role_based_inflection_4(role, association_name, join_options)
|
20
|
-
has_many "#{association_name.to_s}".to_sym,
|
21
|
-
-> { where(role: role.to_s) },
|
22
|
-
has_many_options(role, join_options)
|
23
|
-
define_create_role_comments(association_name)
|
24
|
-
end
|
25
|
-
|
26
|
-
def has_many_options(role, join_options)
|
27
|
-
{ :before_add => Proc.new { |x, c| c.role = role.to_s } }.merge(join_options)
|
28
|
-
end
|
29
|
-
|
30
|
-
def define_create_role_comments(association_name)
|
31
|
-
class_eval %{
|
32
|
-
def creates_#{association_name.to_s.pluralize}(attributes = nil)
|
33
|
-
#{association_name.to_s}.create(attributes)
|
34
|
-
end
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
module ClassMethods
|
41
|
-
include HelperMethods
|
42
|
-
|
43
|
-
def acts_as_commentable(types: [], options: {}, as: nil)
|
44
|
-
mattr_accessor :comment_roles
|
45
|
-
|
46
|
-
default_options = {as: :commentable, dependent: :destroy, class_name: 'Comment'}
|
47
|
-
default_as = :comments
|
48
|
-
default_roles = [default_as.to_s.singularize.to_sym]
|
49
|
-
|
50
|
-
types = types.flatten.compact.map(&:to_sym)
|
51
|
-
|
52
|
-
|
53
|
-
association_options = default_options.merge(options.compact)
|
54
|
-
self.comment_roles = types.present? ? types : default_roles
|
55
|
-
association_base_name = (as || default_as).to_s.pluralize
|
56
|
-
|
57
|
-
if comment_roles == [default_as.to_s.singularize.to_sym]
|
58
|
-
has_many association_base_name.to_sym, has_many_options(association_base_name.singularize, association_options)
|
59
|
-
define_create_role_comments(association_base_name)
|
60
|
-
else
|
61
|
-
comment_roles.each do |role|
|
62
|
-
define_role_based_inflection(role, association_base_name, association_options)
|
63
|
-
end
|
64
|
-
|
65
|
-
association_class = association_options[:class_name].classify.constantize
|
66
|
-
|
67
|
-
class_eval %{
|
68
|
-
def all_#{association_base_name.to_s}
|
69
|
-
#{association_class}
|
70
|
-
.where(
|
71
|
-
#{association_options[:as].to_s + '_id'}: self.id,
|
72
|
-
#{association_options[:as].to_s + '_type'}: self.class.base_class.name
|
73
|
-
).order(created_at: :desc)
|
74
|
-
end
|
75
|
-
}
|
76
|
-
|
77
|
-
association_class.class_eval %{
|
78
|
-
private
|
79
|
-
|
80
|
-
def can_change_role?(role)
|
81
|
-
commentable_object = #{association_options[:as]}
|
82
|
-
limit_role = commentable_object.class.comment_roles
|
83
|
-
# p limit_role
|
84
|
-
# p role
|
85
|
-
limit_role.include?(role.to_sym)
|
86
|
-
end
|
87
|
-
|
88
|
-
}
|
89
|
-
|
90
|
-
comment_roles.each do |role|
|
91
|
-
association_class.class_eval %{
|
92
|
-
def is_#{role}?
|
93
|
-
role == "#{role.to_s}"
|
94
|
-
end
|
95
|
-
|
96
|
-
def to_#{role}
|
97
|
-
raise TypeError, "Can not change to " + role.to_s unless can_change_role?("#{role.to_s}")
|
98
|
-
self.role = "#{role.to_s}"
|
99
|
-
end
|
100
|
-
|
101
|
-
def to_#{role}!
|
102
|
-
to_#{role}
|
103
|
-
self.save
|
104
|
-
end
|
105
|
-
|
106
|
-
}
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
ActiveRecord::Base.send(:include, Happio::Acts::Commentable)
|
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
-
|
4
|
-
# require "bundler/gem_tasks"
|
5
|
-
require "rspec/core/rake_task"
|
6
|
-
|
7
|
-
RSpec::Core::RakeTask.new
|
8
|
-
|
9
|
-
task :default => :spec
|
10
|
-
task :test => :spec
|
11
|
-
|
12
|
-
require 'bundler/gem_helper'
|
13
|
-
Bundler::GemHelper.install_tasks :name => "acts_as_commentable_more", :dir => "../.."
|
14
|
-
|
15
|
-
require File.expand_path('../config/application', __FILE__)
|
16
|
-
|
17
|
-
Rails.application.load_tasks
|
File without changes
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
File without changes
|
File without changes
|
data/test/dummy/app/models/.keep
DELETED
File without changes
|
@@ -1,17 +0,0 @@
|
|
1
|
-
|
2
|
-
class Comment < ActiveRecord::Base
|
3
|
-
###################################################################
|
4
|
-
### To implement commentable add the following line to your model
|
5
|
-
### acts_as_commentable types: [:hide, :show], options: { class_name: 'Comment', as: :commentable }
|
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 :commentable, :polymorphic => true
|
14
|
-
belongs_to :user, polymorphic: true
|
15
|
-
|
16
|
-
###################################################################
|
17
|
-
end
|
File without changes
|
@@ -1,17 +0,0 @@
|
|
1
|
-
|
2
|
-
class CustomComment < ActiveRecord::Base
|
3
|
-
###################################################################
|
4
|
-
### To implement commentable add the following line to your model
|
5
|
-
### acts_as_commentable types: [:hide, :show], options: { class_name: 'CustomComment', as: :custom_commentable }
|
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 :custom_commentable, :polymorphic => true
|
14
|
-
belongs_to :user, polymorphic: true
|
15
|
-
|
16
|
-
###################################################################
|
17
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
data/test/dummy/bin/bundle
DELETED
data/test/dummy/bin/rails
DELETED
data/test/dummy/bin/rake
DELETED
data/test/dummy/config.ru
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
Bundler.require(*Rails.groups)
|
6
|
-
require "acts_as_commentable_more"
|
7
|
-
|
8
|
-
module Dummy
|
9
|
-
class Application < Rails::Application
|
10
|
-
# Settings in config/environments/* take precedence over those specified here.
|
11
|
-
# Application configuration should go into files in config/initializers
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
-
|
18
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
-
# config.i18n.default_locale = :de
|
21
|
-
config.generators do |g|
|
22
|
-
g.test_framework :rspec,
|
23
|
-
:fixtures => true,
|
24
|
-
:view_specs => false,
|
25
|
-
:helper_specs => false,
|
26
|
-
:routing_specs => false,
|
27
|
-
:controller_specs => false,
|
28
|
-
:request_specs => true,
|
29
|
-
:model_specs => false
|
30
|
-
g.fixture_replacement :factory_girl,
|
31
|
-
:dir => "spec/factories"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
data/test/dummy/config/boot.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
adapter: postgresql
|
3
|
-
encoding: unicode
|
4
|
-
database: acts_at_commentable_<%= Rails.env %>
|
5
|
-
pool: 5
|
6
|
-
username: postgres
|
7
|
-
password:
|
8
|
-
template: template0
|
9
|
-
host: localhost
|
10
|
-
|
11
|
-
development:
|
12
|
-
<<: *defaults
|
13
|
-
|
14
|
-
test:
|
15
|
-
<<: *defaults
|
16
|
-
|
17
|
-
production:
|
18
|
-
<<: *defaults
|