Module: BunBunBundle
- Defined in:
- lib/bun_bun_bundle.rb,
lib/bun_bun_bundle/config.rb,
lib/bun_bun_bundle/helpers.rb,
lib/bun_bun_bundle/railtie.rb,
lib/bun_bun_bundle/version.rb,
lib/bun_bun_bundle/manifest.rb,
lib/bun_bun_bundle/safe_html.rb,
lib/bun_bun_bundle/reload_tag.rb,
lib/bun_bun_bundle/dev_cache_middleware.rb
Defined Under Namespace
Modules: Helpers, ReloadTag, SafeHtml Classes: Config, DevCacheMiddleware, Manifest, Railtie
Constant Summary collapse
- VERSION =
'0.9.1'
Class Attribute Summary collapse
Class Method Summary collapse
-
.bun_path ⇒ Object
Returns the path to the bundled JS files shipped with the gem.
- .development? ⇒ Boolean
- .production? ⇒ Boolean
-
.reset! ⇒ Object
Resets all state.
-
.setup(root: Dir.pwd, hanami: nil) ⇒ Object
Loads config and manifest.
Class Attribute Details
.asset_host ⇒ Object
23 24 25 |
# File 'lib/bun_bun_bundle.rb', line 23 def asset_host @asset_host || '' end |
.config ⇒ Object
15 16 17 |
# File 'lib/bun_bun_bundle.rb', line 15 def config @config ||= Config.new end |
.environment ⇒ Object
27 28 29 |
# File 'lib/bun_bun_bundle.rb', line 27 def environment @environment || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development' end |
Class Method Details
.bun_path ⇒ Object
Returns the path to the bundled JS files shipped with the gem.
53 54 55 |
# File 'lib/bun_bun_bundle.rb', line 53 def bun_path File.('bun', __dir__) end |
.development? ⇒ Boolean
31 32 33 |
# File 'lib/bun_bun_bundle.rb', line 31 def development? environment == 'development' end |
.production? ⇒ Boolean
35 36 37 |
# File 'lib/bun_bun_bundle.rb', line 35 def production? environment == 'production' end |
.reset! ⇒ Object
Resets all state. Useful for testing.
58 59 60 61 62 63 |
# File 'lib/bun_bun_bundle.rb', line 58 def reset! @config = nil @manifest = nil @asset_host = nil @environment = nil end |
.setup(root: Dir.pwd, hanami: nil) ⇒ Object
Loads config and manifest. Call this from Hanami’s config/app.rb or any Rack app’s startup.
Pass ‘hanami: config` from within a Hanami::App class body to automatically register middleware and configure CSP for development.
44 45 46 47 48 49 50 |
# File 'lib/bun_bun_bundle.rb', line 44 def setup(root: Dir.pwd, hanami: nil) self.config = Config.load(root: root.to_s) = development? ? {} : { retries: 1, delay: 0 } self.manifest = Manifest.load(root: root.to_s, **) configure_hanami(hanami) if hanami end |