Sha256: 4c0f6927c99450090ddd2b81be955401b028f0fe272579d6db5805d4229fb805
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
# DSLize # ## Summary ## Finally an way to generate code with a custom DSL the ruby way ! ### In brief: ### * Use real ruby classes to define your DSL * Add custom behaviors defining ruby methods * Create custom formatters/generators extending a base class * Module `DSLize::Methods` defines your attributes types, include `DSLize::Methods::Base` to import the standard attributes * Module `DSLize::Definition` defines your classes ## Installation ## gem install dslize then: require "dslize" ## Sample ## #! /usr/bin/env ruby require 'dslize' module DSLize::Methods include DSLize::Methods::Base def self.my_first_custom_method(attr, args = {}) args[:type] = :custom DSLize.current_object[attr] = args end def self.my_second_custom_method DSLize.current_object['baz'] = true end end module DSLize::Definition class City string :name integer :population, :default => 42 end class Country string :name, :default => 'France' has_many City, :as => :cities has_one City, :as => :capital end class World root has_many Country my_first_custom_method :foo, :default => 'bar' my_second_custom_method end class Planet abstract end class GazPlanet < Planet end class WaterPlanet < Planet end end class MyCustomFormatter < DSLize::Formatter::Base def do_stuff # with self.object # and self.superclasses end end DSLize::Formatter::XSD.new.generate!("/tmp/schema.xsd") MyCustomFormatter.new.do_stuff ## About me ## Sylvain UTARD - http://sylvain.utard.info
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dslize-0.0.5 | README.md |
dslize-0.0.4 | README.md |
dslize-0.0.3 | README.md |