Class: Evergreen::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/evergreen/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(suite, name) ⇒ Template

Returns a new instance of Template.



5
6
7
8
# File 'lib/evergreen/template.rb', line 5

def initialize(suite, name)
  @suite = suite
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/evergreen/template.rb', line 3

def name
  @name
end

#suiteObject (readonly)

Returns the value of attribute suite.



3
4
5
# File 'lib/evergreen/template.rb', line 3

def suite
  @suite
end

Instance Method Details

#escaped_contentsObject



23
24
25
# File 'lib/evergreen/template.rb', line 23

def escaped_contents
  contents.to_json.gsub("<script>", %{<scr" + "ipt>}).gsub("</script>", %{</scr" + "ipt>})
end

#exist?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/evergreen/template.rb', line 27

def exist?
  File.exist?(full_path)
end

#full_pathObject



14
15
16
# File 'lib/evergreen/template.rb', line 14

def full_path
  File.join(root, Evergreen.template_dir, name)
end

#readObject Also known as: contents



18
19
20
# File 'lib/evergreen/template.rb', line 18

def read
  File.read(full_path)
end

#rootObject



10
11
12
# File 'lib/evergreen/template.rb', line 10

def root
  suite.root
end