Skip to content

Commit ea69b27

Browse files
authored
Rebuild of ActiveAdmin::Chat (#52)
* Reestructure * Fix rubocop * Restore rubocop exclusions * Fix tests * Try to fix travis * Split channels * Fix dummy app * Fix tests * Fix tests and deprecation warnings * Reestructure JS * Install webpacker in dummy app * Update README * Fix tests * Fix rubocop * Webpacker is a prod dependency too * Use npm package * Use gemspec * Fix Travis * Fix gemfiles * Fix deprecation warning * Fix link * Fix TravisCI * Refactor JS package * Fix rubocop * Improve gemspec * Fix require issue * Remove useless files * Bump version * Restore dev dependencies * Bump version * Fix code style * Fix rubocop * Use local dependency * Update ruby requirement * Fix actioncable dependency
1 parent e3ea0e5 commit ea69b27

File tree

106 files changed

+9036
-1288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+9036
-1288
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ spec/dummy/node_modules/
88
spec/dummy/yarn-error.log
99
spec/dummy/storage/
1010
spec/dummy/tmp/
11+
spec/dummy/public/packs/
12+
spec/dummy/public/packs-test/
1113
spec/tmp/
1214
node_modules/
1315
/coverage/

.rubocop.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
AllCops:
2+
TargetRubyVersion: 2.5
23
Exclude:
34
- spec/dummy/db/schema.rb
5+
- spec/dummy/node_modules/**/*
6+
- node_modules/**/*
47
- vendor/bundle/**/*
58
- gemfiles/vendor/bundle/**/*
69

@@ -13,24 +16,24 @@ Lint/AmbiguousBlockAssociation:
1316

1417
Lint/NestedMethodDefinition:
1518
Exclude:
16-
- lib/active_admin_chat/active_admin/application.rb
19+
- lib/active_admin/chat/extensions/application.rb
1720

1821
Metrics/AbcSize:
1922
# The ABC size is a calculated magnitude, so this number can be an Integer or
2023
# a Float.
2124
Max: 15
2225
Exclude:
23-
- lib/generators/active_admin_chat/install/install_generator.rb
24-
- lib/active_admin_chat/active_admin/application.rb
25-
- app/channels/chat_channel.rb
26+
- lib/generators/active_admin/chat/install/install_generator.rb
27+
- lib/active_admin/chat/extensions/application.rb
28+
- app/channels/active_admin/chat/chat_channel.rb
2629

2730
Metrics/BlockLength:
2831
CountComments: false # count full line comments?
2932
Max: 25
3033
Exclude:
3134
- spec/generators/install_generator_spec.rb
32-
- lib/active_admin_chat/active_admin/application.rb
33-
- active_admin_chat.gemspec
35+
- lib/active_admin/chat/extensions/application.rb
36+
- activeadmin-chat.gemspec
3437
ExcludedMethods: ['describe', 'context', 'feature', 'scenario']
3538

3639
Metrics/BlockNesting:
@@ -48,7 +51,7 @@ Metrics/MethodLength:
4851
CountComments: false # count full line comments?
4952
Max: 24
5053
Exclude:
51-
- lib/active_admin_chat/active_admin/application.rb
54+
- lib/active_admin/chat/extensions/application.rb
5255

5356
Metrics/ModuleLength:
5457
CountComments: false # count full line comments?
@@ -64,7 +67,7 @@ Metrics/LineLength:
6467
- https
6568
Exclude:
6669
- spec/dummy/**/*
67-
- spec/channels/chat_channel_spec.rb
70+
- spec/channels/active_admin/chat/chat_channel_spec.rb
6871
- config/routes.rb
6972

7073
Metrics/ParameterLists:
@@ -74,6 +77,10 @@ Metrics/ParameterLists:
7477
Metrics/PerceivedComplexity:
7578
Max: 12
7679

80+
Naming/FileName:
81+
Exclude:
82+
- lib/activeadmin-chat.rb
83+
7784
Style/FrozenStringLiteralComment:
7885
Enabled: false
7986

@@ -86,4 +93,4 @@ Style/MixinUsage:
8693

8794
Style/GuardClause:
8895
Exclude:
89-
- lib/generators/active_admin_chat/install/install_generator.rb
96+
- lib/generators/active_admin/chat/install/install_generator.rb

.travis.yml

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1+
language: ruby
2+
3+
dist: xenial
4+
5+
os: linux
6+
7+
addons:
8+
chrome: stable
9+
110
env:
211
global:
312
- CC_TEST_REPORTER_ID=796169b8dd8f24e0dfbe4ce3f7c3c3f95f5ecc5475b95871f1797664f6b2b3e3
413

5-
language: ruby
6-
cache: bundler
14+
cache:
15+
- bundler
16+
- yarn
17+
718
rvm:
8-
- 2.2.2
9-
- 2.3.8
10-
- 2.4.5
11-
- 2.5.3
19+
- 2.5.8
20+
- 2.6.6
21+
- 2.7.1
1222
- ruby-head
1323

14-
addons:
15-
chrome: stable
24+
gemfile:
25+
- gemfiles/rails_5_2.gemfile
26+
- gemfiles/rails_6_0.gemfile
1627

17-
dist: xenial
18-
os: linux
28+
jobs:
29+
fast_finish: true
30+
allow_failures:
31+
- rvm: ruby-head
1932

2033
before_install:
21-
- bundle install
22-
- sudo apt-get update
23-
- sudo apt-get install chromium-chromedriver
24-
- "export PATH=$PATH:/usr/lib/chromium-browser/"
34+
- nvm install 12
35+
- bin/yarn install
2536
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
2637
- chmod +x ./cc-test-reporter
2738
- ./cc-test-reporter before-build
39+
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
40+
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
41+
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
42+
- unzip chromedriver_linux64.zip -d ~/bin
43+
- gem update --system --no-doc
44+
- gem install bundler --no-doc
45+
2846

2947
after_script:
3048
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
31-
32-
gemfile:
33-
- gemfiles/5.0.gemfile
34-
- gemfiles/5.1.gemfile
35-
- gemfiles/5.2.gemfile
36-
37-
jobs:
38-
fast_finish: true
39-
exclude:
40-
- gemfile: gemfiles/5.2.gemfile
41-
rvm: 2.2.2
42-
allow_failures:
43-
- rvm: ruby-head

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
# Declare your gem's dependencies in active_admin_chat.gemspec.
4+
# Declare your gem's dependencies in activeadmin-chat.gemspec.
55
# Bundler will treat runtime dependencies like base dependencies, and
66
# development dependencies will be added by default to the :development group.
77
gemspec

README.md

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# ActiveAdminChat
1+
# ActiveAdmin::Chat
22

3-
[![Build Status](https://travis-ci.org/rootstrap/active_admin_chat.svg?branch=master)](https://travis-ci.org/rootstrap/active_admin_chat)
4-
[![Maintainability](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/maintainability)](https://codeclimate.com/github/rootstrap/active_admin_chat/maintainability)
5-
[![Test Coverage](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/test_coverage)](https://codeclimate.com/github/rootstrap/active_admin_chat/test_coverage)
3+
[![Build Status](https://travis-ci.org/rootstrap/activeadmin-chat.svg?branch=master)](https://travis-ci.org/rootstrap/activeadmin-chat)
4+
[![Maintainability](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/maintainability)](https://codeclimate.com/github/rootstrap/activeadmin-chat/maintainability)
5+
[![Test Coverage](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/test_coverage)](https://codeclimate.com/github/rootstrap/activeadmin-chat/test_coverage)
66

77
Get a chat for your ActiveAdmin app out of the box.
88

9-
![](active_admin_chat_gif.gif)
9+
![](images/activeadmin-chat.gif)
1010

1111
## Prerequisites
1212
- It assumes you have models for your admins and users in place.
@@ -16,47 +16,57 @@ Get a chat for your ActiveAdmin app out of the box.
1616
## Installation
1717
Add to Gemfile:
1818
```ruby
19-
gem 'active_admin_chat'
19+
gem 'activeadmin-chat'
2020
```
2121

2222
And then run:
2323
```bash
2424
$ bundle install
2525
```
2626

27-
Install ActiveAdminChat:
27+
This gem requires Webpacker for the Javascript. Add the npm package:
2828
```bash
29-
$ rails generate active_admin_chat:install
29+
$ yarn add activeadmin-chat
30+
```
31+
32+
And install it:
33+
```bash
34+
$ yarn install
35+
```
36+
37+
Install `ActiveAdmin::Chat`:
38+
```bash
39+
$ rails generate active_admin:chat:install
3040
```
3141
It will generate:
3242
- `Conversation` and `Message` models and migrations.
3343
- Initializer that configures the model names for conversation, message, admin user and user.
3444
- Default chat page.
3545

36-
You can customize the namings of the models when installing ActiveAdminChat with the usage of the `--conversation_model_name`, `--message_model_name`, `--admin_user_model_name` and `--user_model_name` flags.
46+
You can customize the namings of the models when installing `ActiveAdmin::Chat` with the usage of the `--conversation_model_name`, `--message_model_name`, `--admin_user_model_name` and `--user_model_name` flags.
3747

3848
For example:
3949
```bash
40-
$ rails generate active_admin_chat:install --conversation_model_name=chat
50+
$ rails generate active_admin:chat:install --conversation_model_name=chat
4151
```
4252

43-
Once you've successfully installed ActiveAdminChat, run:
53+
Once you've successfully installed `ActiveAdmin::Chat`, run:
4454
```bash
4555
$ rails db:migrate
4656
```
4757

4858
Add including of CSS to `app/assets/stylesheets/active_admin.css.scss`:
4959
```css
50-
@import 'active_admin_chat';
60+
@import 'active_admin/chat';
5161
```
5262

53-
And including of JS to `app/assets/javascripts/active_admin.js`:
63+
Create a file named `app/javascript/packs/activeadmin-chat.js`, with the following content:
5464
```js
55-
#= require active_admin_chat
65+
import 'activeadmin-chat';
5666
```
5767

5868
### Example diagram
59-
![](admin_chat_diagram.png?raw=true "Chat diagram")
69+
![](images/activeadmin-chat_diagram.png?raw=true "Chat diagram")
6070

6171
## Usage
6272
All you need to get the chat up and running is to authenticate your users in the websocket connection in `app/channels/application_cable/connection.rb`. It's important that you identify them as the `current_user` here, this will be used by the gem internally.
@@ -128,12 +138,12 @@ end
128138
```
129139

130140
## Contributing
131-
Bug reports (please use Issues) and pull requests are welcome on GitHub at https://github.com/rootstrap/active_admin_chat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
141+
Bug reports (please use Issues) and pull requests are welcome on GitHub at https://github.com/rootstrap/activeadmin-chat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
132142

133143
## License
134144
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
135145

136146
## Credits
137-
**Active Admin Chat** is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our [contributors](https://github.com/rootstrap/active_admin_chat/contributors).
147+
**Active Admin Chat** is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our [contributors](https://github.com/rootstrap/activeadmin-chat/contributors).
138148

139149
[<img src="https://s3-us-west-1.amazonaws.com/rootstrap.com/img/rs.png" width="100"/>](http://www.rootstrap.com)

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require 'rdoc/task'
88

99
RDoc::Task.new(:rdoc) do |rdoc|
1010
rdoc.rdoc_dir = 'rdoc'
11-
rdoc.title = 'ActiveAdminChat'
11+
rdoc.title = 'ActiveAdmin::Chat'
1212
rdoc.options << '--line-numbers'
1313
rdoc.rdoc_files.include('README.md')
1414
rdoc.rdoc_files.include('lib/**/*.rb')
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
$LOAD_PATH.push File.expand_path('lib', __dir__)
1+
# frozen_string_literal: true
22

3-
# Maintain your gem's version:
4-
require 'active_admin_chat/version'
3+
require_relative 'lib/active_admin/chat/version'
54

65
# Describe your gem and declare its dependencies:
76
Gem::Specification.new do |s|
8-
s.name = 'active_admin_chat'
9-
s.version = ActiveAdminChat::VERSION
7+
s.name = 'activeadmin-chat'
8+
s.version = ActiveAdmin::Chat::VERSION
109
s.authors = ['Santiago Bartesaghi', 'Federico Aldunate']
1110
s.email = ['santiago.bartesaghi@rootstrap.com', 'federico@rootstrap.com']
12-
s.homepage = 'https://github.com/rootstrap/active_admin_chat'
11+
s.homepage = 'https://github.com/rootstrap/activeadmin-chat'
1312
s.summary = 'ActiveAdmin chat plugin'
1413
s.description = s.summary
1514
s.license = 'MIT'
1615

1716
s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']
17+
s.require_paths = ['lib']
1818

19-
s.required_ruby_version = '>= 2.2.2'
19+
s.required_ruby_version = '>= 2.5.0'
2020

21-
s.add_dependency 'activeadmin', '>= 1.0.0'
22-
s.add_dependency 'rails', '>= 5.0.0'
23-
s.add_dependency 'sassc-rails', '~> 2.1.2'
21+
s.add_dependency 'activeadmin', '>= 2.0'
22+
s.add_dependency 'rails', '>= 5.2'
23+
s.add_dependency 'webpacker', '>= 5.0'
2424

25-
s.add_development_dependency 'action-cable-testing', '~> 0.4.0'
25+
s.add_development_dependency 'action-cable-testing', '>= 0.4.0'
2626
s.add_development_dependency 'byebug', '~> 10.0.0'
27-
s.add_development_dependency 'capybara', '~> 3.1.1'
28-
s.add_development_dependency 'database_cleaner', '~> 1.8.4'
27+
s.add_development_dependency 'capybara', '~> 3.32.2'
2928
s.add_development_dependency 'factory_bot_rails', '~> 4.11.1'
3029
s.add_development_dependency 'generator_spec', '~> 0.9.4'
3130
s.add_development_dependency 'puma', '~> 4.3.3'
3231
s.add_development_dependency 'rspec-rails', '~> 3.8'
3332
s.add_development_dependency 'rubocop', '~> 0.59.2'
3433
s.add_development_dependency 'selenium-webdriver', '~> 3.0'
3534
s.add_development_dependency 'simplecov', '~> 0.17.1'
36-
s.add_development_dependency 'sqlite3', '~> 1.4.0'
37-
s.add_development_dependency 'timecop', '~> 0.9.1'
35+
s.add_development_dependency 'sqlite3', '>= 1.3.0'
3836
end

app/assets/images/active_admin_chat/.keep

Whitespace-only changes.

app/assets/javascripts/active_admin_chat.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)