Sha256: 13f0a39ea64b363f3dfc0d58389d5725bf0ff42894e0289658c4300e15ac2ba6

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
cassette-rack-0.8.1 lib/cassette-rack/configure.rb
cassette-rack-0.8.0 lib/cassette-rack/configure.rb
cassette-rack-0.7.0 lib/cassette-rack/configure.rb