Class: JsFixtures::HTML

Inherits:
Base
  • Object
show all
Defined in:
lib/js_fixtures/html.rb

Direct Known Subclasses

HTMLS3

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from Base

#location, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

config, create, generate_all, get

Constructor Details

#initialize(name, config) ⇒ HTML

Returns a new instance of HTML.



28
29
30
31
32
33
34
35
36
37
# File 'lib/js_fixtures/html.rb', line 28

def initialize(name, config)
  @name     =  name
  @scripts  =  config[:scripts]  ||= []
  @pre_scripts =  config[:settings] ||= "" 
  @post_scripts =  config[:post_scripts] ||= "" 

  self.class.local_fixture_path ||= Dir.mktmpdir
  @location = "#{self.class.local_fixture_path}/#{@name}.html"
  @local_file = File.expand_path(@location)
end

Class Attribute Details

.local_fixture_pathObject

Returns the value of attribute local_fixture_path.



10
11
12
# File 'lib/js_fixtures/html.rb', line 10

def local_fixture_path
  @local_fixture_path
end

.templateObject

Returns the value of attribute template.



11
12
13
# File 'lib/js_fixtures/html.rb', line 11

def template
  @template
end

.typeObject (readonly)

Returns the value of attribute type.



11
12
13
# File 'lib/js_fixtures/html.rb', line 11

def type
  @type
end

Instance Attribute Details

#post_scriptsObject

Returns the value of attribute post_scripts.



26
27
28
# File 'lib/js_fixtures/html.rb', line 26

def post_scripts
  @post_scripts
end

#pre_scriptsObject

Returns the value of attribute pre_scripts.



26
27
28
# File 'lib/js_fixtures/html.rb', line 26

def pre_scripts
  @pre_scripts
end

#scriptsObject

Returns the value of attribute scripts.



26
27
28
# File 'lib/js_fixtures/html.rb', line 26

def scripts
  @scripts
end

Class Method Details

.inherited(subclass) ⇒ Object



17
18
19
# File 'lib/js_fixtures/html.rb', line 17

def inherited(subclass)
  super
end

Instance Method Details

#clone(new_name) ⇒ Object



46
47
48
49
50
51
# File 'lib/js_fixtures/html.rb', line 46

def clone(new_name)
  self.class.new(new_name, 
                 :scripts => @scripts.dup, 
                 :settings => @pre_scripts.dup,
                 :post_scripts => @post_scripts.dup)
end

#generateObject



39
40
41
42
43
# File 'lib/js_fixtures/html.rb', line 39

def generate
  file = File.open(@local_file, 'w')
  file.syswrite(render_template())
  file.close
end