Sha256: a237f8ef304fcb2c5126074ae2698d96635886afbd13a0836e6854ce9ae3d4c6

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

module DMGen
  class Adapter < Templater::Generator
    first_argument :name, :required => true

    desc <<-eos
      Generates a DataMapper Adapter skeleton.

      Use like
        dm-gen adapter data_source

      This generates the full plugin structure with skeleton code and specs, as
      well as a Rakefile.  All it needs is a README and some real functionality.
    eos

    def self.source_root
      File.join(File.dirname(__FILE__), '..', 'templates', 'adapter')
    end

    def gem_name
      "dm-#{adapter_name}"
    end

    def adapter_name
      "#{snake_name}-adapter"
    end

    def adapter_file
      "#{snake_name}_adapter"
    end

    def snake_name
      name.snake_case
    end

    def class_name
      "#{name.camel_case}Adapter"
    end

    def destination_root
      File.join(@destination_root, gem_name)
    end

    # glob the template dir for all templates.
    # since we want text files processed, we have to replace the default
    # extension list.
    glob!('', %w[rb txt Rakefile LICENSE TODO])

    def manifest_files
      self.all_actions.map {|t| t.destination.gsub(/#{destination_root}\//,'') }.sort
    end
  end

  add :adapter, Adapter
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
namelessjon-dm-gen-0.2.0 lib/generators/adapter.rb
namelessjon-dm-gen-0.2.1 lib/generators/adapter.rb
namelessjon-dm-gen-0.2.2 lib/generators/adapter.rb
namelessjon-dm-gen-0.2.3 lib/generators/adapter.rb
namelessjon-dm-gen-0.2.4 lib/generators/adapter.rb
namelessjon-dm-gen-0.2.5 lib/generators/adapter.rb
namelessjon-dm-gen-0.3.0 lib/generators/adapter.rb
namelessjon-dm-gen-0.3.1 lib/generators/adapter.rb
namelessjon-dm-gen-0.4.0 lib/dm-gen/generators/adapter.rb
dm-gen-0.4.2 lib/dm-gen/generators/adapter.rb
dm-gen-0.4.1 lib/dm-gen/generators/adapter.rb