Skip to content

Commit

Permalink
Freeze all the strings
Browse files Browse the repository at this point in the history
This will help us be prepared for Ruby 3
  • Loading branch information
jcoyne committed Dec 17, 2019
1 parent 3a38748 commit 26612f4
Show file tree
Hide file tree
Showing 86 changed files with 167 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ RSpec/MultipleExpectations:
RSpec/NestedGroups:
Max: 4 # default: 3

Style/FrozenStringLiteralComment:
Enabled: false

Style/NumericPredicate: # "> 0" is not less readable than ".positive?"
Enabled: false

Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
before_action :authenticate_user! # ensures that remote user is logged in locally (via database)
end
2 changes: 2 additions & 0 deletions app/controllers/bundle_contexts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class BundleContextsController < ApplicationController
def new
@bundle_context = BundleContext.new(
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/job_runs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class JobRunsController < ApplicationController
def create
raise ActionController::ParameterMissing, :bundle_context_id unless job_run_params[:bundle_context_id]
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
2 changes: 2 additions & 0 deletions app/jobs/discovery_report_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class DiscoveryReportJob < ApplicationJob
queue_as :discovery_report

Expand Down
2 changes: 2 additions & 0 deletions app/jobs/preassembly_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class PreassemblyJob < ApplicationJob
queue_as :preassembly

Expand Down
2 changes: 2 additions & 0 deletions app/lib/csv_importer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CsvImporter
# load CSV allowing UTF-8 to pass through, deleting blank columns
# @param [String] filename
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/assembly_directory.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
# Represents the assembly structure on the filesystem
class AssemblyDirectory
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/bundle.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
class Bundle
include PreAssembly::Logging
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/content_metadata_creator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
class ContentMetadataCreator
def initialize(druid_id:, content_md_creation:, object_files:, content_md_creation_style:, media_manifest:)
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/copy_stager.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
class CopyStager
def self.stage(source, destination)
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/digital_object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
class DigitalObject
include PreAssembly::Logging
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/link_stager.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
class LinkStager
def self.stage(source, destination)
Expand Down
6 changes: 4 additions & 2 deletions app/lib/pre_assembly/logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
module Logging
LEVELS = {
Expand All @@ -8,8 +10,8 @@ module Logging
debug: Logger::DEBUG
}.freeze

LOG_FORMAT = "%-6s -- %s -- %s\n".freeze
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'.freeze
LOG_FORMAT = "%-6s -- %s -- %s\n"
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'

@@log ||= Logger.new(File.join(Rails.root, 'log', "#{Rails.env}.log"))
@@log.level = LEVELS[:info]
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/media.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This class generates contentMetadata from a Media supplied manifest
# see the "SMPL Content" section here for a description of the manifest:
# https://consul.stanford.edu/pages/viewpage.action?pageId=136365158#AutomatedAccessioningandObjectRemediation(pre-assemblyandassembly)-SMPLContent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
# Looks for *_techmd.xml files in the bundle_dir and concatenates them
class MediaProjectTechnicalMetadataCreator
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pre_assembly/object_file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PreAssembly
class ObjectFile < Assembly::ObjectFile
include ActiveModel::AttributeMethods
Expand Down
2 changes: 2 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: 'no-reply-preassembly@.stanford.edu'
layout 'mailer'
Expand Down
2 changes: 2 additions & 0 deletions app/mailers/job_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class JobMailer < ApplicationMailer
default from: 'no-reply-preassembly-job@stanford.edu'

Expand Down
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 2 additions & 0 deletions app/models/bundle_context.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class BundleContext < ApplicationRecord
belongs_to :user
has_many :job_runs, dependent: :destroy
Expand Down
2 changes: 2 additions & 0 deletions app/models/job_run.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class JobRun < ApplicationRecord
belongs_to :bundle_context
validates :job_type, presence: true
Expand Down
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class User < ApplicationRecord
devise :remote_user_authenticatable # We don't want other (default) Devise modules
has_many :bundle_contexts, dependent: :destroy
Expand Down
2 changes: 2 additions & 0 deletions app/services/discovery_report.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Previously a single untested 200-line method from ./lib/pre_assembly/reporting.rb
# Takes a Bundle, enumerates report data via #each_row
class DiscoveryReport
Expand Down
2 changes: 2 additions & 0 deletions app/services/object_file_validator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ObjectFileValidator
def initialize(object:, bundle:)
@object = object
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'boot'
require 'rails/all'

Expand Down
2 changes: 2 additions & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
2 changes: 2 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

set :application, 'pre-assembly'
set :repo_url, 'ssh://git@github.com/sul-dlss/pre-assembly'

Expand Down
2 changes: 2 additions & 0 deletions config/deploy/prod.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

server 'sul-preassembly-prod.stanford.edu', user: 'preassembly', roles: %w[web app db]

Capistrano::OneTimeKey.generate_one_time_key!
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/stage.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

server 'sul-preassembly-stage.stanford.edu', user: 'preassembly', roles: %w[web app db]

Capistrano::OneTimeKey.generate_one_time_key!
Expand Down
2 changes: 2 additions & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Load the Rails application.
require_relative 'application'

Expand Down
1 change: 1 addition & 0 deletions config/initializers/application_controller_renderer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# ActiveSupport::Reloader.to_prepare do
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# 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.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/backtrace_silencers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# 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.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Config.setup do |config|
# Name of the constant exposing loaded settings
config.const_name = 'Settings'
Expand Down
1 change: 1 addition & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Specify a serializer for the signed and encrypted cookie jars.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/dor_config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'dor-services'

Dor::Config.configure do
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Configure sensitive parameters which will be filtered from the log file.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/load_config.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

bundle_dir_roots = YAML.safe_load(ERB.new(File.read("#{Rails.root}/config/initializers/bundle_dir_roots.yml.erb")).result)[Rails.env]
ALLOWABLE_BUNDLE_DIRS = bundle_dir_roots.map { |path| path.chomp('/') }
1 change: 1 addition & 0 deletions config/initializers/mime_types.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/okcomputer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# by default, okcomputer does "app up?" and "database conntected?" checks
OkComputer.mount_at = 'status' # use /status or /status/all or /status/<name-of-check>
OkComputer.check_in_parallel = true
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/resque.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'resque/failure/redis_multi_queue'

# load environment specific configuration
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# This file contains settings for ActionController::ParamsWrapper which
Expand Down
2 changes: 2 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'resque/server'
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
Expand Down
2 changes: 2 additions & 0 deletions config/spring.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

%w[
.ruby-version
.rbenv-vars
Expand Down
2 changes: 2 additions & 0 deletions lib/dev_shibboleth_headers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This is a Rack middleware that we use in development. It sets an env var in such a way as to
# simulate the way mod_shib injects request headers that then result in an env var being set
# for the request.
Expand Down
2 changes: 2 additions & 0 deletions lib/tasks/resque.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'resque/tasks'
task 'resque:setup' => :environment

Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/bundle_contexts_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe BundleContextsController, type: :controller do
let(:params) do
{
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/job_runs_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe JobRunsController, type: :controller do
let(:bc) { create(:bundle_context_with_deleted_output_dir) }

Expand Down
2 changes: 2 additions & 0 deletions spec/factories/bundle_contexts.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

FactoryBot.define do
factory :bundle_context do
bundle_dir { 'spec/test_data/multimedia' }
Expand Down
2 changes: 2 additions & 0 deletions spec/factories/job_runs.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

FactoryBot.define do
factory :job_run do
job_type { 'discovery_report' }
Expand Down
2 changes: 2 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

FactoryBot.define do
factory :user do
sequence(:sunet_id) { |n| "fake_#{n}" }
Expand Down
2 changes: 2 additions & 0 deletions spec/jobs/discovery_report_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe DiscoveryReportJob, type: :job do
let(:job) { described_class.new }
let(:job_run) { create(:job_run) }
Expand Down
2 changes: 2 additions & 0 deletions spec/jobs/preassembly_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe PreassemblyJob, type: :job do
let(:job) { described_class.new }
let(:job_run) { create(:job_run) }
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/csv_importer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe CsvImporter do
describe '#parse_to_hash' do
let(:manifest) do
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/pre_assembly/assembly_directory_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe PreAssembly::AssemblyDirectory do
subject(:object) { described_class.new(druid_id: 'gn330dv6119') }

Expand Down
2 changes: 2 additions & 0 deletions spec/lib/pre_assembly/bundle_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe PreAssembly::Bundle do
let(:md5_regex) { /^[0-9a-f]{32}$/ }
let(:flat_dir_images) { bundle_setup(:flat_dir_images) }
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/pre_assembly/content_metadata_creator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe PreAssembly::ContentMetadataCreator do
subject(:object) do
described_class.new(druid_id: druid_id,
Expand Down

0 comments on commit 26612f4

Please sign in to comment.