Commit e3ba7c5e authored by hellekin's avatar hellekin

Setup development environment

- power up Gemfile
- skip gem documentation
- specification with rspec
- mock with fabrication
- model annotations with annotate
- model diagrams with erd
- remove ActiveRecord internal from domain models documentation
- code quality check with rubocop and rubycritic
- code coverage with simplecov
- make rubocop happy with default Rails app
- dependencies security check with brakeman
- fix default inflections: say humans not humen
- add lib/ to eager_load_path (meh)
parent 4549848f
attributes:
- content
- foreign_keys
- inheritance
- primary_keys
- timestamps
disconnected: true
exclude:
- ApplicationRecord
- ActiveRecord::InternalMetadata
- ActiveRecord::SchemaMigration
filename: doc/models_diagram
filetype: pdf
inheritance: true
indirect: true
notation: bachman
orientation: vertical
polymorphism: true
sort: true
title: Incommon API domain models (all)
gem: --no-document
......@@ -13,8 +13,14 @@
!/log/.keep
!/tmp/.keep
.byebug_history
# Ignore master key for decrypting credentials and more.
/config/master.key
# Ignore coverage
/coverage/*
!/coverage/.keep
# Ignore rspec persistence file
/spec/examples.txt
--require spec_helper
--require rails_helper
--color
AllCops:
TargetRubyVersion: 2.5
Exclude:
- 'spec/**/*'
- 'db/**/*'
- 'app/views/**/*'
- 'config/**/*'
- 'bin/*'
- 'Rakefile'
- 'node_modules/**/*'
- 'Vagrantfile'
- 'vendor/**/*'
- 'lib/json_ld/*'
Bundler/OrderedGems:
Enabled: false
Layout/AccessModifierIndentation:
EnforcedStyle: indent
Layout/EmptyLineAfterMagicComment:
Enabled: false
Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: space
Metrics/AbcSize:
Max: 100
Metrics/BlockLength:
Max: 35
Exclude:
- 'lib/tasks/**/*'
Metrics/BlockNesting:
Max: 3
Metrics/ClassLength:
CountComments: false
Max: 300
Metrics/CyclomaticComplexity:
Max: 25
Metrics/LineLength:
AllowURI: true
Enabled: true
Max: 96
Metrics/MethodLength:
CountComments: false
Max: 55
Metrics/ModuleLength:
CountComments: false
Max: 200
Metrics/ParameterLists:
Max: 5
CountKeywordArgs: true
Metrics/PerceivedComplexity:
Max: 20
Rails:
Enabled: true
Rails/HasAndBelongsToMany:
Enabled: false
Rails/SkipsModelValidations:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/CollectionMethods:
Enabled: true
PreferredMethods:
find_all: 'select'
Style/Documentation:
Enabled: false
Style/DoubleNegation:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: true
Style/GuardClause:
Enabled: false
Style/Lambda:
Enabled: false
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%i': '()'
'%w': '()'
Style/PerlBackrefs:
AutoCorrect: false
Style/RegexpLiteral:
Enabled: false
Style/SymbolArray:
Enabled: false
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: 'comma'
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: 'comma'
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
gem 'rgeo'
gem 'activerecord-postgis-adapter'
gem 'bootsnap', '>= 1.1.0', require: false, platform: :mri
gem 'acts_as_list'
gem 'bcrypt', '~> 3.1.7'
gem 'bitfields'
gem 'faker', '~> 1.9.0'
gem 'fast_blank', platform: :mri
gem 'iana-data', require: 'iana'
gem 'jsonapi-rails'
gem 'phony_rails'
gem 'rack-cors', require: 'rack/cors'
gem 'rack-protection'
gem 'uuid_parameter'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'byebug', platform: :mri
gem 'fabrication'
gem 'guard'
gem 'pry'
gem 'rb-inotify', '~> 0.9'
gem 'rspec'
gem 'rspec-rails', '~> 3.7'
gem 'shoulda', require: false
gem 'shoulda-matchers'
end
group :development do
gem 'annotate'
gem 'fasterer', require: false
gem 'guard-brakeman'
gem 'guard-preek'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'pry-rails'
gem 'rails-erd'
gem 'rubycritic', require: false
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
group :test do
gem 'database_cleaner'
gem 'rails-controller-testing'
gem 'simplecov', require: false
end
......@@ -33,6 +33,9 @@ GEM
activemodel (= 5.2.1)
activesupport (= 5.2.1)
arel (>= 9.0)
activerecord-postgis-adapter (5.2.1)
activerecord (~> 5.1)
rgeo-activerecord (~> 6.0)
activestorage (5.2.1)
actionpack (= 5.2.1)
activerecord (= 5.2.1)
......@@ -42,19 +45,107 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
acts_as_list (0.9.16)
activerecord (>= 3.0)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
annotate (2.7.4)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 13.0)
arel (9.0.0)
ast (2.4.0)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bcrypt (3.1.12)
bitfields (0.8.0)
bootsnap (1.3.2)
msgpack (~> 1.0)
brakeman (4.3.1)
builder (3.2.3)
byebug (10.0.2)
choice (0.2.0)
codeclimate-engine-rb (0.4.1)
virtus (~> 1.0)
coderay (1.1.2)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
colorize (0.8.1)
concurrent-ruby (1.0.5)
crass (1.0.4)
database_cleaner (1.7.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.3)
docile (1.3.1)
equalizer (0.0.11)
erubi (1.7.1)
erubis (2.7.0)
fabrication (2.20.1)
faker (1.9.1)
i18n (>= 0.7)
fast_blank (1.0.0)
fasterer (0.4.1)
colorize (~> 0.7)
ruby_parser (~> 3.11.0)
ffi (1.9.25)
flay (2.12.0)
erubis (~> 2.7.0)
path_expander (~> 1.0)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
flog (4.6.2)
path_expander (~> 1.0)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.8)
formatador (0.2.5)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (1.1.0)
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)
guard-brakeman (0.8.3)
brakeman (>= 2.1.1)
guard (>= 2.0.0)
guard-compat (1.2.1)
guard-preek (0.0.9)
guard (~> 2.0)
preek (~> 1.2)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
guard-rubocop (1.3.0)
guard (~> 2.0)
rubocop (~> 0.20)
i18n (1.1.1)
concurrent-ruby (~> 1.0)
iana-data (1.2.3)
nokogiri (~> 1.6)
open-uri-cached (= 0.0.5)
ice_nine (0.11.2)
jaro_winkler (1.5.1)
json (2.1.0)
jsonapi-deserializable (0.2.0)
jsonapi-parser (0.1.1)
jsonapi-rails (0.3.1)
jsonapi-parser (~> 0.1.0)
jsonapi-rb (~> 0.5.0)
jsonapi-rb (0.5.0)
jsonapi-deserializable (~> 0.2.0)
jsonapi-serializable (~> 0.3.0)
jsonapi-renderer (0.2.0)
jsonapi-serializable (0.3.0)
jsonapi-renderer (~> 0.2.0)
launchy (2.4.3)
addressable (~> 2.3)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
......@@ -62,7 +153,8 @@ GEM
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
lumberjack (1.0.13)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
......@@ -72,12 +164,38 @@ GEM
mini_portile2 (2.3.0)
minitest (5.11.3)
msgpack (1.2.4)
nenv (0.3.0)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
open-uri-cached (0.0.5)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
path_expander (1.0.3)
pg (1.1.3)
phony (2.16.5)
phony_rails (0.14.11)
activesupport (>= 3.0)
phony (> 2.15)
powerpack (0.1.2)
preek (1.2.1)
reek (>= 1.3)
thor (>= 0.16)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.5)
rack-cors (1.0.2)
rack-protection (2.0.4)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.1)
......@@ -93,9 +211,18 @@ GEM
bundler (>= 1.3.0)
railties (= 5.2.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
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)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.1)
......@@ -104,11 +231,76 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
reek (4.8.2)
codeclimate-engine-rb (~> 0.4.0)
parser (>= 2.5.0.0, < 2.6)
rainbow (>= 2.0, < 4.0)
rgeo (1.1.2)
rgeo-activerecord (6.0.0)
activerecord (~> 5.0)
rgeo (~> 1.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.59.2)
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.0, >= 1.0.1)
ruby-graphviz (1.2.3)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
ruby_parser (3.11.0)
sexp_processor (~> 4.9)
rubycritic (3.5.2)
flay (~> 2.8)
flog (~> 4.4)
launchy (= 2.4.3)
parser (~> 2.5.0)
rainbow (~> 3.0)
reek (~> 4.4)
ruby_parser (~> 3.8)
tty-which (~> 0.3.0)
virtus (~> 1.0)
sexp_processor (4.11.0)
shellany (0.0.1)
shoulda (3.6.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (~> 3.0)
shoulda-context (1.2.2)
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
......@@ -118,8 +310,17 @@ GEM
sprockets (>= 3.0.0)
thor (0.20.0)
thread_safe (0.3.6)
tty-which (0.3.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.4.0)
uuid_parameter (0.2.4)
rails (~> 5.2.1)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
......@@ -128,13 +329,45 @@ PLATFORMS
ruby
DEPENDENCIES
activerecord-postgis-adapter
acts_as_list
annotate
bcrypt (~> 3.1.7)
bitfields
bootsnap (>= 1.1.0)
byebug
database_cleaner
fabrication
faker (~> 1.9.0)
fast_blank
fasterer
guard
guard-brakeman
guard-preek
guard-rspec
guard-rubocop
iana-data
jsonapi-rails
listen (>= 3.0.5, < 3.2)
pg (>= 0.18, < 2.0)
phony_rails
pry
pry-rails
puma (~> 3.11)
rack-cors
rack-protection
rails (~> 5.2.1)
tzinfo-data
rails-controller-testing
rails-erd
rb-inotify (~> 0.9)
rgeo
rspec
rspec-rails (~> 3.7)
rubycritic
shoulda
shoulda-matchers
simplecov
uuid_parameter
RUBY VERSION
ruby 2.5.1p57
......
# 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"
# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'
guard :rspec, cmd: 'bundle exec rspec' do
require 'guard/rspec/dsl'
dsl = Guard::RSpec::Dsl.new(self)
# Feel free to open issues for suggestions and improvements
# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)
# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)
# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)
watch(rails.controllers) do |m|
[
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller"),
rspec.spec.call("acceptance/#{m[1]}"),
]
end
# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
end
end
guard :rubocop, all_on_start: true, cli: ['-FEaR'] do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
end
guard :brakeman, run_on_start: true, quiet: true do
watch(%r{^app/.+\.(erb|haml|rhtml|rb)$})
watch(%r{^config/.+\.rb$})
watch(%r{^lib/.+\.rb$})
watch('Gemfile')
end
# frozen_string_literal: true
class ApplicationController < ActionController::API
end
# frozen_string_literal: true
class ApplicationJob < ActiveJob::Base
end
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
......
......@@ -8,10 +8,10 @@ require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view/railtie"
# require "action_view/railtie"
# require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
# require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
......@@ -22,6 +22,8 @@ module IncommonApi
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.eager_load_paths << Rails.root.join('lib')
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
......
......@@ -14,3 +14,7 @@
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'human', 'humans'
end
attributes:
# - content
# - foreign_keys
# - inheritance
# - primary_keys
# - timestamps
disconnected: true
exclude:
- ApplicationRecord
- ActiveRecord::InternalMetadata
- ActiveRecord::SchemaMigration
filename: doc/models_diagram
filetype: pdf
inheritance: true
indirect: true
notation: bachman
orientation: vertical
polymorphism: false
sort: true
title: Incommon API domain models | Classifications
only:
- Agent
- Taxonomy
- Category
- Section
attributes:
# - content
# - foreign_keys
# - inheritance
# - primary_keys
# - timestamps
disconnected: true
exclude:
- ApplicationRecord
- ActiveRecord::InternalMetadata
- ActiveRecord::SchemaMigration
filename: doc/models_diagram
filetype: pdf
inheritance: true
indirect: true
notation: bachman
orientation: vertical
polymorphism: false
sort: true
title: Incommon API domain models | Humans
only:
# - Resource
- Entity
- Agent
- User
- Role
attributes:
# - content
# - foreign_keys
# - inheritance
# - primary_keys
# - timestamps
disconnected: true
exclude:
- ApplicationRecord
- ActiveRecord::InternalMetadata
- ActiveRecord::SchemaMigration
filename: doc/models_diagram