Class: Daiku::Plugins::Datamapper::CLI

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/daiku/plugins/datamapper/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



12
13
14
# File 'lib/daiku/plugins/datamapper/cli.rb', line 12

def self.source_root
  File.expand_path('../', __FILE__)
end

Instance Method Details

#bootrbObject



16
17
18
19
20
21
22
23
24
# File 'lib/daiku/plugins/datamapper/cli.rb', line 16

def bootrb
  insert_into_file "#{app}/lib/boot.rb", :after => "#models\n" do
    <<-DMREQ.strip_heredoc
      require File.join($app_root, 'config/datamapper')
      # require models here
      DataMapper.finalize
    DMREQ
  end
end

#configObject



26
27
28
# File 'lib/daiku/plugins/datamapper/cli.rb', line 26

def config
  template('_templates/datamapper.rb.tt', "#{app}/config/datamapper.rb")
end

#gemfileObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/daiku/plugins/datamapper/cli.rb', line 30

def gemfile
  content = <<-DMGEMS.strip_heredoc
    group :datamapper do
      gem 'dm-aspects'
      gem 'dm-aggregates'
      gem 'dm-core'
      gem 'dm-migrations'
      gem 'dm-pager'
      gem 'dm-postgres-adapter'
      gem 'dm-postgres-types'
      gem 'dm-timestamps'
      gem 'dm-transactions'
      gem 'dm-validations'
    end
  DMGEMS
  append_to_file "#{app}/Gemfile", content
end