Sha256: fec8a7368d1df8a20f3df4995a539ac29a1e9e695d23ab5816b98296b4533d2d

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module Resulang
  class App
    attr_reader :path, :resume

    def initialize(path:)
      @path = path
      load_app
    end

    def template_path
      File.join(path, 'templates', 'resume.html.erb')
    end

    def processor(output:, format:)
      Processor.new(app: self, output: output, format: format)
    end

    class Processor
      attr_reader :app, :output, :format

      def initialize(app:, output:, format:)
        @app    = app
        @output = output
        @format = format
      end

      def filename
        File.extname(output) == ".#{format}" ? output : "#{output}.#{format}"
      end

      def process
        case format.to_sym
          when :html then process_html
        end
      end

      private

        def process_html
          Resulang::Template.new(resume: app.resume, path: app.template_path).process
        end
    end

    private

      def load_app
        unless File.directory?('templates')
          raise "no Resulang app found at #{path.inspect}: 'templates' directory not found."
        end

        load_resume
      end

      def load_resume
        @resume = Resulang::Resume.new(path: resume_path)
      end

      def resume_path
        File.join(path, 'resume.yaml')
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
resulang-3.0.0 lib/resulang/app.rb