diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..65f43eb --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,49 @@ +AllCops: + Exclude: + - db/schema.rb + - db/seeds.rb + - bin/**/* + +Style/ClassAndModuleChildren: + Exclude: + - test/test_helper.rb + +Style/Documentation: + Enabled: false + +Style/EmptyLines: + Exclude: + - config/initializers/sorcery.rb + +Style/ExtraSpacing: + Exclude: + - db/migrate/**/* + +Style/IndentationConsistency: + EnforcedStyle: rails + +Style/MethodDefParentheses: + Enabled: false + +Style/SpaceBeforeFirstArg: + Exclude: + - config/routes.rb + +Style/StringLiterals: + Enabled: false + +Metrics/AbcSize: + Exclude: + - db/migrate/**/* + +Metrics/LineLength: + Max: 110 + Exclude: + - Rakefile + - config/**/* + - lib/tasks/**/* + - test/test_helper.rb + +Metrics/MethodLength: + Exclude: + - db/migrate/* diff --git a/.scss-lint.yml b/.scss-lint.yml new file mode 100644 index 0000000..39eef5a --- /dev/null +++ b/.scss-lint.yml @@ -0,0 +1,11 @@ +scss_files: 'app/assets/stylesheets/**/*.scss' + +linters: + StringQuotes: + enabled: false + LeadingZero: + style: 'include_zero' + SelectorFormat: + ignored_names: + QualifyingElement: + allow_element_with_attribute: true diff --git a/Dockerfile b/Dockerfile index c8429bc..b933c69 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ ENV BUILD_PACKAGES="build-essential libmysqlclient-dev openssl graphviz nodejs c RUN apt-get update \ && apt-get install --fix-missing -y $BUILD_PACKAGES \ && /usr/sbin/mysqld --initialize --user=mysql \ + && service mysql start \ && echo 'gem: --no-document' >> ~/.gemrc \ && cp ~/.gemrc /etc/gemrc \ && chmod uog+r /etc/gemrc \ @@ -33,7 +34,7 @@ RUN cd /root \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -EXPOSE 3000 3306 +EXPOSE 3000 3306 35729 WORKDIR /usr/app CMD ["mysqld"] diff --git a/Gemfile b/Gemfile index 1a5f53f..2549807 100644 --- a/Gemfile +++ b/Gemfile @@ -5,15 +5,21 @@ gem 'bcrypt', '~> 3.1.7' gem 'mysql2', '>= 0.3.18', '< 0.5' gem 'rails', '~> 5.0.0' -gem 'autoprefixer-rails' -gem 'jbuilder', '~> 2.5' +# gem 'autoprefixer-rails' +gem 'jbuilder', '~> 2.6' gem 'jquery-rails' -gem 'json', '~> 2.0.1' +gem 'json', '~> 2.0.2' gem 'puma', '~> 3.0' gem 'sass-rails', '~> 5.0' gem 'turbolinks', '~> 5' gem 'uglifier', '>= 1.3.0' +group :development do + gem 'rack-livereload' + gem 'rails-erd' + gem 'web-console' +end + group :development, :test do gem 'awesome_print' gem 'binding_of_caller' @@ -23,16 +29,13 @@ group :development, :test do gem 'guard-minitest' gem 'guard-rubocop' gem 'guard-shell' - gem 'listen', '~> 3.0.5' + gem 'listen', '~> 3.0' gem 'minitest-reporters' gem 'pry-byebug' gem 'pry-rails' - gem 'rack-livereload' - gem 'rails-erd' - gem 'rubocop' + gem 'rubocop', '~> 0.42.0' gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' - gem 'web-console' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index dc3cacd..404f65b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,10 +39,8 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) ansi (1.5.0) - arel (7.0.0) + arel (7.1.0) ast (2.3.0) - autoprefixer-rails (6.3.7) - execjs awesome_print (1.7.0) bcrypt (3.1.11) binding_of_caller (0.7.2) @@ -91,17 +89,18 @@ GEM guard-compat (~> 1.0) http_parser.rb (0.6.0) i18n (0.7.0) - jbuilder (2.5.0) + jbuilder (2.6.0) activesupport (>= 3.0.0, < 5.1) multi_json (~> 1.2) jquery-rails (4.1.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.0.1) - listen (3.0.8) + json (2.0.2) + listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) loofah (2.0.3) nokogiri (>= 1.5.9) lumberjack (1.0.10) @@ -141,7 +140,7 @@ GEM pry (~> 0.10) pry-rails (0.3.4) pry (>= 0.9.10) - puma (3.4.0) + puma (3.6.0) rack (2.0.1) rack-livereload (0.3.16) rack @@ -180,7 +179,7 @@ GEM rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) - rubocop (0.41.2) + rubocop (0.42.0) parser (>= 2.3.1.1, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) @@ -188,8 +187,9 @@ GEM unicode-display_width (~> 1.0, >= 1.0.1) ruby-graphviz (1.2.2) ruby-progressbar (1.8.1) + ruby_dep (1.3.1) sass (3.4.22) - sass-rails (5.0.5) + sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) @@ -201,7 +201,7 @@ GEM spring-watcher-listen (2.0.0) listen (>= 2.7, < 4.0) spring (~> 1.2) - sprockets (3.6.3) + sprockets (3.7.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.1.1) @@ -232,7 +232,6 @@ PLATFORMS ruby DEPENDENCIES - autoprefixer-rails awesome_print bcrypt (~> 3.1.7) binding_of_caller @@ -243,10 +242,10 @@ DEPENDENCIES guard-minitest guard-rubocop guard-shell - jbuilder (~> 2.5) + jbuilder (~> 2.6) jquery-rails - json (~> 2.0.1) - listen (~> 3.0.5) + json (~> 2.0.2) + listen (~> 3.0) minitest-reporters mysql2 (>= 0.3.18, < 0.5) pry-byebug @@ -255,7 +254,7 @@ DEPENDENCIES rack-livereload rails (~> 5.0.0) rails-erd - rubocop + rubocop (~> 0.42.0) sass-rails (~> 5.0) spring spring-watcher-listen (~> 2.0.0) diff --git a/README.md b/README.md index 7db80e4..4d6c5f9 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,26 @@ -# README +# Skill Assessment Quiz -This README would normally document whatever steps are necessary to get the -application up and running. +This application manages quizzes intended to be used as pre-interview skill assessments. -Things you may want to cover: -* Ruby version -* System dependencies +# dev +* you can dev native, or in docker +* use guard + * honor RuboCop + * keep tests green +* pull --rebase !always `git config --global pull.rebase true` -* Configuration +# Docker -* Database creation +* ./start-docker.sh + - will build source image, it not exist + - created contaier and starts +* ./start-dev.sh + - after connected to container, run this to spin up a dev session + - edit files from host in favorite editor +* ./start-server.sh + - starts up simple server for viewing/demo sans guard -* Database initialization +visit http://localhost:3000 -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... diff --git a/config/environments/production.rb b/config/environments/production.rb index 517a8bf..2b66046 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -47,7 +47,7 @@ Rails.application.configure do config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store diff --git a/start-dev.sh b/start-dev.sh index 838e310..b74e8cd 100755 --- a/start-dev.sh +++ b/start-dev.sh @@ -1,12 +1,16 @@ -cd /usr/app -bundle +if [ -d '/usr/app' ]; then + cd /usr/app + bundle -service mysql start -rails db:setup -rails db:migrate -rails db:fixtures:load + service mysql start + rails db:setup + rails db:migrate + rails db:fixtures:load -tmux new-session -d -s 'rails-dev' 'rails s -b 0.0.0.0' -tmux split-window -p 80 -v guard -tmux split-window -p 25 -v -tmux attach -t rails-dev + tmux new-session -d -s 'rails-dev' 'rails s -b 0.0.0.0' + tmux split-window -p 85 -v 'bundle exec guard' + tmux split-window -p 20 -v + tmux attach -t rails-dev +else + echo "Are you in docker container?" +fi diff --git a/start-docker.sh b/start-docker.sh index b3d8687..5e9740e 100755 --- a/start-docker.sh +++ b/start-docker.sh @@ -10,7 +10,7 @@ fi STATUS=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null) if [ $? -eq 1 ]; then - docker run --name $CONTAINER -it -p 3000:3000 -p 3306:3306 -v ${PWD}:/usr/app $IMAGE /bin/bash + docker run --name $CONTAINER -it -p 3000:3000 -p 35729:35729 -p 3306:3306 -v ${PWD}:/usr/app $IMAGE /bin/bash exit fi diff --git a/start-server.sh b/start-server.sh index 7f6d270..a7592d7 100755 --- a/start-server.sh +++ b/start-server.sh @@ -1,10 +1,13 @@ -cd /usr/app -bundle +if [ -d '/usr/app' ]; then + cd /usr/app + bundle -service mysql start -rails db:setup -rails db:migrate -rails db:fixtures:load - -rails s -b 0.0.0.0 + service mysql start + rails db:setup + rails db:migrate + rails db:fixtures:load + rails s -b 0.0.0.0 +else + echo "Are you in docker container?" +fi