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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +70 -16
  4. data/Rakefile +5 -9
  5. data/app/assets/config/beetle_reporter_manifest.js +1 -0
  6. data/app/assets/stylesheets/beetle_reporter/application.css +15 -0
  7. data/app/assets/stylesheets/beetle_reporter/home.css +4 -0
  8. data/app/assets/stylesheets/beetle_reporter/reports.css +4 -0
  9. data/app/assets/stylesheets/beetle_reporter/tailwind.min.css +1 -0
  10. data/app/assets/stylesheets/scaffold.css +80 -0
  11. data/app/controllers/beetle_reporter/application_controller.rb +11 -0
  12. data/app/controllers/beetle_reporter/home_controller.rb +8 -0
  13. data/app/controllers/beetle_reporter/reports_controller.rb +166 -0
  14. data/app/helpers/beetle_reporter/application_helper.rb +9 -0
  15. data/app/helpers/beetle_reporter/home_helper.rb +4 -0
  16. data/app/helpers/beetle_reporter/reports_helper.rb +4 -0
  17. data/app/jobs/beetle_reporter/application_job.rb +4 -0
  18. data/app/mailers/beetle_reporter/application_mailer.rb +6 -0
  19. data/app/models/beetle_reporter/application_record.rb +5 -0
  20. data/app/models/beetle_reporter/report.rb +123 -0
  21. data/app/views/beetle_reporter/home/index.html.haml +4 -0
  22. data/app/views/beetle_reporter/reports/_form.html.haml +14 -0
  23. data/app/views/beetle_reporter/reports/_report.html.haml +55 -0
  24. data/app/views/beetle_reporter/reports/destroy.turbo_stream.haml +1 -0
  25. data/app/views/beetle_reporter/reports/edit.html.haml +6 -0
  26. data/app/views/beetle_reporter/reports/index.html.haml +38 -0
  27. data/app/views/beetle_reporter/reports/new.html.haml +5 -0
  28. data/app/views/beetle_reporter/reports/show.html.haml +1 -0
  29. data/app/views/layouts/beetle_reporter/application.html.haml +22 -0
  30. data/config/locales/beetle_reporter.yml +18 -0
  31. data/config/routes.rb +13 -0
  32. data/db/migrate/20211216073022_create_beetle_reporter_reports.rb +20 -0
  33. data/lib/beetle_reporter/configuration.rb +9 -0
  34. data/lib/beetle_reporter/engine.rb +9 -0
  35. data/lib/beetle_reporter/version.rb +1 -3
  36. data/lib/beetle_reporter.rb +46 -4
  37. data/lib/tasks/beetle_reporter_tasks.rake +4 -0
  38. metadata +137 -15
  39. data/.rspec +0 -3
  40. data/.rubocop.yml +0 -13
  41. data/CHANGELOG.md +0 -5
  42. data/Gemfile +0 -12
  43. data/LICENSE.txt +0 -21
  44. data/beetle_reporter.gemspec +0 -39
  45. data/bin/console +0 -15
  46. data/bin/setup +0 -8
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module BeetleReporter
4
- VERSION = "0.1.0"
2
+ VERSION = '0.1.4'
5
3
  end
@@ -1,8 +1,50 @@
1
- # frozen_string_literal: true
1
+ require "beetle_reporter/version"
2
+ require "beetle_reporter/engine"
3
+ require 'beetle_reporter/configuration'
2
4
 
3
- require_relative "beetle_reporter/version"
5
+ require 'aasm'
6
+ require 'pagy'
7
+ require 'hamlit'
8
+ require 'discard'
9
+ require 'turbo-rails'
4
10
 
5
11
  module BeetleReporter
6
- class Error < StandardError; end
7
- # Your code goes here...
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
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :beetle_reporter do
3
+ # # Task goes here
4
+ # 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.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-15 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Write a longer description or delete this line.
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
- - ".rspec"
21
- - ".rubocop.yml"
22
- - CHANGELOG.md
23
- - Gemfile
24
- - LICENSE.txt
118
+ - MIT-LICENSE
25
119
  - README.md
26
120
  - Rakefile
27
- - beetle_reporter.gemspec
28
- - bin/console
29
- - bin/setup
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: 2.4.0
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: Write a short summary, because RubyGems requires one.
179
+ summary: Summary of BeetleReporter.
58
180
  test_files: []
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2021-12-15
4
-
5
- - Initial release
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in beetle_reporter.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.7"
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.
@@ -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__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here