Class: Quartet::Builders::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/quartet/builder.rb

Direct Known Subclasses

App, Config, Database, Gemfile, Rakefile, Readme, Welcome

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



5
6
7
8
# File 'lib/quartet/builder.rb', line 5

def initialize
  @directory = ''
  @file_type = '.rb'
end

Instance Method Details

#build(app_name) ⇒ Object



26
# File 'lib/quartet/builder.rb', line 26

def build(app_name); end

#filepath(app_name) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/quartet/builder.rb', line 10

def filepath(app_name)
  unless @name_override
    return "#{app_name}/#{@directory}/#{underscore(self.class.to_s.split('::')[-1])}#{@file_type}"
  end

  "#{app_name}/#{@directory}/#{@name_override}#{@file_type}"
end

#underscore(string) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/quartet/builder.rb', line 18

def underscore(string)
  string.gsub(/::/, '/')
        .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        .gsub(/([a-z\d])([A-Z])/, '\1_\2')
        .tr('-', '_')
        .downcase
end