class Nanoc::CLI::Commands::Shell

Public Class Methods

env_for_site(site) click to toggle source
# File lib/nanoc/cli/commands/shell.rb, line 45
def self.env_for_site(site)
  view_context = view_context_for(site)

  {
    items: Nanoc::Core::ItemCollectionWithRepsView.new(site.items, view_context),
    layouts: Nanoc::Core::LayoutCollectionView.new(site.layouts, view_context),
    config: Nanoc::Core::ConfigView.new(site.config, view_context),
  }
end
reps_for(site) click to toggle source
# File lib/nanoc/cli/commands/shell.rb, line 30
def self.reps_for(site)
  Nanoc::Core::ItemRepRepo.new.tap do |reps|
    action_provider = Nanoc::Core::ActionProvider.named(site.config.action_provider).for(site)
    builder = Nanoc::Core::ItemRepBuilder.new(site, action_provider, reps)
    builder.run
  end
end
view_context_for(site) click to toggle source
# File lib/nanoc/cli/commands/shell.rb, line 38
def self.view_context_for(site)
  Nanoc::Core::ViewContextForShell.new(
    items: site.items,
    reps: reps_for(site),
  )
end

Public Instance Methods

env() click to toggle source
# File lib/nanoc/cli/commands/shell.rb, line 26
def env
  self.class.env_for_site(@site)
end
run() click to toggle source
# File lib/nanoc/cli/commands/shell.rb, line 14
def run
  require 'pry'

  # Needed to make pry behave properly sometimes -- see nanoc/nanoc#1309
  Signal.trap('SIGINT') { raise Interrupt }

  @site = load_site
  Nanoc::Core::Compiler.new_for(@site).run_until_preprocessed if options[:preprocess]

  Nanoc::Core::Context.new(env).pry
end