Sha256: b8fcee008804827e4e49726907c84cfaafa8b0d5526c61e7df9972127851b02f

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Nanoc::Int::ProcessingActions
  class Snapshot < Nanoc::Int::ProcessingAction
    # snapshot :before_layout
    # snapshot :before_layout, path: '/about.md'

    include Nanoc::Int::ContractsSupport

    attr_reader :snapshot_names
    attr_reader :paths

    contract C::IterOf[Symbol], C::IterOf[String] => C::Any
    def initialize(snapshot_names, paths)
      @snapshot_names = snapshot_names
      @paths = paths
    end

    contract C::None => Array
    def serialize
      [:snapshot, @snapshot_names, true, @paths]
    end

    contract C::KeywordArgs[snapshot_names: C::Optional[C::IterOf[Symbol]], paths: C::Optional[C::IterOf[String]]] => self
    def update(snapshot_names: [], paths: [])
      self.class.new(@snapshot_names + snapshot_names, @paths + paths)
    end

    contract C::None => String
    def to_s
      "snapshot #{@snapshot_names.inspect}, paths: #{@paths.inspect}"
    end

    def hash
      self.class.hash ^ snapshot_names.hash ^ paths.hash
    end

    def ==(other)
      self.class == other.class && snapshot_names == other.snapshot_names && paths == other.paths
    end

    def eql?(other)
      self == other
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nanoc-4.10.2 lib/nanoc/base/entities/processing_actions/snapshot.rb
nanoc-4.10.1 lib/nanoc/base/entities/processing_actions/snapshot.rb
nanoc-4.10.0 lib/nanoc/base/entities/processing_actions/snapshot.rb
nanoc-4.9.9 lib/nanoc/base/entities/processing_actions/snapshot.rb
nanoc-4.9.8 lib/nanoc/base/entities/processing_actions/snapshot.rb
nanoc-4.9.7 lib/nanoc/base/entities/processing_actions/snapshot.rb