Class: Detroit::Erbside

Inherits:
Tool
  • Object
show all
Includes:
Standard
Defined in:
lib/detroit-erbside.rb

Overview

Erbside tool is an inline templating tool for source code. It can be useful for keeping information uptodate that is static in code, but dynamic to the project itself. A good example a ‘VERSION` constant.

module MyApp
  VERSION = "1.2.0"  #:erb: VERSION = "<%= version %>"
  ...

Constant Summary collapse

MANPAGE =

Loction of manpage for tool.

File.dirname(__FILE__) + '/../man/detroit-erbside.5'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#excludeObject

Exclude subpaths from ‘path`.



45
46
47
# File 'lib/detroit-erbside.rb', line 45

def exclude
  @exclude
end

#ignoreObject

Exclude subpaths from ‘path` by matching basename.



48
49
50
# File 'lib/detroit-erbside.rb', line 48

def ignore
  @ignore
end

#pathObject

Paths of lifes to render.



39
40
41
# File 'lib/detroit-erbside.rb', line 39

def path
  @path
end

#promptObject

Prompt on each write.



51
52
53
# File 'lib/detroit-erbside.rb', line 51

def prompt
  @prompt
end

#resourcesObject

Metadata resources, default is project metadata.



54
55
56
# File 'lib/detroit-erbside.rb', line 54

def resources
  @resources
end

Instance Method Details

#assemble?(station, options = {}) ⇒ Boolean

This tool ties into the ‘generate` station of the standard assembly.

Returns:

  • (Boolean)


74
75
76
# File 'lib/detroit-erbside.rb', line 74

def assemble?(station, options={})
  return true if station == :generate
end

#generateObject

Render templates.



60
61
62
63
64
65
66
67
68
# File 'lib/detroit-erbside.rb', line 60

def generate
  options = {}
  options[:prompt]    = prompt
  options[:exclude]   = exclude
  options[:ignore]    = ignore
  options[:resources] = resources || 

  ::Erbside::Runner.new(path, options).render
end

#prerequisitevoid

This method returns an undefined value.

Load requirements and set attribute defaults.



31
32
33
34
35
36
# File 'lib/detroit-erbside.rb', line 31

def prerequisite
  require 'erbside'
  require 'shellwords'

  @path = 'lib'
end