Sha256: a085e12e5ef740d361932e98f799e49b775c3cdea96d8e026cc1c32b9c1d8d0f

Contents?: true

Size: 1.54 KB

Versions: 14

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Paperwork
    ##
    # task generators for building with middleman
    module Tasks
        require "rake"

        ##
        # task generator for root_helpers.rb that will
        # provide url path to the root page
        #
        class RootHelpers < Paperwork::Tasks::Base
            attr_reader :root

            include Rake::DSL

            def initialize(dir, root, *dependencies)
                super(
                    File.join(dir, "lib", "root_helpers.rb"),
                    dir,
                    *dependencies
                )
                Template.new(dir)

                @root = File.basename(root, ".md") + ".html"
            end

            def tasks
                file self.name => self.dependencies do
                    File.write(
                        name,
                        <<~ROOT_HELPERS
                            module RootHelpers
                                def root_path
                                    relative_link "#{self.root}"
                                end

                                def custom_css
                                    ["#{Paperwork::Config[:custom_css].join("\", \"")}"]
                                end

                                def custom_js
                                    ["#{Paperwork::Config[:custom_js].join("\", \"")}"]
                                end
                            end
                        ROOT_HELPERS
                    )
                end
            end
        end
    end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
paperwork-0.5.1 lib/paperwork/tasks/root_helpers.rb
paperwork-0.5.0 lib/paperwork/tasks/root_helpers.rb
paperwork-0.4.1 lib/paperwork/tasks/root_helpers.rb
paperwork-0.4.0 lib/paperwork/tasks/root_helpers.rb
paperwork-0.3.5 lib/paperwork/tasks/root_helpers.rb
paperwork-0.3.4 lib/paperwork/tasks/root_helpers.rb
paperwork-0.3.3 lib/paperwork/tasks/root_helpers.rb
paperwork-0.3.2 lib/paperwork/tasks/root_helpers.rb
paperwork-0.3.1 lib/paperwork/tasks/root_helpers.rb
paperwork-0.3.0 lib/paperwork/tasks/root_helpers.rb
paperwork-0.2.6 lib/paperwork/tasks/root_helpers.rb
paperwork-0.2.5 lib/paperwork/tasks/root_helpers.rb
paperwork-0.2.4 lib/paperwork/tasks/root_helpers.rb
paperwork-0.2.3 lib/paperwork/tasks/root_helpers.rb