Below are some examples of using Autocode:

JSON Stringify

Uses json.stringify.Engine to load spec as a JSON string:

imports:
  crystal/json: latest
outputs:
  - filename: albums.json
    engine: json.StringifyEngine
    spec:
      albums:
        - artist: Anniversary, The
          title: Designing a Nervous Breakdown
        - artist: Cursive
          title: Burst and Bloom
        - artist: Thrice
          title: The Illusion of Safety
{
	"albums": [
		{
			"artist": "Anniversary, The",
			"title": "Designing a Nervous Breakdown"
		},
		{
			"artist": "Cursive",
			"title": "Burst and Bloom"
		},
		{
			"artist": "Thrice",
			"title": "The Illusion of Safety"
		}
	]
}

JSON Parse

Uses json.parse.Processor to process a spec as a JSON object:

imports:
  crystal/json: latest
outputs:
  - filename: albums.json
    engine: json.StringifyEngine
    processor: json.ParseProcessor
    spec:
      albums:
        $processor: json
        $value: [{"artist":"Anniversary, The","title":"Designing a Nervous Breakdown"},{"artist":"Cursive","title":"Burst and Bloom"},{"artist":"Thrice","title":"The Illusion of Safety"}]
{
	"albums": [
		{
			"artist": "Anniversary, The",
			"title": "Designing a Nervous Breakdown"
		},
		{
			"artist": "Cursive",
			"title": "Burst and Bloom"
		},
		{
			"artist": "Thrice",
			"title": "The Illusion of Safety"
		}
	]
}

Express.js App

Uses express.app.Generator to generate an Express.js app:

imports:
  crystal/express: latest
outputs:
  - generator: express.AppGenerator
    spec:
      port: 8080
# load modules
express       = require 'express'
path          = require 'path'

# create app
app = express()

# serve app
console.log 'Serving...'
app.listen 8080

Bower Config: .bowerrc

Uses bower.config.Generator to generate a .bowerrc file:

imports:
  crystal/bower: latest
outputs:
  - generator: bower.ConfigGenerator
    spec:
      directory: app/components/
      analytics: false
      timeout: 120000
      registry:
        search:
          - http://localhost:8000
          - https://bower.herokuapp.com
{
	"analytics": false,
	"directory": "app/components/",
	"registry": {
		"search": [
			"http://localhost:8000",
			"https://bower.herokuapp.com"
		]
	},
	"timeout": 120000
}

Bower Package: bower.json

Uses bower.package.Generator to generate a bower.json file:

imports:
  crystal/bower: latest
outputs:
  - generator: bower.PackageGenerator
    spec:
      name: blue-leaf
      version: 1.2.3
      description: Physics-like animations for pretty particles
      main:
        - js/motion.js
        - sass/motion.scss
      dependencies:
        get-size: ~1.2.2
        eventEmitter: ~4.2.11
      devDependencies:
        qunit: ~1.16.0
      moduleType:
        - amd
        - globals
        - node
      keywords:
        - motion
        - physics
        - particles
      authors:
        - Betty Beta <[email protected]>
      license: MIT
      ignore:
        - '**/.*'
        - node_modules
        - bower_components
        - test
        - tests
{
	"authors": [
		"Betty Beta <[email protected]>"
	],
	"dependencies": {
		"get-size": "~1.2.2",
		"eventEmitter": "~4.2.11"
	},
	"description": "Physics-like animations for pretty particles",
	"devDependencies": {
		"qunit": "~1.16.0"
	},
	"ignore": [
		"**/.*",
		"node_modules",
		"bower_components",
		"test",
		"tests"
	],
	"keywords": [
		"motion",
		"physics",
		"particles"
	],
	"license": "MIT",
	"main": [
		"js/motion.js",
		"sass/motion.scss"
	],
	"moduleType": [
		"amd",
		"globals",
		"node"
	],
	"name": "blue-leaf",
	"version": "1.2.3"
}

Composer Package - composer.json

Uses composer.package.Generator to generate a composer.json file:

imports:
  crystal/composer: latest
outputs:
  - generator: composer.PackageGenerator
    spec:
      name: test
      description: test
      require:
        monolog/monolog: 1.0.*
{
	"description": "test",
	"name": "test",
	"require": {
		"monolog/monolog": "1.0.*"
	}
}

Gruntfile

Uses grunt.file.Generator to generate a Gruntfile.js file:

imports:
  crystal/git: latest
  crystal/grunt: latest
  crystal/npm: latest
outputs:
  - generator: git.GitignoreGenerator
    spec:
      items:
        - node_modules/
  - generator: grunt.GruntfileGenerator
    spec:
      loadNpmTasks:
        - grunt-contrib-sass
        - grunt-contrib-watch
      registerTask:
        default:
          - sass
      config:
        pkg: package.json
        sass:
          dist:
            files:
              - expand: true
                cwd: src/sass
                src:
                  - '**/*.scss'
                dest: src/public/css
                ext: .css
            options:
              sourcemap: none
              style: compressed
        watch:
          files: src/sass/**/*.scss
          tasks: sass
  - generator: npm.PackageGenerator
    spec:
      dependencies:
        grunt-contrib-sass: latest
        grunt-contrib-watch: latest
module.exports = function(grunt) {

    grunt.initConfig({
        "pkg": "package.json",
        "sass": {
            "dist": {
                "files": [{
                    "expand": true,
                    "cwd": "src/sass",
                    "src": [
                        "**/*.scss"
                    ],
                    "dest": "src/public/css",
                    "ext": ".css"
                }],
                "options": {
                    "sourcemap": "none",
                    "style": "compressed"
                }
            }
        },
        "watch": {
            "files": "src/sass/**/*.scss",
            "tasks": "sass"
        }
    });

    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['sass']);

};

Laravel Models

Uses laravel.model.Generator to generate models for Laravel:

imports:
  crystal/laravel: latest
outputs:
  - generator: laravel.ModelGenerator
    path: model
    spec:
      models:
        - name: post
          attributes:
            - name: content
              required: true
              type: string
        - name: user
          attributes:
            - name: username
              required: true
              type: string
<?php
class Post extends Eloquent {
}
?>
<?php
class User extends Eloquent {
}
?>

PHP Config

Uses php.config.Generator to generate a php.ini file:

imports:
  crystal/php: latest
outputs:
  - generator: php.ConfigGenerator
    spec:
      register_globals: false
      include_path: /usr/local
register_globals=false
include_path=/usr/local

PIP Package - requirements.txt

Uses pip.requirements.Generator to generate a requirements.txt file:

imports:
  crystal/pip: latest
outputs:
  - generator: pip.RequirementsGenerator
    spec:
      requirements:
        Flask: 0.8
        Jinja2: 2.6
        Werkzeug: 0.8.3
        certifi: 0.0.8
        chardet: 1.0.1
        distribute: 0.6.24
        gunicorn: 0.14.2
        requests: 0.11.1
Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
gunicorn==0.14.2
requests==0.11.1

README.md

Uses readme.md.Generator to generate a README.md file:

imports:
  crystal/readme: latest
outputs:
  - generator: readme.ReadmeGenerator
    spec:
      name: readme
      version: 1.2.3
      description: a readme test
# readme 1.2.3

a readme test

Redis Config - redis.conf

Uses redis.config.Generator to generate a redis.conf file:

imports:
  crystal/redis: latest
outputs:
  - generator: redis.ConfigGenerator
    spec:
      daemonize: true
      port: 6379
      timeout: 0
daemonize yes
port 6379

Sequelize Model

Uses sequels.model.Generator to generate models for Sequelize:

imports:
  crystal/sequelize: latest
outputs:
  - generator: sequelize.ModelGenerator
    path: model
    spec:
      models:
        post:
          attributes:
            content:
              required: true
              type: string
        user:
          attributes:
            username:
              required: true
              unique: true
              type: string
            birthday:
              type: date
var Post = sequelize.define('post', {
  content: {
    type: mysql.STRING
  }
});
var User = sequelize.define('user', {
  username: {
    type: mysql.STRING
    unique: true
  }
  birthday: {
    type: mysql.DATE
  }
});