Skip to content

Commit

Permalink
restore and update.
Browse files Browse the repository at this point in the history
  • Loading branch information
avonderluft committed Nov 10, 2023
1 parent 78783cc commit b2805cd
Show file tree
Hide file tree
Showing 27 changed files with 77 additions and 79 deletions.
4 changes: 2 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class Application < Rails::Application
# config.active_record.allow_deprecated_singular_associations_name = true
# config.active_support.raise_on_invalid_cache_expiration_time = false
# config.active_record.sqlite3_adapter_strict_strings_by_default = false
# config.active_support.cache_format_version = 7.0
config.active_support.cache_format_version = 7.0
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w[tasks])
config.autoload_lib(ignore: %w[generators])
end

# Making sure we don't load our dev routes as part of the engine
Expand Down
File renamed without changes.
67 changes: 67 additions & 0 deletions lib/generators/occams/cms/cms_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# frozen_string_literal: true

require 'rails/generators/active_record'

module Occams
module Generators
class CmsGenerator < Rails::Generators::Base
include Rails::Generators::Migration
include Thor::Actions

source_root File.expand_path('../../../..', __dir__)

def generate_migration
destination = File.expand_path('db/migrate/01_create_cms.rb', destination_root)
migration_dir = File.dirname(destination)
destination = self.class.migration_exists?(migration_dir, 'create_cms')

if destination
puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m"
else
migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb'
end
end

def generate_initializer
copy_file 'config/initializers/occams.rb',
'config/initializers/occams.rb'
end

def generate_railties_order
application <<~RUBY
# Ensuring that ActiveStorage routes are loaded before Occams's globbing
# route. Without this file serving routes are inaccessible.
config.railties_order = [ActiveStorage::Engine, :main_app, :all]
RUBY
end

def generate_routing
route_string = <<~RUBY
occams_route :cms_admin, path: "/admin"
# Ensure that this route is defined last
occams_route :cms, path: "/"
RUBY
route route_string
end

def generate_cms_seeds
directory 'db/cms_seeds', 'db/cms_seeds'
end

def generate_assets
copy_file 'app/assets/javascripts/occams/admin/cms/custom.js',
'app/assets/javascripts/occams/admin/cms/custom.js'
copy_file 'app/assets/stylesheets/occams/admin/cms/custom.sass',
'app/assets/stylesheets/occams/admin/cms/custom.sass'
end

def show_readme
readme 'lib/generators/occams/cms/README'
end

def self.next_migration_number(dirname)
ActiveRecord::Generators::Base.next_migration_number(dirname)
end
end
end
end
File renamed without changes.
File renamed without changes.
69 changes: 0 additions & 69 deletions lib/occams/generators/cms/cms_generator.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/generators/cms_assets_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/occams/generators/cms/assets_generator'
require_relative '../../lib/generators/occams/cms/assets_generator'

class CmsAssetsGeneratorTest < Rails::Generators::TestCase
tests Occams::Generators::Cms::AssetsGenerator
Expand Down
2 changes: 1 addition & 1 deletion test/generators/cms_controllers_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/occams/generators/cms/controllers_generator'
require_relative '../../lib/generators/occams/cms/controllers_generator'

class CmsControllersGeneratorTest < Rails::Generators::TestCase
tests Occams::Generators::Cms::ControllersGenerator
Expand Down
4 changes: 2 additions & 2 deletions test/generators/cms_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/occams/generators/cms/cms_generator'
require_relative '../../lib/generators/occams/cms/cms_generator'

class CmsGeneratorTest < Rails::Generators::TestCase
tests Occams::Generators::Cms::CmsGenerator
tests Occams::Generators::CmsGenerator

def test_generator
run_generator
Expand Down
2 changes: 1 addition & 1 deletion test/generators/cms_models_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/occams/generators/cms/models_generator'
require_relative '../../lib/generators/occams/cms/models_generator'

class CmsModelsGeneratorTest < Rails::Generators::TestCase
tests Occams::Generators::Cms::ModelsGenerator
Expand Down
2 changes: 1 addition & 1 deletion test/generators/cms_views_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/occams/generators/cms/views_generator'
require_relative '../../lib/generators/occams/cms/views_generator'

class CmsViewsGeneratorTest < Rails::Generators::TestCase
tests Occams::Generators::Cms::ViewsGenerator
Expand Down
2 changes: 1 addition & 1 deletion test/generators/scaffold_generator_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/occams/generators/scaffold_generator'
require_relative '../../lib/generators/occams/scaffold/scaffold_generator'

class ScaffoldGeneratorTest < Rails::Generators::TestCase
tests Occams::Generators::ScaffoldGenerator
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
SimpleCov.command_name 'Unit Tests'
SimpleCov.start 'rails' do
add_filter 'lib/tasks'
add_filter 'lib/generators'
add_filter 'lib/occams/engine'
add_filter 'lib/occams/generators'
add_filter 'lib/occams/version'
end

Expand Down

0 comments on commit b2805cd

Please sign in to comment.