beetle_reporter 0.1.0 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +70 -16
- data/Rakefile +5 -9
- data/app/assets/config/beetle_reporter_manifest.js +1 -0
- data/app/assets/stylesheets/beetle_reporter/application.css +15 -0
- data/app/assets/stylesheets/beetle_reporter/home.css +4 -0
- data/app/assets/stylesheets/beetle_reporter/reports.css +4 -0
- data/app/assets/stylesheets/beetle_reporter/tailwind.min.css +1 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/controllers/beetle_reporter/application_controller.rb +11 -0
- data/app/controllers/beetle_reporter/home_controller.rb +8 -0
- data/app/controllers/beetle_reporter/reports_controller.rb +166 -0
- data/app/helpers/beetle_reporter/application_helper.rb +9 -0
- data/app/helpers/beetle_reporter/home_helper.rb +4 -0
- data/app/helpers/beetle_reporter/reports_helper.rb +4 -0
- data/app/jobs/beetle_reporter/application_job.rb +4 -0
- data/app/mailers/beetle_reporter/application_mailer.rb +6 -0
- data/app/models/beetle_reporter/application_record.rb +5 -0
- data/app/models/beetle_reporter/report.rb +123 -0
- data/app/views/beetle_reporter/home/index.html.haml +4 -0
- data/app/views/beetle_reporter/reports/_form.html.haml +14 -0
- data/app/views/beetle_reporter/reports/_report.html.haml +55 -0
- data/app/views/beetle_reporter/reports/destroy.turbo_stream.haml +1 -0
- data/app/views/beetle_reporter/reports/edit.html.haml +6 -0
- data/app/views/beetle_reporter/reports/index.html.haml +38 -0
- data/app/views/beetle_reporter/reports/new.html.haml +5 -0
- data/app/views/beetle_reporter/reports/show.html.haml +1 -0
- data/app/views/layouts/beetle_reporter/application.html.haml +22 -0
- data/config/locales/beetle_reporter.yml +18 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20211216073022_create_beetle_reporter_reports.rb +20 -0
- data/lib/beetle_reporter/configuration.rb +9 -0
- data/lib/beetle_reporter/engine.rb +9 -0
- data/lib/beetle_reporter/version.rb +1 -3
- data/lib/beetle_reporter.rb +46 -4
- data/lib/tasks/beetle_reporter_tasks.rake +4 -0
- metadata +137 -15
- data/.rspec +0 -3
- data/.rubocop.yml +0 -13
- data/CHANGELOG.md +0 -5
- data/Gemfile +0 -12
- data/LICENSE.txt +0 -21
- data/beetle_reporter.gemspec +0 -39
- data/bin/console +0 -15
- data/bin/setup +0 -8
data/lib/beetle_reporter.rb
CHANGED
@@ -1,8 +1,50 @@
|
|
1
|
-
|
1
|
+
require "beetle_reporter/version"
|
2
|
+
require "beetle_reporter/engine"
|
3
|
+
require 'beetle_reporter/configuration'
|
2
4
|
|
3
|
-
|
5
|
+
require 'aasm'
|
6
|
+
require 'pagy'
|
7
|
+
require 'hamlit'
|
8
|
+
require 'discard'
|
9
|
+
require 'turbo-rails'
|
4
10
|
|
5
11
|
module BeetleReporter
|
6
|
-
class
|
7
|
-
|
12
|
+
class << self
|
13
|
+
def config
|
14
|
+
return @config if defined?(@config)
|
15
|
+
|
16
|
+
@config = Configuration.new
|
17
|
+
@config.user_class = 'User'
|
18
|
+
@config.current_user_method = 'current_user'
|
19
|
+
@config.user_name_method = 'name'
|
20
|
+
@config.main_app_root_path_method = 'root_path'
|
21
|
+
@config.main_app_user_path_method = 'user_path'
|
22
|
+
|
23
|
+
@config
|
24
|
+
end
|
25
|
+
|
26
|
+
def configure
|
27
|
+
yield(config)
|
28
|
+
end
|
29
|
+
|
30
|
+
def add(record, user_id, reason)
|
31
|
+
report = BeetleReporter::Report.pending.kept.find_by(record: record)
|
32
|
+
if report
|
33
|
+
report.user_ids << user_id unless report.user_ids.include?(user_id)
|
34
|
+
report.reasons << reason unless report.reasons.include?(reason)
|
35
|
+
# 未登录用户也有可能
|
36
|
+
report.reported_count += 1
|
37
|
+
report.user_ids = report.user_ids.uniq
|
38
|
+
report.reasons = report.reasons.uniq
|
39
|
+
report.save
|
40
|
+
else
|
41
|
+
report = BeetleReporter::Report.create(record: record,
|
42
|
+
user_ids: [user_id],
|
43
|
+
reasons: [reason],
|
44
|
+
reported_count: 1,
|
45
|
+
)
|
46
|
+
end
|
47
|
+
report
|
48
|
+
end
|
49
|
+
end
|
8
50
|
end
|
metadata
CHANGED
@@ -1,34 +1,156 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beetle_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 42up
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
12
|
-
dependencies:
|
13
|
-
|
11
|
+
date: 2021-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aasm
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hamlit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: haml-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: turbo-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: discard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pagy
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.6'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.6'
|
111
|
+
description: Description of BeetleReporter.
|
14
112
|
email:
|
15
113
|
- foobar@v2up.com
|
16
114
|
executables: []
|
17
115
|
extensions: []
|
18
116
|
extra_rdoc_files: []
|
19
117
|
files:
|
20
|
-
-
|
21
|
-
- ".rubocop.yml"
|
22
|
-
- CHANGELOG.md
|
23
|
-
- Gemfile
|
24
|
-
- LICENSE.txt
|
118
|
+
- MIT-LICENSE
|
25
119
|
- README.md
|
26
120
|
- Rakefile
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
121
|
+
- app/assets/config/beetle_reporter_manifest.js
|
122
|
+
- app/assets/stylesheets/beetle_reporter/application.css
|
123
|
+
- app/assets/stylesheets/beetle_reporter/home.css
|
124
|
+
- app/assets/stylesheets/beetle_reporter/reports.css
|
125
|
+
- app/assets/stylesheets/beetle_reporter/tailwind.min.css
|
126
|
+
- app/assets/stylesheets/scaffold.css
|
127
|
+
- app/controllers/beetle_reporter/application_controller.rb
|
128
|
+
- app/controllers/beetle_reporter/home_controller.rb
|
129
|
+
- app/controllers/beetle_reporter/reports_controller.rb
|
130
|
+
- app/helpers/beetle_reporter/application_helper.rb
|
131
|
+
- app/helpers/beetle_reporter/home_helper.rb
|
132
|
+
- app/helpers/beetle_reporter/reports_helper.rb
|
133
|
+
- app/jobs/beetle_reporter/application_job.rb
|
134
|
+
- app/mailers/beetle_reporter/application_mailer.rb
|
135
|
+
- app/models/beetle_reporter/application_record.rb
|
136
|
+
- app/models/beetle_reporter/report.rb
|
137
|
+
- app/views/beetle_reporter/home/index.html.haml
|
138
|
+
- app/views/beetle_reporter/reports/_form.html.haml
|
139
|
+
- app/views/beetle_reporter/reports/_report.html.haml
|
140
|
+
- app/views/beetle_reporter/reports/destroy.turbo_stream.haml
|
141
|
+
- app/views/beetle_reporter/reports/edit.html.haml
|
142
|
+
- app/views/beetle_reporter/reports/index.html.haml
|
143
|
+
- app/views/beetle_reporter/reports/new.html.haml
|
144
|
+
- app/views/beetle_reporter/reports/show.html.haml
|
145
|
+
- app/views/layouts/beetle_reporter/application.html.haml
|
146
|
+
- config/locales/beetle_reporter.yml
|
147
|
+
- config/routes.rb
|
148
|
+
- db/migrate/20211216073022_create_beetle_reporter_reports.rb
|
30
149
|
- lib/beetle_reporter.rb
|
150
|
+
- lib/beetle_reporter/configuration.rb
|
151
|
+
- lib/beetle_reporter/engine.rb
|
31
152
|
- lib/beetle_reporter/version.rb
|
153
|
+
- lib/tasks/beetle_reporter_tasks.rake
|
32
154
|
homepage: https://github.com/42up/beetle_reporter.git
|
33
155
|
licenses:
|
34
156
|
- MIT
|
@@ -44,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
166
|
requirements:
|
45
167
|
- - ">="
|
46
168
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
169
|
+
version: '0'
|
48
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
171
|
requirements:
|
50
172
|
- - ">="
|
@@ -54,5 +176,5 @@ requirements: []
|
|
54
176
|
rubygems_version: 3.2.22
|
55
177
|
signing_key:
|
56
178
|
specification_version: 4
|
57
|
-
summary:
|
179
|
+
summary: Summary of BeetleReporter.
|
58
180
|
test_files: []
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/CHANGELOG.md
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2021 42up
|
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
|
13
|
-
all 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
|
21
|
-
THE SOFTWARE.
|
data/beetle_reporter.gemspec
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/beetle_reporter/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "beetle_reporter"
|
7
|
-
spec.version = BeetleReporter::VERSION
|
8
|
-
spec.authors = ["42up"]
|
9
|
-
spec.email = ["foobar@v2up.com"]
|
10
|
-
|
11
|
-
spec.summary = "Write a short summary, because RubyGems requires one."
|
12
|
-
spec.description = "Write a longer description or delete this line."
|
13
|
-
spec.homepage = "https://github.com/42up/beetle_reporter.git"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.4.0"
|
16
|
-
|
17
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
|
18
|
-
|
19
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
-
spec.metadata["changelog_uri"] = spec.homepage
|
22
|
-
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
-
end
|
29
|
-
end
|
30
|
-
spec.bindir = "exe"
|
31
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = ["lib"]
|
33
|
-
|
34
|
-
# Uncomment to register a new dependency of your gem
|
35
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
36
|
-
|
37
|
-
# For more information and examples about making a new gem, checkout our
|
38
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
-
end
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "beetle_reporter"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|