Class: CreateProj::Creator::RubyCreator
- Inherits:
-
CreateProj::Creator
- Object
- CreateProj::Creator
- CreateProj::Creator::RubyCreator
- Defined in:
- lib/createproj/creator/ruby.rb
Overview
Class for creating Ruby project
Direct Known Subclasses
Instance Method Summary collapse
-
#gemset_name ⇒ String
Creates a namespaced gemset name to avoid overwriting of gemsets.
-
#initialize(*args) ⇒ RubyCreator
constructor
A new instance of RubyCreator.
-
#install_dependencies ⇒ Object
Installs dependencies in the new sandbox.
-
#install_sandbox ⇒ Object
Nothing.
-
#write_rvm_files ⇒ Object
Write the .ruby-gemset and .ruby-version rvm files.
Constructor Details
#initialize(*args) ⇒ RubyCreator
Returns a new instance of RubyCreator.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/createproj/creator/ruby.rb', line 5 def initialize(*args) super(*args) @precommit_template = 'lint-pre-commit' @precommit_options = { linter: 'rubocop', file_ext: '.rb' } @gitignore_files = %w(.ruby-gemset .ruby-version .bundle Gemfile.lock doc .yardoc) @gems_to_install = { 'rubocop' => '0.28', 'rspec' => '3.0', 'yard' => '0.8' } @default_ruby_version = '2.0.0' end |
Instance Method Details
#gemset_name ⇒ String
Creates a namespaced gemset name to avoid overwriting of gemsets
24 25 26 |
# File 'lib/createproj/creator/ruby.rb', line 24 def gemset_name "#{@name}-createproj" end |
#install_dependencies ⇒ Object
Installs dependencies in the new sandbox
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/createproj/creator/ruby.rb', line 69 def install_dependencies File.open('Gemfile', 'w+') do |f| f.write("source 'https://rubygems.org'\n\n") @gems_to_install.each do |k, v| f.write("gem '#{k}', '~> #{v}'\n") end end command = 'Enter the directory and run bundle install.' puts command end |
#install_sandbox ⇒ Object
Returns Nothing.
57 58 59 60 61 |
# File 'lib/createproj/creator/ruby.rb', line 57 def install_sandbox RVM.gemset_create(gemset_name) write_rvm_files end |
#write_rvm_files ⇒ Object
TODO:
-
make it so can specify ruby version
Write the .ruby-gemset and .ruby-version rvm files
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/createproj/creator/ruby.rb', line 36 def write_rvm_files # must have both .ruby-gemset and .ruby-version file File.open('.ruby-gemset', 'w+') do |f| f.write(gemset_name) end # @todo - make this an option File.open('.ruby-version', 'w+') do |f| f.write(@default_ruby_version) end end |