Class: Jax::Generators::MaterialGenerator
- Inherits:
-
NamedBase
- Object
- Rails::Generators::NamedBase
- NamedBase
- Jax::Generators::MaterialGenerator
- Defined in:
- lib/generators/jax/material/material_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #append_shaders ⇒ Object
- #create_resource_file ⇒ Object
-
#initialize(args = [], options = [], config = {}) ⇒ MaterialGenerator
constructor
A new instance of MaterialGenerator.
- #prepend_lighting_shader ⇒ Object
Methods included from SourceRoot
Methods included from CoffeeGenerator
Constructor Details
#initialize(args = [], options = [], config = {}) ⇒ MaterialGenerator
Returns a new instance of MaterialGenerator.
37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/jax/material/material_generator.rb', line 37 def initialize(args = [], = [], config = {}) if args.length > 1 super([args.shift], , config) @shaders = args else super @shaders = [] end end |
Class Method Details
.all_shaders ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/generators/jax/material/material_generator.rb', line 24 def self.all_shaders shaders = [] ::Rails.application.assets.each_logical_path do |path| if path =~ /shaders\/(.*)\/manifest.yml/ info = (YAML.load(StringIO.new ::Rails.application.assets[path].to_s) || {}).with_indifferent_access info[:name] ||= $1 info[:description] ||= "" shaders << info end end shaders.sort { |a,b| a['name'] <=> b['name'] } end |
.desc(description = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/generators/jax/material/material_generator.rb', line 11 def self.desc(description = nil) # TODO This can be removed under future versions of Rails, which use ERB for Usage out of the box. # TODO it would help if one could configure the location of USAGE return super if description usage = source_root && File.("USAGE", File.dirname(__FILE__)) @desc ||= if usage && File.exist?(usage) ERB.new(File.read(usage)).result(binding) else super end end |
Instance Method Details
#append_shaders ⇒ Object
57 58 59 60 61 |
# File 'lib/generators/jax/material/material_generator.rb', line 57 def append_shaders # first line of array is just array header stuff, we can do without it = .to_yaml.lines.to_a[1..-1].collect { |line| " "+line }.join append_file relative_path, end |
#create_resource_file ⇒ Object
53 54 55 |
# File 'lib/generators/jax/material/material_generator.rb', line 53 def create_resource_file template 'material.resource.erb', relative_path unless [:append] and File.file?(absolute_path) end |
#prepend_lighting_shader ⇒ Object
47 48 49 50 51 |
# File 'lib/generators/jax/material/material_generator.rb', line 47 def prepend_lighting_shader unless [:skip_lighting] or shader_selected?('lighting') or File.file?(relative_path) @shaders.unshift 'lighting' end end |