Class: Biran::ERBConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/biran/erb_config.rb

Constant Summary collapse

DEFAULT_TEMPLATE_CONFIG_INDEX =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, name, extension, source, output_dir, output_name) ⇒ ERBConfig

Returns a new instance of ERBConfig.



8
9
10
11
12
13
14
15
16
17
# File 'lib/biran/erb_config.rb', line 8

def initialize(config, name, extension, source, output_dir, output_name)
  before_process_erb do
    @name       = name
    @extension  = extension
    @config     = config
    @source_dir = source
    @output_dir = output_dir
    @output_name = output_name
  end
end

Instance Attribute Details

#bindingsObject

Returns the value of attribute bindings.



4
5
6
# File 'lib/biran/erb_config.rb', line 4

def bindings
  @bindings
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/biran/erb_config.rb', line 3

def config
  @config
end

#extensionObject (readonly)

Returns the value of attribute extension.



3
4
5
# File 'lib/biran/erb_config.rb', line 3

def extension
  @extension
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/biran/erb_config.rb', line 3

def name
  @name
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



3
4
5
# File 'lib/biran/erb_config.rb', line 3

def output_dir
  @output_dir
end

#output_nameObject

Returns the value of attribute output_name.



4
5
6
# File 'lib/biran/erb_config.rb', line 4

def output_name
  @output_name
end

#source_dirObject (readonly)

Returns the value of attribute source_dir.



3
4
5
# File 'lib/biran/erb_config.rb', line 3

def source_dir
  @source_dir
end

#template_config_indexObject

Returns the value of attribute template_config_index.



4
5
6
# File 'lib/biran/erb_config.rb', line 4

def template_config_index
  @template_config_index
end

#template_contentsObject (readonly)

Returns the value of attribute template_contents.



3
4
5
# File 'lib/biran/erb_config.rb', line 3

def template_contents
  @template_contents
end

Instance Method Details

#save!Object



19
20
21
22
23
# File 'lib/biran/erb_config.rb', line 19

def save!
  File.open(File.join(output_dir, "#{output_name}#{extension}"), 'w') do |f|
    f.print template_contents.result(build_erb_env.call)
  end
end