Class: EspressoInit::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/espresso_init/task.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Task

Returns a new instance of Task.



4
5
6
7
8
9
# File 'lib/espresso_init/task.rb', line 4

def initialize(dir)
  @dir = dir
  @name = 'Gemfile'
  @path = File.join(@dir, @name)
  fail("Will NOT overwrite the existing #{@path}") if File.exists?(@path)
end

Instance Method Details

#gemfileObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/espresso_init/task.rb', line 24

def gemfile
<<GEMFILE
gem 'e',           '0.4.10', :git => 'git://github.com/wokibe/espresso'
gem 'el',          '0.4.10', :git => 'git://github.com/wokibe/espresso-lungo'
gem 'el-ace',      '0.0.7',  :git => 'git://github.com/wokibe/el-ace'
gem 'el-finder',   '0.0.9',  :git => 'git://github.com/wokibe/el-finder'
gem 'el-ckeditor', '0.0.2',  :git => 'git://github.com/wokibe/el-ckeditor'
gem 'rear',        '0.1.2',  :git => 'git://github.com/wokibe/rear'
gem 'enginery',    '0.2.12', :git => 'git://github.com/wokibe/enginery'

group :development do
  gem 'specular',  '0.2.2',  :git => 'git://github.com/wokibe/specular'
  gem 'sonar',     '0.2.0',  :git => 'git://github.com/wokibe/sonar'
end    
GEMFILE
end

#generateObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/espresso_init/task.rb', line 11

def generate
  if File.exists?(@dir)
    fail("#{@dir} is not a directory") unless File.directory?(@dir)
  else
    puts "Generating the directory #{@dir}"
    Dir.mkdir(@dir)
  end
  
  source = gemfile
  puts "Generating the file #{@path}"
  File.open(@path, 'w') {|f| f << source}
end