Class: ReactManifest::Configuration
- Inherits:
-
Object
- Object
- ReactManifest::Configuration
- Defined in:
- lib/react_manifest/configuration.rb
Overview
Holds all configuration for the gem. Obtain via configure.
Instance Attribute Summary collapse
-
#always_include ⇒ Object
Bundles always prepended by react_bundle_tag (e.g. [“ux_main”]).
-
#app_dir ⇒ Object
Subdir within ux_root that contains per-controller JSX.
-
#dry_run ⇒ Object
Preview mode: print what would change, write nothing.
-
#exclude_paths ⇒ Object
Path segments to exclude while scanning files under ux_root.
-
#extensions ⇒ Object
File extensions to scan (default: js and jsx; add “ts”, “tsx” for TypeScript).
-
#ignore ⇒ Object
Controller directory names directly under ux_root/app_dir to skip entirely.
-
#manifest_subdir ⇒ Object
Subdirectory under output_dir that holds generated ux_*.js manifests.
-
#output_dir ⇒ Object
Where generated ux_*.js manifests are written (relative to Rails.root).
-
#shared_bundle ⇒ Object
Bundle name for auto-generated shared bundle (all non-app/ dirs).
-
#size_threshold_kb ⇒ Object
Warn if a bundle exceeds this size in KB (0 = disabled).
-
#stdout_logging ⇒ Object
Emit ReactManifest status lines to stdout in development.
-
#ux_root ⇒ Object
Root of the ux/ tree to scan (relative to Rails.root).
-
#verbose ⇒ Object
Extra diagnostic logging (summary lines and richer error context).
Instance Method Summary collapse
- #abs_app_dir ⇒ Object
- #abs_manifest_dir ⇒ Object
- #abs_output_dir ⇒ Object
-
#abs_ux_root ⇒ Object
Absolute path helpers (requires Rails.root to be set).
- #dry_run? ⇒ Boolean
-
#extensions_glob ⇒ Object
Glob fragment used by Dir.glob, e.g.
-
#extensions_pattern ⇒ Object
Regexp used by the file watcher to filter events, e.g.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #normalized_manifest_subdir ⇒ Object
- #stdout_logging? ⇒ Boolean
- #verbose? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/react_manifest/configuration.rb', line 57 def initialize @ux_root = "app/assets/javascripts/ux" @app_dir = "app" @output_dir = "app/assets/javascripts" @manifest_subdir = "ux_manifests" @shared_bundle = "ux_shared" @always_include = [] @ignore = [] @exclude_paths = %w[react react_dev vendor] @size_threshold_kb = 500 @extensions = %w[js jsx] @dry_run = false @verbose = false @stdout_logging = true end |
Instance Attribute Details
#always_include ⇒ Object
Bundles always prepended by react_bundle_tag (e.g. [“ux_main”])
28 29 30 |
# File 'lib/react_manifest/configuration.rb', line 28 def always_include @always_include end |
#app_dir ⇒ Object
Subdir within ux_root that contains per-controller JSX
15 16 17 |
# File 'lib/react_manifest/configuration.rb', line 15 def app_dir @app_dir end |
#dry_run ⇒ Object
Preview mode: print what would change, write nothing. Applies anywhere generation runs (manual task, boot sync, watcher).
48 49 50 |
# File 'lib/react_manifest/configuration.rb', line 48 def dry_run @dry_run end |
#exclude_paths ⇒ Object
Path segments to exclude while scanning files under ux_root. This is segment matching (not full path matching), so “vendor” excludes ux/vendor/foo.js and ux/app/users/vendor/bar.jsx, but not ux/vendor_custom/x.js. These are not application.js includes; they only affect ux tree scanning.
38 39 40 |
# File 'lib/react_manifest/configuration.rb', line 38 def exclude_paths @exclude_paths end |
#extensions ⇒ Object
File extensions to scan (default: js and jsx; add “ts”, “tsx” for TypeScript)
44 45 46 |
# File 'lib/react_manifest/configuration.rb', line 44 def extensions @extensions end |
#ignore ⇒ Object
Controller directory names directly under ux_root/app_dir to skip entirely. Example: ignore = [“admin”] skips ux/app/admin/* when building ux_<controller>.js.
32 33 34 |
# File 'lib/react_manifest/configuration.rb', line 32 def ignore @ignore end |
#manifest_subdir ⇒ Object
Subdirectory under output_dir that holds generated ux_*.js manifests. Keeping generated files out of output_dir root avoids clutter.
22 23 24 |
# File 'lib/react_manifest/configuration.rb', line 22 def manifest_subdir @manifest_subdir end |
#output_dir ⇒ Object
Where generated ux_*.js manifests are written (relative to Rails.root)
18 19 20 |
# File 'lib/react_manifest/configuration.rb', line 18 def output_dir @output_dir end |
#shared_bundle ⇒ Object
Bundle name for auto-generated shared bundle (all non-app/ dirs)
25 26 27 |
# File 'lib/react_manifest/configuration.rb', line 25 def shared_bundle @shared_bundle end |
#size_threshold_kb ⇒ Object
Warn if a bundle exceeds this size in KB (0 = disabled)
41 42 43 |
# File 'lib/react_manifest/configuration.rb', line 41 def size_threshold_kb @size_threshold_kb end |
#stdout_logging ⇒ Object
Emit ReactManifest status lines to stdout in development. Independent from Rails.logger output.
55 56 57 |
# File 'lib/react_manifest/configuration.rb', line 55 def stdout_logging @stdout_logging end |
#ux_root ⇒ Object
Root of the ux/ tree to scan (relative to Rails.root)
12 13 14 |
# File 'lib/react_manifest/configuration.rb', line 12 def ux_root @ux_root end |
#verbose ⇒ Object
Extra diagnostic logging (summary lines and richer error context).
51 52 53 |
# File 'lib/react_manifest/configuration.rb', line 51 def verbose @verbose end |
Instance Method Details
#abs_app_dir ⇒ Object
100 101 102 |
# File 'lib/react_manifest/configuration.rb', line 100 def abs_app_dir File.join(abs_ux_root, app_dir) end |
#abs_manifest_dir ⇒ Object
108 109 110 111 112 113 |
# File 'lib/react_manifest/configuration.rb', line 108 def abs_manifest_dir subdir = normalized_manifest_subdir return abs_output_dir if subdir.empty? File.join(abs_output_dir, subdir) end |
#abs_output_dir ⇒ Object
104 105 106 |
# File 'lib/react_manifest/configuration.rb', line 104 def abs_output_dir Rails.root.join(output_dir).to_s end |
#abs_ux_root ⇒ Object
Absolute path helpers (requires Rails.root to be set)
96 97 98 |
# File 'lib/react_manifest/configuration.rb', line 96 def abs_ux_root Rails.root.join(ux_root).to_s end |
#dry_run? ⇒ Boolean
73 74 75 |
# File 'lib/react_manifest/configuration.rb', line 73 def dry_run? !!@dry_run end |
#extensions_glob ⇒ Object
Glob fragment used by Dir.glob, e.g. “*.js,jsx” or “*.js,jsx,ts,tsx”
86 87 88 |
# File 'lib/react_manifest/configuration.rb', line 86 def extensions_glob "*.{#{extensions.join(',')}}" end |
#extensions_pattern ⇒ Object
Regexp used by the file watcher to filter events, e.g. /.(js|jsx)$/
91 92 93 |
# File 'lib/react_manifest/configuration.rb', line 91 def extensions_pattern Regexp.new("\\.(#{extensions.map { |e| Regexp.escape(e) }.join('|')})$") end |
#normalized_manifest_subdir ⇒ Object
115 116 117 |
# File 'lib/react_manifest/configuration.rb', line 115 def normalized_manifest_subdir manifest_subdir.to_s.gsub(%r{\A/+|/+\z}, "") end |
#stdout_logging? ⇒ Boolean
81 82 83 |
# File 'lib/react_manifest/configuration.rb', line 81 def stdout_logging? !!@stdout_logging end |
#verbose? ⇒ Boolean
77 78 79 |
# File 'lib/react_manifest/configuration.rb', line 77 def verbose? !!@verbose end |