Class: GBud::ProjectBuilder
- Inherits:
-
Object
- Object
- GBud::ProjectBuilder
- 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
-
#assets ⇒ Object
readonly
Hash containing file names for project assets.
-
#cli ⇒ Object
readonly
Option for making project executable.
-
#metadata ⇒ Object
readonly
Project metadata information supplied by user.
-
#paths ⇒ Object
readonly
Hash specifying project directories.
-
#templates ⇒ Object
readonly
Hash containing file names for project templates.
Instance Method Summary collapse
-
#build ⇒ Object
Builds the project.
-
#initialize(metadata, cli) ⇒ ProjectBuilder
constructor
Instantiates a ProjectBuilder object.
Constructor Details
#initialize(metadata, cli) ⇒ ProjectBuilder
Instantiates a ProjectBuilder object
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 72 |
# File 'lib/gbud/project_builder.rb', line 45 def initialize(, cli) @metadata = @cli = cli @templates = { 'readme.md': 'README.md', 'gemspec.rb': "#{snake_case([:name])}.gemspec", 'gemfile.rb': 'Gemfile', 'rakefile.rb': 'Rakefile', 'base.rb': 'base.rb', 'hello.rb': 'hello.rb', 'test_hello.rb': 'test_hello.rb', 'namespace.rb': "#{snake_case([:name])}.rb", 'version.rb': 'version.rb' } @assets = { license: 'LICENSE' } @paths = { project_dir: "#{snake_case([:name])}/", project_lib_dir: "#{snake_case([:name])}/lib/", project_lib_project_dir: "#{snake_case([:name])}/lib/#{snake_case([:name])}/", project_test_dir: "#{snake_case([:name])}/test/" } if cli == true @templates[:'executable.rb'] = snake_case([:name]) @paths[:project_bin_dir] = "#{snake_case([:name])}/bin/" end end |
Instance Attribute Details
#assets ⇒ Object (readonly)
Hash containing file names for project assets
39 40 41 |
# File 'lib/gbud/project_builder.rb', line 39 def assets @assets end |
#cli ⇒ Object (readonly)
Option for making project executable
35 36 37 |
# File 'lib/gbud/project_builder.rb', line 35 def cli @cli end |
#metadata ⇒ Object (readonly)
Project metadata information supplied by user
33 34 35 |
# File 'lib/gbud/project_builder.rb', line 33 def @metadata end |
#paths ⇒ Object (readonly)
Hash specifying project directories
41 42 43 |
# File 'lib/gbud/project_builder.rb', line 41 def paths @paths end |
#templates ⇒ Object (readonly)
Hash containing file names for project templates
37 38 39 |
# File 'lib/gbud/project_builder.rb', line 37 def templates @templates end |
Instance Method Details
#build ⇒ Object
Builds the project
76 77 78 79 80 |
# File 'lib/gbud/project_builder.rb', line 76 def build make_directories render_templates copy_assets end |