Method: Falsework::Mould#initialize

Defined in:
lib/falsework/mould.rb

#initialize(project, template, user = nil, email = nil, gecos = nil) ⇒ Mould

project

A name of the future project; may include all crap with spaces.

template

A name of the template for the project.

user

Github username; if nil we are extracting it from the ~/.gitconfig.

email

Github email

gecos

A full author name from ~/.gitconfig.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/falsework/mould.rb', line 62

def initialize(project, template, user = nil, email = nil, gecos = nil)
  @project = Mould.name_project project
  raise "invalid project name '#{project}'" if !Mould.name_valid? @project
  @camelcase = Mould.name_camelcase project
  @classy = Mould.name_classy project
  
  @verbose = false
  @batch = false
  @template = template
  @dir_t = Mould.templates[@template || TEMPLATE_DEFAULT] || CliUtils.errx(1, "no such template: #{template}")

  # default config
  @conf = {
    exe: [{
            src: nil,
            dest: 'bin/%s',
            mode_int: 0744
          }],
    doc: [{
            src: nil,
            dest: 'doc/%s.rdoc',
            mode_int: nil
          }],
    test: [{
             src: nil,
             dir: 'test/test_%s.rb',
             mode_int: nil
           }]
  }
  Mould.config_parse(@dir_t + '/' + TEMPLATE_CONFIG, [], @conf)
  
  gc = Git.global_config rescue gc = {}
  @user = user || gc['github.user']
  @email = email || ENV['GIT_AUTHOR_EMAIL'] || ENV['GIT_COMMITTER_EMAIL'] || gc['user.email']
  @gecos = gecos || ENV['GIT_AUTHOR_NAME'] || ENV['GIT_COMMITTER_NAME']  || gc['user.name']

  [['github.user', @user],
   ['user.email', @email],
   ['user.name', @gecos]].each {|i|
    CliUtils.errx(1, "missing #{i.first} in #{GITCONFIG}") if i.last.to_s == ''
  }
end