Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ Style/NegatedIfElseCondition:
Style/NumericLiterals:
Exclude:
- spec/dummy/db/**/schema*.rb

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
86 changes: 43 additions & 43 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

if ENV['DEVEL'] == '1'
gem 'active_storage_db', path: './'
if ENV["DEVEL"] == "1"
gem "active_storage_db", path: "./"
else
gemspec
end

ruby_ver = ENV.fetch('RUBY_VERSION', '')
rails_ver = ENV.fetch('RAILS_VERSION', '')
ruby_ver = ENV.fetch("RUBY_VERSION", "")
rails_ver = ENV.fetch("RAILS_VERSION", "")

rails =
if rails_ver.empty?
['rails']
elsif rails_ver.count('.') < 2
['rails', "~> #{rails_ver}"]
["rails"]
elsif rails_ver.count(".") < 2
["rails", "~> #{rails_ver}"]
else
['rails', rails_ver]
["rails", rails_ver]
end
gem(*rails)

ruby32 = ruby_ver.empty? || Gem::Version.new(ruby_ver) >= Gem::Version.new('3.2')
gem 'zeitwerk', '~> 2.6.18' unless ruby32
ruby32 = ruby_ver.empty? || Gem::Version.new(ruby_ver) >= Gem::Version.new("3.2")
gem "zeitwerk", "~> 2.6.18" unless ruby32

# DB driver
case ENV.fetch('DB_TEST', nil)
when 'mssql'
gem 'activerecord-sqlserver-adapter'
gem 'tiny_tds'
when 'mysql'
gem 'mysql2'
when 'postgres'
gem 'pg'
case ENV.fetch("DB_TEST", nil)
when "mssql"
gem "activerecord-sqlserver-adapter"
gem "tiny_tds"
when "mysql"
gem "mysql2"
when "postgres"
gem "pg"
else
rails72 = rails_ver.empty? || Gem::Version.new(rails_ver) >= Gem::Version.new('7.2')
sqlite3 = ruby32 && rails72 ? ['sqlite3'] : ['sqlite3', '~> 1.4']
rails72 = rails_ver.empty? || Gem::Version.new(rails_ver) >= Gem::Version.new("7.2")
sqlite3 = ruby32 && rails72 ? ["sqlite3"] : ["sqlite3", "~> 1.4"]
gem(*sqlite3)
end

# NOTE: to avoid error: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger
gem 'concurrent-ruby', '1.3.4'
gem "concurrent-ruby", "1.3.4"

gem 'bigdecimal'
gem 'bullet'
gem 'image_processing', '>= 1.2'
gem 'mutex_m'
gem 'puma'
gem 'sprockets-rails'
gem "bigdecimal"
gem "bullet"
gem "image_processing", ">= 1.2"
gem "mutex_m"
gem "puma"
gem "sprockets-rails"

# Testing
gem 'capybara'
gem 'factory_bot_rails'
gem 'rspec_junit_formatter'
gem 'rspec-rails'
gem 'selenium-webdriver'
gem 'simplecov'
gem 'simplecov-lcov'
gem "capybara"
gem "factory_bot_rails"
gem "rspec_junit_formatter"
gem "rspec-rails"
gem "selenium-webdriver"
gem "simplecov"
gem "simplecov-lcov"

# Linters
gem 'brakeman'
gem 'fasterer'
gem 'rubocop'
gem 'rubocop-packaging'
gem 'rubocop-performance'
gem 'rubocop-rails'
gem 'rubocop-rspec'
gem "brakeman"
gem "fasterer"
gem "rubocop"
gem "rubocop-packaging"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rspec"

# Tools
gem 'pry-rails'
gem "pry-rails"
28 changes: 14 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# frozen_string_literal: true

begin
require 'bundler/setup'
require "bundler/setup"
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end

require 'rdoc/task'
require "rdoc/task"

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ActiveStorageDB'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_dir = "rdoc"
rdoc.title = "ActiveStorageDB"
rdoc.options << "--line-numbers"
rdoc.rdoc_files.include("README.md")
rdoc.rdoc_files.include("lib/**/*.rb")
end

APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load 'rails/tasks/engine.rake'
load "rails/tasks/engine.rake"

load 'rails/tasks/statistics.rake'
load "rails/tasks/statistics.rake"

require 'bundler/gem_tasks'
require "bundler/gem_tasks"

begin
require 'rspec/core/rake_task'
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec) do |t|
# t.ruby_opts = %w[-w]
t.rspec_opts = ['--color', '--format documentation']
t.rspec_opts = ["--color", "--format documentation"]
end

task default: :spec
rescue LoadError
puts '! LoadError: no RSpec available'
puts "! LoadError: no RSpec available"
end
2 changes: 1 addition & 1 deletion config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'DB'
inflect.acronym "DB"
end
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

ActiveStorageDB::Engine.routes.draw do
get '/files/:encoded_key/*filename', to: 'files#show', as: :service
put '/files/:encoded_token', to: 'files#update', as: :update_service
get "/files/:encoded_key/*filename", to: "files#show", as: :service
put "/files/:encoded_token", to: "files#update", as: :update_service
end
4 changes: 2 additions & 2 deletions lib/active_storage_db.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'active_storage_db/engine'
require 'active_storage/service/db_service'
require "active_storage_db/engine"
require "active_storage/service/db_service"

module ActiveStorageDB
end
2 changes: 1 addition & 1 deletion lib/active_storage_db/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ActiveStorageDB
VERSION = '1.6.0'
VERSION = "1.6.0"
end
2 changes: 1 addition & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Application < Rails::Application
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

config.hosts << 'test.example.com'
config.hosts << "test.example.com"

config.before_initialize do
FactoryBot.definition_file_paths << Rails.root.join("../factories") if defined?(FactoryBot)
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

Rails.application.routes.draw do
mount ActiveStorageDB::Engine => '/active_storage_db'
mount ActiveStorageDB::Engine => "/active_storage_db"

resources :posts

root 'posts#index'
root "posts#index"
end
4 changes: 2 additions & 2 deletions spec/factories/active_storage_db_files.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

FactoryBot.define do
factory :active_storage_db_file, class: 'ActiveStorageDB::File' do
ref { ('a'..'z').to_a.sample(32).join }
factory :active_storage_db_file, class: "ActiveStorageDB::File" do
ref { ("a".."z").to_a.sample(32).join }

data do
(+"\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000\020\000\000\000\020\001\003\000\000\000%=m\"\000\000\000\006PLTE\000\000\000\377\377\377\245\331\237\335\000\000\0003IDATx\234c\370\377\237\341\377_\206\377\237\031\016\2603\334?\314p\1772\303\315\315\f7\215\031\356\024\203\320\275\317\f\367\201R\314\f\017\300\350\377\177\000Q\206\027(\316]\233P\000\000\000\000IEND\256B`\202").force_encoding(Encoding::BINARY)
Expand Down
20 changes: 10 additions & 10 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

ENV['RAILS_ENV'] = 'test'
ENV["RAILS_ENV"] = "test"

require 'simplecov'
require 'simplecov-lcov'
require "simplecov"
require "simplecov-lcov"

SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
Expand All @@ -26,15 +26,15 @@
add_filter %r{^/vendor/}
end

require 'spec_helper'
require "spec_helper"

require File.expand_path("dummy/config/environment.rb", __dir__)

abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'rspec/rails'
require 'factory_bot_rails'
abort("The Rails environment is running in production mode!") if Rails.env.production?
require "rspec/rails"
require "factory_bot_rails"

support_files = File.expand_path('support/**/*.rb', __dir__)
support_files = File.expand_path("support/**/*.rb", __dir__)
Dir[support_files].sort.each { |f| require f }

RSpec.configure do |config|
Expand All @@ -50,14 +50,14 @@
ActiveRecord::Base.connection_config
end

intro = ('-' * 80)
intro = ("-" * 80)
intro << "\n"
intro << "- Ruby: #{RUBY_VERSION}\n"
intro << "- Rails: #{Rails.version}\n"
intro << "- ActiveStorage: #{ActiveStorage.version}\n"
intro << "- DB adapter: #{db_config[:adapter]}\n"
intro << "- DB name: #{db_config[:database]}\n"
intro << ('-' * 80)
intro << ("-" * 80)

RSpec.configuration.reporter.message(intro)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/file_url_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

RSpec.describe 'File URL' do
RSpec.describe "File URL" do
let(:app_url_helpers) { Rails.application.routes.url_helpers }
let(:engine_url_helpers) { ActiveStorageDB::Engine.routes.url_helpers }

it 'has the service URL in the engine URL helpers' do
it "has the service URL in the engine URL helpers" do
expect(app_url_helpers).to respond_to :active_storage_db_path
expect(engine_url_helpers).to respond_to :service_url
end
Expand Down
Loading