Module: YUML

Defined in:
lib/yuml.rb,
lib/yuml/diagram.rb,
lib/yuml/version.rb,
lib/yuml/class_diagram.rb,
lib/yuml/class_entities.rb,
lib/yuml/activity_diagram.rb,
lib/yuml/use_case_diagram.rb,
lib/yuml/activity_entities.rb,
lib/yuml/use_case_entities.rb

Defined Under Namespace

Classes: Activity, ActivityDiagram, ActivityEntity, Actor, ClassDiagram, Decision, Diagram, KNote, Klass, KlassEntity, Note, Parallel, UseCase, UseCaseDiagram, UseCaseEntity

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.activityDiagram(*options, &block) ⇒ Object

Create a new Activity Diagram


5
6
7
# File 'lib/yuml/activity_diagram.rb', line 5

def self.activityDiagram( *options, &block )
  ActivityDiagram.new( *options, &block )
end

.classDiagram(*options, &block) ⇒ Object

Create a new Class Diagram


5
6
7
# File 'lib/yuml/class_diagram.rb', line 5

def self.classDiagram( *options, &block )
  ClassDiagram.new( *options, &block )
end

.options_string(options) ⇒ Object

:nodoc:


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yuml.rb', line 8

def self.options_string( options ) #:nodoc:
  str = ""
  sep = ""
  options.each do |k, v|
    if v.class == TrueClass
      str << sep << k.to_s
    else
      str << sep << k.to_s << ":" << v.to_s
    end
    sep = ";"
  end
  str << "/" if str.size > 0
end

.output(options, data, type, file) ⇒ Object

:nodoc:


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/yuml.rb', line 22

def self.output( options, data, type, file ) #:nodoc:
  opts = options.clone
  diagram = opts.delete(:diagram)
  uri = "/diagram/#{self.options_string(opts)}#{diagram}/#{data}#{type}"
  # puts "*** #{uri}"
  
  writer = STDOUT
  writer = open(file, "wb") unless file.nil?
  res = Net::HTTP.start("yuml.me", 80) {|http|
    http.get(URI.escape(uri))
  }
  writer.write(res.body)
  writer.close
end

.to_jpg(options, data, file) ⇒ Object

:nodoc:


45
46
47
# File 'lib/yuml.rb', line 45

def self.to_jpg( options, data, file ) #:nodoc:
  self.output( options, data, ".jpg", file)
end

.to_pdf(options, data, file) ⇒ Object

:nodoc:


41
42
43
# File 'lib/yuml.rb', line 41

def self.to_pdf( options, data, file ) #:nodoc:
  self.output( options, data, ".pdf", file)
end

.to_png(options, data, file) ⇒ Object

:nodoc:


37
38
39
# File 'lib/yuml.rb', line 37

def self.to_png( options, data, file ) #:nodoc:
  self.output( options, data, "", file)
end

.to_url(options, data, type) ⇒ Object

:nodoc:


49
50
51
52
53
54
55
56
57
58
# File 'lib/yuml.rb', line 49

def self.to_url( options, data, type ) #:nodoc:
  opts = options.clone
  diagram = opts.delete(:diagram)
  if type.nil?
    type = ""
  else
    type = ".#{type}" if type[0].chr != "."
  end
  "http://yuml.me/diagram/#{self.options_string(opts)}#{diagram}/#{data}#{type}"
end

.trim(text) ⇒ Object

TODO: replace with UTF-8 similar chars


67
68
69
# File 'lib/yuml.rb', line 67

def self.trim(text) #:nodoc:
  text.gsub(/[,\[\]^]/, '').strip unless text.nil?
end

.trim!(*args) ⇒ Object

Remove/substitute special characters


62
63
64
# File 'lib/yuml.rb', line 62

def self.trim!(*args) #:nodoc:
  args.each { |text| text.replace trim(text) }
end

.useCaseDiagram(*options, &block) ⇒ Object

Create a new Use Case Diagram


5
6
7
# File 'lib/yuml/use_case_diagram.rb', line 5

def self.useCaseDiagram( *options, &block )
  UseCaseDiagram.new( *options, &block )
end