diff options
author | Alex Legler <alex@a3li.li> | 2015-12-30 18:56:17 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2015-12-30 18:56:17 +0100 |
commit | 4e081ac5d6024b80cb85f73eaf018029d1a47119 (patch) | |
tree | ca3858bc67ce3648d08adc01a1d14f4a991f6b98 | |
parent | Add functionality to add CVEs to CVETool (diff) | |
download | glsamaker-4e081ac5d6024b80cb85f73eaf018029d1a47119.tar.gz glsamaker-4e081ac5d6024b80cb85f73eaf018029d1a47119.tar.bz2 glsamaker-4e081ac5d6024b80cb85f73eaf018029d1a47119.zip |
Update to rails-4.2; first bits of code cleanup
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .rubocop.yml | 20 | ||||
-rw-r--r-- | Gemfile | 26 | ||||
-rw-r--r-- | Gemfile.lock | 282 | ||||
-rwxr-xr-x | bin/rails | 2 | ||||
-rwxr-xr-x | bin/setup | 29 | ||||
-rw-r--r-- | config/application.rb | 4 | ||||
-rw-r--r-- | config/boot.rb | 3 | ||||
-rw-r--r-- | config/environment.rb | 10 | ||||
-rw-r--r-- | config/environments/development.rb | 16 | ||||
-rw-r--r-- | config/environments/production.rb | 11 | ||||
-rw-r--r-- | config/environments/test.rb | 14 | ||||
-rw-r--r-- | config/initializers/assets.rb | 11 | ||||
-rw-r--r-- | config/initializers/cookies_serializer.rb | 3 | ||||
-rw-r--r-- | config/initializers/session_store.rb | 2 | ||||
-rw-r--r-- | config/secrets.yml | 22 |
16 files changed, 291 insertions, 165 deletions
@@ -17,3 +17,4 @@ coverage *.tmproj *.sphinx.conf db/sphinx +.bundle diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..d2f9768 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,20 @@ +Style/AsciiComments: + Enabled: false + +Style/FormatString: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/PerlBackrefs: + Enabled: false + +Metrics/LineLength: + Max: 120 + +Metrics/MethodLength: + Max: 20 + +Metrics/ModuleLength: + Max: 200 @@ -1,13 +1,13 @@ -source :rubygems +source 'https://rubygems.org' -gem 'rails', '4.0.0' +gem 'rails', '4.2.0' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -gem 'mysql2', ' > 0.3.10' +gem 'mysql2', '~> 0.3.18' -gem 'json' +gem 'json', '~>1.8.2' # Gems used only for assets and not required # in production environments by default. @@ -17,7 +17,7 @@ gem 'json' # gem 'uglifier' #end -gem 'prototype-rails' +gem 'prototype-rails', github: 'rails/prototype-rails', branch: '4.2' # Use unicorn as the web server #gem 'unicorn' @@ -35,15 +35,15 @@ group :development do # gem 'require_relative' end -gem "mechanize" -gem "fastercsv" -gem "diff-lcs", :require => "diff/lcs" -gem "nokogiri" -gem "text-format", :require => "text/format" -gem "kramdown" +gem 'mechanize' +gem 'fastercsv' +gem 'diff-lcs', require: 'diff/lcs' +gem 'nokogiri' +gem 'text-format-revised', require: 'text/format' +gem 'kramdown' -gem "thinking-sphinx", '~> 3.0.2' -gem "runspell" +gem 'thinking-sphinx', '~> 3.0.2' +gem 'runspell' # gem "rdoc" diff --git a/Gemfile.lock b/Gemfile.lock index cc32711..7f6394a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,161 +1,185 @@ +GIT + remote: git://github.com/rails/prototype-rails.git + revision: 0fed929ff48c10c3b978edd3baa983a81f404dbf + branch: 4.2 + specs: + prototype-rails (4.0.0) + rails (~> 4.0) + GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - actionmailer (4.0.0) - actionpack (= 4.0.0) - mail (~> 2.5.3) - actionpack (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) + actionmailer (4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.0) + actionview (= 4.2.0) + activesupport (= 4.2.0) + rack (~> 1.6.0) rack-test (~> 0.6.2) - activemodel (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - activerecord (4.0.0) - activemodel (= 4.0.0) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.0) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.0) - i18n (~> 0.6, >= 0.6.4) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - ansi (1.4.3) - arel (4.0.0) - atomic (1.1.14) - builder (3.1.4) - capistrano (2.15.5) - highline - net-scp (>= 1.0.0) - net-sftp (>= 2.0.0) - net-ssh (>= 2.0.14) - net-ssh-gateway (>= 1.1.0) - ci_reporter (1.9.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.0) + activesupport (= 4.2.0) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + activejob (4.2.0) + activesupport (= 4.2.0) + globalid (>= 0.3.0) + activemodel (4.2.0) + activesupport (= 4.2.0) + builder (~> 3.1) + activerecord (4.2.0) + activemodel (= 4.2.0) + activesupport (= 4.2.0) + arel (~> 6.0) + activesupport (4.2.0) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + ansi (1.5.0) + arel (6.0.3) + builder (3.2.2) + capistrano (3.4.0) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + ci_reporter (2.0.0) builder (>= 2.1.2) - daemons (1.2.2) - diff-lcs (1.2.4) - domain_name (0.5.13) + concurrent-ruby (1.0.0) + daemons (1.2.3) + diff-lcs (1.2.5) + docile (1.1.5) + domain_name (0.5.25) unf (>= 0.0.5, < 1.0.0) erubis (2.7.0) - eventmachine (1.0.7) + eventmachine (1.0.8) fastercsv (1.5.5) - hashie (2.0.5) - highline (1.6.19) - hike (1.2.3) + globalid (0.3.6) + activesupport (>= 4.1.0) http-cookie (1.0.2) domain_name (~> 0.5) - i18n (0.6.5) + i18n (0.7.0) innertube (1.1.0) - json (1.8.0) - kramdown (1.2.0) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mechanize (2.7.2) + json (1.8.3) + kramdown (1.9.0) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mechanize (2.7.3) domain_name (~> 0.5, >= 0.5.1) - http-cookie (~> 1.0.0) - mime-types (~> 1.17, >= 1.17.2) + http-cookie (~> 1.0) + mime-types (~> 2.0) net-http-digest_auth (~> 1.1, >= 1.1.1) net-http-persistent (~> 2.5, >= 2.5.2) nokogiri (~> 1.4) ntlm-http (~> 0.1, >= 0.1.1) webrobots (>= 0.0.9, < 0.2) middleware (0.1.0) - mime-types (1.25) - mini_portile (0.5.1) - minitest (4.7.5) - minitest-reporters (0.14.23) + mime-types (2.99) + mini_portile2 (2.0.0) + minitest (5.8.3) + minitest-reporters (1.1.7) ansi builder - minitest (>= 2.12, < 5.0) - powerbar - multi_json (1.8.0) - mysql2 (0.3.13) + minitest (>= 5.0) + ruby-progressbar + mysql2 (0.3.20) net-http-digest_auth (1.4) - net-http-persistent (2.9) - net-scp (1.1.2) + net-http-persistent (2.9.4) + net-scp (1.2.1) net-ssh (>= 2.6.5) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) - net-ssh (2.7.0) - net-ssh-gateway (1.2.0) - net-ssh (>= 2.6.5) - nokogiri (1.6.0) - mini_portile (~> 0.5.0) + net-ssh (3.0.2) + nokogiri (1.6.7.1) + mini_portile2 (~> 2.0.0.rc2) ntlm-http (0.1.1) - polyglot (0.3.3) - powerbar (1.0.11) - ansi (~> 1.4.0) - hashie (>= 1.1.0) - prototype-rails (3.2.0) - railties (>= 3.2.0.beta, < 5.0) - rack (1.5.2) - rack-test (0.6.2) + rack (1.6.4) + rack-test (0.6.3) rack (>= 1.0) - rails (4.0.0) - actionmailer (= 4.0.0) - actionpack (= 4.0.0) - activerecord (= 4.0.0) - activesupport (= 4.0.0) + rails (4.2.0) + actionmailer (= 4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) + activemodel (= 4.2.0) + activerecord (= 4.2.0) + activesupport (= 4.2.0) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.0) - sprockets-rails (~> 2.0.0) - railties (4.0.0) - actionpack (= 4.0.0) - activesupport (= 4.0.0) + railties (= 4.2.0) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.7) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.2) + loofah (~> 2.0) + railties (4.2.0) + actionpack (= 4.2.0) + activesupport (= 4.2.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.1.0) - riddle (1.5.8) - rspec (2.14.1) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rspec-core (2.14.5) - rspec-expectations (2.14.3) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.3) + rake (10.4.2) + riddle (1.5.12) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.1) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) + ruby-progressbar (1.7.5) runspell (0.0.1) - simplecov (0.7.1) - multi_json (~> 1.0) - simplecov-html (~> 0.7.1) - simplecov-html (0.7.1) - sprockets (2.10.0) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (~> 2.8) - text-format (1.0.0) - thin (1.6.3) + simplecov (0.11.1) + docile (~> 1.1.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) + sprockets (3.5.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.0.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sshkit (1.8.1) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) + text-format-revised (1.1.0) + text-hyphen (~> 1.2.0) + text-hyphen (1.2) + thin (1.6.4) daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0) + eventmachine (~> 1.0, >= 1.0.4) rack (~> 1.0) - thinking-sphinx (3.0.5) + thinking-sphinx (3.0.6) activerecord (>= 3.1.0) builder (>= 2.1.2) innertube (>= 1.0.2) middleware (>= 0.1.0) - riddle (>= 1.5.8) - thor (0.18.1) - thread_safe (0.1.3) - atomic - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.37) - unf (0.1.2) + riddle (>= 1.5.9) + thor (0.19.1) + thread_safe (0.3.5) + tzinfo (1.2.2) + thread_safe (~> 0.1) + unf (0.1.4) unf_ext - unf_ext (0.0.6) + unf_ext (0.0.7.1) webrobots (0.1.1) PLATFORMS @@ -166,17 +190,17 @@ DEPENDENCIES ci_reporter diff-lcs fastercsv - json + json (~> 1.8.2) kramdown mechanize minitest-reporters - mysql2 (> 0.3.10) + mysql2 (~> 0.3.18) nokogiri - prototype-rails - rails (= 4.0.0) + prototype-rails! + rails (= 4.2.0) rspec runspell simplecov - text-format + text-format-revised thin thinking-sphinx (~> 3.0.2) @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..acdb2c1 --- /dev/null +++ b/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/config/application.rb b/config/application.rb index f962768..fff588f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,6 +13,8 @@ module Glsamaker # -- all .rb files in that directory are automatically loaded. config.autoload_paths += ["#{config.root}/lib"] + config.assets.precompile += %w( cve.css jsui.js ) + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' @@ -30,4 +32,4 @@ module Glsamaker end # Manually load the kramdown extensions -require_relative '../lib/kramdown_ext'
\ No newline at end of file +require_relative '../lib/kramdown_ext' diff --git a/config/boot.rb b/config/boot.rb index 3596736..6b750f0 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index dc20617..88a9809 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,9 +1,9 @@ -# Load the rails application +# Load the rails Rpplication require File.expand_path('../application', __FILE__) -# Initialize the rails application -Glsamaker::Application.initialize! +# Initialize the Rails application +Rails.application.initialize! -GLSAMAKER_VERSION="2.0" +GLSAMAKER_VERSION = '2.0' -require 'digest/md5'
\ No newline at end of file +require 'digest/md5' diff --git a/config/environments/development.rb b/config/environments/development.rb index e344a71..b55e214 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -Glsamaker::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on @@ -19,11 +19,23 @@ Glsamaker::Application.configure do # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 0a5b615..3c15775 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,11 +1,11 @@ -Glsamaker::Application.configure do +Rails.Application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both thread web servers + # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true @@ -20,7 +20,7 @@ Glsamaker::Application.configure do # config.action_dispatch.rack_cache = true # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.compress = false @@ -33,9 +33,6 @@ Glsamaker::Application.configure do # Generate digests for assets URLs. config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. - config.assets.version = '1.0' - # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx @@ -60,7 +57,7 @@ Glsamaker::Application.configure do # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. - config.assets.precompile += %w( cve.css jsui.js ) + # config.assets.precompile += %w( cve.css jsui.js ) # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. diff --git a/config/environments/test.rb b/config/environments/test.rb index f022bf2..1c19f08 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -Glsamaker::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's @@ -12,9 +12,9 @@ Glsamaker::Application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" + # Configure static file server for tests with Cache-Control for performance. + config.serve_static_files = true + config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -31,6 +31,12 @@ Glsamaker::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Randomize the order test cases are executed. + config.active_support.test_order = :random + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..01ef3e6 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..ac5f8b6 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :marshal diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index b8f12ea..df488ac 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Glsamaker::Application.config.session_store :cookie_store, key: '_glsamaker_session' +Rails.application.config.session_store :cookie_store, key: '_glsamaker_session' diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 0000000..a98e48f --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 865902986d47e642f24b044ba251bfa4bc1b180c15a83ed6727b7a18931aa5452cf0d221fb0519c945de1b1828c46fb484eb7c792b213a2530f1f605cf465b60 + +test: + secret_key_base: 7b16cf2278f7afa09663e09c8043579e1ed7d4df18a48f60d878b810824a89ec8ddbe7b948b10701f3636e78c44f0baa3bdbd7b38e2ed6afa669bb2bd197f5e3 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> |