Sha256: 546d4fb2d368e616b629ac5576dcf28d44feaf7c2660f15d7883a7710b180f71

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 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')
              # insert require statements for 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

2 entries across 2 versions & 1 rubygems

Version Path
daiku-0.1.1 lib/daiku/plugins/datamapper/cli.rb
daiku-0.1.0 lib/daiku/plugins/datamapper/cli.rb