Module: RubyCms::Excludes
- Defined in:
- lib/ruby_cms/excludes.rb
Overview
App-relative paths that ruby_cms update / ruby_cms sync must never touch.
Two layers:
* DEFAULT — gem-owned files that hosts are expected to customize (config
initializers, generated nav). Shipped once, then left alone.
* Per-app — globs listed under `exclude:` in the host's .ruby_cms.yml.
Both are matched against the APP-relative path with File.fnmatch (globs + extglob), e.g. "config/initializers/admin.rb" or "app/views/layouts/admin/*".
Constant Summary collapse
- DEFAULT =
[ "config/initializers/admin.rb", # RubyCms.configure block — host config "config/initializers/admin_dashboard.rb", # dashboard blocks — host-arranged "config/initializers/admin_nav.rb", # sidebar nav — host-arranged / generated "config/initializers/admin_pages.rb", # app-registered admin pages "config/initializers/ruby_cms_custom_settings.rb", # host-registered custom settings "app/assets/builds/**" # compiled Tailwind/CSS — never overwrite ].freeze
- FNM_FLAGS =
File::FNM_PATHNAME | File::FNM_EXTGLOB
Class Method Summary collapse
-
.all(extra = []) ⇒ Object
Combine gem defaults with the host's per-app excludes.
- .excluded?(app_relative_path, extra = []) ⇒ Boolean
Class Method Details
.all(extra = []) ⇒ Object
Combine gem defaults with the host's per-app excludes.
30 31 32 |
# File 'lib/ruby_cms/excludes.rb', line 30 def all(extra=[]) (DEFAULT + Array(extra)).uniq end |
.excluded?(app_relative_path, extra = []) ⇒ Boolean
34 35 36 37 38 39 |
# File 'lib/ruby_cms/excludes.rb', line 34 def excluded?(app_relative_path, extra=[]) # Normalize first ("./x", "a//b", "a/../b" → clean) so the safety net can't be # bypassed by a non-canonical path. path = Pathname.new(app_relative_path.to_s).cleanpath.to_s all(extra).any? {|glob| File.fnmatch?(glob, path, FNM_FLAGS) } end |