class Sitepress::CLI
Command line interface for compiling Sitepress
sites.
Constants
- COMPILE_DEFAULT_TARGET_PATH
- SERVER_DEFAULT_BIND_ADDRESS
- SERVER_DEFAULT_PORT
Public Instance Methods
compile()
click to toggle source
# File lib/sitepress/cli.rb, line 32 def compile initialize! # Page compilation logger.info "Sitepress compiling pages" Compiler.new(site: configuration.site, root_path: options.fetch("output_path")).compile # Sprockets compilation logger.info "Sitepress compiling assets" sprockets_manifest(target_path: options.fetch("output_path")).compile precompile_assets end
console()
click to toggle source
# File lib/sitepress/cli.rb, line 43 def console initialize! # Start's an interactive console. REPL.new(context: configuration).start end
new(target)
click to toggle source
# File lib/sitepress/cli.rb, line 50 def new(target) # Peg the generated site to roughly the released version. *segments, _ = Gem::Version.new(Sitepress::VERSION).segments @target_sitepress_version = segments.join(".") inside target do directory self.class.source_root, "." run "bundle install" end end
server()
click to toggle source
# File lib/sitepress/cli.rb, line 17 def server initialize! # Enable Sitepress web error reporting so users have more friendly # error messages instead of seeing a Rails exception. controller.enable_sitepress_error_reporting = true # Enable reloading the site between requests so we can see changes. controller.enable_site_reloading = true # This will use whatever server is found in the user's Gemfile. Rack::Server.start app: app, Port: options.fetch("port"), Host: options.fetch("bind_address") end
version()
click to toggle source
# File lib/sitepress/cli.rb, line 62 def version say Sitepress::VERSION end
Private Instance Methods
app()
click to toggle source
# File lib/sitepress/cli.rb, line 99 def app Sitepress::Server end
configuration()
click to toggle source
# File lib/sitepress/cli.rb, line 67 def configuration Sitepress.configuration end
controller()
click to toggle source
# File lib/sitepress/cli.rb, line 95 def controller ::SiteController end
initialize!()
click to toggle source
# File lib/sitepress/cli.rb, line 90 def initialize! require_relative "boot" app.initialize! end
logger()
click to toggle source
# File lib/sitepress/cli.rb, line 82 def logger rails.config.logger end
precompile_assets()
click to toggle source
# File lib/sitepress/cli.rb, line 86 def precompile_assets rails.config.assets.precompile end
rails()
click to toggle source
# File lib/sitepress/cli.rb, line 78 def rails configuration.parent_engine end
sprockets_manifest(target_path: )
click to toggle source
# File lib/sitepress/cli.rb, line 71 def sprockets_manifest(target_path: ) target_path = Pathname.new(target_path) Sprockets::Manifest.new(rails.assets, target_path.join("assets/manifest.json")).tap do |manifest| manifest.environment.logger = logger end end