Class: Proscenium::Builder
- Inherits:
-
Object
- Object
- Proscenium::Builder
show all
- Defined in:
- lib/proscenium/builder.rb
Defined Under Namespace
Modules: Request
Classes: BuildError, CompileResult, ResolveError, ResolveResult, Result
Constant Summary
collapse
- ENVIRONMENTS =
{ development: 1, test: 2, production: 3 }.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(root: nil) ⇒ Builder
Returns a new instance of Builder.
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/proscenium/builder.rb', line 93
def initialize(root: nil)
@request_config = FFI::MemoryPointer.from_string({
RootPath: (root || Rails.root).to_s,
OutputDir: "public#{Proscenium.config.output_dir}",
GemPath: gem_root,
Environment: ENVIRONMENTS.fetch(Rails.env.to_sym, 2),
EnvVars: env_vars,
CodeSplitting: Proscenium.config.code_splitting,
RubyGems: Proscenium::BundledGems.paths,
Bundle: Proscenium.config.bundle,
Aliases: Proscenium.config.aliases,
External: Proscenium.config.external,
Precompile: Proscenium.config.precompile,
Debug: Proscenium.config.debug
}.to_json)
end
|
Class Method Details
.build_to_string(path, root: nil) ⇒ Object
76
77
78
|
# File 'lib/proscenium/builder.rb', line 76
def self.build_to_string(path, root: nil)
new(root:).build_to_string(path)
end
|
.compile(root: nil) ⇒ Object
84
85
86
|
# File 'lib/proscenium/builder.rb', line 84
def self.compile(root: nil)
new(root:).compile
end
|
.reset_config! ⇒ Object
89
90
91
|
# File 'lib/proscenium/builder.rb', line 89
def self.reset_config!
Request.reset_config
end
|
.resolve(path, root: nil) ⇒ Object
80
81
82
|
# File 'lib/proscenium/builder.rb', line 80
def self.resolve(path, root: nil)
new(root:).resolve(path)
end
|
Instance Method Details
#build_to_string(path) ⇒ Object
110
111
112
113
114
115
116
117
118
|
# File 'lib/proscenium/builder.rb', line 110
def build_to_string(path)
ActiveSupport::Notifications.instrument('build.proscenium', identifier: path) do
result = Request.build_to_string(path, @request_config)
raise BuildError.new(path, result[:response]) unless result[:success]
result
end
end
|
#compile ⇒ Object
130
131
132
133
|
# File 'lib/proscenium/builder.rb', line 130
def compile
result = Request.compile(@request_config)
result[:success]
end
|
#resolve(path) ⇒ Object
120
121
122
123
124
125
126
127
128
|
# File 'lib/proscenium/builder.rb', line 120
def resolve(path)
ActiveSupport::Notifications.instrument('resolve.proscenium', identifier: path) do
result = Request.resolve(path, @request_config)
raise ResolveError.new(path, result[:url_path]) unless result[:success]
[result[:url_path], result[:abs_path]]
end
end
|