kuniri 0.0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +9 -7
  4. data/COPYING +160 -656
  5. data/Gemfile +4 -3
  6. data/README.md +57 -27
  7. data/Rakefile +3 -1
  8. data/bin/kuniri +50 -26
  9. data/data/aggregation_lang.rb +33 -0
  10. data/data/attribute_lang.rb +14 -87
  11. data/data/class_lang.rb +19 -41
  12. data/data/comment_lang.rb +52 -0
  13. data/data/conditional_lang.rb +14 -41
  14. data/data/constructor_lang.rb +4 -12
  15. data/data/end_block_lang.rb +7 -6
  16. data/data/extern_requirement_lang.rb +10 -17
  17. data/data/function_behavior_lang.rb +17 -66
  18. data/data/global_function_lang.rb +26 -0
  19. data/data/lang_syntax.rb +82 -49
  20. data/data/method_lang.rb +26 -0
  21. data/data/module_namespace_lang.rb +8 -13
  22. data/data/repetition_lang.rb +19 -32
  23. data/data/token_lang.rb +2 -44
  24. data/data/variable_behaviour_lang.rb +43 -0
  25. data/data/variable_global_lang.rb +13 -72
  26. data/kuniri.gemspec +4 -4
  27. data/lib/kuniri/core/configuration/language_available.rb +2 -2
  28. data/lib/kuniri/core/kuniri.rb +32 -24
  29. data/lib/kuniri/core/setting.rb +51 -85
  30. data/lib/kuniri/error/parser_error.rb +9 -0
  31. data/lib/kuniri/language/abstract_container/structured_and_oo/aggregation.rb +29 -0
  32. data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +0 -40
  33. data/lib/kuniri/language/abstract_container/structured_and_oo/global_tokens.rb +20 -0
  34. data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +9 -1
  35. data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +0 -35
  36. data/lib/kuniri/language/container_data/structured_and_oo/aggregation_data.rb +23 -0
  37. data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +4 -2
  38. data/lib/kuniri/language/container_data/structured_and_oo/basic_structure.rb +24 -0
  39. data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +13 -19
  40. data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +2 -13
  41. data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +2 -0
  42. data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +11 -6
  43. data/lib/kuniri/language/container_data/structured_and_oo/{file_element.rb → file_element_data.rb} +11 -9
  44. data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +58 -11
  45. data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +3 -3
  46. data/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb +55 -0
  47. data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +5 -4
  48. data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +3 -1
  49. data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +2 -13
  50. data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +2 -0
  51. data/lib/kuniri/language/language.rb +37 -11
  52. data/lib/kuniri/language/metadata.rb +29 -0
  53. data/lib/kuniri/language/ruby/aggregation_ruby.rb +37 -0
  54. data/lib/kuniri/language/ruby/attribute_ruby.rb +23 -38
  55. data/lib/kuniri/language/ruby/class_ruby.rb +2 -10
  56. data/lib/kuniri/language/ruby/conditional_ruby.rb +20 -6
  57. data/lib/kuniri/language/ruby/constructor_ruby.rb +5 -7
  58. data/lib/kuniri/language/ruby/end_block_ruby.rb +1 -1
  59. data/lib/kuniri/language/ruby/function_behavior_ruby.rb +1 -9
  60. data/lib/kuniri/language/ruby/global_function_ruby.rb +32 -0
  61. data/lib/kuniri/language/ruby/method_ruby.rb +33 -0
  62. data/lib/kuniri/language/ruby/repetition_ruby.rb +60 -14
  63. data/lib/kuniri/language/ruby/ruby_syntax.rb +76 -49
  64. data/lib/kuniri/parser/output_factory.rb +29 -0
  65. data/lib/kuniri/parser/output_format.rb +134 -0
  66. data/lib/kuniri/parser/parser.rb +3 -7
  67. data/lib/kuniri/parser/xml_builder_engine.rb +94 -0
  68. data/lib/kuniri/parser/xml_output_format.rb +143 -0
  69. data/lib/kuniri/state_machine/OO_structured_fsm/aggregation_state.rb +45 -0
  70. data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +0 -1
  71. data/lib/kuniri/state_machine/OO_structured_fsm/basic_structure_state.rb +182 -0
  72. data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +12 -3
  73. data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +11 -68
  74. data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +7 -52
  75. data/lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb +86 -0
  76. data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +2 -3
  77. data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +8 -50
  78. data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +6 -1
  79. data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +10 -59
  80. data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +4 -0
  81. data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +0 -1
  82. data/lib/kuniri/version.rb +1 -1
  83. data/other/analyseFile.asta +0 -0
  84. data/spec/core/kuniri_spec.rb +2 -1
  85. data/spec/core/setting_spec.rb +35 -61
  86. data/spec/language/abstract_container/aggregation_spec.rb +13 -0
  87. data/spec/language/abstract_container/extern_requirement_spec.rb +13 -0
  88. data/spec/language/container_data/structured_and_oo/aggregation_data_spec.rb +29 -0
  89. data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +9 -2
  90. data/spec/language/container_data/structured_and_oo/class_data_spec.rb +1 -46
  91. data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +32 -2
  92. data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +31 -7
  93. data/spec/language/container_data/structured_and_oo/{file_element_spec.rb → file_element_data_spec.rb} +21 -5
  94. data/spec/language/container_data/structured_and_oo/function_abstract_spec.rb +213 -0
  95. data/spec/language/container_data/structured_and_oo/function_data_spec.rb +31 -2
  96. data/spec/language/container_data/structured_and_oo/manager_basic_structure_data_spec.rb +150 -0
  97. data/spec/language/container_data/structured_and_oo/method_data_spec.rb +80 -0
  98. data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +7 -1
  99. data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +9 -0
  100. data/spec/language/language_factory_spec.rb +1 -1
  101. data/spec/language/language_spec.rb +46 -9
  102. data/spec/language/ruby/aggregation_ruby_spec.rb +80 -0
  103. data/spec/language/ruby/class_ruby_spec.rb +66 -6
  104. data/spec/language/ruby/constructor_ruby_spec.rb +1 -1
  105. data/spec/language/ruby/end_block_ruby_spec.rb +11 -0
  106. data/spec/language/ruby/extern_requirement_ruby_spec.rb +59 -0
  107. data/spec/language/ruby/function_behavior_ruby_spec.rb +54 -2
  108. data/spec/language/ruby/global_test/.kuniri.yml +4 -0
  109. data/spec/language/ruby/global_test/complete_class_ruby_spec.rb +161 -0
  110. data/spec/language/ruby/global_test/conditional/.kuniri.yml +4 -0
  111. data/spec/language/ruby/global_test/conditional/.kuniri1.yml +4 -0
  112. data/spec/language/ruby/global_test/conditional/.kuniri2.yml +4 -0
  113. data/spec/language/ruby/global_test/conditional/.kuniri3.yml +4 -0
  114. data/spec/language/ruby/global_test/conditional/.kuniri4.yml +4 -0
  115. data/spec/language/ruby/global_test/conditional/.kuniri5.yml +4 -0
  116. data/spec/language/ruby/global_test/conditional/.kuniri6.yml +4 -0
  117. data/spec/language/ruby/global_test/conditional/a_lot_of_conditionals_spec.rb +92 -0
  118. data/spec/language/ruby/global_test/conditional/constructor_very_mix_conditional_spec.rb +105 -0
  119. data/spec/language/ruby/global_test/conditional/function_with_conditional_spec.rb +94 -0
  120. data/spec/language/ruby/global_test/conditional/function_with_nested_conditional_spec.rb +56 -0
  121. data/spec/language/ruby/global_test/conditional/method_very_mix_conditional_spec.rb +109 -0
  122. data/spec/language/ruby/global_test/conditional/very_deep_conditional_structure_spec.rb +61 -0
  123. data/spec/language/ruby/global_test/conditional/very_mix_conditional_spec.rb +105 -0
  124. data/spec/language/ruby/global_test/conditionalAndRepetition/.kuniri.yml +4 -0
  125. data/spec/language/ruby/global_test/conditionalAndRepetition/mix_conditional_repetition_spec.rb +57 -0
  126. data/spec/language/ruby/global_test/repetition/.kuniri.yml +4 -0
  127. data/spec/language/ruby/global_test/repetition/.kuniri2.yml +4 -0
  128. data/spec/language/ruby/global_test/repetition/.kuniri3.yml +4 -0
  129. data/spec/language/ruby/global_test/repetition/.kuniri4.yml +4 -0
  130. data/spec/language/ruby/global_test/repetition/.kuniri5.yml +4 -0
  131. data/spec/language/ruby/global_test/repetition/.kuniri6.yml +4 -0
  132. data/spec/language/ruby/global_test/repetition/.kuniri7.yml +4 -0
  133. data/spec/language/ruby/global_test/repetition/.kuniri8.yml +4 -0
  134. data/spec/language/ruby/global_test/repetition/complete_class_integrity.rb +41 -0
  135. data/spec/language/ruby/global_test/repetition/complete_class_until_loop_spec.rb +42 -0
  136. data/spec/language/ruby/global_test/repetition/complete_class_while_loop_spec.rb +41 -0
  137. data/spec/language/ruby/global_test/repetition/complete_class_with_repetition_spec.rb +42 -0
  138. data/spec/language/ruby/global_test/repetition/constructor_with_mix_repetition_spec.rb +57 -0
  139. data/spec/language/ruby/global_test/repetition/method_with_mix_repetition_spec.rb +59 -0
  140. data/spec/language/ruby/global_test/repetition/very_mix_repetition_spec.rb +61 -0
  141. data/spec/language/ruby/global_test/repetition/very_nested_repetition_spec.rb +65 -0
  142. data/spec/language/ruby/method_ruby_spec.rb +52 -0
  143. data/spec/language/ruby/repetition_ruby_spec.rb +175 -8
  144. data/spec/language/ruby/ruby_syntax_spec.rb +213 -84
  145. data/spec/parser/output_factory_spec.rb +32 -0
  146. data/spec/parser/output_format_spec.rb +83 -0
  147. data/spec/parser/parser_spec.rb +7 -0
  148. data/spec/parser/xmlSchemaValidate/.kuniri1.yml +3 -0
  149. data/spec/parser/xmlSchemaValidate/.kuniri2.yml +3 -0
  150. data/spec/parser/xmlSchemaValidate/.kuniri3.yml +3 -0
  151. data/spec/parser/xmlSchemaValidate/class_data.xsd +99 -0
  152. data/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd +119 -0
  153. data/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd +146 -0
  154. data/spec/parser/xmlSchemaValidate/simpleFunction.xsd +25 -0
  155. data/spec/parser/xmlSchemaValidate/validate_xml_spec.rb +52 -0
  156. data/spec/parser/xml_builder_engine_spec.rb +258 -0
  157. data/spec/parser/xml_output_format_spec.rb +274 -0
  158. data/spec/samples/rubySyntaxParts/aggregation/classAggregation.rb +37 -0
  159. data/spec/samples/rubySyntaxParts/aggregation/constructorAggregation.rb +36 -0
  160. data/spec/samples/rubySyntaxParts/aggregation/methodAggregation.rb +36 -0
  161. data/spec/samples/rubySyntaxParts/aggregation/multipleAggregation.rb +59 -0
  162. data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +7 -0
  163. data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +2 -1
  164. data/spec/samples/rubySyntaxParts/conditionalStatment/aLotOfConditionals.rb +42 -0
  165. data/spec/samples/rubySyntaxParts/conditionalStatment/commonCasesOfConditionals.rb +47 -0
  166. data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +1 -1
  167. data/spec/samples/rubySyntaxParts/conditionalStatment/constructorMixConditional.rb +41 -0
  168. data/spec/samples/rubySyntaxParts/conditionalStatment/methodMixConditional.rb +41 -0
  169. data/spec/samples/rubySyntaxParts/conditionalStatment/mixConditionalWithRepetition.rb +20 -0
  170. data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +61 -0
  171. data/spec/samples/rubySyntaxParts/conditionalStatment/veryDeepConditionalStructure.rb +48 -0
  172. data/spec/samples/rubySyntaxParts/conditionalStatment/veryMixConditional.rb +37 -0
  173. data/spec/samples/rubySyntaxParts/fullCode/fullCodeTwo.rb +56 -0
  174. data/spec/samples/rubySyntaxParts/fullCode/fullCodeWithComments.rb +64 -0
  175. data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +9 -1
  176. data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +2 -0
  177. data/spec/samples/rubySyntaxParts/repetition/beginWithWhileLoopInClass.rb +10 -0
  178. data/spec/samples/rubySyntaxParts/repetition/constructorWithMixRepetition.rb +22 -0
  179. data/spec/samples/rubySyntaxParts/repetition/forLoopInClass.rb +7 -0
  180. data/spec/samples/rubySyntaxParts/repetition/methodWithMixRepetition.rb +19 -0
  181. data/spec/samples/rubySyntaxParts/repetition/mixConditionalRepetition.rb +17 -0
  182. data/spec/samples/rubySyntaxParts/repetition/untilLoopInClass.rb +16 -0
  183. data/spec/samples/rubySyntaxParts/repetition/veryMixRepetition.rb +28 -0
  184. data/spec/samples/rubySyntaxParts/repetition/veryNestedRepetition.rb +17 -0
  185. data/spec/samples/rubySyntaxParts/repetition/whileLoopInClass.rb +12 -0
  186. data/spec/state_machine/OO_structured_fsm/aggregation_state_spec.rb +67 -0
  187. data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +15 -0
  188. data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +64 -0
  189. data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +3 -3
  190. data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +18 -0
  191. data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +27 -0
  192. metadata +195 -28
  193. data/lib/kuniri/core/configuration/monitor_available.rb +0 -13
  194. data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +0 -52
  195. data/lib/kuniri/parser/parser_xml.rb +0 -128
  196. data/spec/language/abstract_container/constructor_spec.rb +0 -13
  197. data/spec/util/html_logger_spec.rb +0 -31
  198. data/spec/util/logger_spec.rb +0 -20
  199. data/spec/util/txt_logger_spec.rb +0 -31
@@ -7,11 +7,11 @@ module Languages
7
7
 
8
8
  public
9
9
 
10
- attr_reader :parameters
11
-
10
+ # Initialize function data based on name.
11
+ # @param pFunctionName name string.
12
12
  def initialize(pFunctionName)
13
13
  super(pFunctionName)
14
- @visibility = "global"
14
+ @type = GLOBAL_FUNCTION_DATA
15
15
  end
16
16
 
17
17
  # class
@@ -0,0 +1,55 @@
1
+ require_relative 'basic_data'
2
+ require_relative 'conditional_data'
3
+ require_relative 'repetition_data'
4
+
5
+ module Languages
6
+
7
+ # ManagerBasicStructureData Class responsible for management conditionals
8
+ # and repetition.
9
+ class ManagerBasicStructureData < Languages::BasicData
10
+
11
+ public
12
+
13
+ attr_accessor :basicStructure
14
+
15
+ def initialize
16
+ @basicStructure = []
17
+ @currentLevel = 0
18
+ end
19
+
20
+ # Add conditional to basicStructure
21
+ # @param pConditional ConditionalData to add inside basicStructure
22
+ def add_conditional(pConditional)
23
+ return nil unless pConditional.is_a?(Languages::ConditionalData)
24
+ pConditional.level = @currentLevel
25
+ @basicStructure.push(pConditional)
26
+ end
27
+
28
+ # Add repetition to basicStructure
29
+ # @param pRepetition RepetitionData to add inside basicStrure
30
+ def add_repetition(pRepetition)
31
+ return nil unless pRepetition.is_a?(Languages::RepetitionData)
32
+ pRepetition.level = @currentLevel
33
+ @basicStructure.push(pRepetition)
34
+ end
35
+
36
+ # Up current level
37
+ def up_level
38
+ @currentLevel -= 1 if @currentLevel > 0
39
+ end
40
+
41
+ # Add nested level, basically, if we have a lot of nested conditional or
42
+ # repetition we add one level for each nest.
43
+ def down_level
44
+ @currentLevel += 1
45
+ end
46
+
47
+ private
48
+
49
+ @currentLevel
50
+
51
+ # End class
52
+ end
53
+
54
+ # End module
55
+ end
@@ -7,10 +7,11 @@ module Languages
7
7
 
8
8
  public
9
9
 
10
- attr_reader :parameters
11
-
12
- def initialize(pMethod_name)
13
- super(pMethod_name)
10
+ # Initialize Method object, based on name.
11
+ # @param pMethodName Method name.
12
+ def initialize(pMethodName)
13
+ super(pMethodName)
14
+ @type = METHOD_DATA
14
15
  end
15
16
 
16
17
  # Class
@@ -8,7 +8,9 @@ module Languages
8
8
  public
9
9
 
10
10
  def initialize(pName)
11
- @name = pName
11
+ return nil if pName.nil? or !pName.is_a? String
12
+
13
+ @name = pName
12
14
  end
13
15
 
14
16
  # Class
@@ -1,20 +1,9 @@
1
- require_relative 'basic_data'
1
+ require_relative 'basic_structure'
2
2
 
3
3
  module Languages
4
4
 
5
5
  # Class responsible for handling repetition data
6
- class RepetitionData < Languages::BasicData
7
-
8
- public
9
-
10
- attr_accessor :type
11
- attr_accessor :expression
12
-
13
- def initialize
14
- @name = "nothing"
15
- @type = "none"
16
- @expression = "empty"
17
- end
6
+ class RepetitionData < Languages::BasicStructure
18
7
 
19
8
  # class
20
9
  end
@@ -11,6 +11,8 @@ module Languages
11
11
  attr_accessor :type
12
12
 
13
13
  def initialize(pName)
14
+ return nil if pName.nil? or !pName.is_a? String
15
+
14
16
  @name = pName
15
17
  @visibility = "global"
16
18
  end
@@ -11,6 +11,7 @@ require_relative '../state_machine/OO_structured_fsm/oo_structured_state'
11
11
  require_relative '../state_machine/OO_structured_fsm/conditional_state'
12
12
  require_relative '../state_machine/OO_structured_fsm/repetition_state'
13
13
  require_relative '../state_machine/OO_structured_fsm/comment_state'
14
+ require_relative '../state_machine/OO_structured_fsm/aggregation_state'
14
15
 
15
16
  # Module that keeps the language syntax.
16
17
  module Languages
@@ -37,6 +38,7 @@ module Languages
37
38
  attr_reader :conditionalState
38
39
  attr_reader :repetitionState
39
40
  attr_reader :commentState
41
+ attr_reader :aggregationState
40
42
 
41
43
  attr_reader :externRequirementHandler
42
44
  attr_reader :variableHandler
@@ -50,6 +52,9 @@ module Languages
50
52
  attr_reader :conditionalHandler
51
53
  attr_reader :repetitionHandler
52
54
  attr_reader :commentHandler
55
+ attr_reader :aggregationHandler
56
+
57
+ attr_reader :metadata
53
58
 
54
59
  attr_accessor :fileElements
55
60
 
@@ -57,6 +62,8 @@ module Languages
57
62
  # conditional information and repetition data.
58
63
  attr_accessor :flagFunctionBehaviour
59
64
 
65
+ attr_reader :countNestedCondLoop
66
+
60
67
  attr_accessor :string_comment_to_transfer
61
68
 
62
69
  # This method initialize all the needed states of state machine.
@@ -78,6 +85,8 @@ module Languages
78
85
  @repetitionState =
79
86
  StateMachine::OOStructuredFSM::RepetitionState.new(self)
80
87
  @commentState = StateMachine::OOStructuredFSM::CommentState.new(self)
88
+ @aggregationState =
89
+ StateMachine::OOStructuredFSM::AggregationState.new(self)
81
90
 
82
91
  @state = @idleState
83
92
  @previousState = []
@@ -85,6 +94,7 @@ module Languages
85
94
 
86
95
  @fileElements = []
87
96
  @flagFunctionBehaviour = nil
97
+ @countNestedCondLoop = 0
88
98
 
89
99
  @string_comment_to_transfer = ""
90
100
  end
@@ -138,16 +148,6 @@ module Languages
138
148
  @state = @previousState.pop
139
149
  end
140
150
 
141
- # TODO: REMOVE IT
142
- def get_name
143
- return @name
144
- end
145
-
146
- # TODO: REMOVE IT
147
- def get_path
148
- return @path
149
- end
150
-
151
151
  # Handling line
152
152
  def handle_line(pLine)
153
153
  @state.handle_line
@@ -204,17 +204,43 @@ module Languages
204
204
  @state.conditional_capture
205
205
  end
206
206
 
207
+ # Aggregation state.
208
+ def aggregation_capture
209
+ @state.aggregation_capture
210
+ end
211
+
207
212
  # keep track of state.
208
213
  def set_state (pState)
209
214
  @previousState.push(@state)
210
215
  @state = pState
211
216
  end
212
217
 
218
+ # Increase nested level
219
+ def moreNested
220
+ @countNestedCondLoop += 1
221
+ end
222
+
223
+ # Reduce nested level
224
+ def lessNested
225
+ @countNestedCondLoop -= 1 if @countNestedCondLoop > 0
226
+ end
227
+
228
+ # Verify if is nested or not
229
+ def isNested?
230
+ return true if @countNestedCondLoop > 0
231
+ return false
232
+ end
233
+
234
+ # Reset nested structure
235
+ def resetNested
236
+ @countNestedCondLoop = 0
237
+ end
238
+
213
239
  protected
214
240
 
215
241
  @languageType
216
242
  @source
217
-
243
+
218
244
  # End class
219
245
  end
220
246
 
@@ -0,0 +1,29 @@
1
+ module Languages
2
+
3
+ # Keep important information for second parser.
4
+ class Metadata
5
+
6
+ public
7
+
8
+ private_class_method :new
9
+ attr_accessor :allClasses # !@attribute All classes to be analysed.
10
+ attr_accessor :allAggregations # !@attribute All aggregation in classes.
11
+
12
+ def initialize
13
+ @allClasses = []
14
+ @allAggregations = []
15
+ end
16
+
17
+ def Metadata.create
18
+ @@metadata = new unless @@metadata
19
+ return @@metadata
20
+ end
21
+
22
+ private
23
+
24
+ @@metadata = nil
25
+
26
+ # Class
27
+ end
28
+ # Module
29
+ end
@@ -0,0 +1,37 @@
1
+ require_relative '../abstract_container/structured_and_oo/aggregation'
2
+ require_relative '../../core/setting'
3
+ require_relative '../container_data/structured_and_oo/aggregation_data'
4
+
5
+ module Languages
6
+
7
+ module Ruby
8
+
9
+ # Ruby Handling Ruby aggregation
10
+ class AggregationRuby < Languages::Aggregation
11
+
12
+ public
13
+
14
+ # @param pLine Verify if line has a ruby aggregation.
15
+ # @return Return string or nil.
16
+ def get_aggregation(pLine)
17
+ result = detect_aggregation(pLine)
18
+ return nil unless result
19
+ return Languages::AggregationData.new(result)
20
+ end
21
+
22
+ protected
23
+
24
+ # Override
25
+ def detect_aggregation(pLine)
26
+ regexExp = /(\w*)\s*\.\s*new[\n|\s|\(]+/
27
+ return nil unless pLine =~ regexExp
28
+ return pLine[regexExp, 1]
29
+ end
30
+
31
+ #Class
32
+ end
33
+
34
+ # Ruby
35
+ end
36
+ #Language
37
+ end
@@ -1,6 +1,5 @@
1
1
  require_relative '../abstract_container/structured_and_oo/attribute'
2
2
  require_relative '../container_data/structured_and_oo/attribute_data'
3
- require_relative '../../util/html_logger'
4
3
  require_relative '../../core/setting'
5
4
 
6
5
  module Languages
@@ -13,19 +12,16 @@ module Languages
13
12
  public
14
13
 
15
14
  def initialize
16
- @log = @settings = Kuniri::Setting.create.log
17
15
  @attributeList = []
18
16
  end
19
17
 
20
- # Get ruby attribute.
18
+ # Get ruby attribute.
21
19
  # @param pLine Verify if line has a ruby attribute.
22
20
  # @return Return AttributeData or nil.
23
21
  def get_attribute(pLine)
24
22
  result = detect_attribute(pLine)
25
23
  return nil unless result
26
24
 
27
- @log.write_log("Info: Prepare to get attribute.")
28
-
29
25
  listOfAttributes = []
30
26
 
31
27
  # Has comma? Split string by comma
@@ -34,13 +30,10 @@ module Languages
34
30
  # Separated by comma, equal or the common case
35
31
  if result.scan(/,/).count >= 1
36
32
  listOfAttributes = handle_multiple_declaration_with_comma(result)
37
- @log.write_log("Debug: Declared with comma: #{listOfAttributes}")
38
33
  elsif result.scan(/=/).count > 1
39
34
  listOfAttributes = handle_multiple_declaration_with_equal(result)
40
- @log.write_log("Debug: separed by comma: #{listOfAttributes}")
41
35
  else
42
36
  listOfAttributes = handle_line_declaration(result)
43
- @log.write_log("Debug: One line declaration #{listOfAttributes}")
44
37
  end
45
38
 
46
39
  return listOfAttributes
@@ -71,59 +64,51 @@ module Languages
71
64
 
72
65
  # Override
73
66
  def handle_multiple_declaration_with_comma(pString)
74
- listOfAttributes = []
75
- pString = pString.split(",")
76
- pString.each do |variable|
77
- return nil if variable.scan(/=/).count > 1
78
-
67
+ return handle_multiple_declaration(pString, ",") do |variable|
79
68
  variable = variable.scan(/.*=/).join("") if variable =~ /.*=/
80
-
81
- return nil if variable =~ /\./
82
-
83
- variable = prepare_final_string(variable)
84
- attribute = Languages::AttributeData.new(variable)
85
- listOfAttributes.push(attribute)
69
+ variable
86
70
  end
87
-
88
- return listOfAttributes
89
71
  end
90
72
 
91
73
  # Override
92
74
  def handle_multiple_declaration_with_equal(pString)
93
- listOfAttributes = []
94
- pString = pString.split("=")
95
- pString.each do |variable|
96
- return nil if variable =~ /\./
75
+ return handle_multiple_declaration(pString, "="){ |variable| variable }
76
+ end
97
77
 
98
- variable = prepare_final_string(variable)
99
- attribute = Languages::AttributeData.new(variable)
100
- listOfAttributes.push(attribute)
101
- end
78
+ private
102
79
 
103
- return listOfAttributes
104
- end
80
+ @attributeList
105
81
 
106
- # Override
107
82
  def handle_line_declaration(pString)
108
- listOfAttributes = []
83
+ return handle_line(pString){ |pString| pString }
84
+ end
85
+
86
+ def handle_line(pString)
109
87
  if pString =~ /=/
110
88
  pString = pString.scan(/.*=/).join("")
111
89
  return nil if pString =~ /\./
112
90
  end
113
91
 
92
+ pString = yield(pString)
93
+
114
94
  return nil if pString =~ /\./
115
95
 
116
96
  pString = prepare_final_string(pString)
117
97
  attribute = Languages::AttributeData.new(pString)
118
- listOfAttributes.push(attribute)
119
98
 
120
- return listOfAttributes
99
+ return [attribute]
121
100
  end
122
101
 
123
- private
102
+ def handle_multiple_declaration(pString, pSplitChar)
103
+ listOfAttributes = []
104
+ pString = pString.split(pSplitChar)
105
+ pString.each do |variable|
106
+ attribute = handle_line(variable) { |pString| yield(pString) }
107
+ listOfAttributes.concat(attribute) if attribute
108
+ end
124
109
 
125
- @log
126
- @attributeList
110
+ return listOfAttributes
111
+ end
127
112
 
128
113
  #Class
129
114
  end
@@ -1,6 +1,5 @@
1
1
  require_relative '../abstract_container/structured_and_oo/class'
2
2
  require_relative '../container_data/structured_and_oo/class_data'
3
- require_relative '../../util/html_logger'
4
3
  require_relative '../../core/setting'
5
4
 
6
5
  module Languages
@@ -13,7 +12,6 @@ module Languages
13
12
  public
14
13
 
15
14
  def initialize
16
- @log = @settings = Kuniri::Setting.create.log
17
15
  end
18
16
 
19
17
  # Get ruby class.
@@ -22,8 +20,6 @@ module Languages
22
20
  result = detect_class(pLine)
23
21
  return nil unless result
24
22
 
25
- @log.write_log("Info: Detect class")
26
-
27
23
  classCaptured = Languages::ClassData.new
28
24
 
29
25
  inheritance = get_inheritance(result)
@@ -32,8 +28,6 @@ module Languages
32
28
  result = prepare_final_string(result)
33
29
  classCaptured.name = result
34
30
 
35
- @log.write_log("Debug: Class: #{classCaptured.name}")
36
-
37
31
  return classCaptured
38
32
  end
39
33
 
@@ -49,7 +43,7 @@ module Languages
49
43
  # Override
50
44
  def get_inheritance(pString)
51
45
  if pString =~ /</
52
- partial = pString.scan(/<(.*)/)
46
+ partial = pString.scan(/<\s*(\w+)/)
53
47
  return remove_unnecessary_information(partial)
54
48
  end
55
49
  return nil
@@ -71,11 +65,9 @@ module Languages
71
65
 
72
66
  private
73
67
 
74
- @log
75
-
76
68
  # class
77
69
  end
78
-
70
+
79
71
  # Ruby
80
72
  end
81
73