xumlidot 0.1.0

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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/bin/xumlidot +39 -0
  3. data/lib/xumlidot.rb +10 -0
  4. data/lib/xumlidot/diagram.rb +18 -0
  5. data/lib/xumlidot/diagram/dot.rb +55 -0
  6. data/lib/xumlidot/diagram/dot/klass.rb +75 -0
  7. data/lib/xumlidot/diagram/dot/module.rb +11 -0
  8. data/lib/xumlidot/diagram/shared/naming.rb +19 -0
  9. data/lib/xumlidot/diagram/xmi.rb +190 -0
  10. data/lib/xumlidot/diagram/xmi/argument.rb +34 -0
  11. data/lib/xumlidot/diagram/xmi/attribute.rb +24 -0
  12. data/lib/xumlidot/diagram/xmi/constant.rb +16 -0
  13. data/lib/xumlidot/diagram/xmi/id.rb +39 -0
  14. data/lib/xumlidot/diagram/xmi/klass.rb +133 -0
  15. data/lib/xumlidot/diagram/xmi/method.rb +38 -0
  16. data/lib/xumlidot/diagram/xmi/superklass.rb +18 -0
  17. data/lib/xumlidot/directory_tree.rb +24 -0
  18. data/lib/xumlidot/options.rb +104 -0
  19. data/lib/xumlidot/parsers.rb +14 -0
  20. data/lib/xumlidot/parsers/args.rb +159 -0
  21. data/lib/xumlidot/parsers/call.rb +92 -0
  22. data/lib/xumlidot/parsers/file.rb +15 -0
  23. data/lib/xumlidot/parsers/generic.rb +106 -0
  24. data/lib/xumlidot/parsers/klass_definition.rb +76 -0
  25. data/lib/xumlidot/parsers/method_signature.rb +95 -0
  26. data/lib/xumlidot/parsers/module_definition.rb +55 -0
  27. data/lib/xumlidot/parsers/scope.rb +54 -0
  28. data/lib/xumlidot/parsers/stack.rb +96 -0
  29. data/lib/xumlidot/types.rb +18 -0
  30. data/lib/xumlidot/types/argument.rb +61 -0
  31. data/lib/xumlidot/types/arguments.rb +14 -0
  32. data/lib/xumlidot/types/attribute.rb +34 -0
  33. data/lib/xumlidot/types/attributes.rb +11 -0
  34. data/lib/xumlidot/types/constant.rb +49 -0
  35. data/lib/xumlidot/types/constants.rb +57 -0
  36. data/lib/xumlidot/types/inherited_module.rb +24 -0
  37. data/lib/xumlidot/types/instance_methods.rb +10 -0
  38. data/lib/xumlidot/types/klass.rb +60 -0
  39. data/lib/xumlidot/types/klass_definition.rb +61 -0
  40. data/lib/xumlidot/types/klass_methods.rb +10 -0
  41. data/lib/xumlidot/types/method.rb +10 -0
  42. data/lib/xumlidot/types/method_signature.rb +64 -0
  43. data/lib/xumlidot/types/methods.rb +10 -0
  44. data/lib/xumlidot/types/module.rb +11 -0
  45. data/lib/xumlidot/types/module_definition.rb +14 -0
  46. data/lib/xumlidot/types/superklass.rb +32 -0
  47. data/spec/spec_helper.rb +2 -0
  48. metadata +175 -0
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ # representation for class information
8
+ class KlassDefinition
9
+ # TODO: I think the name could be a constant rather than an array of
10
+ # constants
11
+ class Name < Array
12
+ def name
13
+ map(&:name).flatten
14
+ end
15
+
16
+ def namespace
17
+ map(&:namespace).flatten
18
+ end
19
+
20
+ def ==(other)
21
+ namespace == other.namespace &&
22
+ name == other.name
23
+ end
24
+ end
25
+
26
+ attr_accessor :name,
27
+ :superklass,
28
+ :inherited_modules
29
+
30
+ def initialize
31
+ @name = Name.new
32
+ @superklass = Superklass.new(nil)
33
+ @inherited_modules = []
34
+ end
35
+
36
+ def to_s
37
+ "KLASS: #{@name.first} < #{@superklass} "
38
+ end
39
+
40
+ # No need to compare namespaces here since that is done in the
41
+ # name
42
+ def ==(other)
43
+ @name == other.name
44
+ end
45
+
46
+ # Returns true or false depending on whether or not, given the
47
+ # definition for the class, it can be considered the root namespace of
48
+ # the other class.
49
+ #
50
+ # This allows us to work out is this is a klass under which the other
51
+ # class should be nested in a class or module namespace heirarchy.
52
+ def root_namespace_for?(other)
53
+ [@name.name, @name.namespace].flatten == other.definition.name.namespace
54
+ end
55
+
56
+ def superklass_of?(other)
57
+ [@name.name, @name.namespace].flatten == [other.name, other.namespace].flatten
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ class KlassMethods < Methods
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ class Method
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ # Container class
8
+ class MethodSignatures < Array
9
+ def to_s
10
+ each.map(&:to_s).join(', ')
11
+ end
12
+ end
13
+
14
+ # Value object for a method
15
+ #
16
+ # we store all the method details here including many
17
+ # which we are not yet using.
18
+ class MethodSignature
19
+ attr_accessor :name, # symbol
20
+ :args, # Arguments
21
+ :file, # string
22
+ :line_number, # int - these are areally a range
23
+ :line_max,
24
+ :visibility, # symbol - :public, :private, or :protected
25
+ :superclass_method # true or false
26
+
27
+ def initialize
28
+ @superclass_method = false
29
+ end
30
+
31
+ def to_s
32
+ "#{klass} #{visibility_symbol} #{clean_name}(#{@args})"
33
+ end
34
+
35
+ private
36
+
37
+ def clean_name
38
+ tmp = @name.is_a?(Regexp) ? @name.inspect : @name.to_s
39
+
40
+ case tmp
41
+ when '<<'
42
+ '&lt;&lt;'
43
+ else
44
+ tmp
45
+ end
46
+ end
47
+
48
+ def visibility_symbol
49
+ case @visibility
50
+ when :public
51
+ '+'
52
+ when :private
53
+ '-'
54
+ when :protected
55
+ '#'
56
+ end
57
+ end
58
+
59
+ def klass
60
+ @superclass_method ? 'S' : 'I'
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ class Methods < Array
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ # representation for module information
8
+ class Module < Klass
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ # Contains information as to how the module was defined.
8
+ class ModuleDefinition < KlassDefinition
9
+ def to_s
10
+ "MODULE: #{@name.first}"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../types'
4
+
5
+ module Xumlidot
6
+ module Types
7
+ class Superklass < ::Xumlidot::Types::Constant
8
+ def initialize(name, namespace = nil)
9
+ super
10
+ @has_root = false
11
+ end
12
+
13
+ def <<(constant)
14
+ if constant == '::'
15
+ @has_root = true
16
+ return
17
+ end
18
+
19
+ @namespace << constant unless @name.nil?
20
+ @name ||= constant
21
+ end
22
+
23
+ # Create a klass from the superclass for adding
24
+ # to the list of constants.
25
+ def to_klass
26
+ definition = KlassDefinition.new
27
+ definition.name << ::Xumlidot::Types::Constant.new(@name, @namespace)
28
+ Klass.new(definition)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,2 @@
1
+ require_relative '../lib/xumlidot/types'
2
+ require_relative '../lib/xumlidot/parsers'
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xumlidot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adrian Lee Jackson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sexp_processor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: zeus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Generates XMI and DOT files for Ruby and Rails Class Diagrams
98
+ email:
99
+ - xumlidot@librely.com
100
+ executables:
101
+ - xumlidot
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - bin/xumlidot
106
+ - lib/xumlidot.rb
107
+ - lib/xumlidot/diagram.rb
108
+ - lib/xumlidot/diagram/dot.rb
109
+ - lib/xumlidot/diagram/dot/klass.rb
110
+ - lib/xumlidot/diagram/dot/module.rb
111
+ - lib/xumlidot/diagram/shared/naming.rb
112
+ - lib/xumlidot/diagram/xmi.rb
113
+ - lib/xumlidot/diagram/xmi/argument.rb
114
+ - lib/xumlidot/diagram/xmi/attribute.rb
115
+ - lib/xumlidot/diagram/xmi/constant.rb
116
+ - lib/xumlidot/diagram/xmi/id.rb
117
+ - lib/xumlidot/diagram/xmi/klass.rb
118
+ - lib/xumlidot/diagram/xmi/method.rb
119
+ - lib/xumlidot/diagram/xmi/superklass.rb
120
+ - lib/xumlidot/directory_tree.rb
121
+ - lib/xumlidot/options.rb
122
+ - lib/xumlidot/parsers.rb
123
+ - lib/xumlidot/parsers/args.rb
124
+ - lib/xumlidot/parsers/call.rb
125
+ - lib/xumlidot/parsers/file.rb
126
+ - lib/xumlidot/parsers/generic.rb
127
+ - lib/xumlidot/parsers/klass_definition.rb
128
+ - lib/xumlidot/parsers/method_signature.rb
129
+ - lib/xumlidot/parsers/module_definition.rb
130
+ - lib/xumlidot/parsers/scope.rb
131
+ - lib/xumlidot/parsers/stack.rb
132
+ - lib/xumlidot/types.rb
133
+ - lib/xumlidot/types/argument.rb
134
+ - lib/xumlidot/types/arguments.rb
135
+ - lib/xumlidot/types/attribute.rb
136
+ - lib/xumlidot/types/attributes.rb
137
+ - lib/xumlidot/types/constant.rb
138
+ - lib/xumlidot/types/constants.rb
139
+ - lib/xumlidot/types/inherited_module.rb
140
+ - lib/xumlidot/types/instance_methods.rb
141
+ - lib/xumlidot/types/klass.rb
142
+ - lib/xumlidot/types/klass_definition.rb
143
+ - lib/xumlidot/types/klass_methods.rb
144
+ - lib/xumlidot/types/method.rb
145
+ - lib/xumlidot/types/method_signature.rb
146
+ - lib/xumlidot/types/methods.rb
147
+ - lib/xumlidot/types/module.rb
148
+ - lib/xumlidot/types/module_definition.rb
149
+ - lib/xumlidot/types/superklass.rb
150
+ - spec/spec_helper.rb
151
+ homepage: http://github.com/os6sense/xumlidot
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.0.3
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Generates DOT and XMI for Ruby and Rails UML Class Diagrams.
174
+ test_files:
175
+ - spec/spec_helper.rb