Sha256: b8b96ca51f1ed6a9952b149c52ab174bcfb5e558a97a057af1044c49afaa6fc4

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

module LocalPac
  class Initializer

    private

    attr_reader :config, :options

    public

    def initialize(options = {}, config = LocalPac.config)
      @options = options
      @config  = config
    end

    def run
      LocalPac.ui_logger.info "Creating pid directory: #{::File.dirname(config.pid_file)}"
      Actions::CreateDirectory.new(::File.dirname(config.pid_file), force: options[:force]).run

      LocalPac.ui_logger.info "Creating log directory: #{::File.dirname(config.access_log)}"
      Actions::CreateDirectory.new(::File.dirname(config.access_log), force: options[:force]).run

      LocalPac.ui_logger.info "Creating sass cache #{config.sass_cache}"
      Actions::CreateDirectory.new(config.sass_cache, force: options[:force]).run

      LocalPac.ui_logger.info "Creating local storage: #{config.local_storage}"
      Actions::CreateRepository.new(config.local_storage, bare: true, force: options[:force]).run

      LocalPac.ui_logger.info "Creating pre-receive hook in local storage \"#{config.local_storage}\"."
      Actions::CreateFile.new(:'git-hook', ::File.join(config.local_storage, 'hooks', 'pre-receive'), Data.new(config), force: options[:force], executable: true).run

      LocalPac.ui_logger.info "Creating config file at \"#{config.config_file}\"."
      Actions::CreateFile.new(:'example-config', config.config_file, Data.new(config), force: options[:force], create_directories: true).run

      if options[:pre_seed]
        LocalPac.ui_logger.info "Adding examples to repository at #{config.local_storage}/examples"
        Actions::AddExamplesToLocalStorage.new(config.local_storage).run
      end

      LocalPac.ui_logger.info "Showing the configuration of local_pac on your system."
      Actions::CreateOutput.new(:'example-config', $stdout, Data.new(config)).run
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
local_pac-0.3.0 lib/local_pac/initializer.rb
local_pac-0.2.3 lib/local_pac/initializer.rb
local_pac-0.2.2 lib/local_pac/initializer.rb
local_pac-0.2.1 lib/local_pac/initializer.rb