Skip to content

Commit b9609e5

Browse files
committed
Add a shebang so the script can be started directly and run rubocop -a.
1 parent bdc9bd5 commit b9609e5

11 files changed

+146
-184
lines changed

generateEntityDiagram.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env ruby
2+
13
require_relative 'rubyResources/logger.rb'
24
require_relative 'rubyResources/swiftEntityElement.rb'
35
require_relative 'rubyResources/swiftMethod.rb'

htmltemplate/js/diagram.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function createDiagram() {
113113
};
114114

115115
// tested at http://visjs.org/examples/network/physics/physicsConfiguration.html
116-
const options = {
116+
let options = {
117117
edges: {
118118
smooth: false
119119
},

rubyResources/entity.rb

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class Entity
2-
32
@@id = 1
43

54
attr_accessor :id
@@ -37,29 +36,18 @@ def to_hash
3736
'typeString' => @typeString
3837
}
3938

40-
if !@properties.empty?
41-
hash['properties'] = @properties
42-
end
39+
hash['properties'] = @properties unless @properties.empty?
4340

44-
if !@methods.empty?
45-
hash['methods'] = @methods
46-
end
41+
hash['methods'] = @methods unless @methods.empty?
4742

48-
if !@protocols.empty?
49-
hash['protocols'] = @protocols.map { |protocol|
50-
protocol.id
51-
}
52-
end
43+
hash['protocols'] = @protocols.map(&:id) unless @protocols.empty?
5344

54-
if !@cases.empty?
55-
hash['cases'] = @cases
56-
end
45+
hash['cases'] = @cases unless @cases.empty?
5746

58-
return hash
47+
hash
5948
end
6049

61-
def to_json(*args)
62-
return JSON.pretty_generate(to_hash)
50+
def to_json(*_args)
51+
JSON.pretty_generate(to_hash)
6352
end
64-
6553
end

rubyResources/entityExtension.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
class EntityExtension < Entity
2-
32
attr_accessor :extendedEntityName
43

54
def initialize(inheritedEntities, extendedEntityName, contentsCodeString)
65
super(inheritedEntities, 'extension', contentsCodeString)
76

87
@extendedEntityName = extendedEntityName
98
end
10-
119
end

rubyResources/entityType.rb

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class EntityType < Entity
2-
32
attr_accessor :name
43
attr_accessor :startIndex
54
attr_accessor :contentsStartIndex
@@ -21,28 +20,19 @@ def initialize(typeString, name, inheritedEntities, contentsCodeString, startInd
2120
@extensions = []
2221
end
2322

24-
def to_json(*args)
23+
def to_json(*_args)
2524
hash = to_hash
2625

2726
hash['name'] = @name
2827

29-
if @superClass
30-
hash['superClass'] = @superClass.id
31-
end
28+
hash['superClass'] = @superClass.id if @superClass
3229

33-
if !@containedEntities.empty?
34-
hash['containedEntities'] = @containedEntities.map { |containedEntity|
35-
containedEntity.id
36-
}
30+
unless @containedEntities.empty?
31+
hash['containedEntities'] = @containedEntities.map(&:id)
3732
end
3833

39-
if !@extensions.empty?
40-
hash['extensions'] = @extensions.map { |extension|
41-
extension.id
42-
}
43-
end
34+
hash['extensions'] = @extensions.map(&:id) unless @extensions.empty?
4435

45-
return JSON.pretty_generate(hash)
36+
JSON.pretty_generate(hash)
4637
end
47-
4838
end

0 commit comments

Comments
 (0)