Skip to content

Commit

Permalink
Fix all rubocop errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkit110 committed Aug 30, 2024
1 parent aba071a commit 752d55b
Show file tree
Hide file tree
Showing 73 changed files with 90 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ jobs:
run: bundle exec rails db:create db:schema:load --trace
- name: Run tests
run: bundle exec rails test
- name: Lint
run: bundle exec rubocop
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source "https://rubygems.org"

gemspec
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
begin
require "bundler/setup"
rescue LoadError
Expand Down
1 change: 1 addition & 0 deletions app/controllers/fogged/resources_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# The Resource API. This API has only 3 methods: create, confirm and destroy.
#
# To create a new resource, call the create method with a filename and a
Expand Down
1 change: 1 addition & 0 deletions app/jobs/fogged/resources/awsthumbnailjob.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
module Resources
class AWSThumbnailJob < ActiveJob::Base
Expand Down
6 changes: 6 additions & 0 deletions app/models/fogged/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true
module Fogged
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
end
5 changes: 3 additions & 2 deletions app/models/fogged/resource.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true
module Fogged
class Resource < ActiveRecord::Base
class Resource < ApplicationRecord
validates :extension, :content_type, :name, presence: true

before_save :ensure_token
Expand Down Expand Up @@ -75,7 +76,7 @@ def image?
def encoding?
unless encoding_progress.present? &&
(video? || (image? && Fogged.active_job_enabled))
return
return false
end

encoding_progress < 100
Expand Down
1 change: 1 addition & 0 deletions app/models/fogged/resources/awsencoder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
module Resources
class AWSEncoder
Expand Down
1 change: 1 addition & 0 deletions app/models/fogged/resources/encoder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
module Resources
class Encoder
Expand Down
1 change: 1 addition & 0 deletions app/serializers/fogged/resource_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
class ResourceSerializer < ActiveModel::Serializer
type :resource
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Fogged::Engine.routes.draw do
resources :resources do
put :confirm, on: :member
Expand Down
3 changes: 2 additions & 1 deletion db/migrate/20141103143408_create_fogged_resources.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class CreateFoggedResources < ActiveRecord::Migration
def change
create_table :fogged_resources do |t|
Expand All @@ -6,7 +7,7 @@ def change
t.integer :width
t.integer :height
t.string :extension, null: false
t.boolean :uploading
t.boolean :uploading # rubocop:disable Rails/ThreeStateBooleanColumn
t.string :content_type, null: false
t.integer :encoding_progress
t.string :encoding_job_id
Expand Down
3 changes: 2 additions & 1 deletion lib/fogged.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Gem.loaded_specs["fogged"].dependencies.select { |d| d.type == :runtime }.each do |d|
require d.name
end
Expand Down Expand Up @@ -83,7 +84,7 @@ def self.aws_resources
aws_access_key_id: Fogged.aws_key,
aws_secret_access_key: Fogged.aws_secret
}
storage_options.merge!(region: Fogged.aws_region) if Fogged.aws_region
storage_options[:region] = Fogged.aws_region if Fogged.aws_region
Fogged.storage = Fog::Storage.new(storage_options)

Fogged.storage.directories.get(Fogged.aws_bucket)
Expand Down
1 change: 1 addition & 0 deletions lib/fogged/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
class Engine < ::Rails::Engine
isolate_namespace Fogged
Expand Down
3 changes: 2 additions & 1 deletion lib/fogged/has_many_resources.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
module HasManyResources
extend ActiveSupport::Concern
Expand All @@ -20,7 +21,7 @@ def has_many_resources(*args)
private

def _check_resources
return if resources.to_a.select(&:uploading).empty?
return if resources.to_a.none?(&:uploading)

errors.add(:resources, I18n.t("fogged.resources.still_uploading"))
end
Expand Down
1 change: 1 addition & 0 deletions lib/fogged/has_one_resource.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
module HasOneResource
extend ActiveSupport::Concern
Expand Down
1 change: 1 addition & 0 deletions lib/fogged/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym "AWSEncoder"
inflect.acronym "AWSThumbnailJob"
Expand Down
1 change: 1 addition & 0 deletions lib/fogged/utils.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
def self.directory_public_url(directory_name)
case Fogged.provider
Expand Down
1 change: 1 addition & 0 deletions lib/fogged/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
VERSION = "0.2.2"
end
1 change: 1 addition & 0 deletions lib/fogged/with_directory.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
def self.with_directory(directory_name)
old_resources = Fogged._resources
Expand Down
1 change: 1 addition & 0 deletions lib/fogged/zencoder_additional_outputs.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Fogged
mattr_accessor :zencoder_additional_outputs_block

Expand Down
1 change: 1 addition & 0 deletions lib/tasks/fogged_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# desc "Explaining what the task does"
# task :fogged do
# # Task goes here
Expand Down
1 change: 1 addition & 0 deletions test/controllers/concerns/json_test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module JsonTestHelper
extend ActiveSupport::Concern

Expand Down
1 change: 1 addition & 0 deletions test/controllers/concerns/resource_test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module ResourceTestHelper
extend ActiveSupport::Concern
include JsonTestHelper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
1 change: 1 addition & 0 deletions test/controllers/fogged/resources_controller/show_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
1 change: 1 addition & 0 deletions test/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/controllers/images_controllers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class ImagesControllers < ApplicationController
def index
render json: Image.all
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
module ApplicationHelper
end
4 changes: 4 additions & 0 deletions test/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
3 changes: 2 additions & 1 deletion test/dummy/app/models/image.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class Image < ActiveRecord::Base
# frozen_string_literal: true
class Image < ApplicationRecord
has_one_resource
end
3 changes: 2 additions & 1 deletion test/dummy/app/models/movie.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Movie < ActiveRecord::Base
# frozen_string_literal: true
class Movie < ApplicationRecord
has_many :movie_fogged_resources
has_many_resources through: :movie_fogged_resources
end
3 changes: 2 additions & 1 deletion test/dummy/app/models/movie_fogged_resource.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class MovieFoggedResource < ActiveRecord::Base
# frozen_string_literal: true
class MovieFoggedResource < ApplicationRecord
belongs_to :movie
belongs_to :resource, class_name: "Fogged::Resource"
end
1 change: 1 addition & 0 deletions test/dummy/bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
load Gem.bin_path("bundler", "bundle")
1 change: 1 addition & 0 deletions test/dummy/bin/delayed_job
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require File.expand_path(File.join(File.dirname(__FILE__), "..", "config", "environment"))
require "delayed/command"
Expand Down
1 change: 1 addition & 0 deletions test/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
1 change: 1 addition & 0 deletions test/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative "../config/boot"
require "rake"
Rake.application.run
1 change: 1 addition & 0 deletions test/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.

require File.expand_path("config/environment", __dir__)
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require File.expand_path("boot", __dir__)

require "rails/all"
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)

Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Load the Rails application.
require File.expand_path("application", __dir__)

Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do
config.active_support.test_order = :sorted
# Settings specified here will take precedence over those in config/application.rb.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/assets.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.

# Version of your assets, change this if you want to expire all your assets.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/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
1 change: 1 addition & 0 deletions test/dummy/config/initializers/cookies_serializer.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.

Rails.application.config.action_dispatch.cookies_serializer = :json
1 change: 1 addition & 0 deletions test/dummy/config/initializers/filter_parameter_logging.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.

# Configure sensitive parameters which will be filtered from the log file.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/fog.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# frozen_string_literal: true
Fog.mock! if Rails.env.test?
1 change: 1 addition & 0 deletions test/dummy/config/initializers/fogged.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Fogged.configure do |config|
config.provider = :aws
config.aws_key = ENV.fetch("AWS_KEY", nil)
Expand Down
1 change: 1 addition & 0 deletions test/dummy/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
1 change: 1 addition & 0 deletions test/dummy/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
1 change: 1 addition & 0 deletions test/dummy/config/initializers/session_store.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.

Rails.application.config.session_store :cookie_store, key: "_dummy_session"
1 change: 1 addition & 0 deletions test/dummy/config/initializers/wrap_parameters.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.

# This file contains settings for ActionController::ParamsWrapper which
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.routes.draw do
resources :images, only: :index
mount Fogged::Engine => "/"
Expand Down
1 change: 1 addition & 0 deletions test/dummy/db/migrate/20141104135257_create_images.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class CreateImages < ActiveRecord::Migration
def change
create_table :images, force: true do |t|
Expand Down
1 change: 1 addition & 0 deletions test/dummy/db/migrate/20141104152227_create_movies.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class CreateMovies < ActiveRecord::Migration
def change
create_table :movies, force: true do |t|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class CreateMovieFoggedResources < ActiveRecord::Migration
def change
create_table :movie_fogged_resources, force: true do |t|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class CreateDelayedJobs < ActiveRecord::Migration
def self.up
create_table :delayed_jobs, force: true do |table|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class ResourcesControllerIndexTest < ActionController::TestCase
Expand Down
1 change: 1 addition & 0 deletions test/dummy/test/models/image_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class ImageTest < ActiveSupport::TestCase
Expand Down
1 change: 1 addition & 0 deletions test/dummy/test/models/movie_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class MovieTest < ActiveSupport::TestCase
Expand Down
1 change: 1 addition & 0 deletions test/fogged_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

class FoggedTest < ActiveSupport::TestCase
Expand Down
1 change: 1 addition & 0 deletions test/jobs/fogged/resources/aws_thumbnail_job_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
1 change: 1 addition & 0 deletions test/models/fogged/resource_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "test_helper"

module Fogged
Expand Down
Loading

0 comments on commit 752d55b

Please sign in to comment.