Class: CreateProj::Creator::RubyCreator

Inherits:
CreateProj::Creator show all
Defined in:
lib/createproj/creator/ruby.rb

Overview

Class for creating Ruby project

Direct Known Subclasses

RailsCreator

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RubyCreator

Returns a new instance of RubyCreator.



5
6
7
8
9
# 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' }
end

Instance Method Details

#install_dependenciesObject

Installs dependencies in the new sandbox

Examples:

Installs rubocop in the gemset sandbox

install_dependencies #=> rubocop is no installed in the gemset

Returns:

  • Nothing



35
36
37
38
39
40
41
# File 'lib/createproj/creator/ruby.rb', line 35

def install_dependencies
  gems_to_install = %w(rubocop)

  gems_to_install.each do |g|
    system("gem install #{g}")
  end
end

#install_sandboxObject

TODO:
  • make it so can specify ruby version

Create an rvm gemset with the project name and creates file dictating gemset

Examples:

Create rvm sandbox for project named test

install_sandbox #=> Executes `rvm gemset create test`

Returns:

  • Nothing



20
21
22
23
24
25
26
27
# File 'lib/createproj/creator/ruby.rb', line 20

def install_sandbox
  RVM.gemset_create @name
  RVM.gemset_use @name

  File.open('.ruby-gemset', 'w+') do |f|
    f.write(@name)
  end
end