care 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +0 -0
  4. data/.rubocop.yml +10 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +0 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +27 -0
  9. data/Gemfile.lock +206 -0
  10. data/README.md +40 -0
  11. data/Rakefile +12 -0
  12. data/bin/console +0 -0
  13. data/bin/setup +0 -0
  14. data/care.gemspec +49 -0
  15. data/exe/care +0 -0
  16. data/lib/care.rb +27 -0
  17. data/lib/care/auto_finder/by_ids.rb +24 -0
  18. data/lib/care/auto_finder/findable.rb +68 -0
  19. data/lib/care/auto_finder/finder_methods.rb +28 -0
  20. data/lib/care/auto_finder/paginateble.rb +30 -0
  21. data/lib/care/auto_finder/searchable.rb +56 -0
  22. data/lib/care/auto_finder/searcher.rb +101 -0
  23. data/lib/care/auto_finder/sortable.rb +41 -0
  24. data/lib/care/finder.rb +17 -0
  25. data/lib/care/jwt_service.rb +24 -0
  26. data/lib/care/rspec.rb +15 -0
  27. data/lib/care/seed.rb +21 -0
  28. data/lib/care/support/authorization_helper.rb +20 -0
  29. data/lib/care/support/error_collection.rb +43 -0
  30. data/lib/care/support/factory_bot.rb +5 -0
  31. data/lib/care/support/pagination.rb +9 -0
  32. data/lib/care/support/parameters.rb +39 -0
  33. data/lib/care/support/request_helper.rb +11 -0
  34. data/lib/care/version.rb +5 -0
  35. data/lib/generators/care/install/USAGE +19 -0
  36. data/lib/generators/care/install/install_generator.rb +33 -0
  37. data/lib/generators/care/install/templates/.env.local.example +62 -0
  38. data/lib/generators/care/install/templates/active_model_serializer.rb +1 -0
  39. data/lib/generators/care/install/templates/centrifuge.rb +4 -0
  40. data/lib/generators/care/install/templates/rswag-ui.rb +3 -0
  41. data/lib/generators/care/install/templates/rswag_api.rb +3 -0
  42. data/lib/generators/care/install/templates/swagger.yml +76 -0
  43. data/lib/generators/care/install/templates/swagger_helper.rb +24 -0
  44. data/lib/patch/action_controller/api.rb +17 -0
  45. data/lib/patch/action_controller/concerns/authentication.rb +50 -0
  46. data/lib/patch/action_controller/concerns/authorization.rb +46 -0
  47. data/lib/patch/action_controller/concerns/exception_handler.rb +67 -0
  48. data/lib/patch/action_controller/concerns/filter_sort_pagination.rb +98 -0
  49. metadata +321 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 14977cccfa8498c0a1f393c82b87cd82e17158f2d011a87cec06bfb1f985bf23
4
+ data.tar.gz: 925a627e30e5336da9831c25d81dfce770b824839f16a0339f3801e660974405
5
+ SHA512:
6
+ metadata.gz: 0c436afc6b630ee40142a5d0548114c32df40611d50b2697b427c3c1bab94db2d4f08059aac3b0b9d229df128f1c69ebfd6b25ead68a4b0de01df23f97999ddf
7
+ data.tar.gz: 79c72894f82c9af2a30a152b3137e285c2b105fc5cbd9af7fb36ff22466ccbd39e7f3c2954225d663f318b15639afc4d8099e713c2c6162b4f83d3feb2ce0357
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ /.idea/
data/.rspec ADDED
File without changes
@@ -0,0 +1,10 @@
1
+ Style/StringLiterals:
2
+ Enabled: true
3
+ EnforcedStyle: double_quotes
4
+
5
+ Style/StringLiteralsInInterpolation:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Layout/LineLength:
10
+ Max: 120
@@ -0,0 +1 @@
1
+ care
File without changes
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at v.mahanov@isoit.ru. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in care.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rubocop", "~> 0.80"
10
+ gem "actionpack"
11
+ gem "cancancan"
12
+ gem 'jwt'
13
+ gem 'devise'
14
+ gem 'kaminari'
15
+ gem "activerecord-import"
16
+
17
+ group :development, :test do
18
+ gem "faker"
19
+ gem 'rspec-rails', ">= 4.0.1"
20
+ gem "shoulda-matchers"
21
+ gem "factory_bot_rails", "~> 5.1", ">= 5.1.1"
22
+ end
23
+
24
+ group :development, :test do
25
+ gem 'dotenv-rails'
26
+ gem 'database_cleaner-active_record'
27
+ end
@@ -0,0 +1,206 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ care (0.1.0)
5
+ active_model_serializers (~> 0.10.10)
6
+ activerecord-import
7
+ cancancan
8
+ centrifuge (~> 1.2)
9
+ database_cleaner-active_record
10
+ dotenv-rails
11
+ factory_bot_rails (~> 5.1, >= 5.1.1)
12
+ faker
13
+ jwt
14
+ kaminari
15
+ prometheus-client (~> 1.0)
16
+ rspec-rails
17
+ shoulda-matchers
18
+
19
+ GEM
20
+ remote: https://rubygems.org/
21
+ specs:
22
+ actionpack (5.2.4.1)
23
+ actionview (= 5.2.4.1)
24
+ activesupport (= 5.2.4.1)
25
+ rack (~> 2.0, >= 2.0.8)
26
+ rack-test (>= 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.2.4.1)
30
+ activesupport (= 5.2.4.1)
31
+ builder (~> 3.1)
32
+ erubi (~> 1.4)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
35
+ active_model_serializers (0.10.10)
36
+ actionpack (>= 4.1, < 6.1)
37
+ activemodel (>= 4.1, < 6.1)
38
+ case_transform (>= 0.2)
39
+ jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
40
+ activemodel (5.2.4.1)
41
+ activesupport (= 5.2.4.1)
42
+ activerecord (5.2.4.1)
43
+ activemodel (= 5.2.4.1)
44
+ activesupport (= 5.2.4.1)
45
+ arel (>= 9.0)
46
+ activerecord-import (1.0.7)
47
+ activerecord (>= 3.2)
48
+ activesupport (5.2.4.1)
49
+ concurrent-ruby (~> 1.0, >= 1.0.2)
50
+ i18n (>= 0.7, < 2)
51
+ minitest (~> 5.1)
52
+ tzinfo (~> 1.1)
53
+ arel (9.0.0)
54
+ ast (2.4.1)
55
+ bcrypt (3.1.16)
56
+ builder (3.2.4)
57
+ cancancan (3.1.0)
58
+ case_transform (0.2)
59
+ activesupport
60
+ centrifuge (1.2.0)
61
+ httpclient
62
+ multi_json
63
+ concurrent-ruby (1.1.5)
64
+ crass (1.0.5)
65
+ database_cleaner (1.8.5)
66
+ database_cleaner-active_record (1.8.0)
67
+ activerecord
68
+ database_cleaner (~> 1.8.0)
69
+ devise (4.7.3)
70
+ bcrypt (~> 3.0)
71
+ orm_adapter (~> 0.1)
72
+ railties (>= 4.1.0)
73
+ responders
74
+ warden (~> 1.2.3)
75
+ diff-lcs (1.4.4)
76
+ dotenv (2.7.6)
77
+ dotenv-rails (2.7.6)
78
+ dotenv (= 2.7.6)
79
+ railties (>= 3.2)
80
+ erubi (1.9.0)
81
+ factory_bot (5.2.0)
82
+ activesupport (>= 4.2.0)
83
+ factory_bot_rails (5.2.0)
84
+ factory_bot (~> 5.2.0)
85
+ railties (>= 4.2.0)
86
+ faker (2.14.0)
87
+ i18n (>= 1.6, < 2)
88
+ httpclient (2.8.3)
89
+ i18n (1.7.1)
90
+ concurrent-ruby (~> 1.0)
91
+ jsonapi-renderer (0.2.2)
92
+ jwt (2.2.2)
93
+ kaminari (1.1.1)
94
+ activesupport (>= 4.1.0)
95
+ kaminari-actionview (= 1.1.1)
96
+ kaminari-activerecord (= 1.1.1)
97
+ kaminari-core (= 1.1.1)
98
+ kaminari-actionview (1.1.1)
99
+ actionview
100
+ kaminari-core (= 1.1.1)
101
+ kaminari-activerecord (1.1.1)
102
+ activerecord
103
+ kaminari-core (= 1.1.1)
104
+ kaminari-core (1.1.1)
105
+ loofah (2.4.0)
106
+ crass (~> 1.0.2)
107
+ nokogiri (>= 1.5.9)
108
+ method_source (1.0.0)
109
+ mini_portile2 (2.4.0)
110
+ minitest (5.13.0)
111
+ multi_json (1.15.0)
112
+ nokogiri (1.10.7)
113
+ mini_portile2 (~> 2.4.0)
114
+ orm_adapter (0.5.0)
115
+ parallel (1.19.2)
116
+ parser (2.7.2.0)
117
+ ast (~> 2.4.1)
118
+ prometheus-client (1.0.0)
119
+ rack (2.0.8)
120
+ rack-test (1.1.0)
121
+ rack (>= 1.0, < 3)
122
+ rails-dom-testing (2.0.3)
123
+ activesupport (>= 4.2.0)
124
+ nokogiri (>= 1.6)
125
+ rails-html-sanitizer (1.3.0)
126
+ loofah (~> 2.3)
127
+ railties (5.2.4.1)
128
+ actionpack (= 5.2.4.1)
129
+ activesupport (= 5.2.4.1)
130
+ method_source
131
+ rake (>= 0.8.7)
132
+ thor (>= 0.19.0, < 2.0)
133
+ rainbow (3.0.0)
134
+ rake (13.0.1)
135
+ regexp_parser (1.8.2)
136
+ responders (3.0.1)
137
+ actionpack (>= 5.0)
138
+ railties (>= 5.0)
139
+ rexml (3.2.4)
140
+ rspec (3.9.0)
141
+ rspec-core (~> 3.9.0)
142
+ rspec-expectations (~> 3.9.0)
143
+ rspec-mocks (~> 3.9.0)
144
+ rspec-core (3.9.3)
145
+ rspec-support (~> 3.9.3)
146
+ rspec-expectations (3.9.2)
147
+ diff-lcs (>= 1.2.0, < 2.0)
148
+ rspec-support (~> 3.9.0)
149
+ rspec-mocks (3.9.1)
150
+ diff-lcs (>= 1.2.0, < 2.0)
151
+ rspec-support (~> 3.9.0)
152
+ rspec-rails (4.0.1)
153
+ actionpack (>= 4.2)
154
+ activesupport (>= 4.2)
155
+ railties (>= 4.2)
156
+ rspec-core (~> 3.9)
157
+ rspec-expectations (~> 3.9)
158
+ rspec-mocks (~> 3.9)
159
+ rspec-support (~> 3.9)
160
+ rspec-support (3.9.3)
161
+ rubocop (0.93.1)
162
+ parallel (~> 1.10)
163
+ parser (>= 2.7.1.5)
164
+ rainbow (>= 2.2.2, < 4.0)
165
+ regexp_parser (>= 1.8)
166
+ rexml
167
+ rubocop-ast (>= 0.6.0)
168
+ ruby-progressbar (~> 1.7)
169
+ unicode-display_width (>= 1.4.0, < 2.0)
170
+ rubocop-ast (0.8.0)
171
+ parser (>= 2.7.1.5)
172
+ ruby-progressbar (1.10.1)
173
+ shoulda-matchers (4.4.1)
174
+ activesupport (>= 4.2.0)
175
+ thor (1.0.1)
176
+ thread_safe (0.3.6)
177
+ tzinfo (1.2.6)
178
+ thread_safe (~> 0.1)
179
+ unicode-display_width (1.7.0)
180
+ warden (1.2.8)
181
+ rack (>= 2.0.6)
182
+
183
+ PLATFORMS
184
+ ruby
185
+
186
+ DEPENDENCIES
187
+ actionpack
188
+ activerecord-import
189
+ bundler (~> 2.0)
190
+ cancancan
191
+ care!
192
+ database_cleaner-active_record
193
+ devise
194
+ dotenv-rails
195
+ factory_bot_rails (~> 5.1, >= 5.1.1)
196
+ faker
197
+ jwt
198
+ kaminari
199
+ rake (~> 13.0)
200
+ rspec (~> 3.0)
201
+ rspec-rails (>= 4.0.1)
202
+ rubocop (~> 0.80)
203
+ shoulda-matchers
204
+
205
+ BUNDLED WITH
206
+ 2.2.0.rc.2
@@ -0,0 +1,40 @@
1
+ # Care
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/care`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'care'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install care
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/care. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/care/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+
38
+ ## Code of Conduct
39
+
40
+ Everyone interacting in the Care project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/care/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
File without changes
File without changes
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require_relative "lib/care/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "care"
8
+ spec.version = Care::VERSION
9
+ spec.authors = ["Валерий Маханов"]
10
+ spec.email = ["v.mahanov@isoit.ru"]
11
+
12
+ spec.summary = "Care"
13
+ spec.description = "Common concerns for docshell microservices"
14
+ spec.homepage = "https://gitlab.isoit.ru/ruby/sgrc/care"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
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 { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'jwt'
33
+ spec.add_dependency 'activerecord-import'
34
+ spec.add_dependency 'active_model_serializers', '~> 0.10.10'
35
+ spec.add_dependency 'centrifuge', '~> 1.2'
36
+ spec.add_dependency 'prometheus-client', '~> 1.0'
37
+ spec.add_dependency 'cancancan'
38
+ spec.add_dependency 'kaminari'
39
+ spec.add_dependency 'faker'
40
+ spec.add_dependency 'rspec-rails'
41
+ spec.add_dependency 'shoulda-matchers'
42
+ spec.add_dependency 'factory_bot_rails', "~> 5.1", ">= 5.1.1"
43
+ spec.add_dependency 'dotenv-rails'
44
+ spec.add_dependency 'database_cleaner-active_record'
45
+
46
+ spec.add_development_dependency 'bundler', '~> 2.0'
47
+ spec.add_development_dependency 'rake', '~> 10.0'
48
+ spec.add_development_dependency 'rspec', '~> 3.0'
49
+ end