Sha256: a36c5efeb5a36c0dd1478ad609cf99143bdff29bf6454e6834ee6af4b32dd3a7

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

require 'thor'

module Daiku
  class Plugins
    class Datamapper
      class CLI < ::Thor::Group
        include ::Thor::Actions
        argument :app

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

        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

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

        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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
daiku-0.2.0 lib/daiku/plugins/datamapper/cli.rb