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
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ permissions:
contents: read

jobs:
rubocop:
name: RuboCop
standardrb:
name: StandardRB
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand All @@ -25,5 +25,5 @@ jobs:
ruby-version: "3.4"
bundler-cache: true
rubygems: latest
- name: Run RuboCop
run: bundle exec rubocop --parallel
- name: Run StandardRB
run: bundle exec standardrb
38 changes: 0 additions & 38 deletions .rubocop.yml

This file was deleted.

73 changes: 0 additions & 73 deletions .rubocop_todo.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parallel: true
format: progress
ruby_version: 3.1
ignore:
- 'spec/dummy/**/*'
- 'sandbox/**/*'
38 changes: 19 additions & 19 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# frozen_string_literal: true

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

branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: 'solidusio/solidus', branch: branch
branch = ENV.fetch("SOLIDUS_BRANCH", "main")
gem "solidus", github: "solidusio/solidus", branch: branch

# The solidus_frontend gem has been pulled out since v3.2
if branch >= 'v3.2'
gem 'solidus_frontend'
elsif branch == 'main'
gem 'solidus_frontend', github: 'solidusio/solidus_frontend'
if branch >= "v3.2"
gem "solidus_frontend"
elsif branch == "main"
gem "solidus_frontend", github: "solidusio/solidus_frontend"
else
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
gem "solidus_frontend", github: "solidusio/solidus", branch: branch
end

rails_version = ENV.fetch('RAILS_VERSION', '~> 7.0')
rails_version = ENV.fetch("RAILS_VERSION", "~> 7.0")
# CI passes bare versions such as "8.0", which Bundler reads as an exact
# requirement that no released gem satisfies. Treat them as pessimistic instead.
rails_version = "~> #{rails_version}.0" if rails_version.match?(/\A\d+\.\d+\z/)
gem 'rails', rails_version
gem "rails", rails_version

# Extract the minimum Rails version from the version requirement.
# For example, both "~> 7.0" and ">= 7.0" translate to a minimum of "7.0".
rails_req = Gem::Requirement.new(rails_version)
min_rails_version = rails_req.requirements.map(&:last).min || Gem::Version.new('0')
min_rails_version = rails_req.requirements.map(&:last).min || Gem::Version.new("0")

# Determine the sqlite3 version based on the minimum Rails version.
# If the minimum Rails version is less than 7.2, use "~> 1.4"; otherwise, use "~> 2.0".
sqlite_version =
if min_rails_version < Gem::Version.new('7.2')
if min_rails_version < Gem::Version.new("7.2")
"~> 1.4"
else
"~> 2.0"
end

case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
case ENV.fetch("DB", nil)
when "mysql"
gem "mysql2"
when "postgresql"
gem "pg"
else
gem 'sqlite3', sqlite_version
gem "sqlite3", sqlite_version
end

gemspec
Expand All @@ -51,4 +51,4 @@ gemspec
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
14 changes: 7 additions & 7 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

guard "rspec", cmd: "bundle exec rspec" do
watch("spec/spec_helper.rb") { "spec" }
watch("config/routes.rb") { "spec/controllers" }
watch("app/controllers/application_controller.rb") { "spec/controllers" }
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
watch("spec/spec_helper.rb") { "spec" }
watch("config/routes.rb") { "spec/controllers" }
watch("app/controllers/application_controller.rb") { "spec/controllers" }
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ bundle
bin/rake
```

To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
To run [Standard](https://github.com/standardrb/standard) static code analysis run

```shell
bundle exec rubocop
bundle exec standardrb
```

When testing your application's integration with this extension you may use its factories.
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'solidus_dev_support/rake_tasks'
require "solidus_dev_support/rake_tasks"
SolidusDevSupport::RakeTasks.install

task default: 'extension:specs'
task default: "extension:specs"
6 changes: 3 additions & 3 deletions app/models/spree/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class Page < ApplicationRecord
acts_as_list
default_scope -> { order("position ASC") }

has_and_belongs_to_many :stores, join_table: 'spree_pages_stores'
has_and_belongs_to_many :stores, join_table: "spree_pages_stores"

validates :title, presence: true
validates :slug, :body, presence: true, if: :not_using_foreign_link?
validates :layout, presence: { if: :render_layout_as_partial? }
validates :layout, presence: {if: :render_layout_as_partial?}
validates :stores, presence: true

validates :slug, uniqueness: true, if: :not_using_foreign_link?
Expand Down Expand Up @@ -39,7 +39,7 @@ def meta_title

def normalize_slug
# ensure that all slugs start with a slash
slug.prepend('/') if not_using_foreign_link? && (!slug.start_with? '/')
slug.prepend("/") if not_using_foreign_link? && (!slug.start_with? "/")
end

def not_using_foreign_link?
Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
end

# Check if the layout is not the default layout to avoid conflicts with the starter_frontend routes
if Spree::Config.layout != 'layouts/storefront'
if Spree::Config.layout != "layouts/storefront"
constraints(SolidusStaticContent::RouteMatcher) do
get '/(*path)', to: 'static_content#show', as: 'static'
get "/(*path)", to: "static_content#show", as: "static"
end
end
end
6 changes: 3 additions & 3 deletions db/migrate/20090625125735_extend_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def self.up
change_table :spree_pages do |t|
t.boolean :show_in_header, default: false, null: false
t.boolean :show_in_footer, default: false, null: false
t.string :foreign_link
t.string :foreign_link
t.integer :position, default: 1, null: false
if Page.table_exists?
Page.order(:updated_at).each_with_index{ |page, x| page.update_attribute(:position, x + 1) }
Page.order(:updated_at).each_with_index { |page, x| page.update_attribute(:position, x + 1) }
else
Spree::Page.order(:updated_at).each_with_index{ |page, x| page.update_attribute(:position, x + 1) }
Spree::Page.order(:updated_at).each_with_index { |page, x| page.update_attribute(:position, x + 1) }
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ def self.up
change_column :spree_pages, :visible, :boolean, default: true
end

def self.down; end
def self.down
end
end
3 changes: 2 additions & 1 deletion db/migrate/20091219021134_add_meta_fields_to_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ def self.up
add_column :spree_pages, :meta_description, :string
end

def self.down; end
def self.down
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Spree
class StaticContentController < Spree::StoreController
helper 'spree/products'
helper "spree/products"
layout :determine_layout

def show
Expand Down
24 changes: 12 additions & 12 deletions lib/generators/solidus_static_content/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
module SolidusStaticContent
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
source_root File.expand_path("templates", __dir__)
class_option :auto_run_migrations, type: :boolean, default: false
# Either 'starter' or 'classic'
class_option :frontend, type: :string, default: 'classic'
class_option :frontend, type: :string, default: "classic"

def add_stylesheets
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_static_content\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength
inject_into_file "vendor/assets/stylesheets/spree/frontend/all.css", " *= require spree/frontend/solidus_static_content\n", before: %r{\*/}, verbose: true
end

def add_migrations
run 'bin/rails railties:install:migrations FROM=solidus_static_content'
run "bin/rails railties:install:migrations FROM=solidus_static_content"
end

def add_javascripts
empty_directory 'app/assets/javascripts'
empty_directory "app/assets/javascripts"
end

def copy_starter_frontend_files
return if options[:frontend] != 'starter'
return if options[:frontend] != "starter"

copy_file 'app/controllers/static_content_controller.rb'
copy_file 'app/views/static_content/show.html.erb'
copy_file "app/controllers/static_content_controller.rb"
copy_file "app/views/static_content/show.html.erb"

insert_into_file 'config/initializers/spree.rb', after: "Spree.config do |config|\n" do
insert_into_file "config/initializers/spree.rb", after: "Spree.config do |config|\n" do
<<~RUBY.indent(2)
config.layout = 'layouts/storefront'

Expand All @@ -42,11 +42,11 @@ def copy_starter_frontend_files
end

def run_migrations
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Metrics/LineLength
run_migrations = options[:auto_run_migrations] || ["", "y", "Y"].include?(ask("Would you like to run the migrations now? [Y/n]"))
if run_migrations
run 'bin/rails db:migrate'
run "bin/rails db:migrate"
else
puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
puts "Skipping bin/rails db:migrate, don't forget to run it!"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class StaticContentController < StoreController
helper 'spree/products'
helper "spree/products"
layout :determine_layout

def show
Expand Down
Loading
Loading