Module: SchemaDev::Gemfiles
Constant Summary collapse
- TEMPLATES_ROOT =
Pathname.new(__FILE__).dirname.parent.parent + "templates"
Instance Method Summary collapse
Instance Method Details
#_blow_away(path) ⇒ Object
41 42 43 44 |
# File 'lib/schema_dev/gemfiles.rb', line 41 def _blow_away(path) (@dst_root + path).rmtree rescue Errno::ENOENT end |
#_copy(path, filename) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/schema_dev/gemfiles.rb', line 32 def _copy(path, filename) srcfile = @src_root + path + filename dstfile = @dst_root + path + filename return unless srcfile.exist? dstfile.dirname.mkpath FileUtils.copy_file(srcfile, dstfile) end |
#build(config) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/schema_dev/gemfiles.rb', line 10 def build(config) @src_root = TEMPLATES_ROOT @dst_root = Pathname.new('.') path = Pathname.new("gemfiles") _blow_away(path) _copy(path, 'Gemfile.base') config.rails.each do |rails| rails_path = path + "rails-#{rails}" _copy(rails_path, 'Gemfile.base') config.db.each do |db| _copy(rails_path, "Gemfile.#{db}") end end return true end |