Class: GoodData::Command::Scaffold
- Defined in:
- lib/gooddata/commands/scaffold.rb
Constant Summary collapse
- TEMPLATES_PATH =
Pathname(__FILE__) + '../../../templates'
Class Method Summary collapse
-
.brick(name) ⇒ Object
Scaffolds new brick TODO: Add option for custom output dir.
-
.project(name) ⇒ Object
Scaffolds new project TODO: Add option for custom output dir.
Class Method Details
permalink .brick(name) ⇒ Object
Scaffolds new brick TODO: Add option for custom output dir
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gooddata/commands/scaffold.rb', line 47 def brick(name) fail ArgumentError, 'No name specified' if name.nil? FileUtils.mkdir(name) FileUtils.cd(name) do input = File.read(TEMPLATES_PATH + 'bricks/brick.rb.erb') erb = ERB.new(input) File.open('brick.rb', 'w') do |f| f.write(erb.result) end input = File.read(TEMPLATES_PATH + 'bricks/main.rb.erb') erb = ERB.new(input) File.open('main.rb', 'w') do |f| f.write(erb.result) end end end |
permalink .project(name) ⇒ Object
Scaffolds new project TODO: Add option for custom output dir
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gooddata/commands/scaffold.rb', line 19 def project(name) fail ArgumentError, 'No name specified' if name.nil? FileUtils.mkdir(name) FileUtils.cd(name) do FileUtils.mkdir('model') FileUtils.cd('model') do input = File.read(TEMPLATES_PATH + 'project/model/model.rb.erb') erb = ERB.new(input) File.open('model.rb', 'w') do |f| f.write(erb.result_with_hash(:name => name)) end end FileUtils.mkdir('data') FileUtils.cd('data') do FileUtils.cp(Dir.glob(TEMPLATES_PATH + 'project/data/*.csv'), '.') end input = File.read(TEMPLATES_PATH + 'project/Goodfile.erb') erb = ERB.new(input) File.open('Goodfile', 'w') do |f| f.write(erb.result) end end end |