Sha256: 1f3ca3cc5d281fbe1052961208194d598a5652241d7b8d60d41d14a047f9b6a3

Contents?: true

Size: 572 Bytes

Versions: 31

Compression:

Stored size: 572 Bytes

Contents

module Troy
  class Meta
    extend Forwardable
    def_delegators :data, :[], :fetch, :key?

    REGEX = /^---\n(.*?)\n---\n+/m

    attr_reader :file

    def initialize(file)
      @file = file
    end

    def content
      @content ||= raw.gsub(REGEX, "")
    end

    def data
      @data ||= (raw =~ REGEX ? YAML.load(raw[REGEX, 1]) : {})
    end

    def method_missing(name, *args, &block)
      data[name.to_s]
    end

    def respond_to_missing?(method, include_private = false)
      true
    end

    def raw
      @raw ||= File.read(file)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
troy-0.0.35 lib/troy/meta.rb
troy-0.0.34 lib/troy/meta.rb
troy-0.0.33 lib/troy/meta.rb
troy-0.0.32 lib/troy/meta.rb
troy-0.0.31 lib/troy/meta.rb
troy-0.0.30 lib/troy/meta.rb
troy-0.0.29 lib/troy/meta.rb
troy-0.0.28 lib/troy/meta.rb
troy-0.0.27 lib/troy/meta.rb
troy-0.0.26 lib/troy/meta.rb
troy-0.0.25 lib/troy/meta.rb
troy-0.0.24 lib/troy/meta.rb
troy-0.0.23 lib/troy/meta.rb
troy-0.0.22 lib/troy/meta.rb
troy-0.0.21 lib/troy/meta.rb
troy-0.0.20 lib/troy/meta.rb
troy-0.0.19 lib/troy/meta.rb
troy-0.0.18 lib/troy/meta.rb
troy-0.0.17 lib/troy/meta.rb
troy-0.0.16 lib/troy/meta.rb