commentui 0.1.01 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bca51f6161bc71cf5cf350f50c64ad10eb49415f4ba69216904f66508ca3c55
4
- data.tar.gz: '02900136895d81f1b3a4c3e501466b57785568dd727663f87214b09b5887fc80'
3
+ metadata.gz: ad0908a8083abe7a1d1259737e6b29b018dac8fcb20018fc07942a7dc6a9bf41
4
+ data.tar.gz: 4d14f9228b136fba56899558a551037c452164d9675ac3d8a6df588b433337d6
5
5
  SHA512:
6
- metadata.gz: 44c26ef6404f40348fada9c1f6c42ffa7ae37043776103ede7574359575856b9984ab1efe9d4170f1743fa2acf51a57503efc7c72912613fd5f562373a0be57c
7
- data.tar.gz: 77432261dc67cf8a35441914166fd43ab6bcaed86b7518b39beec31c69137f81f870cb9a991baf333d9e8112b45350530eadc6bb10f4700c4d1f73b9d65de732
6
+ metadata.gz: '058506a2f751d862840c6b4fd3596c55ee12b53740c495f56ec24f73587d788ba93e5bb5b857a34c89e08f68cc152b96f242df359c4cee40d6bad7f4bef937b1'
7
+ data.tar.gz: 7f6f84809b084fb8b0c5888a4d7e715acf14f99983eebbd783763c47d6d63b0bfe157e6de942fd9cd806d4d2aa9bafd14e087962f0e56059c2a3934146de5b4e
data/README.md CHANGED
@@ -6,7 +6,7 @@ A simple comment API gem
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
  ```ruby
9
- gem 'commentui', "~> 0.1"
9
+ gem 'commentui', "~> 0.2.0"
10
10
  ```
11
11
 
12
12
  And then execute:
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
  $ gem install commentui
19
19
  ```
20
20
  ### 2. Migrations
21
- Run the following [command](https://edgeguides.rubyonrails.org/engines.html#engine-setup) to copy Commentui's migrations to your application:
21
+ Run the following [command](https://edgeguides.rubyonrails.org/engines.html#engine-setup) to copy Commentui's migrations to your application (run when update gem also):
22
22
  ```bash
23
23
  $ bundle exec rake commentui:install:migrations
24
24
  ```
@@ -75,13 +75,13 @@ Supported actions
75
75
 
76
76
  |Helper|HTTP Verb|Path|Controller#Action|
77
77
  |--- |--- |--- |--- |
78
- |thread_comments_path|GET|/threads/:thread_id/comments(.:format)|commentui/comments#index|
79
- ||POST|/threads/:thread_id/comments(.:format)|commentui/comments#create|
80
- |thread_comment_path|GET|/threads/:thread_id/comments/:id(.:format)|commentui/comments#show|
81
- ||PATCH|/threads/:thread_id/comments/:id(.:format)|commentui/comments#update|
82
- ||PUT|/threads/:thread_id/comments/:id(.:format)|commentui/comments#update|
83
- ||DELETE|/threads/:thread_id/comments/:id(.:format)|commentui/comments#destroy|
84
- |thread_path|GET|/threads/:id(.:format)|commentui/threads#show|
78
+ |topic_comments_path|GET|/topics/:topic_id/comments(.:format)|commentui/comments#index|
79
+ ||POST|/topics/:topic_id/comments(.:format)|commentui/comments#create|
80
+ |topic_comment_path|GET|/topics/:topic_id/comments/:id(.:format)|commentui/comments#show|
81
+ ||PATCH|/topics/:topic_id/comments/:id(.:format)|commentui/comments#update|
82
+ ||PUT|/topics/:topic_id/comments/:id(.:format)|commentui/comments#update|
83
+ ||DELETE|/topics/:topic_id/comments/:id(.:format)|commentui/comments#destroy|
84
+ |topic_path|GET|/topics/:id(.:format)|commentui/topics#show|
85
85
 
86
86
 
87
87
  ## Contributing
@@ -4,7 +4,7 @@ module Commentui
4
4
  class CommentsController < ApplicationController
5
5
  include Pagy::Backend
6
6
 
7
- before_action :set_thread
7
+ before_action :set_topic
8
8
  before_action :set_comment, only: [:update, :destroy]
9
9
  before_action :check_user, only: [:update, :destroy]
10
10
  after_action { pagy_headers_merge(@pagy) if @pagy }
@@ -37,12 +37,12 @@ module Commentui
37
37
 
38
38
  private
39
39
 
40
- def set_thread
41
- @thread ||= Commentui::Thread.find(params[:thread_id])
40
+ def set_topic
41
+ @topic ||= Commentui::Topic.find(params[:topic_id])
42
42
  end
43
43
 
44
44
  def comments_scope
45
- @thread.comments.order(created_at: :asc)
45
+ @topic.comments.order(created_at: :asc)
46
46
  end
47
47
 
48
48
  def set_comment
@@ -2,7 +2,7 @@ require_dependency "commentui/application_record"
2
2
 
3
3
  module Commentui
4
4
  class Comment < ApplicationRecord
5
- belongs_to :thread
5
+ belongs_to :topic
6
6
  belongs_to :creator, polymorphic: true
7
7
  belongs_to :editor, optional: true, polymorphic: true
8
8
 
@@ -1,7 +1,7 @@
1
1
  require_dependency "commentui/application_record"
2
2
 
3
3
  module Commentui
4
- class Thread < ApplicationRecord
4
+ class Topic < ApplicationRecord
5
5
  belongs_to :commentable, polymorphic: true
6
6
  belongs_to :closer, optional: true, polymorphic: true
7
7
 
@@ -1,5 +1,5 @@
1
1
  Commentui::Engine.routes.draw do
2
- resources :threads, only: [:show] do
2
+ resources :topics, only: [:show] do
3
3
  comment_resources = [:index, :show, :create]
4
4
  comment_resources << :update if Commentui.allow_modify_comment
5
5
  comment_resources << :destroy if Commentui.allow_modify_destroy
@@ -0,0 +1,6 @@
1
+ class RenameCommentuiThreadsToCommentuiTopics < ActiveRecord::Migration[5.1]
2
+ def change
3
+ rename_column :commentui_comments, :thread_id, :topic_id
4
+ rename_table :commentui_threads, :commentui_topics
5
+ end
6
+ end
@@ -7,13 +7,13 @@ module Commentui
7
7
  class_methods do
8
8
  def acts_as_commentuiable
9
9
  class_exec do
10
- has_one :commentui_thread,
10
+ has_one :commentui_topic,
11
11
  dependent: :nullify,
12
12
  as: :commentable,
13
- class_name: "Commentui::Thread"
13
+ class_name: "Commentui::Topic"
14
14
 
15
- def commentui_thread
16
- @commentui_thread ||= (super || create_commentui_thread)
15
+ def commentui_topic
16
+ @commentui_topic ||= (super || create_commentui_topic)
17
17
  end
18
18
  end
19
19
  end
@@ -15,10 +15,10 @@ module Commentui
15
15
  dependent: :nullify,
16
16
  as: :editor,
17
17
  class_name: "Commentui::Comment"
18
- has_many :commentui_closed_threads,
18
+ has_many :commentui_closed_topics,
19
19
  dependent: :nullify,
20
20
  as: :closer,
21
- class_name: "Commentui::Thread"
21
+ class_name: "Commentui::Topic"
22
22
  end
23
23
  end
24
24
  end ###
@@ -1,3 +1,3 @@
1
1
  module Commentui
2
- VERSION = "0.1.01"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commentui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.01
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phuoc Phan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-29 00:00:00.000000000 Z
11
+ date: 2019-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -181,11 +181,12 @@ files:
181
181
  - app/controllers/commentui/comments_controller.rb
182
182
  - app/models/commentui/application_record.rb
183
183
  - app/models/commentui/comment.rb
184
- - app/models/commentui/thread.rb
184
+ - app/models/commentui/topic.rb
185
185
  - config/initializers/commentui.rb
186
186
  - config/routes.rb
187
187
  - db/migrate/20191012044238_create_commentui_threads.rb
188
188
  - db/migrate/20191012050923_create_commentui_comments.rb
189
+ - db/migrate/20191109044444_rename_commentui_threads_to_commentui_topics.rb
189
190
  - lib/commentui.rb
190
191
  - lib/commentui/acts_as_commentuiable.rb
191
192
  - lib/commentui/acts_as_commentuier.rb