Sha256: 15392550709f3f970f006d2f26fbfb1d79f61ae4b18cdaf801edc669cc5e7ace

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 Bytes

Contents

module HighVoltage
  class Page
    attr_reader :content_path, :file_path

    def initialize(content_path, file_path)
      @content_path = content_path
      @file_path = file_path
    end

    def id
      file_path.gsub(content_path, "").gsub(html_file_pattern, "")
    end

    def valid?
      exists? && file_in_content_path? && !directory? && !partial? && html?
    end

    private

    def exists?
      File.exists?(file_path)
    end

    def file_in_content_path?
      file_path.start_with?(content_path)
    end

    def directory?
      FileTest.directory?(file_path)
    end

    def partial?
      File.basename(file_path).first == "_"
    end

    def html?
      !file_path.match(html_file_pattern).nil?
    end

    def html_file_pattern
      /\.(html)(\.[a-z]+)?$/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
high_voltage-3.0.0 lib/high_voltage/page.rb
high_voltage-2.4.0 lib/high_voltage/page.rb