Sha256: 19b48d795fa627d0bf336c42dc08a73c1af77ceee843459782bb921f244a2d19

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'vcr'

module CassetteRack
  module Configure
    class << self
      attr_accessor :cassette_extension, :cassette_path, :url

      def setup
        keys.each do |key|
          instance_variable_set(:"@#{key}", CassetteRack::Default.send(key))
        end

        FileUtils.mkdir_p(self.source_path)

        VCR.configure do |config|
          config.cassette_library_dir = self.source_path
        end
      end

      def keys
        @keys ||= %i[cassette_extension cassette_path url]
      end

      def source_path
        @source_path ||= File.expand_path(self.cassette_path)
      end

      def templates_path
        @templates_path ||= CassetteRack.root.join('lib', 'templates').to_s
      end

      def application_layout
        @application_layout ||= File.expand_path('application.html.liquid', File.join(self.templates_path, 'layouts'))
      end

      def content_layout
        @content_layout ||= File.expand_path('content.md.liquid', File.join(self.templates_path, 'layouts'))
      end

      def application_template
        File.read(self.application_layout)
      end

      def content_template
        File.read(self.content_layout)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cassette-rack-0.4.0 lib/cassette-rack/configure.rb