Class: Jax::Generators::Material::MaterialGenerator

Inherits:
PluggableCommand show all
Defined in:
lib/jax/generators/material/material_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PluggableCommand

#check_plugin_destination

Methods inherited from Command

inherited

Methods included from Usage

extended, included

Constructor Details

#initialize(args = [], *other) ⇒ MaterialGenerator

Returns a new instance of MaterialGenerator.



10
11
12
13
# File 'lib/jax/generators/material/material_generator.rb', line 10

def initialize(args = [], *other)
  chain.unshift args.pop while args.length > 1 # name is arg0
  super(args, *other)
end

Class Method Details

.source_rootObject



15
16
17
# File 'lib/jax/generators/material/material_generator.rb', line 15

def self.source_root
  File.expand_path("templates", File.dirname(__FILE__))
end

.supported_shadersObject



50
51
52
53
54
# File 'lib/jax/generators/material/material_generator.rb', line 50

def supported_shaders
  Jax.application.shaders.select do |shader|
    shader.manifest && !shader.manifest.empty?
  end
end

Instance Method Details

#materialObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jax/generators/material/material_generator.rb', line 19

def material
  filename = File.join("app/resources/materials", "#{file_name}.yml")
  
  if options[:append]
    tmp = "tmp/amendment.#{file_name}.yml"
    template 'append.yml.tt', tmp, :verbose => false
    
    if File.file?(filename)
      say_status :append, filename, :green
    else
      say_status :missing, filename, :red
      return
    end
    
    File.open(filename, "a+") { |f| f.puts File.read(tmp) }
    
    # doesn't append if the end of the file matches string identically - usually useful, but in this case troublesome.
    # append_to_file File.join("app/resources/materials", "#{file_name}.yml"), File.read("tmp/amendment.#{file_name}.yml")
    
    remove_file tmp, :verbose => false
  else
    template 'material.yml.tt', filename
  end
end