Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

183 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crygen

license GitHub Release ci commit activity issues prs

crygen is a library that allows to generate a Crystal file. It is inspired by the PHP library : nette/php-generator.

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  crygen:
    github: tamdaz/crygen
    version: ~> 1.3.0
  1. Run shards install

  2. Finally, import crygen from the entrypoint file:

require "crygen"

module App
  VERSION = "1.0.0"

  class_type = CGT::Class.new("MyClass")
  method_type = CGT::Method.new("my_method", "String")

  class_type.add_method(method_type)

  puts class_type.generate
  # or
  puts class_type

  # Output:
  # class MyClass
  #   def my_method : String
  #   end
  # end

  # You can save the generated code into the .cr file.
  File.write("src/classes/my_class.cr", class_type)
end

Contributing

  1. Fork it (https://github.com/tamdaz/crygen/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

About

A library that allows to generate the Crystal code

Topics

Resources

Stars

Watchers

Forks

Releases

Used by

Contributors

Languages