Giter Site home page Giter Site logo

spectifly-sequel's Introduction

Spectifly Sequel Add-on

An add-on to Spectifly, which uses entity definitions based on YAML, to create Sequel migrations and model files

Caveat

This is very much a work in progress and any migrations generated from the gem should be carefully scrutinized for correctness prior to applying them to your database. Right now, the gem's output is only tested with Postgres and only creates new tables but does not update schema that already exists (though ideally, that would be a future feature).

Installation

Add this line to your application's Gemfile:

gem 'spectifly-sequel'

And then execute:

$ bundle

Once on rubygems, you'll also be able to install it yourself as:

$ gem install spectifly-sequel

Usage

The Spectifly markup language is a subset of YAML. Only one root node is allowed per file (since a single .entity file represents a single business entity), and there are other restrictions, as well as additional features, which we'll discuss here.

Given a Spectifly entity defintion lib/entities/widget.entity:

Widget:
  Description: A widget produced by WidgetCo
  Fields:
    Name*:
      Description: Display name of widget

    Created At:
      Description: When the widget was built
      Type: DateTime

    Awesome?:
      Description: Whether or not the widget is awesome

When rake spectifly:sequel:generate['widget'] is run, the following migration db/migrate/001_create_widgets.rb will be created.

Sequel.migration do
  change do
    create_table(:widgets) do
      primary_key :id
      String :name, :null => false
      DateTime :created_at
      Boolean :awesome
    end
  end
end

Configuration

Spectifly Sequel does not make any assumptions about where you put your entity definitions or migrations. In order for the gem to run correctly, you'll need to specifly the path to a YAML file or set the config directly via a hash.

# to set via YAML file
Spectifly::Sequel.configure_with PATH_TO_CONFIG_YAML

# to set via hash
Spectifly::Sequel.configure {
  'migration_path' => PATH_TO_MIGRATION_DIRECTORY
  'entity_definition_path' => PATH_TO_ENTITY_DEFINITION_DIRECTORY
}

The YAML configuration file should look something like this:

sequel_migration_path: PATH_TO_MIGRATION_DIRECTORY
entity_path: PATH_TO_ENTITY_DEFINITION_DIRECTORY

Contributing

  1. Fork it
  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 new Pull Request

spectifly-sequel's People

Contributors

lkemmerer avatar

Watchers

Ravi Gadad avatar ProjectDX CI User avatar  avatar Dave Miller avatar  avatar Seth MacPherson avatar James Cloos avatar Sarah Horn avatar Ada Fairweather avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.