sober_swag 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +33 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +7 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +92 -0
- data/LICENSE.txt +21 -0
- data/README.md +7 -0
- data/Rakefile +8 -0
- data/bin/console +38 -0
- data/bin/setup +8 -0
- data/example/.gitignore +24 -0
- data/example/.ruby-version +1 -0
- data/example/Gemfile +42 -0
- data/example/Gemfile.lock +212 -0
- data/example/README.md +24 -0
- data/example/Rakefile +6 -0
- data/example/app/controllers/application_controller.rb +2 -0
- data/example/app/controllers/concerns/.keep +0 -0
- data/example/app/controllers/people_controller.rb +74 -0
- data/example/app/jobs/application_job.rb +7 -0
- data/example/app/models/application_record.rb +3 -0
- data/example/app/models/concerns/.keep +0 -0
- data/example/app/models/person.rb +2 -0
- data/example/bin/bundle +114 -0
- data/example/bin/rails +9 -0
- data/example/bin/rake +9 -0
- data/example/bin/setup +33 -0
- data/example/bin/spring +17 -0
- data/example/config/application.rb +37 -0
- data/example/config/boot.rb +4 -0
- data/example/config/credentials.yml.enc +1 -0
- data/example/config/database.yml +25 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +44 -0
- data/example/config/environments/production.rb +91 -0
- data/example/config/environments/test.rb +38 -0
- data/example/config/initializers/application_controller_renderer.rb +8 -0
- data/example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/config/initializers/cors.rb +16 -0
- data/example/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/config/initializers/inflections.rb +16 -0
- data/example/config/initializers/mime_types.rb +4 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/en.yml +33 -0
- data/example/config/puma.rb +38 -0
- data/example/config/routes.rb +6 -0
- data/example/config/spring.rb +6 -0
- data/example/config.ru +5 -0
- data/example/db/migrate/20200311152021_create_people.rb +12 -0
- data/example/db/schema.rb +23 -0
- data/example/db/seeds.rb +7 -0
- data/example/lib/tasks/.keep +0 -0
- data/example/log/.keep +0 -0
- data/example/person.json +4 -0
- data/example/public/robots.txt +1 -0
- data/example/test/controllers/.keep +0 -0
- data/example/test/fixtures/.keep +0 -0
- data/example/test/fixtures/files/.keep +0 -0
- data/example/test/fixtures/people.yml +11 -0
- data/example/test/integration/.keep +0 -0
- data/example/test/models/.keep +0 -0
- data/example/test/models/person_test.rb +7 -0
- data/example/test/test_helper.rb +13 -0
- data/example/tmp/.keep +0 -0
- data/example/vendor/.keep +0 -0
- data/lib/sober_swag/blueprint/field.rb +36 -0
- data/lib/sober_swag/blueprint/field_syntax.rb +17 -0
- data/lib/sober_swag/blueprint/view.rb +44 -0
- data/lib/sober_swag/blueprint.rb +113 -0
- data/lib/sober_swag/compiler/error.rb +5 -0
- data/lib/sober_swag/compiler/path.rb +80 -0
- data/lib/sober_swag/compiler/paths.rb +54 -0
- data/lib/sober_swag/compiler/type.rb +235 -0
- data/lib/sober_swag/compiler.rb +107 -0
- data/lib/sober_swag/controller/route.rb +136 -0
- data/lib/sober_swag/controller/undefined_body_error.rb +6 -0
- data/lib/sober_swag/controller/undefined_path_error.rb +6 -0
- data/lib/sober_swag/controller/undefined_query_error.rb +6 -0
- data/lib/sober_swag/controller.rb +157 -0
- data/lib/sober_swag/nodes/array.rb +30 -0
- data/lib/sober_swag/nodes/attribute.rb +31 -0
- data/lib/sober_swag/nodes/base.rb +51 -0
- data/lib/sober_swag/nodes/binary.rb +44 -0
- data/lib/sober_swag/nodes/enum.rb +28 -0
- data/lib/sober_swag/nodes/list.rb +40 -0
- data/lib/sober_swag/nodes/nullable_primitive.rb +6 -0
- data/lib/sober_swag/nodes/object.rb +12 -0
- data/lib/sober_swag/nodes/one_of.rb +12 -0
- data/lib/sober_swag/nodes/primitive.rb +29 -0
- data/lib/sober_swag/nodes/sum.rb +6 -0
- data/lib/sober_swag/nodes.rb +20 -0
- data/lib/sober_swag/parser.rb +73 -0
- data/lib/sober_swag/path/integer.rb +21 -0
- data/lib/sober_swag/path/lit.rb +41 -0
- data/lib/sober_swag/path/literal.rb +29 -0
- data/lib/sober_swag/path/param.rb +33 -0
- data/lib/sober_swag/path.rb +8 -0
- data/lib/sober_swag/serializer/array.rb +21 -0
- data/lib/sober_swag/serializer/base.rb +38 -0
- data/lib/sober_swag/serializer/conditional.rb +49 -0
- data/lib/sober_swag/serializer/field_list.rb +44 -0
- data/lib/sober_swag/serializer/mapped.rb +29 -0
- data/lib/sober_swag/serializer/optional.rb +29 -0
- data/lib/sober_swag/serializer/primitive.rb +15 -0
- data/lib/sober_swag/serializer.rb +23 -0
- data/lib/sober_swag/types.rb +5 -0
- data/lib/sober_swag/version.rb +5 -0
- data/lib/sober_swag.rb +29 -0
- data/sober_swag.gemspec +40 -0
- metadata +269 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e58f142c7c7e5716d0d023844846ffcac306ff45f6ab84650cdf33003898ff83
|
4
|
+
data.tar.gz: 33e35fb1910ebe36f1618b2091e0cfb7762dbadbebaba046c8a67d3f58038e24
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 747f4d9f9c0750de1a8109fb443bbe21df72929f74f447ce1473d676b2dcbc952c52dcc7731c6cd097d6f06452220ee808b883d4529da458b89baa2dde84ee76
|
7
|
+
data.tar.gz: 839284d0a57c363348e486320256c3f4d097b4c193eab3914416037a178a4a32e7b07e236e72b77376a68fce9715ffe62898a2b8ef7659fb9f2ccbf3a7b01378
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
|
+
# uses: ruby/setup-ruby@v1
|
27
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
28
|
+
with:
|
29
|
+
ruby-version: 2.7
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sober_swag (0.1.0)
|
5
|
+
activesupport
|
6
|
+
dry-struct (~> 1.0)
|
7
|
+
dry-types (~> 1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.0.2.1)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 0.7, < 2)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
zeitwerk (~> 2.2)
|
18
|
+
coderay (1.1.2)
|
19
|
+
concurrent-ruby (1.1.6)
|
20
|
+
diff-lcs (1.3)
|
21
|
+
docile (1.3.2)
|
22
|
+
dry-configurable (0.11.3)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
dry-core (~> 0.4, >= 0.4.7)
|
25
|
+
dry-equalizer (~> 0.2)
|
26
|
+
dry-container (0.7.2)
|
27
|
+
concurrent-ruby (~> 1.0)
|
28
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
29
|
+
dry-core (0.4.9)
|
30
|
+
concurrent-ruby (~> 1.0)
|
31
|
+
dry-equalizer (0.3.0)
|
32
|
+
dry-inflector (0.2.0)
|
33
|
+
dry-logic (1.0.6)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
dry-core (~> 0.2)
|
36
|
+
dry-equalizer (~> 0.2)
|
37
|
+
dry-struct (1.3.0)
|
38
|
+
dry-core (~> 0.4, >= 0.4.4)
|
39
|
+
dry-equalizer (~> 0.3)
|
40
|
+
dry-types (~> 1.3)
|
41
|
+
ice_nine (~> 0.11)
|
42
|
+
dry-types (1.4.0)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
dry-container (~> 0.3)
|
45
|
+
dry-core (~> 0.4, >= 0.4.4)
|
46
|
+
dry-equalizer (~> 0.3)
|
47
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
48
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
49
|
+
i18n (1.8.2)
|
50
|
+
concurrent-ruby (~> 1.0)
|
51
|
+
ice_nine (0.11.2)
|
52
|
+
method_source (0.9.2)
|
53
|
+
minitest (5.14.0)
|
54
|
+
pry (0.12.2)
|
55
|
+
coderay (~> 1.1.0)
|
56
|
+
method_source (~> 0.9.0)
|
57
|
+
rake (13.0.1)
|
58
|
+
rspec (3.9.0)
|
59
|
+
rspec-core (~> 3.9.0)
|
60
|
+
rspec-expectations (~> 3.9.0)
|
61
|
+
rspec-mocks (~> 3.9.0)
|
62
|
+
rspec-core (3.9.1)
|
63
|
+
rspec-support (~> 3.9.1)
|
64
|
+
rspec-expectations (3.9.0)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.9.0)
|
67
|
+
rspec-mocks (3.9.1)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.9.0)
|
70
|
+
rspec-support (3.9.2)
|
71
|
+
simplecov (0.18.5)
|
72
|
+
docile (~> 1.1)
|
73
|
+
simplecov-html (~> 0.11)
|
74
|
+
simplecov-html (0.12.2)
|
75
|
+
thread_safe (0.3.6)
|
76
|
+
tzinfo (1.2.6)
|
77
|
+
thread_safe (~> 0.1)
|
78
|
+
zeitwerk (2.3.0)
|
79
|
+
|
80
|
+
PLATFORMS
|
81
|
+
ruby
|
82
|
+
|
83
|
+
DEPENDENCIES
|
84
|
+
bundler (~> 2.0)
|
85
|
+
pry
|
86
|
+
rake (~> 13.0)
|
87
|
+
rspec (~> 3.0)
|
88
|
+
simplecov
|
89
|
+
sober_swag!
|
90
|
+
|
91
|
+
BUNDLED WITH
|
92
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Anthony Super
|
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/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# SoberSwag
|
2
|
+
|
3
|
+
![Ruby Test Status](https://github.com/SonderMindOrg/sober_swag/workflows/Ruby/badge.svg?branch=master)
|
4
|
+
|
5
|
+
SoberSwag is a combination of [Dry-Types](https://dry-rb.org/gems/dry-types/1.2/) and [Swagger](https://swagger.io/) that makes your Rails APIs more awesome.
|
6
|
+
Other tools generate documenation from a DSL.
|
7
|
+
This generates documentation from *types*, which (conveniently) also lets you get supercharged strong-params-on-steroids.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby -W:no-experimental
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'sober_swag'
|
6
|
+
require 'dry-struct'
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
module Types
|
11
|
+
include Dry.Types()
|
12
|
+
end
|
13
|
+
|
14
|
+
class Bio < Dry::Struct
|
15
|
+
attribute :name, Types::String
|
16
|
+
end
|
17
|
+
|
18
|
+
class Person < Dry::Struct
|
19
|
+
attribute :name, Types::String
|
20
|
+
attribute :age, Types::Integer.constrained(gt: 0).optional | Types::String.optional
|
21
|
+
attribute? :mood, Types::String
|
22
|
+
attribute :bio, Bio
|
23
|
+
|
24
|
+
attribute :foo do
|
25
|
+
attribute :bar, Types::String
|
26
|
+
attribute :baz, Types::String.optional
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class PersonSearch < Dry::Struct
|
31
|
+
attribute? :name, Types::String
|
32
|
+
attribute? :age, Types::Integer
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
37
|
+
require "pry"
|
38
|
+
Pry.start
|
data/bin/setup
ADDED
data/example/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
/db/*.sqlite3-*
|
14
|
+
|
15
|
+
# Ignore all logfiles and tempfiles.
|
16
|
+
/log/*
|
17
|
+
/tmp/*
|
18
|
+
!/log/.keep
|
19
|
+
!/tmp/.keep
|
20
|
+
|
21
|
+
.byebug_history
|
22
|
+
|
23
|
+
# Ignore master key for decrypting credentials and more.
|
24
|
+
/config/master.key
|
@@ -0,0 +1 @@
|
|
1
|
+
2.7.0
|
data/example/Gemfile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
ruby '2.7.0'
|
5
|
+
|
6
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
7
|
+
gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
|
8
|
+
# Use sqlite3 as the database for Active Record
|
9
|
+
gem 'sqlite3', '~> 1.4'
|
10
|
+
# Use Puma as the app server
|
11
|
+
gem 'puma', '~> 4.1'
|
12
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
13
|
+
# gem 'jbuilder', '~> 2.7'
|
14
|
+
# Use Active Model has_secure_password
|
15
|
+
# gem 'bcrypt', '~> 3.1.7'
|
16
|
+
|
17
|
+
# Reduces boot times through caching; required in config/boot.rb
|
18
|
+
gem 'bootsnap', '>= 1.4.2', require: false
|
19
|
+
|
20
|
+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
|
21
|
+
# gem 'rack-cors'
|
22
|
+
|
23
|
+
gem 'sober_swag', path: '..'
|
24
|
+
|
25
|
+
group :development, :test do
|
26
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
27
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
28
|
+
|
29
|
+
gem 'dry-types-rails'
|
30
|
+
|
31
|
+
gem 'pry'
|
32
|
+
end
|
33
|
+
|
34
|
+
group :development do
|
35
|
+
gem 'listen', '>= 3.0.5', '< 3.2'
|
36
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
37
|
+
gem 'spring'
|
38
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
42
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
@@ -0,0 +1,212 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
sober_swag (0.1.0)
|
5
|
+
activesupport
|
6
|
+
dry-struct (~> 1.0)
|
7
|
+
dry-types (~> 1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actioncable (6.0.2.1)
|
13
|
+
actionpack (= 6.0.2.1)
|
14
|
+
nio4r (~> 2.0)
|
15
|
+
websocket-driver (>= 0.6.1)
|
16
|
+
actionmailbox (6.0.2.1)
|
17
|
+
actionpack (= 6.0.2.1)
|
18
|
+
activejob (= 6.0.2.1)
|
19
|
+
activerecord (= 6.0.2.1)
|
20
|
+
activestorage (= 6.0.2.1)
|
21
|
+
activesupport (= 6.0.2.1)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
actionmailer (6.0.2.1)
|
24
|
+
actionpack (= 6.0.2.1)
|
25
|
+
actionview (= 6.0.2.1)
|
26
|
+
activejob (= 6.0.2.1)
|
27
|
+
mail (~> 2.5, >= 2.5.4)
|
28
|
+
rails-dom-testing (~> 2.0)
|
29
|
+
actionpack (6.0.2.1)
|
30
|
+
actionview (= 6.0.2.1)
|
31
|
+
activesupport (= 6.0.2.1)
|
32
|
+
rack (~> 2.0, >= 2.0.8)
|
33
|
+
rack-test (>= 0.6.3)
|
34
|
+
rails-dom-testing (~> 2.0)
|
35
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
+
actiontext (6.0.2.1)
|
37
|
+
actionpack (= 6.0.2.1)
|
38
|
+
activerecord (= 6.0.2.1)
|
39
|
+
activestorage (= 6.0.2.1)
|
40
|
+
activesupport (= 6.0.2.1)
|
41
|
+
nokogiri (>= 1.8.5)
|
42
|
+
actionview (6.0.2.1)
|
43
|
+
activesupport (= 6.0.2.1)
|
44
|
+
builder (~> 3.1)
|
45
|
+
erubi (~> 1.4)
|
46
|
+
rails-dom-testing (~> 2.0)
|
47
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
+
activejob (6.0.2.1)
|
49
|
+
activesupport (= 6.0.2.1)
|
50
|
+
globalid (>= 0.3.6)
|
51
|
+
activemodel (6.0.2.1)
|
52
|
+
activesupport (= 6.0.2.1)
|
53
|
+
activerecord (6.0.2.1)
|
54
|
+
activemodel (= 6.0.2.1)
|
55
|
+
activesupport (= 6.0.2.1)
|
56
|
+
activestorage (6.0.2.1)
|
57
|
+
actionpack (= 6.0.2.1)
|
58
|
+
activejob (= 6.0.2.1)
|
59
|
+
activerecord (= 6.0.2.1)
|
60
|
+
marcel (~> 0.3.1)
|
61
|
+
activesupport (6.0.2.1)
|
62
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
63
|
+
i18n (>= 0.7, < 2)
|
64
|
+
minitest (~> 5.1)
|
65
|
+
tzinfo (~> 1.1)
|
66
|
+
zeitwerk (~> 2.2)
|
67
|
+
bootsnap (1.4.6)
|
68
|
+
msgpack (~> 1.0)
|
69
|
+
builder (3.2.4)
|
70
|
+
byebug (11.1.1)
|
71
|
+
coderay (1.1.2)
|
72
|
+
concurrent-ruby (1.1.6)
|
73
|
+
crass (1.0.6)
|
74
|
+
dry-configurable (0.11.3)
|
75
|
+
concurrent-ruby (~> 1.0)
|
76
|
+
dry-core (~> 0.4, >= 0.4.7)
|
77
|
+
dry-equalizer (~> 0.2)
|
78
|
+
dry-container (0.7.2)
|
79
|
+
concurrent-ruby (~> 1.0)
|
80
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
81
|
+
dry-core (0.4.9)
|
82
|
+
concurrent-ruby (~> 1.0)
|
83
|
+
dry-equalizer (0.3.0)
|
84
|
+
dry-inflector (0.2.0)
|
85
|
+
dry-logic (1.0.6)
|
86
|
+
concurrent-ruby (~> 1.0)
|
87
|
+
dry-core (~> 0.2)
|
88
|
+
dry-equalizer (~> 0.2)
|
89
|
+
dry-struct (1.3.0)
|
90
|
+
dry-core (~> 0.4, >= 0.4.4)
|
91
|
+
dry-equalizer (~> 0.3)
|
92
|
+
dry-types (~> 1.3)
|
93
|
+
ice_nine (~> 0.11)
|
94
|
+
dry-types (1.4.0)
|
95
|
+
concurrent-ruby (~> 1.0)
|
96
|
+
dry-container (~> 0.3)
|
97
|
+
dry-core (~> 0.4, >= 0.4.4)
|
98
|
+
dry-equalizer (~> 0.3)
|
99
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
100
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
101
|
+
dry-types-rails (0.3.4)
|
102
|
+
dry-types (>= 0.8.1)
|
103
|
+
rails (>= 3)
|
104
|
+
erubi (1.9.0)
|
105
|
+
ffi (1.12.2)
|
106
|
+
globalid (0.4.2)
|
107
|
+
activesupport (>= 4.2.0)
|
108
|
+
i18n (1.8.2)
|
109
|
+
concurrent-ruby (~> 1.0)
|
110
|
+
ice_nine (0.11.2)
|
111
|
+
listen (3.1.5)
|
112
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
113
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
114
|
+
ruby_dep (~> 1.2)
|
115
|
+
loofah (2.4.0)
|
116
|
+
crass (~> 1.0.2)
|
117
|
+
nokogiri (>= 1.5.9)
|
118
|
+
mail (2.7.1)
|
119
|
+
mini_mime (>= 0.1.1)
|
120
|
+
marcel (0.3.3)
|
121
|
+
mimemagic (~> 0.3.2)
|
122
|
+
method_source (0.9.2)
|
123
|
+
mimemagic (0.3.4)
|
124
|
+
mini_mime (1.0.2)
|
125
|
+
mini_portile2 (2.4.0)
|
126
|
+
minitest (5.14.0)
|
127
|
+
msgpack (1.3.3)
|
128
|
+
nio4r (2.5.2)
|
129
|
+
nokogiri (1.10.9)
|
130
|
+
mini_portile2 (~> 2.4.0)
|
131
|
+
pry (0.12.2)
|
132
|
+
coderay (~> 1.1.0)
|
133
|
+
method_source (~> 0.9.0)
|
134
|
+
puma (4.3.3)
|
135
|
+
nio4r (~> 2.0)
|
136
|
+
rack (2.2.2)
|
137
|
+
rack-test (1.1.0)
|
138
|
+
rack (>= 1.0, < 3)
|
139
|
+
rails (6.0.2.1)
|
140
|
+
actioncable (= 6.0.2.1)
|
141
|
+
actionmailbox (= 6.0.2.1)
|
142
|
+
actionmailer (= 6.0.2.1)
|
143
|
+
actionpack (= 6.0.2.1)
|
144
|
+
actiontext (= 6.0.2.1)
|
145
|
+
actionview (= 6.0.2.1)
|
146
|
+
activejob (= 6.0.2.1)
|
147
|
+
activemodel (= 6.0.2.1)
|
148
|
+
activerecord (= 6.0.2.1)
|
149
|
+
activestorage (= 6.0.2.1)
|
150
|
+
activesupport (= 6.0.2.1)
|
151
|
+
bundler (>= 1.3.0)
|
152
|
+
railties (= 6.0.2.1)
|
153
|
+
sprockets-rails (>= 2.0.0)
|
154
|
+
rails-dom-testing (2.0.3)
|
155
|
+
activesupport (>= 4.2.0)
|
156
|
+
nokogiri (>= 1.6)
|
157
|
+
rails-html-sanitizer (1.3.0)
|
158
|
+
loofah (~> 2.3)
|
159
|
+
railties (6.0.2.1)
|
160
|
+
actionpack (= 6.0.2.1)
|
161
|
+
activesupport (= 6.0.2.1)
|
162
|
+
method_source
|
163
|
+
rake (>= 0.8.7)
|
164
|
+
thor (>= 0.20.3, < 2.0)
|
165
|
+
rake (13.0.1)
|
166
|
+
rb-fsevent (0.10.3)
|
167
|
+
rb-inotify (0.10.1)
|
168
|
+
ffi (~> 1.0)
|
169
|
+
ruby_dep (1.5.0)
|
170
|
+
spring (2.1.0)
|
171
|
+
spring-watcher-listen (2.0.1)
|
172
|
+
listen (>= 2.7, < 4.0)
|
173
|
+
spring (>= 1.2, < 3.0)
|
174
|
+
sprockets (4.0.0)
|
175
|
+
concurrent-ruby (~> 1.0)
|
176
|
+
rack (> 1, < 3)
|
177
|
+
sprockets-rails (3.2.1)
|
178
|
+
actionpack (>= 4.0)
|
179
|
+
activesupport (>= 4.0)
|
180
|
+
sprockets (>= 3.0.0)
|
181
|
+
sqlite3 (1.4.2)
|
182
|
+
thor (1.0.1)
|
183
|
+
thread_safe (0.3.6)
|
184
|
+
tzinfo (1.2.6)
|
185
|
+
thread_safe (~> 0.1)
|
186
|
+
websocket-driver (0.7.1)
|
187
|
+
websocket-extensions (>= 0.1.0)
|
188
|
+
websocket-extensions (0.1.4)
|
189
|
+
zeitwerk (2.3.0)
|
190
|
+
|
191
|
+
PLATFORMS
|
192
|
+
ruby
|
193
|
+
|
194
|
+
DEPENDENCIES
|
195
|
+
bootsnap (>= 1.4.2)
|
196
|
+
byebug
|
197
|
+
dry-types-rails
|
198
|
+
listen (>= 3.0.5, < 3.2)
|
199
|
+
pry
|
200
|
+
puma (~> 4.1)
|
201
|
+
rails (~> 6.0.2, >= 6.0.2.1)
|
202
|
+
sober_swag!
|
203
|
+
spring
|
204
|
+
spring-watcher-listen (~> 2.0.0)
|
205
|
+
sqlite3 (~> 1.4)
|
206
|
+
tzinfo-data
|
207
|
+
|
208
|
+
RUBY VERSION
|
209
|
+
ruby 2.7.0p0
|
210
|
+
|
211
|
+
BUNDLED WITH
|
212
|
+
2.1.2
|
data/example/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
data/example/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class PeopleController < ApplicationController
|
2
|
+
|
3
|
+
include SoberSwag::Controller
|
4
|
+
|
5
|
+
before_action :load_person, only: %i[show update]
|
6
|
+
|
7
|
+
|
8
|
+
PersonBodyParams = SoberSwag.struct do
|
9
|
+
attribute :first_name, SoberSwag::Types::String
|
10
|
+
attribute :last_name, SoberSwag::Types::String
|
11
|
+
attribute? :date_of_birth, SoberSwag::Types::Params::DateTime.optional
|
12
|
+
end
|
13
|
+
|
14
|
+
PersonParams = SoberSwag.struct do
|
15
|
+
attribute :person, PersonBodyParams
|
16
|
+
end
|
17
|
+
|
18
|
+
PersonSerializer = SoberSwag::Blueprint.define do
|
19
|
+
field :id, primitive(:Integer)
|
20
|
+
field :first_name, primitive(:String)
|
21
|
+
field :last_name, primitive(:String)
|
22
|
+
end
|
23
|
+
|
24
|
+
define :post, :create, '/people/' do
|
25
|
+
request_body(PersonParams)
|
26
|
+
response(:ok, 'the person created', PersonSerializer)
|
27
|
+
end
|
28
|
+
def create
|
29
|
+
p = Person.create!(parsed_body.to_h)
|
30
|
+
respond!(:ok, p)
|
31
|
+
end
|
32
|
+
|
33
|
+
define :patch, :update, '/people/{id}' do
|
34
|
+
request_body(PersonParams)
|
35
|
+
path_params { attribute :id, Types::Params::Integer }
|
36
|
+
response(:ok, 'the person updated', PersonSerializer)
|
37
|
+
end
|
38
|
+
def update
|
39
|
+
if @person.update(parsed_body.to_h)
|
40
|
+
respond!(:ok, @person)
|
41
|
+
else
|
42
|
+
render json: @person.errors, status: :unprocessable_entity
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
define :get, :index, '/people/' do
|
47
|
+
query_params do
|
48
|
+
attribute? :first_name, Types::String
|
49
|
+
attribute? :last_name, Types::String
|
50
|
+
end
|
51
|
+
response(:ok, 'all the people', PersonSerializer.new.array)
|
52
|
+
end
|
53
|
+
|
54
|
+
def index
|
55
|
+
@people = Person.all
|
56
|
+
@people = @people.where('first_name ILIKE ?', "%#{parsed_query.first_name}%") if parsed_query.first_name
|
57
|
+
@people = @people.where('last_name ILIKE ?', "%#{parsed_query.last_name}%") if parsed_query.last_name
|
58
|
+
respond!(:ok, @people)
|
59
|
+
end
|
60
|
+
|
61
|
+
define :get, :show, '/people/{id}' do
|
62
|
+
path_params do
|
63
|
+
attribute :id, Types::Params::Integer
|
64
|
+
end
|
65
|
+
response(:ok, 'the person requested', PersonSerializer.new)
|
66
|
+
end
|
67
|
+
def show
|
68
|
+
respond!(:ok, @person)
|
69
|
+
end
|
70
|
+
|
71
|
+
def load_person
|
72
|
+
@person = Person.find(parsed_path.id)
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
2
|
+
# Automatically retry jobs that encountered a deadlock
|
3
|
+
# retry_on ActiveRecord::Deadlocked
|
4
|
+
|
5
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
6
|
+
# discard_on ActiveJob::DeserializationError
|
7
|
+
end
|
File without changes
|