yuml 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -11
- data/lib/yuml/class.rb +8 -14
- data/spec/yuml_class_spec.rb +13 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d301a5a94555df94b0aeb705e58c0e18d10b2f29
|
4
|
+
data.tar.gz: 2058b126b7b21ff0e81b627ec18b533f6aa6d171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01756670bbb5f097a1e90fcbb872483ccc09156b923928da5d2850d811873d688c78355d3e86655d8cff1d67d6ee3773bb7c2d26f51ba8904eec0c24a91e959e
|
7
|
+
data.tar.gz: 7ea6a585f33b5edf0c521ea7f017271cdbd5c0f3d70782cf64aa6ab13ec6dc2cdcc29d322ea5c2f7ebba3b2075e3d3cf589bae42cbd1f928446412effe8b161b
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# The UML DSL
|
2
2
|
|
3
|
-
A Ruby DSL for generating UML built on yuml.me
|
3
|
+
A Ruby DSL for generating UML built on yuml.me, visit the [homepage](http://derekstride.io/yuml/) to learn more.
|
4
4
|
|
5
5
|
## Getting Started
|
6
6
|
|
7
|
-
To build a UML document start with this block of code. Everything inside the block will be used to
|
7
|
+
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.
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
YUML.generate(file: 'tmp.pdf') do |uml|
|
@@ -16,13 +16,10 @@ end
|
|
16
16
|
|
17
17
|
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.
|
18
18
|
|
19
|
-
* `name(name = nil)` (required)
|
20
|
-
* `interface(interface = nil, sterotype = 'interface')`*
|
19
|
+
* `name(name = nil, prototype = nil)` (required)
|
21
20
|
* `variables(*args)`
|
22
21
|
* `methods(*args)`
|
23
22
|
|
24
|
-
\*use `interface` in place of `name` when generating an interface
|
25
|
-
|
26
23
|
#### Example
|
27
24
|
|
28
25
|
```ruby
|
@@ -39,7 +36,7 @@ end
|
|
39
36
|
|
40
37
|
```ruby
|
41
38
|
shape = uml.class do
|
42
|
-
|
39
|
+
name 'Shape', 'module'
|
43
40
|
methods '+draw(id: int, content: String, style: Symbol)'
|
44
41
|
end
|
45
42
|
```
|
@@ -66,13 +63,13 @@ document.has_a(picture, cardinality: '0..*')
|
|
66
63
|
document.is_a(content)
|
67
64
|
|
68
65
|
picture.is_a(content, type: :interface)
|
69
|
-
content.associated_with(content, type:
|
70
|
-
document.attach_note('This is a document',
|
66
|
+
content.associated_with(content, type: :association, cardinality: %w(uses used))
|
67
|
+
document.attach_note('This is a document', 'green')
|
71
68
|
```
|
72
69
|
|
73
70
|
### Adding notes
|
74
71
|
|
75
|
-
You can add notes
|
72
|
+
You can add notes to the document itself as well as attached to a class
|
76
73
|
|
77
74
|
```ruby
|
78
75
|
YUML.generate(file: 'tmp.pd') do |uml|
|
data/lib/yuml/class.rb
CHANGED
@@ -9,21 +9,16 @@ module YUML
|
|
9
9
|
@relationships = []
|
10
10
|
end
|
11
11
|
|
12
|
-
def name(name = nil)
|
12
|
+
def name(name = nil, prototype = nil)
|
13
13
|
@name = name if name
|
14
|
-
|
14
|
+
@prototype = prototype if prototype
|
15
|
+
"#{normalized_prototype}#{@name}"
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
@interface = interface if interface
|
19
|
-
@sterotype = sterotype if interface
|
20
|
-
@interface
|
21
|
-
end
|
22
|
-
|
23
|
-
def interface=(*args)
|
18
|
+
def name=(*args)
|
24
19
|
args.flatten!
|
25
|
-
@
|
26
|
-
@
|
20
|
+
@name = args.first
|
21
|
+
@prototype = args.pop if args.size > 1
|
27
22
|
end
|
28
23
|
|
29
24
|
def variables(*args)
|
@@ -79,9 +74,8 @@ module YUML
|
|
79
74
|
end
|
80
75
|
end
|
81
76
|
|
82
|
-
def
|
83
|
-
|
84
|
-
return normalize(["<<#{@sterotype}>>"]).first << ';' if interface
|
77
|
+
def normalized_prototype
|
78
|
+
return normalize(["<<#{@prototype}>>"]).first << ';' if @prototype
|
85
79
|
end
|
86
80
|
|
87
81
|
def attributes(attrs)
|
data/spec/yuml_class_spec.rb
CHANGED
@@ -26,45 +26,32 @@ describe YUML::Class do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#name' do
|
29
|
-
it 'takes a name and updates the class' do
|
30
|
-
@uut.name 'Document'
|
31
|
-
expect(@uut.to_s).to eq '[Document]'
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should work with name= as well' do
|
35
|
-
@uut.name = 'Document'
|
36
|
-
expect(@uut.to_s).to eq '[Document]'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#interface' do
|
41
29
|
before :all do
|
42
30
|
left = "#{YUML::ESCAPE_CHARACTERS['<']}" * 2
|
43
31
|
right = "#{YUML::ESCAPE_CHARACTERS['>']}" * 2
|
44
|
-
@interface_uml = "[#{left}interface#{right};Document]"
|
45
32
|
@module_uml = "[#{left}module#{right};Document]"
|
46
33
|
end
|
47
34
|
|
48
|
-
context '
|
49
|
-
it 'takes
|
50
|
-
@uut.
|
51
|
-
expect(@uut.to_s).to eq
|
35
|
+
context 'without a prototype' do
|
36
|
+
it 'takes a name and updates the class' do
|
37
|
+
@uut.name 'Document'
|
38
|
+
expect(@uut.to_s).to eq '[Document]'
|
52
39
|
end
|
53
40
|
|
54
|
-
it 'should work with
|
55
|
-
@uut.
|
56
|
-
expect(@uut.to_s).to eq
|
41
|
+
it 'should work with name= as well' do
|
42
|
+
@uut.name = 'Document'
|
43
|
+
expect(@uut.to_s).to eq '[Document]'
|
57
44
|
end
|
58
45
|
end
|
59
46
|
|
60
|
-
context 'with
|
61
|
-
it 'takes
|
62
|
-
@uut.
|
47
|
+
context 'with a prototype' do
|
48
|
+
it 'takes a name and updates the class' do
|
49
|
+
@uut.name 'Document', 'module'
|
63
50
|
expect(@uut.to_s).to eq @module_uml
|
64
51
|
end
|
65
52
|
|
66
|
-
it 'should work with
|
67
|
-
@uut.
|
53
|
+
it 'should work with name= as well' do
|
54
|
+
@uut.name = 'Document', 'module'
|
68
55
|
expect(@uut.to_s).to eq @module_uml
|
69
56
|
end
|
70
57
|
end
|
@@ -121,7 +108,7 @@ describe YUML::Class do
|
|
121
108
|
end
|
122
109
|
|
123
110
|
it 'should handle interfaces' do
|
124
|
-
@pic.
|
111
|
+
@pic.name 'Picture', 'interface'
|
125
112
|
@doc.is_a(@pic, type: :interface)
|
126
113
|
left = "#{YUML::ESCAPE_CHARACTERS['<']}" * 2
|
127
114
|
right = "#{YUML::ESCAPE_CHARACTERS['>']}" * 2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Stride
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|