Class: Paperwork::Tasks::RootHelpers

Inherits:
Base
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/paperwork/tasks/root_helpers.rb

Overview

task generator for root_helpers.rb that will provide url path to the root page

Instance Attribute Summary collapse

Attributes inherited from Base

#dependencies, #name

Instance Method Summary collapse

Methods inherited from Base

#create_tasks, explain, #register, #registered?, #registered_tasks

Constructor Details

#initialize(dir, root, *dependencies) ⇒ RootHelpers

Returns a new instance of RootHelpers.



18
19
20
21
22
23
24
25
26
27
# File 'lib/paperwork/tasks/root_helpers.rb', line 18

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

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



14
15
16
# File 'lib/paperwork/tasks/root_helpers.rb', line 14

def root
  @root
end

Instance Method Details

#tasksObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/paperwork/tasks/root_helpers.rb', line 29

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