Class: Haskell
- Inherits:
-
Thor
show all
- Includes:
- GitConfig, Thor::Actions
- Defined in:
- lib/haskell.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from GitConfig
#author, #email, #github_token, #github_user, #jenkins_password, #jenkins_server, #jenkins_user
Instance Attribute Details
#mod ⇒ Object
Returns the value of attribute mod.
11
12
13
|
# File 'lib/haskell.rb', line 11
def mod
@mod
end
|
Class Method Details
.source_root ⇒ Object
14
15
16
|
# File 'lib/haskell.rb', line 14
def self.source_root
File.join(File.dirname(__FILE__), '..', 'templates')
end
|
Instance Method Details
#cabal_dev ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/haskell.rb', line 68
def cabal_dev
["cabal-dev", "happy"].each do |prereq|
guarded "[ -x `which #{prereq}` ]" do
warn "#{prereq} not installed, attempting..."
guarded "cabal install #{prereq}" do |err|
abort "#{prereq} not installable: #{ap err}"
end
end
end
guarded "cabal install -v"
end
|
#mkdir ⇒ Object
40
41
42
43
44
|
# File 'lib/haskell.rb', line 40
def mkdir
puts "creating #{Dir.getwd}/#{name}"
Dir.mkdir name
Dir.mkdir "#{name}/Tests"
end
|
#preflight ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/haskell.rb', line 19
def preflight
author
email
abort "#{name} already taken on hackage" unless
HTTParty.get("http://hackage.haskell.org/package/#{name}").code == 404
%x{cabal list --simple-output #{name}} == ""
abort "#{name} directory already exists!" if Dir.exists? name
end
|
#setup ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/haskell.rb', line 29
def setup
invoke :mkdir
Dir.chdir name do
invoke :skeleton
invoke :cabal_dev
end
announce "new haskell project set up"
end
|
#skeleton ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/haskell.rb', line 51
def skeleton
@mod = name.camelize
guarded "cabal init -m -n #{name} -l BSD3 -a Mark Wotton -e [email protected] -c #{options.category} -q"
guarded "rm #{name}.cabal" do end
template 'cabal.tt', "#{name}/#{name}.cabal"
template 'test.tt', "#{name}/Tests/Test#{@mod}.hs"
template 'module.tt', "#{name}/src/#{@mod}.hs"
template 'main.tt', "#{name}/src/Main.hs" if options.app?
template 'watchr.tt', "#{name}/watchr.rb"
template 'README.tt', "#{name}/README.md"
File.open("runtests.sh", "w") do |f|
f.write "tbc -v Tests"
end
end
|