mongoid_commentable 0.0.1 → 0.0.2
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.
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.rdoc +11 -6
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/comment.rb +30 -0
- data/lib/generators/mongoid_commentable/install_generator.rb +20 -0
- data/lib/generators/templates/models/comment.rb +7 -0
- data/{app → lib/generators/templates}/views/comments/_form.html.erb +0 -0
- data/{app → lib/generators/templates}/views/comments/edit.html.erb +0 -0
- data/{app → lib/generators/templates}/views/comments/index.html.erb +0 -0
- data/{app → lib/generators/templates}/views/comments/new.html.erb +0 -0
- data/{app → lib/generators/templates}/views/comments/show.html.erb +0 -0
- data/lib/mongoid/commentable.rb +2 -11
- data/lib/mongoid_commentable.rb +2 -2
- data/mongoid_commentable.gemspec +82 -0
- data/spec/models/comment.rb +8 -0
- data/spec/models/commentable_model.rb +5 -0
- data/spec/mongoid/commentable_spec.rb +44 -49
- data/spec/spec_helper.rb +6 -3
- metadata +36 -25
- data/.document +0 -5
- data/.rspec +0 -1
- data/app/models/comment.rb +0 -17
- data/lib/generators/mongoid_commentable/views_generator.rb +0 -15
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -26,6 +26,7 @@ GEM
|
|
|
26
26
|
will_paginate (~> 3.0.pre)
|
|
27
27
|
rake (0.8.7)
|
|
28
28
|
rcov (0.9.9)
|
|
29
|
+
rr (1.0.2)
|
|
29
30
|
rspec (2.3.0)
|
|
30
31
|
rspec-core (~> 2.3.0)
|
|
31
32
|
rspec-expectations (~> 2.3.0)
|
|
@@ -47,4 +48,5 @@ DEPENDENCIES
|
|
|
47
48
|
jeweler (~> 1.6.0)
|
|
48
49
|
mongoid (~> 2.0)
|
|
49
50
|
rcov
|
|
51
|
+
rr
|
|
50
52
|
rspec (~> 2.3.0)
|
data/README.rdoc
CHANGED
|
@@ -9,6 +9,9 @@ You can use latest gem:
|
|
|
9
9
|
or in Gemfile:
|
|
10
10
|
gem 'mongoid_commentable'
|
|
11
11
|
|
|
12
|
+
Then install required model and views:
|
|
13
|
+
rails generate mongoid_commentable:install
|
|
14
|
+
|
|
12
15
|
== Usage
|
|
13
16
|
To make model commentable you need to include Mongoid::Commentable into your document:
|
|
14
17
|
class Article
|
|
@@ -30,11 +33,13 @@ And in your view file:
|
|
|
30
33
|
For a reply link add parent comment id:
|
|
31
34
|
<%= link_to "Reply", new_article_comment_path(:article_id => @article.id.to_s, :parent => comment.id.to_s) %>
|
|
32
35
|
|
|
33
|
-
If you want to make a custom views for a comments, run:
|
|
34
|
-
rails g mongoid_commentable:views
|
|
35
|
-
|
|
36
36
|
To get a list of all comments, use following method:
|
|
37
37
|
@article.comments_list
|
|
38
|
+
Example:
|
|
39
|
+
<% @article.comments_list.each do |comment| %>
|
|
40
|
+
<p> <%= comment.author %> </p>
|
|
41
|
+
<p> <%= comment.text %> </p>
|
|
42
|
+
<% end %>
|
|
38
43
|
it will return comments in ascending order. To get comments in descending order use:
|
|
39
44
|
@article.comments_list(:sort => :desc)
|
|
40
45
|
NOTE: For descending ordered comments you need to add index to your model manually:
|
|
@@ -48,10 +53,10 @@ To get comment level, use following method:
|
|
|
48
53
|
comment.level
|
|
49
54
|
|
|
50
55
|
To mark comment as deleted, use following method:
|
|
51
|
-
@article.
|
|
56
|
+
@article.comments.find(comment_id).remove
|
|
52
57
|
|
|
53
|
-
To
|
|
54
|
-
@article.
|
|
58
|
+
To restore comment, use method restore:
|
|
59
|
+
@article.comments.find(comment_id).restore
|
|
55
60
|
|
|
56
61
|
== Contributing to mongoid_commentable
|
|
57
62
|
|
data/Rakefile
CHANGED
|
@@ -18,6 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
|
18
18
|
gem.description = %Q{Mongoid_commentable provides methods to create commentable documents}
|
|
19
19
|
gem.email = "mgolovnia@gmail.com"
|
|
20
20
|
gem.authors = ["Max Golovnia"]
|
|
21
|
+
gem.version = File.read('VERSION').chomp
|
|
21
22
|
end
|
|
22
23
|
Jeweler::RubygemsDotOrgTasks.new
|
|
23
24
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.2
|
data/lib/comment.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Mongoid_Commentable
|
|
2
|
+
module Comment
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do |base|
|
|
6
|
+
base.attr_accessible :path,:parent
|
|
7
|
+
base.field :path, :type => String, :default => ""
|
|
8
|
+
base.field :parent, :type => String
|
|
9
|
+
base.field :deleted_at, :type => Time
|
|
10
|
+
base.embedded_in :commentable, :polymorphic => true, :inverse_of => :comments
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def level
|
|
14
|
+
path.count('.')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def remove
|
|
18
|
+
self.update_attribute(:deleted_at, Time.now)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def restore
|
|
22
|
+
self.update_attribute(:deleted_at, nil)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def deleted?
|
|
26
|
+
!!self.deleted_at
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'tmpdir'
|
|
2
|
+
module Mongoid_Commentable
|
|
3
|
+
module Generators
|
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
|
6
|
+
desc "Creates mongoid_commentable views and model for your application."
|
|
7
|
+
argument :scope, :required => false, :default => nil,
|
|
8
|
+
:desc => "The scope to copy views to"
|
|
9
|
+
def copy_views
|
|
10
|
+
directory "views/comments", "app/views/#{scope || :comments}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def copy_model
|
|
14
|
+
template "models/comment.rb", "app/models/comment.rb"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/mongoid/commentable.rb
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
module Mongoid::Commentable
|
|
2
2
|
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
3
|
included do |base|
|
|
5
4
|
base.embeds_many :comments, :as => :commentable
|
|
6
|
-
base.field :comments_count, :type => Integer, :default => 0
|
|
7
5
|
base.index [['comments', Mongo::ASCENDING]]
|
|
8
6
|
end
|
|
9
7
|
|
|
10
8
|
module ClassMethods
|
|
11
|
-
|
|
9
|
+
|
|
12
10
|
def commentable?
|
|
13
11
|
true
|
|
14
12
|
end
|
|
15
|
-
|
|
16
13
|
end
|
|
17
|
-
|
|
18
14
|
|
|
19
15
|
def create_comment!(params)
|
|
20
16
|
comment = comments.create!(params)
|
|
21
17
|
comment.path = comment.parent ? comments.find(comment.parent).path + '.' + comment.id.to_s : "root."+comment.id.to_s
|
|
22
|
-
self.inc(:comments_count,1)
|
|
23
18
|
comment
|
|
24
19
|
end
|
|
25
20
|
|
|
@@ -35,9 +30,5 @@ module Mongoid::Commentable
|
|
|
35
30
|
comments.select{|i| i.path =~ Regexp.new('^' + comments.find(comment_id).path)}
|
|
36
31
|
end
|
|
37
32
|
|
|
38
|
-
def mark_comment_deleted(comment_id)
|
|
39
|
-
comments.find(comment_id).deleted = true
|
|
40
|
-
self.inc(:comments_count,-1)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
33
|
end
|
|
34
|
+
|
data/lib/mongoid_commentable.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
require 'comment'
|
|
1
2
|
require File.join(File.dirname(__FILE__), 'mongoid/commentable')
|
|
2
|
-
|
|
3
|
-
%w{ models controllers }.each do |dir|
|
|
3
|
+
%w{ controllers }.each do |dir|
|
|
4
4
|
path = File.join(File.dirname(__FILE__), '../app', dir)
|
|
5
5
|
$LOAD_PATH << path
|
|
6
6
|
ActiveSupport::Dependencies.autoload_paths << path
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{mongoid_commentable}
|
|
8
|
+
s.version = "0.0.2"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = [%q{Max Golovnia}]
|
|
12
|
+
s.date = %q{2011-05-09}
|
|
13
|
+
s.description = %q{Mongoid_commentable provides methods to create commentable documents}
|
|
14
|
+
s.email = %q{mgolovnia@gmail.com}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE.txt",
|
|
17
|
+
"README.rdoc"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
"Gemfile",
|
|
21
|
+
"Gemfile.lock",
|
|
22
|
+
"LICENSE.txt",
|
|
23
|
+
"README.rdoc",
|
|
24
|
+
"Rakefile",
|
|
25
|
+
"VERSION",
|
|
26
|
+
"app/controllers/comments_controller.rb",
|
|
27
|
+
"lib/comment.rb",
|
|
28
|
+
"lib/generators/mongoid_commentable/install_generator.rb",
|
|
29
|
+
"lib/generators/templates/models/comment.rb",
|
|
30
|
+
"lib/generators/templates/views/comments/_form.html.erb",
|
|
31
|
+
"lib/generators/templates/views/comments/edit.html.erb",
|
|
32
|
+
"lib/generators/templates/views/comments/index.html.erb",
|
|
33
|
+
"lib/generators/templates/views/comments/new.html.erb",
|
|
34
|
+
"lib/generators/templates/views/comments/show.html.erb",
|
|
35
|
+
"lib/mongoid/commentable.rb",
|
|
36
|
+
"lib/mongoid_commentable.rb",
|
|
37
|
+
"mongoid_commentable.gemspec",
|
|
38
|
+
"spec/models/comment.rb",
|
|
39
|
+
"spec/models/commentable_model.rb",
|
|
40
|
+
"spec/mongoid/commentable_spec.rb",
|
|
41
|
+
"spec/spec_helper.rb"
|
|
42
|
+
]
|
|
43
|
+
s.homepage = %q{http://github.com/mgolovnia/mongoid_commentable}
|
|
44
|
+
s.licenses = [%q{MIT}]
|
|
45
|
+
s.require_paths = [%q{lib}]
|
|
46
|
+
s.rubygems_version = %q{1.8.1}
|
|
47
|
+
s.summary = %q{Comments for Mongoid documents}
|
|
48
|
+
|
|
49
|
+
if s.respond_to? :specification_version then
|
|
50
|
+
s.specification_version = 3
|
|
51
|
+
|
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
53
|
+
s.add_runtime_dependency(%q<mongoid>, ["~> 2.0"])
|
|
54
|
+
s.add_runtime_dependency(%q<bson_ext>, ["~> 1.3"])
|
|
55
|
+
s.add_development_dependency(%q<rr>, [">= 0"])
|
|
56
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
57
|
+
s.add_development_dependency(%q<database_cleaner>, [">= 0"])
|
|
58
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
59
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
|
60
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
61
|
+
else
|
|
62
|
+
s.add_dependency(%q<mongoid>, ["~> 2.0"])
|
|
63
|
+
s.add_dependency(%q<bson_ext>, ["~> 1.3"])
|
|
64
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
|
65
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
66
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
|
67
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
|
69
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
70
|
+
end
|
|
71
|
+
else
|
|
72
|
+
s.add_dependency(%q<mongoid>, ["~> 2.0"])
|
|
73
|
+
s.add_dependency(%q<bson_ext>, ["~> 1.3"])
|
|
74
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
|
75
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
76
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
|
77
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
78
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
|
79
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
@@ -1,53 +1,48 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
class TestModel
|
|
3
|
-
include Mongoid::Document
|
|
4
|
-
include Mongoid::Commentable
|
|
5
|
-
end
|
|
6
|
-
describe 'Make commentable' do
|
|
7
|
-
|
|
8
|
-
let(:test_model){TestModel.create!}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
it 'should be commentable' do
|
|
12
|
-
test_model.class.commentable?.should == true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'should allow to add a comment' do
|
|
16
|
-
comment = test_model.create_comment!(:author => 'Test author', :text => 'Hello, World!')
|
|
17
|
-
comment.author.should == 'Test author'
|
|
18
|
-
comment.text.should == 'Hello, World!'
|
|
19
|
-
comment.path.should == "root.#{comment.id.to_s}"
|
|
20
|
-
comment.deleted.should == false
|
|
21
|
-
test_model.comments_count == 1
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'should allow to add a reply to a comment' do
|
|
25
|
-
comment = test_model.create_comment!(:author => 'Author', :text => 'Parent')
|
|
26
|
-
reply = test_model.create_comment!(:author => 'Author2', :text => 'Reply', :parent => comment.id.to_s)
|
|
27
|
-
test_model.comments.find(reply.id).path.should == "#{comment.path}.#{reply.id.to_s}"
|
|
28
|
-
end
|
|
29
2
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
3
|
+
describe Mongoid::Commentable do
|
|
4
|
+
|
|
5
|
+
describe Comment do
|
|
6
|
+
|
|
7
|
+
context 'creating new comment' do
|
|
8
|
+
subject {CommentableModel.new.create_comment!(:author => 'Author', :text => 'test') }
|
|
9
|
+
its(:class){should == Comment}
|
|
10
|
+
its(:author){should == 'Author'}
|
|
11
|
+
its(:text){should == 'test'}
|
|
12
|
+
specify{subject.path.should == "root.#{subject.id}"}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'replying to a comment' do
|
|
16
|
+
before do
|
|
17
|
+
@commentable_model = CommentableModel.new
|
|
18
|
+
3.times{|i| @commentable_model.create_comment!(nil)}
|
|
19
|
+
@parent = @commentable_model.comments.first
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
subject{@child = @commentable_model.create_comment!(:parent => @parent.id.to_s)}
|
|
23
|
+
specify{subject.path.should == "root.#{@parent.id}.#{subject.id}"}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context 'marking comment as deleted' do
|
|
27
|
+
before do
|
|
28
|
+
@comment = CommentableModel.new.create_comment!(nil)
|
|
29
|
+
@comment.remove
|
|
30
|
+
end
|
|
31
|
+
subject {@comment}
|
|
32
|
+
its(:deleted_at){should_not be_nil}
|
|
33
|
+
its(:deleted?){should be_true}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context 'getting branch' do
|
|
37
|
+
before do
|
|
38
|
+
@commentable_model = CommentableModel.new
|
|
39
|
+
@comment1 = @commentable_model.create_comment!(nil)
|
|
40
|
+
@comment2 = @commentable_model.create_comment!(nil)
|
|
41
|
+
@child1 = @commentable_model.create_comment!(:parent => @comment1.id.to_s)
|
|
42
|
+
@child2 = @commentable_model.create_comment!(:parent => @child1.id.to_s)
|
|
43
|
+
end
|
|
44
|
+
subject{@commentable_model}
|
|
45
|
+
specify{subject.branch_for(@comment1.id).should == [@comment1,@child1,@child2]}
|
|
46
|
+
end
|
|
49
47
|
end
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
48
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__),'..','lib'))
|
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__),'models'))
|
|
3
3
|
require 'mongoid'
|
|
4
4
|
require 'rubygems'
|
|
5
5
|
require 'bundler'
|
|
6
6
|
require 'logger'
|
|
7
7
|
require 'rspec'
|
|
8
|
+
require 'rr'
|
|
8
9
|
require 'database_cleaner'
|
|
9
10
|
require 'mongoid_commentable'
|
|
11
|
+
require 'models/comment'
|
|
12
|
+
require 'models/commentable_model'
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
RSpec.configure do |config|
|
|
13
|
-
config.mock_with :
|
|
16
|
+
config.mock_with :rr
|
|
14
17
|
config.before(:suite) do
|
|
15
18
|
DatabaseCleaner.strategy = :truncation
|
|
16
19
|
DatabaseCleaner.orm = "mongoid"
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: mongoid_commentable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.0.
|
|
5
|
+
version: 0.0.2
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Max Golovnia
|
|
@@ -10,8 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-05-
|
|
14
|
-
default_executable:
|
|
13
|
+
date: 2011-05-09 00:00:00 Z
|
|
15
14
|
dependencies:
|
|
16
15
|
- !ruby/object:Gem::Dependency
|
|
17
16
|
name: mongoid
|
|
@@ -36,8 +35,19 @@ dependencies:
|
|
|
36
35
|
prerelease: false
|
|
37
36
|
version_requirements: *id002
|
|
38
37
|
- !ruby/object:Gem::Dependency
|
|
39
|
-
name:
|
|
38
|
+
name: rr
|
|
40
39
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
40
|
+
none: false
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: "0"
|
|
45
|
+
type: :development
|
|
46
|
+
prerelease: false
|
|
47
|
+
version_requirements: *id003
|
|
48
|
+
- !ruby/object:Gem::Dependency
|
|
49
|
+
name: rspec
|
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
41
51
|
none: false
|
|
42
52
|
requirements:
|
|
43
53
|
- - ~>
|
|
@@ -45,10 +55,10 @@ dependencies:
|
|
|
45
55
|
version: 2.3.0
|
|
46
56
|
type: :development
|
|
47
57
|
prerelease: false
|
|
48
|
-
version_requirements: *
|
|
58
|
+
version_requirements: *id004
|
|
49
59
|
- !ruby/object:Gem::Dependency
|
|
50
60
|
name: database_cleaner
|
|
51
|
-
requirement: &
|
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
52
62
|
none: false
|
|
53
63
|
requirements:
|
|
54
64
|
- - ">="
|
|
@@ -56,10 +66,10 @@ dependencies:
|
|
|
56
66
|
version: "0"
|
|
57
67
|
type: :development
|
|
58
68
|
prerelease: false
|
|
59
|
-
version_requirements: *
|
|
69
|
+
version_requirements: *id005
|
|
60
70
|
- !ruby/object:Gem::Dependency
|
|
61
71
|
name: bundler
|
|
62
|
-
requirement: &
|
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
63
73
|
none: false
|
|
64
74
|
requirements:
|
|
65
75
|
- - ~>
|
|
@@ -67,10 +77,10 @@ dependencies:
|
|
|
67
77
|
version: 1.0.0
|
|
68
78
|
type: :development
|
|
69
79
|
prerelease: false
|
|
70
|
-
version_requirements: *
|
|
80
|
+
version_requirements: *id006
|
|
71
81
|
- !ruby/object:Gem::Dependency
|
|
72
82
|
name: jeweler
|
|
73
|
-
requirement: &
|
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
74
84
|
none: false
|
|
75
85
|
requirements:
|
|
76
86
|
- - ~>
|
|
@@ -78,10 +88,10 @@ dependencies:
|
|
|
78
88
|
version: 1.6.0
|
|
79
89
|
type: :development
|
|
80
90
|
prerelease: false
|
|
81
|
-
version_requirements: *
|
|
91
|
+
version_requirements: *id007
|
|
82
92
|
- !ruby/object:Gem::Dependency
|
|
83
93
|
name: rcov
|
|
84
|
-
requirement: &
|
|
94
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
|
85
95
|
none: false
|
|
86
96
|
requirements:
|
|
87
97
|
- - ">="
|
|
@@ -89,7 +99,7 @@ dependencies:
|
|
|
89
99
|
version: "0"
|
|
90
100
|
type: :development
|
|
91
101
|
prerelease: false
|
|
92
|
-
version_requirements: *
|
|
102
|
+
version_requirements: *id008
|
|
93
103
|
description: Mongoid_commentable provides methods to create commentable documents
|
|
94
104
|
email: mgolovnia@gmail.com
|
|
95
105
|
executables: []
|
|
@@ -100,8 +110,6 @@ extra_rdoc_files:
|
|
|
100
110
|
- LICENSE.txt
|
|
101
111
|
- README.rdoc
|
|
102
112
|
files:
|
|
103
|
-
- .document
|
|
104
|
-
- .rspec
|
|
105
113
|
- Gemfile
|
|
106
114
|
- Gemfile.lock
|
|
107
115
|
- LICENSE.txt
|
|
@@ -109,18 +117,21 @@ files:
|
|
|
109
117
|
- Rakefile
|
|
110
118
|
- VERSION
|
|
111
119
|
- app/controllers/comments_controller.rb
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
- lib/generators/
|
|
120
|
+
- lib/comment.rb
|
|
121
|
+
- lib/generators/mongoid_commentable/install_generator.rb
|
|
122
|
+
- lib/generators/templates/models/comment.rb
|
|
123
|
+
- lib/generators/templates/views/comments/_form.html.erb
|
|
124
|
+
- lib/generators/templates/views/comments/edit.html.erb
|
|
125
|
+
- lib/generators/templates/views/comments/index.html.erb
|
|
126
|
+
- lib/generators/templates/views/comments/new.html.erb
|
|
127
|
+
- lib/generators/templates/views/comments/show.html.erb
|
|
119
128
|
- lib/mongoid/commentable.rb
|
|
120
129
|
- lib/mongoid_commentable.rb
|
|
130
|
+
- mongoid_commentable.gemspec
|
|
131
|
+
- spec/models/comment.rb
|
|
132
|
+
- spec/models/commentable_model.rb
|
|
121
133
|
- spec/mongoid/commentable_spec.rb
|
|
122
134
|
- spec/spec_helper.rb
|
|
123
|
-
has_rdoc: true
|
|
124
135
|
homepage: http://github.com/mgolovnia/mongoid_commentable
|
|
125
136
|
licenses:
|
|
126
137
|
- MIT
|
|
@@ -134,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
134
145
|
requirements:
|
|
135
146
|
- - ">="
|
|
136
147
|
- !ruby/object:Gem::Version
|
|
137
|
-
hash:
|
|
148
|
+
hash: 3455755614861241426
|
|
138
149
|
segments:
|
|
139
150
|
- 0
|
|
140
151
|
version: "0"
|
|
@@ -147,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
147
158
|
requirements: []
|
|
148
159
|
|
|
149
160
|
rubyforge_project:
|
|
150
|
-
rubygems_version: 1.
|
|
161
|
+
rubygems_version: 1.8.1
|
|
151
162
|
signing_key:
|
|
152
163
|
specification_version: 3
|
|
153
164
|
summary: Comments for Mongoid documents
|
data/.document
DELETED
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--color
|
data/app/models/comment.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
class Comment
|
|
2
|
-
include Mongoid::Document
|
|
3
|
-
attr_accessible :text, :author, :path, :parent
|
|
4
|
-
field :text, :type => String
|
|
5
|
-
field :author, :type => String
|
|
6
|
-
field :path, :type => String, :default => ""
|
|
7
|
-
field :deleted, :type => Boolean, :default => false
|
|
8
|
-
field :parent, :type => String
|
|
9
|
-
embedded_in :commentable, :polymorphic => true
|
|
10
|
-
|
|
11
|
-
def level
|
|
12
|
-
path.count('.')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require 'tmpdir'
|
|
2
|
-
module Mongoid_Commentable
|
|
3
|
-
module Generators
|
|
4
|
-
class ViewsGenerator < Rails::Generators::Base
|
|
5
|
-
source_root File.expand_path("../../../../app/views", __FILE__)
|
|
6
|
-
desc "Copies all mongoid_commentable views to your application."
|
|
7
|
-
argument :scope, :required => false, :default => nil,
|
|
8
|
-
:desc => "The scope to copy views to"
|
|
9
|
-
def copy_views
|
|
10
|
-
directory "comments", "app/views/#{scope || :comments}"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|