Class: Stylio::Generators::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/stylio/generators/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Component

Returns a new instance of Component.



7
8
9
# File 'lib/stylio/generators/component.rb', line 7

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/stylio/generators/component.rb', line 5

def name
  @name
end

Instance Method Details

#generateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/stylio/generators/component.rb', line 11

def generate
  puts "Generating component with name #{name}".yellow
  FileUtils::mkdir_p "components/#{name}"
  puts "Created folder components/#{name}".green
  File.open("components/#{name}/#{name}.yml", 'w') do |f|
    f.write('')
  end
  puts "Created file components/#{name}/#{name}.yml".green
  File.open("components/#{name}/#{name}.html.erb", 'w') do |f|
    f.write('')
  end
  puts "Created file components/#{name}/#{name}.html.erb".green
  puts "Generated component with name #{name}".green
end