GithubHelp home page GithubHelp logo

ryanscottlewis / ucd Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 88 KB

UML Class Diagram (UCD) is a language for specifying UML class diagrams and a tool for converting it into various different formats.

License: MIT License

Ruby 99.66% Shell 0.34%
uml uml-diagrams uml-graphs graphviz

ucd's Introduction

UCD

UML Class Diagram (UCD) is a language for specifying UML class diagrams and a tool for converting it into various different formats.

Install

Bundler: gem "ucd"

RubyGems: gem install ucd

Executable

# Convert composite.ucd to composite.png
$ ucd --type png --output . composite.ucd

# Display detailed help message
$ ucd --help

Language

Examples

See the examples directory for UCD files and their generated DOT and PNG files.

Component Pattern

component.ucd

abstract class Component {
  method operation
}

class Leaf {
  generalizes Component
}

class Composite {
  protected field children : Component
  method addChild(child : Component) : Component
  method removeChild(child : Component) : Component
  method getChild(index : Integer) : Component

  generalizes Component
  aggregation Component *
}

component.png

Component Pattern

component.dot

digraph G {
  graph [splines="ortho" rankdir="BT"]
  edge [color="gray50"]
  node [shape="plain"]

  ClassComponent [label=<
    <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
      <TR>
        <TD>«abstract»<BR/><I><B>Component</B></I></TD>
      </TR>
      <TR>
        <TD></TD>
      </TR>
      <TR>
        <TD>
          <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
            <TR><TD ALIGN="LEFT">+ operation()</TD></TR>
          </TABLE>
        </TD>
      </TR>
    </TABLE>
  >]

  ClassLeaf [label=<
    <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
      <TR>
        <TD><B>Leaf</B></TD>
      </TR>
      <TR>
        <TD></TD>
      </TR>
      <TR>
        <TD></TD>
      </TR>
    </TABLE>
  >]

  ClassComposite [label=<
    <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
      <TR>
        <TD><B>Composite</B></TD>
      </TR>
      <TR>
        <TD>
          <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
            <TR><TD ALIGN="LEFT"># children : Component</TD></TR>
          </TABLE>
        </TD>
      </TR>
      <TR>
        <TD>
          <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
            <TR><TD ALIGN="LEFT">+ addChild(child : Component) : Component</TD></TR>
            <TR><TD ALIGN="LEFT">+ removeChild(child : Component) : Component</TD></TR>
            <TR><TD ALIGN="LEFT">+ getChild(index : Integer) : Component</TD></TR>
          </TABLE>
        </TD>
      </TR>
    </TABLE>
  >]

  ClassLeaf -> ClassComponent [arrowhead="onormal"]
  ClassComposite -> ClassComponent [arrowhead="onormal"]

  ClassComposite -> ClassComponent [dir="back" arrowtail="odiamond" headlabel="*"]
}

Syntax

Note: Syntax is represented in ABNF and are omitting spaces for clarity

UCD language simply defines one or more class definitions, inside of which the fields, methods, relationships, and class relationships are defined.

NAME       = 1*( ALPHA / DIGIT / "-" / "_" )
TYPE       = NAME
CLASS_BODY = *( ( FIELD / METHOD / RELATIONSHIP / CLASS_RELATIONSHIP ) NEWLINE )
ACCESS     = ( "public" / "protected" / "private")
ARGUMENT   = NAME [ ":" TYPE ]
ARGUMENTS  = ARGUMENT *( "," ARGUMENT )
FROM       = 1*( ALPHA / DIGIT / "-" / "_" / "*" )
TO         = FROM

CLASS              = [ "abstract" / "interface" ] "class" NAME [ "{" CLASS_BODY "}" ]
FIELD              = [ "static" ] [ ACCESS ] field NAME [ ":" TYPE ]
METHOD             = [ "abstract" ] [ "static" ] [ ACCESS ] method NAME [ "(" [ ARGUMENTS ] ")"] [ ":" TYPE ]
RELATIONSHIP       = [ "generalizes" / "realizes" ] NAME
CLASS_RELATIONSHIP = [ "directional" / "bidirectional" ] ( "dependency" / "association" / "aggregation" / "composition" ) NAME [ FROM ] [ TO ]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/RyanScottLewis/ucd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

ucd's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

w00lf

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.