setup and rubocop corrections
This commit is contained in:
parent
f09ea5faeb
commit
904a071fc0
17
.editorconfig
Normal file
17
.editorconfig
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
# Trailing whitespace is significant in markdown files.
|
||||||
|
[*.md]
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -22,3 +22,7 @@
|
|||||||
|
|
||||||
# Ignore master key for decrypting credentials and more.
|
# Ignore master key for decrypting credentials and more.
|
||||||
/config/master.key
|
/config/master.key
|
||||||
|
|
||||||
|
# Ignore application configuration
|
||||||
|
/config/application.yml
|
||||||
|
coverage/
|
||||||
|
74
.rubocop.yml
Normal file
74
.rubocop.yml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
AllCops:
|
||||||
|
Exclude:
|
||||||
|
- db/schema.rb
|
||||||
|
- db/seeds.rb
|
||||||
|
- bin/**/*
|
||||||
|
- vendor/assets/**/*
|
||||||
|
|
||||||
|
Layout/EmptyLines:
|
||||||
|
Exclude:
|
||||||
|
- config/initializers/sorcery.rb
|
||||||
|
|
||||||
|
Layout/ExtraSpacing:
|
||||||
|
Exclude:
|
||||||
|
- db/migrate/**/*
|
||||||
|
|
||||||
|
Layout/IndentationConsistency:
|
||||||
|
EnforcedStyle: rails
|
||||||
|
Exclude:
|
||||||
|
- config/routes.rb
|
||||||
|
|
||||||
|
Layout/SpaceBeforeFirstArg:
|
||||||
|
Exclude:
|
||||||
|
- config/routes.rb
|
||||||
|
|
||||||
|
Lint/Debugger:
|
||||||
|
AutoCorrect: False
|
||||||
|
|
||||||
|
Style/AndOr:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Style/ClassAndModuleChildren:
|
||||||
|
Exclude:
|
||||||
|
- test/test_helper.rb
|
||||||
|
|
||||||
|
Style/Documentation:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Style/MethodDefParentheses:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Style/StringLiterals:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Style/StructInheritance:
|
||||||
|
Exclude:
|
||||||
|
- app/policies/**/*
|
||||||
|
|
||||||
|
Metrics/AbcSize:
|
||||||
|
Exclude:
|
||||||
|
- db/migrate/**/*
|
||||||
|
Max: 20
|
||||||
|
|
||||||
|
Metrics/BlockLength:
|
||||||
|
Exclude:
|
||||||
|
- lib/tasks/auto_annotate_models.rake
|
||||||
|
- config/routes.rb
|
||||||
|
|
||||||
|
Metrics/LineLength:
|
||||||
|
Max: 110
|
||||||
|
Exclude:
|
||||||
|
- Rakefile
|
||||||
|
- Gemfile
|
||||||
|
- config/**/*
|
||||||
|
- lib/tasks/**/*
|
||||||
|
- test/test_helper.rb
|
||||||
|
|
||||||
|
Metrics/MethodLength:
|
||||||
|
Exclude:
|
||||||
|
- db/migrate/*
|
||||||
|
ExcludedMethods:
|
||||||
|
- base_attributes
|
||||||
|
|
||||||
|
Rails:
|
||||||
|
Enabled: true
|
31
Gemfile
31
Gemfile
@ -1,23 +1,50 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||||
|
|
||||||
ruby '2.5.3'
|
ruby '2.5.3'
|
||||||
|
|
||||||
|
gem 'figaro', '~> 1.1'
|
||||||
gem 'rails', '~> 5.2.1'
|
gem 'rails', '~> 5.2.1'
|
||||||
|
|
||||||
gem 'bcrypt', '~> 3.1.7'
|
gem 'bcrypt', '~> 3.1.7'
|
||||||
gem 'bootsnap', '>= 1.1.0', require: false
|
gem 'bootsnap', '>= 1.1.0', require: false
|
||||||
gem 'jbuilder', '~> 2.5'
|
gem 'jbuilder', '~> 2.5'
|
||||||
|
gem 'json', '~> 2.1'
|
||||||
|
gem 'jwt', '2.1.0'
|
||||||
gem 'puma', '~> 3.11'
|
gem 'puma', '~> 3.11'
|
||||||
|
gem 'pundit', '~> 2.0'
|
||||||
gem 'rack-cors'
|
gem 'rack-cors'
|
||||||
gem 'sqlite3'
|
gem 'sqlite3'
|
||||||
|
gem 'validates_email_format_of'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
gem 'awesome_print'
|
||||||
|
gem 'binding_of_caller'
|
||||||
|
gem 'brakeman'
|
||||||
|
gem 'byebug', platforms: %i[mri mingw x64_mingw]
|
||||||
|
gem 'guard', github: 'guard/guard'
|
||||||
|
gem 'guard-brakeman'
|
||||||
|
gem 'guard-minitest'
|
||||||
|
gem 'guard-rubocop'
|
||||||
|
gem 'guard-shell'
|
||||||
|
gem 'guard-spring'
|
||||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||||
|
gem 'minitest-reporters', github: 'kern/minitest-reporters'
|
||||||
|
gem 'policy-assertions'
|
||||||
|
gem 'pry-byebug'
|
||||||
|
gem 'pry-rails'
|
||||||
|
gem 'rails-erd'
|
||||||
|
gem 'rubocop', '~> 0.59'
|
||||||
|
gem 'simplecov', github: 'colszowka/simplecov', require: false
|
||||||
gem 'spring'
|
gem 'spring'
|
||||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :development do
|
||||||
|
gem 'annotate', require: false
|
||||||
|
end
|
||||||
|
|
||||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
|
||||||
|
145
Gemfile.lock
145
Gemfile.lock
@ -1,3 +1,36 @@
|
|||||||
|
GIT
|
||||||
|
remote: https://github.com/colszowka/simplecov.git
|
||||||
|
revision: 994dbff2780abe420f63036a7f674c296395b6c0
|
||||||
|
specs:
|
||||||
|
simplecov (0.16.1)
|
||||||
|
docile (~> 1.1)
|
||||||
|
json (>= 1.8, < 3)
|
||||||
|
simplecov-html (~> 0.10.0)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/guard/guard.git
|
||||||
|
revision: a47aed1d6654d4025c3192f90c99d6eba8a041a6
|
||||||
|
specs:
|
||||||
|
guard (2.14.2)
|
||||||
|
formatador (>= 0.2.4)
|
||||||
|
listen (>= 2.7, < 4.0)
|
||||||
|
lumberjack (>= 1.0.12, < 2.0)
|
||||||
|
nenv (~> 0.1)
|
||||||
|
notiffany (~> 0.0)
|
||||||
|
pry (>= 0.9.12)
|
||||||
|
shellany (~> 0.0)
|
||||||
|
thor (>= 0.18.1)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/kern/minitest-reporters.git
|
||||||
|
revision: d04c7e9b0504542f6084dc5a2060c774dc6cdda4
|
||||||
|
specs:
|
||||||
|
minitest-reporters (1.3.5)
|
||||||
|
ansi
|
||||||
|
builder
|
||||||
|
minitest (>= 5.0)
|
||||||
|
ruby-progressbar
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
@ -42,19 +75,59 @@ GEM
|
|||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
|
annotate (2.7.4)
|
||||||
|
activerecord (>= 3.2, < 6.0)
|
||||||
|
rake (>= 10.4, < 13.0)
|
||||||
|
ansi (1.5.0)
|
||||||
arel (9.0.0)
|
arel (9.0.0)
|
||||||
|
ast (2.4.0)
|
||||||
|
awesome_print (1.8.0)
|
||||||
|
bcrypt (3.1.12)
|
||||||
|
binding_of_caller (0.8.0)
|
||||||
|
debug_inspector (>= 0.0.1)
|
||||||
bootsnap (1.3.2)
|
bootsnap (1.3.2)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
|
brakeman (4.3.1)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (10.0.2)
|
byebug (10.0.2)
|
||||||
|
choice (0.2.0)
|
||||||
|
coderay (1.1.2)
|
||||||
concurrent-ruby (1.1.3)
|
concurrent-ruby (1.1.3)
|
||||||
crass (1.0.4)
|
crass (1.0.4)
|
||||||
|
debug_inspector (0.0.3)
|
||||||
|
docile (1.3.1)
|
||||||
erubi (1.7.1)
|
erubi (1.7.1)
|
||||||
ffi (1.9.25)
|
ffi (1.9.25)
|
||||||
|
figaro (1.1.1)
|
||||||
|
thor (~> 0.14)
|
||||||
|
formatador (0.2.5)
|
||||||
globalid (0.4.1)
|
globalid (0.4.1)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
|
guard-brakeman (0.8.3)
|
||||||
|
brakeman (>= 2.1.1)
|
||||||
|
guard (>= 2.0.0)
|
||||||
|
guard-compat (1.2.1)
|
||||||
|
guard-minitest (2.4.6)
|
||||||
|
guard-compat (~> 1.2)
|
||||||
|
minitest (>= 3.0)
|
||||||
|
guard-rubocop (1.3.0)
|
||||||
|
guard (~> 2.0)
|
||||||
|
rubocop (~> 0.20)
|
||||||
|
guard-shell (0.7.1)
|
||||||
|
guard (>= 2.0.0)
|
||||||
|
guard-compat (~> 1.0)
|
||||||
|
guard-spring (1.1.1)
|
||||||
|
guard (~> 2.0)
|
||||||
|
guard-compat (~> 1.1)
|
||||||
|
spring
|
||||||
i18n (1.1.1)
|
i18n (1.1.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
|
jaro_winkler (1.5.1)
|
||||||
|
jbuilder (2.8.0)
|
||||||
|
activesupport (>= 4.2.0)
|
||||||
|
multi_json (>= 1.2)
|
||||||
|
json (2.1.0)
|
||||||
|
jwt (2.1.0)
|
||||||
listen (3.1.5)
|
listen (3.1.5)
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||||
rb-inotify (~> 0.9, >= 0.9.7)
|
rb-inotify (~> 0.9, >= 0.9.7)
|
||||||
@ -62,6 +135,7 @@ GEM
|
|||||||
loofah (2.2.3)
|
loofah (2.2.3)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
|
lumberjack (1.0.13)
|
||||||
mail (2.7.1)
|
mail (2.7.1)
|
||||||
mini_mime (>= 0.1.1)
|
mini_mime (>= 0.1.1)
|
||||||
marcel (0.3.3)
|
marcel (0.3.3)
|
||||||
@ -72,11 +146,34 @@ GEM
|
|||||||
mini_portile2 (2.3.0)
|
mini_portile2 (2.3.0)
|
||||||
minitest (5.11.3)
|
minitest (5.11.3)
|
||||||
msgpack (1.2.4)
|
msgpack (1.2.4)
|
||||||
|
multi_json (1.13.1)
|
||||||
|
nenv (0.3.0)
|
||||||
nio4r (2.3.1)
|
nio4r (2.3.1)
|
||||||
nokogiri (1.8.5)
|
nokogiri (1.8.5)
|
||||||
mini_portile2 (~> 2.3.0)
|
mini_portile2 (~> 2.3.0)
|
||||||
|
notiffany (0.1.1)
|
||||||
|
nenv (~> 0.1)
|
||||||
|
shellany (~> 0.0)
|
||||||
|
parallel (1.12.1)
|
||||||
|
parser (2.5.3.0)
|
||||||
|
ast (~> 2.4.0)
|
||||||
|
policy-assertions (0.2.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
|
pundit (>= 1.0.0)
|
||||||
|
powerpack (0.1.2)
|
||||||
|
pry (0.12.0)
|
||||||
|
coderay (~> 1.1.0)
|
||||||
|
method_source (~> 0.9.0)
|
||||||
|
pry-byebug (3.6.0)
|
||||||
|
byebug (~> 10.0)
|
||||||
|
pry (~> 0.10)
|
||||||
|
pry-rails (0.3.7)
|
||||||
|
pry (>= 0.10.4)
|
||||||
puma (3.12.0)
|
puma (3.12.0)
|
||||||
|
pundit (2.0.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
rack (2.0.6)
|
rack (2.0.6)
|
||||||
|
rack-cors (1.0.2)
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rails (5.2.1)
|
rails (5.2.1)
|
||||||
@ -95,6 +192,11 @@ GEM
|
|||||||
rails-dom-testing (2.0.3)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
|
rails-erd (1.5.2)
|
||||||
|
activerecord (>= 3.2)
|
||||||
|
activesupport (>= 3.2)
|
||||||
|
choice (~> 0.2.0)
|
||||||
|
ruby-graphviz (~> 1.2)
|
||||||
rails-html-sanitizer (1.0.4)
|
rails-html-sanitizer (1.0.4)
|
||||||
loofah (~> 2.2, >= 2.2.2)
|
loofah (~> 2.2, >= 2.2.2)
|
||||||
railties (5.2.1)
|
railties (5.2.1)
|
||||||
@ -103,11 +205,24 @@ GEM
|
|||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.19.0, < 2.0)
|
thor (>= 0.19.0, < 2.0)
|
||||||
|
rainbow (3.0.0)
|
||||||
rake (12.3.1)
|
rake (12.3.1)
|
||||||
rb-fsevent (0.10.3)
|
rb-fsevent (0.10.3)
|
||||||
rb-inotify (0.9.10)
|
rb-inotify (0.9.10)
|
||||||
ffi (>= 0.5.0, < 2)
|
ffi (>= 0.5.0, < 2)
|
||||||
|
rubocop (0.60.0)
|
||||||
|
jaro_winkler (~> 1.5.1)
|
||||||
|
parallel (~> 1.10)
|
||||||
|
parser (>= 2.5, != 2.5.1.1)
|
||||||
|
powerpack (~> 0.1)
|
||||||
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
|
ruby-progressbar (~> 1.7)
|
||||||
|
unicode-display_width (~> 1.4.0)
|
||||||
|
ruby-graphviz (1.2.3)
|
||||||
|
ruby-progressbar (1.10.0)
|
||||||
ruby_dep (1.5.0)
|
ruby_dep (1.5.0)
|
||||||
|
shellany (0.0.1)
|
||||||
|
simplecov-html (0.10.2)
|
||||||
spring (2.0.2)
|
spring (2.0.2)
|
||||||
activesupport (>= 4.2)
|
activesupport (>= 4.2)
|
||||||
spring-watcher-listen (2.0.1)
|
spring-watcher-listen (2.0.1)
|
||||||
@ -121,10 +236,13 @@ GEM
|
|||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sqlite3 (1.3.13)
|
sqlite3 (1.3.13)
|
||||||
thor (0.20.2)
|
thor (0.20.3)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
tzinfo (1.2.5)
|
tzinfo (1.2.5)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
|
unicode-display_width (1.4.0)
|
||||||
|
validates_email_format_of (1.6.3)
|
||||||
|
i18n
|
||||||
websocket-driver (0.7.0)
|
websocket-driver (0.7.0)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.3)
|
websocket-extensions (0.1.3)
|
||||||
@ -133,15 +251,40 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
annotate
|
||||||
|
awesome_print
|
||||||
|
bcrypt (~> 3.1.7)
|
||||||
|
binding_of_caller
|
||||||
bootsnap (>= 1.1.0)
|
bootsnap (>= 1.1.0)
|
||||||
|
brakeman
|
||||||
byebug
|
byebug
|
||||||
|
figaro (~> 1.1)
|
||||||
|
guard!
|
||||||
|
guard-brakeman
|
||||||
|
guard-minitest
|
||||||
|
guard-rubocop
|
||||||
|
guard-shell
|
||||||
|
guard-spring
|
||||||
|
jbuilder (~> 2.5)
|
||||||
|
json (~> 2.1)
|
||||||
|
jwt (= 2.1.0)
|
||||||
listen (>= 3.0.5, < 3.2)
|
listen (>= 3.0.5, < 3.2)
|
||||||
|
minitest-reporters!
|
||||||
|
policy-assertions
|
||||||
|
pry-byebug
|
||||||
|
pry-rails
|
||||||
puma (~> 3.11)
|
puma (~> 3.11)
|
||||||
|
pundit (~> 2.0)
|
||||||
|
rack-cors
|
||||||
rails (~> 5.2.1)
|
rails (~> 5.2.1)
|
||||||
|
rails-erd
|
||||||
|
rubocop (~> 0.59)
|
||||||
|
simplecov!
|
||||||
spring
|
spring
|
||||||
spring-watcher-listen (~> 2.0.0)
|
spring-watcher-listen (~> 2.0.0)
|
||||||
sqlite3
|
sqlite3
|
||||||
tzinfo-data
|
tzinfo-data
|
||||||
|
validates_email_format_of
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.5.3p105
|
ruby 2.5.3p105
|
||||||
|
59
Guardfile
Normal file
59
Guardfile
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# A sample Guardfile
|
||||||
|
# More info at https://github.com/guard/guard#readme
|
||||||
|
|
||||||
|
## Uncomment and set this to only include directories you want to watch
|
||||||
|
# directories %w(app lib config test spec features) \
|
||||||
|
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
||||||
|
|
||||||
|
## Note: if you are using the `directories` clause above and you are not
|
||||||
|
## watching the project directory ('.'), then you will want to move
|
||||||
|
## the Guardfile to a watched dir and symlink it back, e.g.
|
||||||
|
#
|
||||||
|
# $ mkdir config
|
||||||
|
# $ mv Guardfile config/
|
||||||
|
# $ ln -s config/Guardfile .
|
||||||
|
#
|
||||||
|
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
||||||
|
|
||||||
|
guard :minitest, spring: "bin/rails test", all_after_pass: true do
|
||||||
|
watch(%r{^app/(.+)\.rb$}) { |m| ["test/#{m[1]}", "test/#{m[1]}_test.rb"] }
|
||||||
|
watch(%r{^app/controllers/(admin|application)_controller\.rb$}) { 'test/controllers' }
|
||||||
|
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
||||||
|
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
||||||
|
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
||||||
|
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
||||||
|
watch(%r{^test/.+_test\.rb$})
|
||||||
|
|
||||||
|
# run controller/integration test when touching the router, jbuilder, or erb files
|
||||||
|
watch(%r{^app/views/((?!_mailer).)*([^/]+)\.erb$}) { ["test/controllers", "test/integration"] }
|
||||||
|
watch(%r{^app/views/((?!_mailer).)*([^/]+)\.jbuilder$}) { ["test/controllers", "test/integration"] }
|
||||||
|
watch(%r{^config/routes.rb}) { ["test/controllers", "test/integration"] }
|
||||||
|
|
||||||
|
# run mailers/integration test when touching mailer erb files
|
||||||
|
watch(%r{^app/views/(.*_mailer/)?([^/]+)\.erb$}) { ["test/mailers", "test/integration"] }
|
||||||
|
end
|
||||||
|
|
||||||
|
guard :rubocop, cli: %w[-D -S -a] do
|
||||||
|
watch(/.rubocop.yml/)
|
||||||
|
watch(/.+\.rb$/)
|
||||||
|
watch(/Rakefile/)
|
||||||
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
guard 'brakeman', run_on_start: true, quiet: true do
|
||||||
|
## Lets not watch files for brakeman, just scan on guard start, and full runs.
|
||||||
|
#
|
||||||
|
# watch(%r{^app/.+\.(erb|haml|rhtml|rb)$})
|
||||||
|
# watch(%r{^config/.+\.rb$})
|
||||||
|
# watch(%r{^lib/.+\.rb$})
|
||||||
|
# watch('Gemfile')
|
||||||
|
end
|
||||||
|
|
||||||
|
guard 'spring', bundler: true do
|
||||||
|
watch('Gemfile.lock')
|
||||||
|
watch(%r{^config/})
|
||||||
|
watch(%r{^spec/(support|factories)/})
|
||||||
|
watch(%r{^spec/factory.rb})
|
||||||
|
end
|
47
README.md
47
README.md
@ -1,3 +1,50 @@
|
|||||||
# MicroBlogger
|
# MicroBlogger
|
||||||
|
|
||||||
|
This is a Rails 5.2.n API stack.
|
||||||
|
|
||||||
|
## Local dev setup
|
||||||
|
|
||||||
|
Be sure to have ruby (2.5.n) installed. RVM is
|
||||||
|
recommended to manage ruby. This dev stack uses `guard` for
|
||||||
|
rapid style and test feedback. It is strongly recommended to
|
||||||
|
have it running for every dev change/session.
|
||||||
|
|
||||||
|
### Initial setup
|
||||||
|
|
||||||
|
* rvm install ruby-2.5.1
|
||||||
|
* bundle install
|
||||||
|
* set up application.yml
|
||||||
|
* copy `config/application.yml.sample` to `config/application.yml`
|
||||||
|
* edit values as needed
|
||||||
|
* rake db:create
|
||||||
|
* rake db:migrate
|
||||||
|
* rake db:fixtures:load
|
||||||
|
|
||||||
|
There is a shell script in the root that will rebuild both
|
||||||
|
the local dev and test databases which executes the last
|
||||||
|
three setup steps:
|
||||||
|
`./rebuild-dev-db.sh`
|
||||||
|
|
||||||
|
Currently fixture files are used to seed local and test dev
|
||||||
|
instead of the `rake db:seed` pattern.
|
||||||
|
|
||||||
|
### dev session
|
||||||
|
|
||||||
|
* `bundle exec guard`
|
||||||
|
* do work until tests pass.
|
||||||
|
* `quit` to exit guard
|
||||||
|
|
||||||
|
The guard config file is `/Guardfile`.
|
||||||
|
|
||||||
|
With (almost) every file save, associated tests to that file
|
||||||
|
are ran, if successful the whole suite is then executed.
|
||||||
|
|
||||||
|
After the test suite `rubocop` kicks off with
|
||||||
|
auto-correction flags.
|
||||||
|
|
||||||
|
Finally simple cover reports are updated.
|
||||||
|
|
||||||
|
## other notes
|
||||||
|
* minitest is the testing framework
|
||||||
|
* editorconfig: https://editorconfig.org/
|
||||||
|
* rails-erd: https://github.com/voormedia/rails-erd
|
||||||
|
2
Rakefile
2
Rakefile
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||||
|
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ApplicationController < ActionController::API
|
class ApplicationController < ActionController::API
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ApplicationJob < ActiveJob::Base
|
class ApplicationJob < ActiveJob::Base
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
default from: 'from@example.com'
|
default from: 'from@example.com'
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ApplicationRecord < ActiveRecord::Base
|
class ApplicationRecord < ActiveRecord::Base
|
||||||
self.abstract_class = true
|
self.abstract_class = true
|
||||||
end
|
end
|
||||||
|
0
app/validators/.keep
Normal file
0
app/validators/.keep
Normal file
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# This file is used by Rack-based servers to start the application.
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
require_relative 'config/environment'
|
require_relative 'config/environment'
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative 'boot'
|
require_relative 'boot'
|
||||||
|
|
||||||
require "rails"
|
require "rails"
|
||||||
|
14
config/application.yml.sample
Normal file
14
config/application.yml.sample
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Add configuration values here, as shown below.
|
||||||
|
#
|
||||||
|
# pusher_app_id: "2954"
|
||||||
|
# pusher_key: 7381a978f7dd7f9a1117
|
||||||
|
# pusher_secret: abdc3b896a0ffb85d373
|
||||||
|
# stripe_api_key: sk_test_2J0l093xOyW72XUYJHE4Dv2r
|
||||||
|
# stripe_publishable_key: pk_test_ro9jV5SNwGb1yYlQfzG17LHK
|
||||||
|
#
|
||||||
|
# production:
|
||||||
|
# stripe_api_key: sk_live_EeHnL644i6zo4Iyq4v1KdV9H
|
||||||
|
# stripe_publishable_key: pk_live_9lcthxpSIHbGwmdO941O1XVU
|
||||||
|
|
||||||
|
aws_key: this-is-the-key
|
||||||
|
aws_secret: this-is-the-secret
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||||
|
|
||||||
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Load the Rails application.
|
# Load the Rails application.
|
||||||
require_relative 'application'
|
require_relative 'application'
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
@ -41,7 +43,6 @@ Rails.application.configure do
|
|||||||
# Highlight code that triggered database queries in logs.
|
# Highlight code that triggered database queries in logs.
|
||||||
config.active_record.verbose_query_logs = true
|
config.active_record.verbose_query_logs = true
|
||||||
|
|
||||||
|
|
||||||
# Raises error for missing translations
|
# Raises error for missing translations
|
||||||
# config.action_view.raise_on_missing_translations = true
|
# config.action_view.raise_on_missing_translations = true
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
# ActiveSupport::Reloader.to_prepare do
|
# ActiveSupport::Reloader.to_prepare do
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
# Avoid CORS issues when API is called from the frontend app.
|
# Avoid CORS issues when API is called from the frontend app.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
# Configure sensitive parameters which will be filtered from the log file.
|
# Configure sensitive parameters which will be filtered from the log file.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
# Add new inflection rules using the following format. Inflections
|
# Add new inflection rules using the following format. Inflections
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
# Add new mime types for use in respond_to blocks:
|
# Add new mime types for use in respond_to blocks:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
# This file contains settings for ActionController::ParamsWrapper which
|
# This file contains settings for ActionController::ParamsWrapper which
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Puma can serve each request in a thread from an internal thread pool.
|
# Puma can serve each request in a thread from an internal thread pool.
|
||||||
# The `threads` method setting takes two numbers: a minimum and maximum.
|
# The `threads` method setting takes two numbers: a minimum and maximum.
|
||||||
# Any libraries that use thread pools should be configured to match
|
# Any libraries that use thread pools should be configured to match
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
%w[
|
%w[
|
||||||
.ruby-version
|
.ruby-version
|
||||||
.rbenv-vars
|
.rbenv-vars
|
||||||
|
15
db/schema.rb
Normal file
15
db/schema.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
|
#
|
||||||
|
# Note that this schema.rb definition is the authoritative source for your
|
||||||
|
# database schema. If you need to create the application database on another
|
||||||
|
# system, you should be using db:schema:load, not running all the migrations
|
||||||
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||||
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||||
|
#
|
||||||
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
|
ActiveRecord::Schema.define(version: 0) do
|
||||||
|
|
||||||
|
end
|
56
lib/tasks/auto_annotate_models.rake
Normal file
56
lib/tasks/auto_annotate_models.rake
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# NOTE: only doing this in development as some production environments (Heroku)
|
||||||
|
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
|
||||||
|
# NOTE: to have a dev-mode tool do its thing in production.
|
||||||
|
if Rails.env.development?
|
||||||
|
require 'annotate'
|
||||||
|
task :set_annotation_options do
|
||||||
|
# You can override any of these by setting an environment variable of the
|
||||||
|
# same name.
|
||||||
|
Annotate.set_defaults(
|
||||||
|
'routes' => 'false',
|
||||||
|
'position_in_routes' => 'before',
|
||||||
|
'position_in_class' => 'before',
|
||||||
|
'position_in_test' => 'before',
|
||||||
|
'position_in_fixture' => 'before',
|
||||||
|
'position_in_factory' => 'before',
|
||||||
|
'position_in_serializer' => 'before',
|
||||||
|
'show_foreign_keys' => 'true',
|
||||||
|
'show_complete_foreign_keys' => 'true',
|
||||||
|
'show_indexes' => 'true',
|
||||||
|
'simple_indexes' => 'false',
|
||||||
|
'model_dir' => 'app/models',
|
||||||
|
'root_dir' => '',
|
||||||
|
'include_version' => 'false',
|
||||||
|
'require' => '',
|
||||||
|
'exclude_tests' => 'true',
|
||||||
|
'exclude_fixtures' => 'false',
|
||||||
|
'exclude_factories' => 'false',
|
||||||
|
'exclude_serializers' => 'true',
|
||||||
|
'exclude_scaffolds' => 'true',
|
||||||
|
'exclude_controllers' => 'true',
|
||||||
|
'exclude_helpers' => 'true',
|
||||||
|
'exclude_sti_subclasses' => 'false',
|
||||||
|
'ignore_model_sub_dir' => 'false',
|
||||||
|
'ignore_columns' => nil, # '^(updated_at|created_at)',
|
||||||
|
'ignore_routes' => nil,
|
||||||
|
'ignore_unknown_models' => 'false',
|
||||||
|
'hide_limit_column_types' => 'integer,boolean',
|
||||||
|
'hide_default_column_types' => 'json,jsonb,hstore',
|
||||||
|
'skip_on_db_migrate' => 'false',
|
||||||
|
'format_bare' => 'true',
|
||||||
|
'format_rdoc' => 'false',
|
||||||
|
'format_markdown' => 'false',
|
||||||
|
'sort' => 'false',
|
||||||
|
'force' => 'false',
|
||||||
|
'classified_sort' => 'true',
|
||||||
|
'trace' => 'false',
|
||||||
|
'wrapper_open' => nil,
|
||||||
|
'wrapper_close' => nil,
|
||||||
|
'with_comment' => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
Annotate.load_tasks
|
||||||
|
end
|
14
rebuild-dev-db.sh
Executable file
14
rebuild-dev-db.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
RAILS_ENV=development \
|
||||||
|
bundle exec rake \
|
||||||
|
db:drop \
|
||||||
|
db:create \
|
||||||
|
db:migrate \
|
||||||
|
db:fixtures:load \
|
||||||
|
|
||||||
|
RAILS_ENV=test \
|
||||||
|
bundle exec rake \
|
||||||
|
db:migrate \
|
||||||
|
db:fixtures:load
|
||||||
|
|
@ -1,10 +1,32 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
ENV['RAILS_ENV'] ||= 'test'
|
ENV['RAILS_ENV'] ||= 'test'
|
||||||
|
|
||||||
|
# https://github.com/colszowka/simplecov
|
||||||
|
require 'simplecov'
|
||||||
|
SimpleCov.start 'rails' do
|
||||||
|
add_group 'Models', %w[app/models app/validators]
|
||||||
|
add_group 'Commands & Libs', %w[app/workers app/services app/libs app/commands]
|
||||||
|
add_group "Jobs", 'app/jobs'
|
||||||
|
add_group "Policies", 'app/policies'
|
||||||
|
end
|
||||||
|
Rails.application.eager_load!
|
||||||
|
|
||||||
require_relative '../config/environment'
|
require_relative '../config/environment'
|
||||||
require 'rails/test_help'
|
require 'rails/test_help'
|
||||||
|
require 'minitest/reporters'
|
||||||
|
require 'policy_assertions'
|
||||||
|
Dir[Rails.root.join("test", "test_helpers", "**", "*.rb")].each { |f| require f }
|
||||||
|
|
||||||
|
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true)]
|
||||||
|
|
||||||
class ActiveSupport::TestCase
|
class ActiveSupport::TestCase
|
||||||
|
ActiveRecord::Migration.maintain_test_schema!
|
||||||
|
ActiveRecord::Migration.check_pending!
|
||||||
|
|
||||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||||
fixtures :all
|
fixtures :all
|
||||||
|
|
||||||
# Add more helper methods to be used by all tests here...
|
# Add more helper methods to be used by all tests here...
|
||||||
|
include AuthTestHelper
|
||||||
end
|
end
|
||||||
|
12
test/test_helpers/auth_test_helper.rb
Normal file
12
test/test_helpers/auth_test_helper.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module AuthTestHelper
|
||||||
|
def user_token user
|
||||||
|
AuthenticateUser.new(email: user.email, password: 'password').perform
|
||||||
|
end
|
||||||
|
|
||||||
|
def auth_headers user, headers = {}
|
||||||
|
headers["HTTP_AUTHORIZATION"] = user_token(user)
|
||||||
|
headers
|
||||||
|
end
|
||||||
|
end
|
37
user_stories.md
Normal file
37
user_stories.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# MicroBlogger
|
||||||
|
|
||||||
|
An API for a micro blogging platform
|
||||||
|
|
||||||
|
Guests can only view published content and author list
|
||||||
|
Standard can edit their profile & blogs
|
||||||
|
Admins can view list of users and edit any blog
|
||||||
|
|
||||||
|
users:
|
||||||
|
display_name
|
||||||
|
email
|
||||||
|
password_digest
|
||||||
|
roles: guest, standard, admin
|
||||||
|
|
||||||
|
blogs:
|
||||||
|
title
|
||||||
|
article
|
||||||
|
published_date
|
||||||
|
author_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Tasks
|
||||||
|
|
||||||
|
### User Bios
|
||||||
|
|
||||||
|
As a user, I want to be able to author a bio that is
|
||||||
|
displayed with each of my postings.
|
||||||
|
|
||||||
|
### Moderation
|
||||||
|
|
||||||
|
As an admin, I want to be able to put a blog it in a state
|
||||||
|
of moderation.
|
||||||
|
|
||||||
|
Once a blog post has this state, the author must edit and
|
||||||
|
submit for another review before an admin will republish.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user