class Stylio::Generators::Component
Attributes
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/stylio/generators/component.rb, line 7 def initialize(name) @name = name end
Public Instance Methods
fullpath(extension)
click to toggle source
# File lib/stylio/generators/component.rb, line 11 def fullpath(extension) if extension == 'html.erb' "components/#{name}/_#{name}.#{extension}" else "components/#{name}/#{name}.#{extension}" end end
generate()
click to toggle source
# File lib/stylio/generators/component.rb, line 19 def generate puts "Generating component with name #{name}".yellow FileUtils::mkdir_p "components/#{name}" puts "Created folder components/#{name}".green File.open(fullpath('yml'), 'w') do |f| f.write('') end puts "Created file #{fullpath('yml')}".green File.open(fullpath('html.erb'), 'w') do |f| f.write('') end puts "Created file #{fullpath('html.erb')}".green puts "Generated component with name #{name}".green end