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
Print what would change, write nothing.
-
#exclude_paths ⇒ Object
Top-level dirs under output_dir to never scan (vendor libs, etc.).
-
#extensions ⇒ Object
File extensions to scan (default: js and jsx; add “ts”, “tsx” for TypeScript).
-
#ignore ⇒ Object
Directories under app_dir to completely ignore.
-
#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).
-
#ux_root ⇒ Object
Root of the ux/ tree to scan (relative to Rails.root).
-
#verbose ⇒ Object
Extra logging.
Instance Method Summary collapse
- #abs_app_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.
- #verbose? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/react_manifest/configuration.rb', line 44 def initialize @ux_root = "app/assets/javascripts/ux" @app_dir = "app" @output_dir = "app/assets/javascripts" @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 end |
Instance Attribute Details
#always_include ⇒ Object
Bundles always prepended by react_bundle_tag (e.g. [“ux_main”])
24 25 26 |
# File 'lib/react_manifest/configuration.rb', line 24 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
Print what would change, write nothing
39 40 41 |
# File 'lib/react_manifest/configuration.rb', line 39 def dry_run @dry_run end |
#exclude_paths ⇒ Object
Top-level dirs under output_dir to never scan (vendor libs, etc.)
30 31 32 |
# File 'lib/react_manifest/configuration.rb', line 30 def exclude_paths @exclude_paths end |
#extensions ⇒ Object
File extensions to scan (default: js and jsx; add “ts”, “tsx” for TypeScript)
36 37 38 |
# File 'lib/react_manifest/configuration.rb', line 36 def extensions @extensions end |
#ignore ⇒ Object
Directories under app_dir to completely ignore
27 28 29 |
# File 'lib/react_manifest/configuration.rb', line 27 def ignore @ignore 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)
21 22 23 |
# File 'lib/react_manifest/configuration.rb', line 21 def shared_bundle @shared_bundle end |
#size_threshold_kb ⇒ Object
Warn if a bundle exceeds this size in KB (0 = disabled)
33 34 35 |
# File 'lib/react_manifest/configuration.rb', line 33 def size_threshold_kb @size_threshold_kb 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 logging
42 43 44 |
# File 'lib/react_manifest/configuration.rb', line 42 def verbose @verbose end |
Instance Method Details
#abs_app_dir ⇒ Object
81 82 83 |
# File 'lib/react_manifest/configuration.rb', line 81 def abs_app_dir File.join(abs_ux_root, app_dir) end |
#abs_output_dir ⇒ Object
85 86 87 |
# File 'lib/react_manifest/configuration.rb', line 85 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)
77 78 79 |
# File 'lib/react_manifest/configuration.rb', line 77 def abs_ux_root Rails.root.join(ux_root).to_s end |
#dry_run? ⇒ Boolean
58 59 60 |
# File 'lib/react_manifest/configuration.rb', line 58 def dry_run? !!@dry_run end |
#extensions_glob ⇒ Object
Glob fragment used by Dir.glob, e.g. “*.js,jsx” or “*.js,jsx,ts,tsx”
67 68 69 |
# File 'lib/react_manifest/configuration.rb', line 67 def extensions_glob "*.{#{extensions.join(',')}}" end |
#extensions_pattern ⇒ Object
Regexp used by the file watcher to filter events, e.g. /.(js|jsx)$/
72 73 74 |
# File 'lib/react_manifest/configuration.rb', line 72 def extensions_pattern Regexp.new("\\.(#{extensions.map { |e| Regexp.escape(e) }.join('|')})$") end |
#verbose? ⇒ Boolean
62 63 64 |
# File 'lib/react_manifest/configuration.rb', line 62 def verbose? !!@verbose end |