Class: GBud::ProjectBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gbud/project_builder.rb

Overview

ProjectBuilder

Author

Richard Davis

Copyright

Copyright 2017 Richard Davis

License

GNU Public License 3

The engine that is instantiated to build out the project directory skeleton and basic files using templates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata, cli) ⇒ ProjectBuilder

Instantiates a ProjectBuilder object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/gbud/project_builder.rb', line 43

def initialize , cli
   = 

  @cli = cli
  @templates = {
    'readme.md': 'README.md',
    'gemspec.rb': "#{metadata[:name]}.gemspec",
    'gemfile.rb': 'Gemfile',
    'guardfile.rb': 'Guardfile',
    'rakefile.rb': 'Rakefile',
    'main.rb': "#{metadata[:name]}.rb",
    'hello.rb': 'hello.rb',
    'test_hello.rb': 'test_hello.rb',
    'namespace.rb': 'namespace.rb'
  }
  @assets = {
    license: 'LICENSE'
  }
  @paths = {
    project_dir: "#{metadata[:name]}/",
    project_lib_dir: "#{metadata[:name]}/lib/",
    project_lib_project_dir: "#{metadata[:name]}/lib/#{metadata[:name]}/",
    project_test_dir: "#{metadata[:name]}/test/",
  }
  if cli == true
    @templates[:'executable.rb'] = "#{metadata[:name]}"
    @paths[:project_bin_dir] = "#{metadata[:name]}/bin/"
  end
end

Instance Attribute Details

#assetsObject (readonly)

Hash containing file names for project assets



37
38
39
# File 'lib/gbud/project_builder.rb', line 37

def assets
  @assets
end

#cliObject (readonly)

Option for making project executable



33
34
35
# File 'lib/gbud/project_builder.rb', line 33

def cli
  @cli
end

#metadataObject (readonly)

Project metadata information supplied by user



31
32
33
# File 'lib/gbud/project_builder.rb', line 31

def 
  
end

#pathsObject (readonly)

Hash specifying project directories



39
40
41
# File 'lib/gbud/project_builder.rb', line 39

def paths
  @paths
end

#templatesObject (readonly)

Hash containing file names for project templates



35
36
37
# File 'lib/gbud/project_builder.rb', line 35

def templates
  @templates
end

Instance Method Details

#buildObject

Builds the project



75
76
77
78
79
# File 'lib/gbud/project_builder.rb', line 75

def build
  make_directories
  render_templates
  copy_assets
end