Giter VIP home page Giter VIP logo

yuml's Introduction

The UML DSL

A Ruby DSL for generating UML built on yuml.me, visit the homepage to learn more.

Getting Started

To build a UML document start with this block of code. Everything inside the block will be used to describe the uml document you want to create.

require 'yuml'

YUML.generate(file: 'tmp.pdf') do |uml|
  ...
end

Generating a Class

To generate a class for the document use uml.class and pass a code block in to configure it. It accepts the following methods for configuration.

  • name(name = nil, prototype = nil) (required)
  • variables(*args)
  • methods(*args)

Example

document = uml.class do
  name 'Document'
  variables '-title: String', '-body: String'
  methods(
    '+add_section(id: int, content: String, style: Symbol)',
    '+remove_section(id: int)',
    '+edit_section(id: int, content: String, style: Symbol)'
  )
end
shape = uml.class do
  name 'Shape', 'module'
  methods '+draw(id: int, content: String, style: Symbol)'
end

Adding Relationships

After generating some classes to add relationships to them use the following YUML::Class methods.

  • has_a(node, options = {})
  • is_a(node, options = {})
  • associated_with(node, options = {})
  • attach_note(content, options = {}) *options include color!

has_a can be composition or aggregation but defaults to aggregation.

is_a can be inheritance or interface but defaults to inheritance.

associated_with can be association, directed_association, two_way_association, or dependancy but defaults to directed_association.

Example

document.has_a(picture, cardinality: '0..*')
document.is_a(content)

picture.is_a(content, type: :interface)
content.associated_with(content, type: :association, cardinality: %w(uses used))
document.attach_note('This is a document', 'green')

Adding notes

You can add notes to the document itself as well as attached to a class

YUML.generate(file: 'tmp.pd') do |uml|
  uml.attach_note('Cool UML Tool?')
end

Test it Out

require 'yuml'

YUML.generate(file: 'example.pdf') do |uml|
  document = uml.class do
    name 'Document'
    variables '-title: String', '-body: String'
    methods(
      '+add_section(id: int, content: String, style: Symbol)',
      '+remove_section(id: int)',
      '+edit_section(id: int, content: String, style: Symbol)'
    )
  end

  picture = uml.class do
    name 'Picture'
  end

  content = uml.class do
    name 'Content'
  end

  document.has_a(picture, cardinality: '0..*')
  document.is_a(content)

  picture.is_a(content)
end

output

yuml's People

Contributors

derekstride avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

damian-m-g

yuml's Issues

PDF exported can't get opened

Hello there, thanks for this gem.

I've found that the example shown in the README.md isn't working. The PDF can't get opened, it's get seen as "corrupted" by Chrome or Adobe Acrobat Reader. I've inquired into the code and by changing the extension from "example.pdf" to "example.png" it works. You may want to take a look at it.

Cheers.

API won't load

The gem's API isn't loading and neither the website pointed out in the README.md is working. Currently, the only way to access to the API is by looking directly at the code of the gem.

Allow naming relationships

This looks cool. The one major feature I'm missing is to be able to name relationships

e.g.
[Customer]-primary[Contact]
[Customer]-secondary[Contact]

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.