Sha256: c7c735edf6eff955ac59660dac7341720851db42b8106b094dc83a95bb97ea41

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'fileutils'
require 'vcr'

module CassetteRack
  module Configure
    class << self
      attr_accessor :cassette_path, :url
      attr_writer :content_layout

      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_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 preview_layout
        @preview_layout ||= File.expand_path('preview.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

      def preview_template
        File.read(self.preview_layout)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cassette-rack-0.10.0 lib/cassette-rack/configure.rb
cassette-rack-0.9.0 lib/cassette-rack/configure.rb