diff --git a/.firstdraft_project.yml b/.firstdraft_project.yml deleted file mode 100644 index 70d47ce..0000000 --- a/.firstdraft_project.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -submission_url: https://grades.firstdraft.com/builds -project_token: deprecated diff --git a/.gitignore b/.gitignore index 855e0c1..b21961d 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,9 @@ # Ignore dotenv files /.env* + +# Ignore dotenv files +/.env* + +.rbenv-gemsets +examples.txt diff --git a/Gemfile b/Gemfile index 4dcb623..45d6718 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,11 @@ source 'https://rubygems.org' +git_source(:github) do |repo_name| + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") + "https://github.com/#{repo_name}.git" +end + + # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '5.0.2' # Use sqlite3 as the database for Active Record @@ -9,7 +15,7 @@ gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.1.0' +gem 'coffee-rails', '~> 4.2' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby @@ -37,6 +43,9 @@ group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '~> 3.0.5' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' end gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] @@ -54,6 +63,7 @@ group :development do gem 'annotate' gem 'awesome_print' gem 'better_errors' + gem 'dev_toolbar', git: 'https://github.com/firstdraft/dev_toolbar.git' gem 'binding_of_caller' gem 'firstdraft_generators', github: 'firstdraft/firstdraft_generators' gem 'letter_opener' diff --git a/Gemfile.lock b/Gemfile.lock index 0999b18..ecd02bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,30 @@ GIT - remote: git://github.com/firstdraft/firstdraft_generators.git + remote: https://github.com/firstdraft/dev_toolbar.git + revision: 6a1ae2e4e1a3dfdfd867e0bcb3f2c465ebacc19a + specs: + dev_toolbar (0.1.0) + better_errors + rails + +GIT + remote: https://github.com/firstdraft/firstdraft_generators.git revision: 9405e70b3d5bf2215917c7d268baa07ab76386fd specs: firstdraft_generators (0.0.3) GIT - remote: git://github.com/firstdraft/grade_runner.git - revision: 1e212e50b3fd46ff5b22783d19e0e1aac7928915 + remote: https://github.com/firstdraft/grade_runner.git + revision: fbddabac089f98821b7d07d9ac957c836a05264b specs: grade_runner (0.0.1) GIT - remote: git://github.com/firstdraft/web_git.git - revision: 3c4f4c18d62012ba151e3aef90a495cbf5c66de5 + remote: https://github.com/firstdraft/web_git.git + revision: 9ef7a0a888858f45d0bcb49fb990d96d00642884 specs: web_git (0.0.1) - bootstrap (~> 4.0.0.alpha6) - jquery-rails (= 4.3.1) + git_clone_url + jquery-rails octicons_helper tether-rails turbolinks (~> 5) @@ -24,7 +32,7 @@ GIT GIT remote: https://github.com/raghubetina/starter_generators - revision: 48fa7a4fbe4eb90ecfe05a133a7d7550167308f8 + revision: c38d341cecde6ff086d8e7882f781f82c2870ffd specs: starter_generators (0.9.6) @@ -74,8 +82,6 @@ GEM activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 13.0) arel (7.1.4) - autoprefixer-rails (7.1.2.3) - execjs awesome_print (1.8.0) bcrypt (3.1.11) better_errors (2.1.1) @@ -85,9 +91,6 @@ GEM bindex (0.5.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootstrap (4.0.0.alpha6) - autoprefixer-rails (>= 6.0.3) - sass (>= 3.4.19) builder (3.2.3) byebug (9.0.6) callsite (0.0.11) @@ -99,9 +102,9 @@ GEM rack-test (>= 0.5.4) xpath (~> 2.0) coderay (1.1.1) - coffee-rails (4.1.1) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs @@ -109,7 +112,7 @@ GEM concurrent-ruby (1.0.5) crack (0.4.3) safe_yaml (~> 1.0.0) - database_cleaner (1.6.1) + database_cleaner (1.6.2) debug_inspector (0.0.3) devise (4.3.0) bcrypt (~> 3.0) @@ -129,11 +132,13 @@ GEM factory_girl_rails (4.8.0) factory_girl (~> 4.8.0) railties (>= 3.0.0) - faker (1.8.4) + faker (1.7.3) i18n (~> 0.5) ffi (1.9.18) font-awesome-sass (4.7.0) sass (>= 3.2) + git_clone_url (2.0.0) + uri-ssh_git (>= 2.0) globalid (0.4.0) activesupport (>= 4.2.0) hashdiff (0.3.4) @@ -171,10 +176,10 @@ GEM nio4r (2.0.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) - octicons (3.0.1) + octicons (5.0.5) nokogiri (>= 1.6.3.1) - octicons_helper (3.0.1) - octicons (~> 3.0) + octicons_helper (4.0.7) + octicons rails orm_adapter (0.5.0) pry (0.10.4) @@ -249,6 +254,11 @@ GEM json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) slop (3.6.0) + spring (2.0.2) + activesupport (>= 4.2) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -267,10 +277,11 @@ GEM turbolinks-source (5.0.3) tzinfo (1.2.3) thread_safe (~> 0.1) - tzinfo-data (1.2017.2) + tzinfo-data (1.2017.3) tzinfo (>= 1.0.0) uglifier (3.2.0) execjs (>= 0.3.0, < 3) + uri-ssh_git (2.0.0) warden (1.2.7) rack (>= 1.0) web-console (3.5.1) @@ -298,8 +309,9 @@ DEPENDENCIES binding_of_caller byebug capybara - coffee-rails (~> 4.1.0) + coffee-rails (~> 4.2) database_cleaner + dev_toolbar! devise dotenv-rails factory_girl_rails @@ -317,6 +329,8 @@ DEPENDENCIES rspec-rails sass-rails (~> 5.0) sdoc (~> 0.4.0) + spring + spring-watcher-listen (~> 2.0.0) sqlite3 starter_generators! tzinfo-data @@ -327,4 +341,4 @@ DEPENDENCIES webmock BUNDLED WITH - 1.15.2 + 1.16.0 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 54de11f..302f4e9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,8 +7,7 @@ <%= csrf_meta_tags %> - -<%= yield %> - + <%= yield %> + <%= dev_tools if Rails.env.development? %> diff --git a/bin/rails b/bin/rails index 0739660..5badb2f 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,9 @@ #!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 1724048..d87d5f5 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,9 @@ #!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/server b/bin/server new file mode 100644 index 0000000..dd85942 --- /dev/null +++ b/bin/server @@ -0,0 +1,4 @@ +#!/bin/bash + +kill -9 $(lsof -i tcp:8080 -t) >/dev/null 2>/dev/null +rails server -b $IP -p $PORT diff --git a/bin/setup b/bin/setup index cd75569..5f257ba 100755 --- a/bin/setup +++ b/bin/setup @@ -31,9 +31,7 @@ chdir APP_ROOT do puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' - - puts "\n== Restarting application server ==" - system! 'bin/rails restart' + puts "\n== Installing diff2html-cli ==" system! "npm install -g diff2html-cli" diff --git a/bin/spring b/bin/spring index 62ec28f..fb2ec2e 100755 --- a/bin/spring +++ b/bin/spring @@ -7,9 +7,11 @@ unless defined?(Spring) require 'rubygems' require 'bundler' - if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) - Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq } - gem 'spring', match[1] + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version require 'spring/binstub' end end diff --git a/bin/whitelist b/bin/whitelist new file mode 100755 index 0000000..ba720f7 --- /dev/null +++ b/bin/whitelist @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +require 'yaml' +include FileUtils + +ip_address = ARGV[0] +path = Pathname.new File.expand_path('../../whitelist.yml', __FILE__) +whitelisted_ips = if File.exist?(path) + YAML.load_file(path) + else + [] + end + +whitelisted_ips << ip_address +whitelisted_ips = whitelisted_ips.uniq.compact + +File.open(path, 'w') {|f| f.write whitelisted_ips.to_yaml } + +puts "Stopping Rails server. Please restart it." +`kill -9 $(lsof -i tcp:8080 -t) >/dev/null 2>/dev/null` diff --git a/config/environments/development.rb b/config/environments/development.rb index e64889c..b2f7ed7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,10 @@ Rails.application.configure do + path = Rails.root.join('whitelist.yml') + if File.exist?(path) + whitelisted_ips = YAML.load_file(path) + config.web_console.whitelisted_ips = whitelisted_ips + end + config.action_mailer.default_url_options = { host: "localhost", port: 3000 } # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on diff --git a/config/initializers/framework_trace.rb b/config/initializers/framework_trace.rb new file mode 100644 index 0000000..9128bda --- /dev/null +++ b/config/initializers/framework_trace.rb @@ -0,0 +1,7 @@ +module ActionDispatch + class ExceptionWrapper + def framework_trace + [] + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 8015e08..787824f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,3 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html - mount WebGit::Engine, at: "/rails/git" end diff --git a/grades.yml b/grades.yml new file mode 100644 index 0000000..2f40b8d --- /dev/null +++ b/grades.yml @@ -0,0 +1,4 @@ +--- +submission_url: https://grades.firstdraft.com +project_token: '' +personal_access_token: diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index e69de29..0000000 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 141e8a9..6045bfe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ require "factory_girl_rails" require "#{File.expand_path('../support/json_output_formatter', __FILE__)}" +require "#{File.expand_path('../support/hint_formatter', __FILE__)}" # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -20,6 +21,7 @@ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods + config.example_status_persistence_file_path = "examples.txt" def h(hint_identifiers) hint_identifiers.split.map { |identifier| I18n.t("hints.#{identifier}") } diff --git a/spec/support/hint_formatter.rb b/spec/support/hint_formatter.rb new file mode 100644 index 0000000..c9d302a --- /dev/null +++ b/spec/support/hint_formatter.rb @@ -0,0 +1,11 @@ +RSpec::Support.require_rspec_core "formatters/documentation_formatter" + +class HintFormatter < RSpec::Core::Formatters::DocumentationFormatter + RSpec::Core::Formatters.register self, :example_failed + + def example_failed(failure) + super + @output.puts "\n\nHint: #{failure.example.metadata[:hint][0]}" if failure.example.metadata[:hint].present? + end + +end diff --git a/whitelist.yml b/whitelist.yml new file mode 100644 index 0000000..ab11e34 --- /dev/null +++ b/whitelist.yml @@ -0,0 +1,4 @@ +--- +- 127.0.0.1 +- 10.240.0.0/16 +- "::1"