Module: Bridgetown
- Defined in:
- bridgetown-core/lib/bridgetown-core/site.rb,
bridgetown-core/lib/bridgetown-core/slot.rb,
bridgetown-core/lib/bridgetown-core/cache.rb,
bridgetown-core/lib/bridgetown-core/hooks.rb,
bridgetown-core/lib/bridgetown-core/utils.rb,
bridgetown-core/lib/bridgetown-core/errors.rb,
bridgetown-core/lib/bridgetown-core/layout.rb,
bridgetown-core/lib/bridgetown-core/plugin.rb,
bridgetown-core/lib/bridgetown-core/reader.rb,
bridgetown-core/lib/bridgetown-core/tags/l.rb,
bridgetown-core/lib/bridgetown-core/tags/t.rb,
bridgetown-core/lib/bridgetown-core/cleaner.rb,
bridgetown-core/lib/bridgetown-core/command.rb,
bridgetown-core/lib/bridgetown-core/current.rb,
bridgetown-core/lib/bridgetown-core/filters.rb,
bridgetown-core/lib/bridgetown-core/helpers.rb,
bridgetown-core/lib/bridgetown-core/watcher.rb,
bridgetown-core/lib/bridgetown-core/tags/dsd.rb,
bridgetown-core/lib/bridgetown-core/component.rb,
bridgetown-core/lib/bridgetown-core/container.rb,
bridgetown-core/lib/bridgetown-core/converter.rb,
bridgetown-core/lib/bridgetown-core/generator.rb,
bridgetown-core/lib/bridgetown-core/rack/boot.rb,
bridgetown-core/lib/bridgetown-core/tags/find.rb,
bridgetown-core/lib/bridgetown-core/tags/link.rb,
bridgetown-core/lib/bridgetown-core/tags/with.rb,
bridgetown-core/lib/bridgetown-core/collection.rb,
bridgetown-core/lib/bridgetown-core/deprecator.rb,
bridgetown-core/lib/bridgetown-core/drops/drop.rb,
bridgetown-core/lib/bridgetown-core/log_writer.rb,
bridgetown-core/lib/bridgetown-core/model/base.rb,
bridgetown-core/lib/bridgetown-core/log_adapter.rb,
bridgetown-core/lib/bridgetown-core/rack/logger.rb,
bridgetown-core/lib/bridgetown-core/rack/routes.rb,
bridgetown-core/lib/bridgetown-core/rack/server.rb,
bridgetown-core/lib/bridgetown-core/static_file.rb,
bridgetown-core/lib/bridgetown-core/yaml_parser.rb,
bridgetown-core/lib/bridgetown-core/commands/new.rb,
bridgetown-core/lib/bridgetown-core/entry_filter.rb,
bridgetown-core/lib/bridgetown-core/front_matter.rb,
bridgetown-core/lib/bridgetown-core/model/origin.rb,
bridgetown-core/lib/bridgetown-core/commands/help.rb,
bridgetown-core/lib/bridgetown-core/configuration.rb,
bridgetown-core/lib/bridgetown-core/resource/base.rb,
bridgetown-core/lib/bridgetown-core/tags/post_url.rb,
bridgetown-core/lib/bridgetown-core/template_view.rb,
bridgetown-core/lib/bridgetown-core/commands/apply.rb,
bridgetown-core/lib/bridgetown-core/commands/build.rb,
bridgetown-core/lib/bridgetown-core/commands/clean.rb,
bridgetown-core/lib/bridgetown-core/commands/start.rb,
bridgetown-core/lib/bridgetown-core/generated_page.rb,
bridgetown-core/lib/bridgetown-core/plugin_manager.rb,
bridgetown-core/lib/bridgetown-core/tags/class_map.rb,
bridgetown-core/lib/bridgetown-core/tags/highlight.rb,
bridgetown-core/lib/bridgetown-core/drops/site_drop.rb,
bridgetown-core/lib/bridgetown-core/liquid_renderer.rb,
bridgetown-core/lib/bridgetown-core/routines/server.rb,
bridgetown-core/lib/bridgetown-core/tags/asset_path.rb,
bridgetown-core/lib/bridgetown-core/utils/ruby_exec.rb,
bridgetown-core/lib/bridgetown-core/utils/wikilinks.rb,
bridgetown-core/lib/bridgetown-core/commands/console.rb,
bridgetown-core/lib/bridgetown-core/commands/esbuild.rb,
bridgetown-core/lib/bridgetown-core/commands/plugins.rb,
bridgetown-core/lib/bridgetown-core/container/policy.rb,
bridgetown-core/lib/bridgetown-core/tags/ruby_render.rb,
bridgetown-core/lib/bridgetown-core/concerns/viewable.rb,
bridgetown-core/lib/bridgetown-core/front_matter/ruby.rb,
bridgetown-core/lib/bridgetown-core/liquid_extensions.rb,
bridgetown-core/lib/bridgetown-core/model/repo_origin.rb,
bridgetown-core/lib/bridgetown-core/rack/loader_hooks.rb,
bridgetown-core/lib/bridgetown-core/commands/configure.rb,
bridgetown-core/lib/bridgetown-core/resource/relations.rb,
bridgetown-core/lib/bridgetown-core/utils/require_gems.rb,
bridgetown-core/lib/bridgetown-core/converters/identity.rb,
bridgetown-core/lib/bridgetown-core/converters/markdown.rb,
bridgetown-core/lib/bridgetown-core/drops/resource_drop.rb,
bridgetown-core/lib/bridgetown-core/filters/from_liquid.rb,
bridgetown-core/lib/bridgetown-core/filters/url_filters.rb,
bridgetown-core/lib/bridgetown-core/model/plugin_origin.rb,
bridgetown-core/lib/bridgetown-core/tags/render_content.rb,
bridgetown-core/lib/bridgetown-core/commands/application.rb,
bridgetown-core/lib/bridgetown-core/commands/application.rb,
bridgetown-core/lib/bridgetown-core/concerns/localizable.rb,
bridgetown-core/lib/bridgetown-core/concerns/publishable.rb,
bridgetown-core/lib/bridgetown-core/drops/relations_drop.rb,
bridgetown-core/lib/bridgetown-core/filters/date_filters.rb,
bridgetown-core/lib/bridgetown-core/front_matter/loaders.rb,
bridgetown-core/lib/bridgetown-core/liquid_renderer/file.rb,
bridgetown-core/lib/bridgetown-core/model/builder_origin.rb,
bridgetown-core/lib/bridgetown-core/resource/destination.rb,
bridgetown-core/lib/bridgetown-core/resource/transformer.rb,
bridgetown-core/lib/bridgetown-core/container/interceptor.rb,
bridgetown-core/lib/bridgetown-core/drops/bridgetown_drop.rb,
bridgetown-core/lib/bridgetown-core/drops/collection_drop.rb,
bridgetown-core/lib/bridgetown-core/front_matter/defaults.rb,
bridgetown-core/lib/bridgetown-core/front_matter/importer.rb,
bridgetown-core/lib/bridgetown-core/liquid_renderer/table.rb,
bridgetown-core/lib/bridgetown-core/readers/layout_reader.rb,
bridgetown-core/lib/bridgetown-core/routines/site_watcher.rb,
bridgetown-core/lib/bridgetown-core/utils/loaders_manager.rb,
bridgetown-core/lib/bridgetown-core/commands/registrations.rb,
bridgetown-core/lib/bridgetown-core/concerns/prioritizable.rb,
bridgetown-core/lib/bridgetown-core/concerns/transformable.rb,
bridgetown-core/lib/bridgetown-core/drops/static_file_drop.rb,
bridgetown-core/lib/bridgetown-core/rack/environments/puma.rb,
bridgetown-core/lib/bridgetown-core/resource/taxonomy_term.rb,
bridgetown-core/lib/bridgetown-core/resource/taxonomy_type.rb,
bridgetown-core/lib/bridgetown-core/readers/defaults_reader.rb,
bridgetown-core/lib/bridgetown-core/tags/live_reload_dev_js.rb,
bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb,
bridgetown-core/lib/bridgetown-core/filters/grouping_filters.rb,
bridgetown-core/lib/bridgetown-core/rack/environments/falcon.rb,
bridgetown-core/lib/bridgetown-core/concerns/layout_placeable.rb,
bridgetown-core/lib/bridgetown-core/converters/ruby_templates.rb,
bridgetown-core/lib/bridgetown-core/drops/generated_page_drop.rb,
bridgetown-core/lib/bridgetown-core/filters/condition_helpers.rb,
bridgetown-core/lib/bridgetown-core/front_matter/loaders/base.rb,
bridgetown-core/lib/bridgetown-core/front_matter/loaders/ruby.rb,
bridgetown-core/lib/bridgetown-core/front_matter/loaders/yaml.rb,
bridgetown-core/lib/bridgetown-core/routines/frontend_watcher.rb,
bridgetown-core/lib/bridgetown-core/drops/unified_payload_drop.rb,
bridgetown-core/lib/bridgetown-core/converters/liquid_templates.rb,
bridgetown-core/lib/bridgetown-core/converters/serbea_templates.rb,
bridgetown-core/lib/bridgetown-core/filters/translation_filters.rb,
bridgetown-core/lib/bridgetown-core/liquid_renderer/file_system.rb,
bridgetown-core/lib/bridgetown-core/filters/localization_filters.rb,
bridgetown-core/lib/bridgetown-core/resource/permalink_processor.rb,
bridgetown-core/lib/bridgetown-core/utils/smarty_pants_converter.rb,
bridgetown-core/lib/bridgetown-core/commands/concerns/automations.rb,
bridgetown-core/lib/bridgetown-core/commands/concerns/git_helpers.rb,
bridgetown-core/lib/bridgetown-core/readers/plugin_content_reader.rb,
bridgetown-core/lib/bridgetown-core/generators/prototype_generator.rb,
bridgetown-core/lib/bridgetown-core/commands/concerns/build_options.rb,
bridgetown-core/lib/bridgetown-core/configuration/configuration_dsl.rb,
bridgetown-core/lib/bridgetown-core/converters/markdown/kramdown_parser.rb,
bridgetown-core/lib/bridgetown-core/commands/concerns/configuration_overridable.rb,
bridgetown-builder/lib/bridgetown-builder.rb,
bridgetown-builder/lib/bridgetown-builder/plugin.rb,
bridgetown-builder/lib/bridgetown-builder/builder.rb,
bridgetown-builder/lib/bridgetown-builder/dsl/http.rb,
bridgetown-builder/lib/bridgetown-builder/dsl/hooks.rb,
bridgetown-builder/lib/bridgetown-builder/dsl/liquid.rb,
bridgetown-builder/lib/bridgetown-builder/dsl/helpers.rb,
bridgetown-builder/lib/bridgetown-builder/dsl/resources.rb,
bridgetown-builder/lib/bridgetown-builder/dsl/generators.rb,
bridgetown-builder/lib/bridgetown-builder/dsl/inspectors.rb,
bridgetown-foundation/lib/bridgetown/version.rb,
bridgetown-foundation/lib/bridgetown-foundation.rb,
bridgetown-foundation/lib/bridgetown/foundation/refine_ext/hash.rb,
bridgetown-foundation/lib/bridgetown/foundation/refine_ext/module.rb,
bridgetown-foundation/lib/bridgetown/foundation/refine_ext/object.rb,
bridgetown-foundation/lib/bridgetown/foundation/refine_ext/string.rb,
bridgetown-foundation/lib/bridgetown/foundation/refine_ext/deep_duplicatable.rb,
bridgetown-paginate/lib/bridgetown-paginate.rb,
bridgetown-paginate/lib/bridgetown-paginate/utils.rb,
bridgetown-paginate/lib/bridgetown-paginate/defaults.rb,
bridgetown-paginate/lib/bridgetown-paginate/paginator.rb,
bridgetown-paginate/lib/bridgetown-paginate/pagination_page.rb,
bridgetown-paginate/lib/bridgetown-paginate/pagination_model.rb,
bridgetown-paginate/lib/bridgetown-paginate/pagination_indexer.rb,
bridgetown-paginate/lib/bridgetown-paginate/pagination_generator.rb,
bridgetown-routes/lib/bridgetown-routes.rb,
bridgetown-routes/lib/bridgetown-routes/manifest.rb,
bridgetown-routes/lib/bridgetown-routes/code_blocks.rb,
bridgetown-routes/lib/bridgetown-routes/view_helpers.rb,
bridgetown-routes/lib/bridgetown-routes/manifest_router.rb,
bridgetown-core/lib/bridgetown-core.rb
Defined Under Namespace
Modules: Builders, Commands, ConsoleMethods, Converters, Deprecator, Drops, ERBCapture, Errors, Filters, Foundation, FrontMatter, Hooks, LayoutPlaceable, LiquidExtensions, Localizable, Model, Paginate, Prioritizable, Publishable, Rack, Refinements, Resource, RodaCallable, Routes, Routines, Streamlined, Tags, Transformable, Utils, Viewable, Watcher Classes: Builder, Cache, Cleaner, Collection, Command, Component, Configuration, Container, Converter, Current, DefaultsReader, ERBEngine, ERBView, EntryFilter, GeneratedPage, Generator, Layout, LayoutReader, LiquidRenderer, LogAdapter, LogWriter, OutputBuffer, Plugin, PluginContentReader, PluginManager, PrototypeGenerator, PrototypePage, Reader, RubyView, SerbeaView, Signals, Site, Slot, StaticFile, TemplateView, WrappedObjectWithRefinements, YAMLParser
Constant Summary collapse
- RubyTemplateView =
TODO: this class alias is deprecated and will be removed in the next major Bridgetown release
TemplateView- PureRubyView =
TODO: this class alias is deprecated and will be removed in the next major Bridgetown release
RubyView- VERSION =
"2.2.1"- CODE_NAME =
"Verdant River City"- Inflector =
compatibility alias
Foundation::Inflector
Class Method Summary collapse
-
.add_refinement(mod) ⇒ Object
-
.begin!(with_config: :preflight) ⇒ Object
Set up the Bridgetown execution environment before attempting to load any plugins or gems prior to a site build.
-
.build_errors_path ⇒ String
When there’s a build error, error details will be logged to a file which the dev server can read and pass along to the browser.
-
.configuration(override = {}) ⇒ Hash
Generate a Bridgetown configuration hash by merging the default options with anything in bridgetown.config.yml, and adding the given options on top.
-
.configure {|config| ... } ⇒ Object
-
.environment ⇒ Object
(also: env)
Tells you which Bridgetown environment you are building in so you can skip tasks if you need to.
-
.initializer(name, prepend: false, replace: false, &block) ⇒ Object
rubocop:todo Metrics.
-
.live_reload_path ⇒ String
This file gets touched each time there’s a new build, which then triggers live reload in the browser.
-
.load_dotenv(root:) ⇒ Object
Loads ENV configuration via dotenv gem, if available.
-
.load_tasks ⇒ Object
-
.logger ⇒ LogAdapter
Fetch the logger instance for this Bridgetown process.
-
.logger=(writer) ⇒ LogAdapter
Set the log writer.
-
.refine(*obj) ⇒ WrappedObjectWithRefinements
Call this method to wrap any object(s) in order to use Foundation’s refinements.
-
.register_command ⇒ Object
Convenience method to register a new Thor command.
-
.reset_configuration! ⇒ Bridgetown::Configuration::Preflight
Initialize a preflight configuration object, copying initializers and source manifests from a previous standard configuration if necessary.
-
.sanitized_path(base_directory, questionable_path) ⇒ String
Ensures the questionable path is prefixed with the base directory and prepends the questionable path with the base directory if false.
-
.set_timezone(timezone) ⇒ void
Set the TZ environment variable to use the timezone specified.
-
.timezone ⇒ String
Get the current TZ environment variable.
-
.touch_live_reload_file(path = live_reload_path) ⇒ Object
-
.with_unbundled_env ⇒ void
Determines the correct Bundler environment block method to use and passes the block on to it.
Class Method Details
.add_refinement(mod) ⇒ Object
73 74 75 76 |
# File 'bridgetown-foundation/lib/bridgetown-foundation.rb', line 73 def self.add_refinement(mod, &) Bridgetown::Refinements.include(mod) Bridgetown::WrappedObjectWithRefinements.class_eval(&) end |
.begin!(with_config: :preflight) ⇒ Object
Set up the Bridgetown execution environment before attempting to load any plugins or gems prior to a site build
136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 136 def begin!(with_config: :preflight) ENV["RACK_ENV"] ||= environment if with_config == :preflight Bridgetown::Current.preloaded_configuration ||= Bridgetown::Configuration::Preflight.new elsif with_config == :initializers && !Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration) Bridgetown::Current.preloaded_configuration = Bridgetown.configuration end Bridgetown::PluginManager.setup_bundler end |
.build_errors_path ⇒ String
When there’s a build error, error details will be logged to a file which the dev server can read and pass along to the browser.
379 380 381 382 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 379 def build_errors_path site_config = Bridgetown::Current.site&.config || Bridgetown::Current.preloaded_configuration File.join(site_config.root_dir, site_config.cache_dir, "build_errors.txt") end |
.configuration(override = {}) ⇒ Hash
Generate a Bridgetown configuration hash by merging the default options with anything in bridgetown.config.yml, and adding the given options on top.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 159 def configuration(override = {}) config = Configuration.new override = Configuration.new(override) unless override.delete("skip_config_files") config = config.read_config_files(config.config_files(override)) end # Merge DEFAULTS < bridgetown.config.yml < override # @param obj [Bridgetown::Configuration] Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |obj| set_timezone(obj["timezone"]) if obj["timezone"] # Copy "global" source manifests and initializers into this new configuration if Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration::Preflight) obj.source_manifests = Bridgetown::Current.preloaded_configuration.source_manifests if Bridgetown::Current.preloaded_configuration.initializers obj.initializers = Bridgetown::Current.preloaded_configuration.initializers end end Bridgetown::Current.preloaded_configuration = obj end end |
.configure {|config| ... } ⇒ Object
257 258 259 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 257 def configure(&) initializer(:init, &) end |
.environment ⇒ Object Also known as: env
Tells you which Bridgetown environment you are building in so you can skip tasks if you need to.
129 130 131 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 129 def environment (ENV["BRIDGETOWN_ENV"] || "development").questionable end |
.initializer(name, prepend: false, replace: false, &block) ⇒ Object
rubocop:todo Metrics
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 216 def initializer(name, prepend: false, replace: false, &block) # rubocop:todo Metrics unless Bridgetown::Current.preloaded_configuration raise "The `#{name}' initializer in #{block.source_location[0]} was called " \ "without a preloaded configuration" end Bridgetown::Current.preloaded_configuration.initializers ||= {} if Bridgetown::Current.preloaded_configuration.initializers.key?(name.to_sym) if replace Bridgetown.logger.warn( "Initializing:", "The previous `#{name}' initializer was replaced by a new initializer" ) else prev_block = Bridgetown::Current.preloaded_configuration.initializers[name.to_sym].block new_block = block block = if prepend proc do |*args, **kwargs| new_block.(*args, **kwargs) prev_block.(*args, **kwargs) end else proc do |*args, **kwargs| prev_block.(*args, **kwargs) new_block.(*args, **kwargs) end end end end Bridgetown::Current.preloaded_configuration.initializers[name.to_sym] = Bridgetown::Configuration::Initializer.new( name: name.to_sym, block:, completed: false ) end |
.live_reload_path ⇒ String
This file gets touched each time there’s a new build, which then triggers live reload in the browser.
389 390 391 392 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 389 def live_reload_path site_config = Bridgetown::Current.site&.config || Bridgetown::Current.preloaded_configuration File.join(site_config.root_dir, site_config.cache_dir, "live_reload.txt") end |
.load_dotenv(root:) ⇒ Object
Loads ENV configuration via dotenv gem, if available
284 285 286 287 288 289 290 291 292 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 284 def load_dotenv(root:) dotenv_files = [ File.join(root, ".env.#{Bridgetown.env}.local"), (File.join(root, ".env.local") unless Bridgetown.env.test?), File.join(root, ".env.#{Bridgetown.env}"), File.join(root, ".env"), ].compact Dotenv.load(*dotenv_files) end |
.load_tasks ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 268 def load_tasks require "bridgetown-core/commands/application" unless Bridgetown::Current.preloaded_configuration Bridgetown::Current.preloaded_configuration = Bridgetown::Configuration::Preflight.new end Bridgetown::PluginManager.setup_bundler if Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration::Preflight) Bridgetown::Current.preloaded_configuration = Bridgetown.configuration end load File.("bridgetown-core/tasks/bridgetown_tasks.rake", __dir__) end |
.logger ⇒ LogAdapter
Fetch the logger instance for this Bridgetown process.
327 328 329 330 331 332 333 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 327 def logger @logger ||= LogAdapter.new( LogWriter.new, (ENV["BRIDGETOWN_LOG_LEVEL"] || :info).to_sym, prefix: ["Bridgetown", :green] ) end |
.logger=(writer) ⇒ LogAdapter
Set the log writer. New log writer must respond to the same methods as Ruby’s internal Logger.
341 342 343 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 341 def logger=(writer) @logger = LogAdapter.new(writer, (ENV["BRIDGETOWN_LOG_LEVEL"] || :info).to_sym) end |
.refine(*obj) ⇒ WrappedObjectWithRefinements
Call this method to wrap any object(s) in order to use Foundation’s refinements
65 66 67 68 69 70 71 |
# File 'bridgetown-foundation/lib/bridgetown-foundation.rb', line 65 def self.refine(*obj) if obj.length == 1 WrappedObjectWithRefinements.new(obj[0]) else obj.map { WrappedObjectWithRefinements.new _1 } end end |
.register_command ⇒ Object
Convenience method to register a new Thor command
264 265 266 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 264 def register_command(&) Bridgetown::Commands::Registrations.register(&) end |
.reset_configuration! ⇒ Bridgetown::Configuration::Preflight
Initialize a preflight configuration object, copying initializers and source manifests from a previous standard configuration if necessary. Typically only needed in test suites to reset before a new test.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 189 def reset_configuration! # rubocop:disable Metrics/AbcSize if Bridgetown::Current.preloaded_configuration.nil? return Bridgetown::Current.preloaded_configuration = Bridgetown::Configuration::Preflight.new end return unless Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration) previous_config = Bridgetown::Current.preloaded_configuration new_config = Bridgetown::Configuration::Preflight.new new_config.initializers = previous_config.initializers new_config.source_manifests = previous_config.source_manifests if new_config.initializers new_config.initializers.delete(:init) new_config.initializers.select! do |_k, initializer| next false if initializer.block.source_location[0].start_with?( File.join(previous_config.root_dir, "config") ) initializer.completed = false true end end Bridgetown::Current.preloaded_configuration = new_config end |
.sanitized_path(base_directory, questionable_path) ⇒ String
Ensures the questionable path is prefixed with the base directory and prepends the questionable path with the base directory if false.
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 354 def sanitized_path(base_directory, questionable_path) return base_directory if base_directory.eql?(questionable_path) clean_path = questionable_path.dup clean_path.insert(0, "/") if clean_path.start_with?("~") clean_path = File.(clean_path, "/") return clean_path if clean_path.eql?(base_directory) # remove any remaining extra leading slashes not stripped away by calling # `File.expand_path` above. clean_path.squeeze!("/") if clean_path.start_with?(base_directory.sub(%r!\z!, "/")) clean_path else clean_path.sub!(%r!\A\w:/!, "/") File.join(base_directory, clean_path) end end |
.set_timezone(timezone) ⇒ void
This method returns an undefined value.
Set the TZ environment variable to use the timezone specified
rubocop:disable Naming/AccessorMethodName
311 312 313 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 311 def set_timezone(timezone) ENV["TZ"] = timezone end |
.timezone ⇒ String
Get the current TZ environment variable
318 319 320 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 318 def timezone ENV["TZ"] end |
.touch_live_reload_file(path = live_reload_path) ⇒ Object
394 395 396 397 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 394 def touch_live_reload_file(path = live_reload_path) FileUtils.mkdir_p File.dirname(path) FileUtils.touch path end |
.with_unbundled_env ⇒ void
This method returns an undefined value.
Determines the correct Bundler environment block method to use and passes the block on to it.
298 299 300 301 302 303 304 |
# File 'bridgetown-core/lib/bridgetown-core.rb', line 298 def with_unbundled_env(&) if Bundler.bundler_major_version >= 2 Bundler.method(:with_unbundled_env).call(&) else Bundler.method(:with_clean_env).call(&) end end |