Class: CreateProj::Creator::HaskellCreator

Inherits:
Creator
  • Object
show all
Defined in:
lib/createproj/creator/haskell.rb

Overview

Class for creating Haskell project

Instance Attribute Summary

Attributes inherited from Creator

#name, #options

Instance Method Summary collapse

Methods inherited from Creator

#add_pre_commit_hook, #create_directory, #extra_setup, #gitignore, #init_git_repository, #run

Constructor Details

#initialize(*args) ⇒ HaskellCreator

Returns a new instance of HaskellCreator.



5
6
7
8
9
10
# File 'lib/createproj/creator/haskell.rb', line 5

def initialize(*args)
  super(*args)
  @precommit_template = 'lint-pre-commit'
  @precommit_options = { linter: 'hlint', file_ext: '.hs' }
  @gitignore_files = %w(cabal.sandbox.config .cabal-sandbox)
end

Instance Method Details

#install_dependenciesObject

Installs dependencies in the new cabal sandbox

Examples:

Installs rubocop in the gemset sandbox

install_dependencies #=> happy & hlint installed in the gemset

Returns:

  • Nothing



28
29
30
31
32
33
34
35
36
# File 'lib/createproj/creator/haskell.rb', line 28

def install_dependencies
  cabals_to_install = %w(happy hlint)

  system('cabal update')

  cabals_to_install.each do |g|
    system("cabal install #{g}")
  end
end

#install_sandboxObject

Create an Haskell sandbox

Examples:

Create rvm sandbox for project named test

install_sandbox #=> Executes `cabal sandbox init`

Returns:

  • Nothing



18
19
20
# File 'lib/createproj/creator/haskell.rb', line 18

def install_sandbox
  system('cabal sandbox init')
end