start on install generator

This commit is contained in:
Torsten 2023-01-27 14:55:27 +02:00
parent 924eb6317c
commit 6a9e2182aa
6 changed files with 33 additions and 14 deletions

View File

@ -1,9 +0,0 @@
require "rails/generators"
module Merged
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)
end
end
end

View File

@ -0,0 +1,18 @@
require "merged"
require "rails/generators"
module Merged
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)
def install
[:card_styles, :option_definitions, :page_styles , :section_styles,
:cards, :sections , :pages].each do |file|
copy_file "empty.yml", "merged/#{file}.yml"
end
empty_directory Merged::Image.asset_root
empty_directory Merged.data_dir + "/merged"
end
end
end

View File

@ -0,0 +1 @@
---[]

View File

@ -0,0 +1,9 @@
require "merged"
# directory inside /app/assets/images where the images are kept
Merged.images_dir = "cms"
# directory where data and styles are kept
# Notice that the data is ALWAYS inside a merged directory,
# so in the default case Rails.root/merged/*.yml
Merged.data_dir = "."

View File

@ -1,17 +1,17 @@
require "merged/version"
require "merged/engine"
require "generators/install/install_generator"
require "generators/merged/install/install_generator"
require "generators/merged/update/update_generator"
module Merged
# Directory inside the app/assets/images
mattr_accessor :image_path
@@image_path = "cms"
mattr_accessor :images_dir
@@images_dir = "cms"
# directory in root to store data
mattr_accessor :data_path
@@image_path = "merged"
mattr_accessor :data_dir
@@data_dir = "."
def self.load_data
# pre-load data