yuml 0.4.3 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3f9891582d589bd54d921e4e9f809917166af7a
4
- data.tar.gz: 5e9ab82dbe3e0a8921f065423a8e638081eaffcb
3
+ metadata.gz: fb41458dc9a3f53d8ae9b6a381568b055141c872
4
+ data.tar.gz: 262dbe5b8793ff75236f522031bfec68ca98b84d
5
5
  SHA512:
6
- metadata.gz: 57ea65c7173f929768e0b0b5fec44fabc08a5bbe6bf4ff59b7762fbb767a0cec5f093f77f9c50cfbd56eb44439be3354ea15fd64c1fcb9314e0c73b47c6e6055
7
- data.tar.gz: f2461b929fe84828c5dff19633f143c15d0b213b98eda120538e7f64ef5851d0cb8e0baea1cc7345dd825952c1bf5ff1c1603437d847eea29d8316090b4e7577
6
+ metadata.gz: 2a228132174120d63b81dea482872fae748a7f6475f13e1a383f3c3704cd479836012862655be2a2f43802b11bb044bcc45000efbdc6ce36f695710ae3b003c2
7
+ data.tar.gz: 5b72d09f11ca6ac00de264f523b776aa0ffb0d1b092dfe6137b826e176d27e71ad02f9acbc1b0ae23a01735358b502719c65f8d6ae12064f327c7b25a29ba00f
@@ -54,11 +54,16 @@ module YUML
54
54
  end
55
55
 
56
56
  def fetch_uml(file)
57
- uri = URI("https://yuml.me/diagram/class/#{yuml}.pdf")
57
+ uri = URI("https://yuml.me/diagram/class/#{yuml}#{extname(file)}")
58
58
  response = Net::HTTP.get_response(uri)
59
59
  File.write(file, response.body)
60
60
  end
61
61
 
62
+ def extname(filename)
63
+ return '.pdf' unless %w(.pdf .png .jpg .jpeg).include?(File.extname(filename))
64
+ File.extname(filename).sub('.jpg', '.jpeg')
65
+ end
66
+
62
67
  def encodings
63
68
  "#{ESCAPE_CHARACTERS.values.join}[](){}+->|.,=;*^ "
64
69
  end
@@ -33,7 +33,8 @@ module YUML
33
33
  @methods << normalize(args)
34
34
  end
35
35
 
36
- def has_a(dest, type: :aggregation, cardinality: nil)
36
+ def has_a(dest, type: :aggregation, cardinality: nil, association_name: cardinality)
37
+ cardinality ||= association_name
37
38
  type = :aggregation unless %i(composition aggregation).include?(type)
38
39
  relationship = YUML::Relationship.send(type, cardinality)
39
40
  @relationships << "[#{name}]#{relationship}[#{dest.name}]"
@@ -45,7 +46,8 @@ module YUML
45
46
  @relationships << "[#{dest.name}]#{relationship}[#{name}]"
46
47
  end
47
48
 
48
- def associated_with(dest, type: :directed_assoication, cardinality: nil)
49
+ def associated_with(dest, type: :directed_assoication, cardinality: nil, association_name: cardinality)
50
+ cardinality ||= association_name
49
51
  type = :directed_assoication unless %i(
50
52
  association directed_assoication two_way_association dependency
51
53
  ).include?(type)
@@ -95,6 +95,11 @@ describe YUML::Class do
95
95
  expect(@doc.relationships).to eq '[Document]+-*>[Picture]'
96
96
  end
97
97
 
98
+ it 'aliases cardinality to association_name' do
99
+ @doc.has_a(@pic, association_name: 'profilePhoto')
100
+ expect(@doc.relationships).to eq '[Document]+-profilePhoto>[Picture]'
101
+ end
102
+
98
103
  it 'should handle composition and cardinality' do
99
104
  @doc.has_a(@pic, type: :composition, cardinality: [0, '*'])
100
105
  expect(@doc.relationships).to eq '[Document]++0-*>[Picture]'
@@ -127,6 +132,11 @@ describe YUML::Class do
127
132
  expect(@doc.relationships).to eq '[Document]uses-used>[Picture]'
128
133
  end
129
134
 
135
+ it 'aliases cardinality to association_name' do
136
+ @doc.has_a(@pic, association_name: 'profilePhoto')
137
+ expect(@doc.relationships).to eq '[Document]+-profilePhoto>[Picture]'
138
+ end
139
+
130
140
  it 'should handle a bi directional associations with cardinality' do
131
141
  @doc.associated_with(@pic, type: :two_way_association, cardinality: ['used by'])
132
142
  expect(@doc.relationships).to eq '[Document]<-used by>[Picture]'
@@ -45,7 +45,7 @@ describe YUML do
45
45
  end
46
46
 
47
47
  before :each do
48
- @stub = stub_request(:any, %r{http://yuml.me/.*}).to_return(body: 'abc', status: 200)
48
+ @stub = stub_request(:any, %r{https://yuml.me/.*}).to_return(body: 'abc', status: 200)
49
49
  end
50
50
 
51
51
  it 'should yield the block' do
@@ -70,6 +70,14 @@ describe YUML do
70
70
  expect(File.exist?(@options[:file])).to be true
71
71
  expect(File.read(@options[:file])).to eq 'abc'
72
72
  end
73
+
74
+ it 'should add a valid filetype if an invalid on is specified' do
75
+ stub = stub_request(:any, %r{https://yuml.me/.*.pdf}).to_return(body: 'abc', status: 200)
76
+ YUML.generate(file: 'invalid.jjj') do |uml|
77
+ uml.class { name 'Document' }
78
+ end
79
+ expect(stub).to have_been_requested
80
+ end
73
81
  end
74
82
 
75
83
  describe '#attach_note' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yuml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Stride