Package not found. Please check the package name and try again.
kuniri 0.0.1
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 +7 -0
- data/.gitignore +43 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/.yardopts +1 -0
- data/COPYING +661 -0
- data/Gemfile +14 -0
- data/Guardfile +8 -0
- data/README.md +102 -0
- data/Rakefile +114 -0
- data/bin/kuniri +53 -0
- data/data/attribute_lang.rb +131 -0
- data/data/class_lang.rb +77 -0
- data/data/conditional_lang.rb +71 -0
- data/data/constructor_lang.rb +34 -0
- data/data/end_block_lang.rb +30 -0
- data/data/extern_requirement_lang.rb +45 -0
- data/data/function_behavior_lang.rb +113 -0
- data/data/lang_syntax.rb +111 -0
- data/data/module_namespace_lang.rb +43 -0
- data/data/repetition_lang.rb +62 -0
- data/data/token_lang.rb +55 -0
- data/data/variable_global_lang.rb +118 -0
- data/kuniri.gemspec +24 -0
- data/lib/kuniri/core/configuration/language_available.rb +7 -0
- data/lib/kuniri/core/configuration/log_available.rb +7 -0
- data/lib/kuniri/core/configuration/monitor_available.rb +13 -0
- data/lib/kuniri/core/kuniri.rb +78 -0
- data/lib/kuniri/core/setting.rb +143 -0
- data/lib/kuniri/error/configuration_file_error.rb +12 -0
- data/lib/kuniri/error/language_error.rb +12 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +73 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/class.rb +51 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/comment.rb +57 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/conditional.rb +42 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +52 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/end_block.rb +27 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/extern_requirement.rb +36 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/function_behavior.rb +55 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/module_namespace.rb +36 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +42 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_behaviour.rb +53 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +67 -0
- data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +26 -0
- data/lib/kuniri/language/container_data/structured_and_oo/basic_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +77 -0
- data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +26 -0
- data/lib/kuniri/language/container_data/structured_and_oo/file_element.rb +77 -0
- data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +52 -0
- data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +21 -0
- data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +20 -0
- data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +22 -0
- data/lib/kuniri/language/language.rb +222 -0
- data/lib/kuniri/language/language_factory.rb +48 -0
- data/lib/kuniri/language/ruby/attribute_ruby.rb +134 -0
- data/lib/kuniri/language/ruby/class_ruby.rb +83 -0
- data/lib/kuniri/language/ruby/comment_ruby.rb +84 -0
- data/lib/kuniri/language/ruby/conditional_ruby.rb +77 -0
- data/lib/kuniri/language/ruby/constructor_ruby.rb +36 -0
- data/lib/kuniri/language/ruby/end_block_ruby.rb +33 -0
- data/lib/kuniri/language/ruby/extern_requirement_ruby.rb +49 -0
- data/lib/kuniri/language/ruby/function_behavior_ruby.rb +120 -0
- data/lib/kuniri/language/ruby/module_namespace_ruby.rb +47 -0
- data/lib/kuniri/language/ruby/repetition_ruby.rb +68 -0
- data/lib/kuniri/language/ruby/ruby_syntax.rb +117 -0
- data/lib/kuniri/language/ruby/token_ruby.rb +59 -0
- data/lib/kuniri/language/ruby/variable_behaviour_ruby.rb +83 -0
- data/lib/kuniri/language/ruby/variable_global_ruby.rb +123 -0
- data/lib/kuniri/parser/parser.rb +45 -0
- data/lib/kuniri/parser/parser_xml.rb +128 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +51 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +94 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/comment_state.rb +76 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +92 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +71 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/function_state.rb +82 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/idle_state.rb +80 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +59 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +69 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/module_state.rb +79 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +92 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +85 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +8 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +49 -0
- data/lib/kuniri/util/html_logger.rb +41 -0
- data/lib/kuniri/util/logger.rb +34 -0
- data/lib/kuniri/util/txt_logger.rb +29 -0
- data/lib/kuniri/version.rb +3 -0
- data/lib/kuniri.rb +5 -0
- data/other/analyseFile.asta +0 -0
- data/spec/core/kuniri_spec.rb +14 -0
- data/spec/core/setting_spec.rb +114 -0
- data/spec/language/abstract_container/attribute_spec.rb +13 -0
- data/spec/language/abstract_container/class_spec.rb +13 -0
- data/spec/language/abstract_container/comment_spec.rb +31 -0
- data/spec/language/abstract_container/conditional_spec.rb +13 -0
- data/spec/language/abstract_container/constructor_spec.rb +13 -0
- data/spec/language/abstract_container/end_block_spec.rb +14 -0
- data/spec/language/abstract_container/module_namespace_spec.rb +13 -0
- data/spec/language/abstract_container/repetition_spec.rb +13 -0
- data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +32 -0
- data/spec/language/container_data/structured_and_oo/class_data_spec.rb +121 -0
- data/spec/language/container_data/structured_and_oo/conditional_data_spec.rb +34 -0
- data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +46 -0
- data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +26 -0
- data/spec/language/container_data/structured_and_oo/file_element_spec.rb +91 -0
- data/spec/language/container_data/structured_and_oo/function_data_spec.rb +22 -0
- data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +20 -0
- data/spec/language/container_data/structured_and_oo/repetition_data_spec.rb +34 -0
- data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +39 -0
- data/spec/language/language_factory_spec.rb +64 -0
- data/spec/language/language_spec.rb +74 -0
- data/spec/language/ruby/attribute_ruby_spec.rb +126 -0
- data/spec/language/ruby/class_ruby_spec.rb +102 -0
- data/spec/language/ruby/comment_ruby_spec.rb +78 -0
- data/spec/language/ruby/conditional_ruby_spec.rb +106 -0
- data/spec/language/ruby/constructor_ruby_spec.rb +57 -0
- data/spec/language/ruby/end_block_ruby_spec.rb +62 -0
- data/spec/language/ruby/function_behavior_ruby_spec.rb +246 -0
- data/spec/language/ruby/module_namespace_ruby_spec.rb +55 -0
- data/spec/language/ruby/repetition_ruby_spec.rb +33 -0
- data/spec/language/ruby/ruby_syntax_spec.rb +482 -0
- data/spec/language/ruby/variable_ruby_spec.rb +134 -0
- data/spec/parser/parser_spec.rb +25 -0
- data/spec/samples/rubySyntaxParts/attribute/simpleAttribute.rb +15 -0
- data/spec/samples/rubySyntaxParts/class/simpleClass.rb +19 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +33 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_global.rb +20 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +23 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_global.rb +16 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +28 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/methodConditional.rb +42 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +0 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/simpleConditional.rb +43 -0
- data/spec/samples/rubySyntaxParts/constructor/simpleConstructor.rb +27 -0
- data/spec/samples/rubySyntaxParts/extern/multipleLineExternRequirement.rb +0 -0
- data/spec/samples/rubySyntaxParts/extern/requireRelative.rb +6 -0
- data/spec/samples/rubySyntaxParts/extern/simpleExternRequirement.rb +14 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleCodeWithConditional.rb +18 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +19 -0
- data/spec/samples/rubySyntaxParts/function/simpleFunction.rb +29 -0
- data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +13 -0
- data/spec/samples/rubySyntaxParts/module/simpleModule.rb +12 -0
- data/spec/samples/rubySyntaxParts/repetition/simpleRepetition.rb +28 -0
- data/spec/samples/rubySyntaxParts/variable/simpleVariable.rb +13 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/state_machine/OO_structured_fsm/attribute_state_spec.rb +44 -0
- data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +90 -0
- data/spec/state_machine/OO_structured_fsm/comment_state_spec.rb +30 -0
- data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +83 -0
- data/spec/state_machine/OO_structured_fsm/constructor_state_spec.rb +48 -0
- data/spec/state_machine/OO_structured_fsm/function_state_spec.rb +41 -0
- data/spec/state_machine/OO_structured_fsm/idle_state_spec.rb +101 -0
- data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +62 -0
- data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +42 -0
- data/spec/state_machine/OO_structured_fsm/module_state_spec.rb +54 -0
- data/spec/state_machine/OO_structured_fsm/oo_structured_state_spec.rb +0 -0
- data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +83 -0
- data/spec/state_machine/OO_structured_fsm/variable_state_spec.rb +40 -0
- data/spec/util/html_logger_spec.rb +31 -0
- data/spec/util/logger_spec.rb +20 -0
- data/spec/util/txt_logger_spec.rb +31 -0
- metadata +326 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require_relative 'oo_structured_state'
|
|
2
|
+
|
|
3
|
+
module StateMachine
|
|
4
|
+
|
|
5
|
+
module OOStructuredFSM
|
|
6
|
+
|
|
7
|
+
# Class responsible for handling Idle state.
|
|
8
|
+
class IdleState < OOStructuredState
|
|
9
|
+
|
|
10
|
+
@language
|
|
11
|
+
|
|
12
|
+
def initialize(pLanguage)
|
|
13
|
+
@language = pLanguage
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @see OOStructuredState
|
|
17
|
+
def handle_line(pLine)
|
|
18
|
+
if @language.externRequirementHandler.get_requirement(pLine)
|
|
19
|
+
include_capture
|
|
20
|
+
elsif @language.variableHandler.get_variable(pLine)
|
|
21
|
+
variable_capture
|
|
22
|
+
elsif @language.functionHandler.get_function(pLine)
|
|
23
|
+
function_capture
|
|
24
|
+
elsif @language.moduleHandler.get_module(pLine)
|
|
25
|
+
module_capture
|
|
26
|
+
elsif @language.classHandler.get_class(pLine)
|
|
27
|
+
class_capture
|
|
28
|
+
elsif ((@language.commentHandler.is_single_line_comment?(pLine)) ||
|
|
29
|
+
(@language.commentHandler.is_multiple_line_comment?(pLine)))
|
|
30
|
+
comment_capture
|
|
31
|
+
else
|
|
32
|
+
return
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @see OOStructuredState
|
|
37
|
+
def include_capture
|
|
38
|
+
@language.set_state(@language.includeState)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @see OOStructuredState
|
|
42
|
+
def variable_capture
|
|
43
|
+
@language.set_state(@language.variableState)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @see OOStructuredState
|
|
47
|
+
def function_capture
|
|
48
|
+
@language.set_state(@language.functionState)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @see OOStructuredState
|
|
52
|
+
def module_capture
|
|
53
|
+
@language.set_state(@language.moduleState)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @see OOStructuredState
|
|
57
|
+
def class_capture
|
|
58
|
+
@language.set_state(@language.classState)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @see OOStructuredState
|
|
62
|
+
def comment_capture
|
|
63
|
+
@language.set_state(@language.commentState)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @see OOStructuredState
|
|
67
|
+
def execute(pElementFile, pLine)
|
|
68
|
+
|
|
69
|
+
# Having nothing to do
|
|
70
|
+
return pElementFile
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# End class
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# End OOStructuredFSM
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# End StateMachine
|
|
80
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require_relative 'oo_structured_state'
|
|
2
|
+
|
|
3
|
+
module StateMachine
|
|
4
|
+
|
|
5
|
+
module OOStructuredFSM
|
|
6
|
+
|
|
7
|
+
# Class responsible for handling Include state.
|
|
8
|
+
class IncludeState < OOStructuredState
|
|
9
|
+
|
|
10
|
+
@language
|
|
11
|
+
|
|
12
|
+
def initialize(pLanguage)
|
|
13
|
+
@language = pLanguage
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @see OOStructuredState
|
|
17
|
+
def handle_line(pLine)
|
|
18
|
+
idle_capture
|
|
19
|
+
# TODO: HANDLING MULTIPLE LINE COMMENT.
|
|
20
|
+
#if @language.idleHandler.get_idle(pLine)
|
|
21
|
+
# idle_capture
|
|
22
|
+
#else
|
|
23
|
+
# TODO: SAME STATE.
|
|
24
|
+
#end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @see OOStructuredState
|
|
28
|
+
def idle_capture
|
|
29
|
+
@language.set_state(@language.idleState)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @see OOStructuredState
|
|
33
|
+
def execute(pElementFile, pLine)
|
|
34
|
+
|
|
35
|
+
requirement = @language.externRequirementHandler.get_requirement(pLine)
|
|
36
|
+
|
|
37
|
+
if requirement
|
|
38
|
+
pElementFile.add_extern_requirement(requirement)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# TODO: You have to handler the return state.
|
|
42
|
+
idle_capture
|
|
43
|
+
|
|
44
|
+
if (@language.state.is_a? StateMachine::OOStructuredFSM::IdleState)
|
|
45
|
+
pElementFile.comments = @language.string_comment_to_transfer
|
|
46
|
+
@language.string_comment_to_transfer = ""
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return pElementFile
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# End class
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# End OOStructuredFSM
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# End StateMachine
|
|
59
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require_relative 'oo_structured_state'
|
|
2
|
+
|
|
3
|
+
module StateMachine
|
|
4
|
+
|
|
5
|
+
module OOStructuredFSM
|
|
6
|
+
|
|
7
|
+
# Class responsible for handling Method state.
|
|
8
|
+
class MethodState < OOStructuredState
|
|
9
|
+
|
|
10
|
+
@language
|
|
11
|
+
|
|
12
|
+
def initialize(pLanguage)
|
|
13
|
+
@language = pLanguage
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @see OOStructuredState
|
|
17
|
+
def handle_line(pLine)
|
|
18
|
+
if @language.conditionalHandler.get_conditional(pLine)
|
|
19
|
+
conditional_capture
|
|
20
|
+
elsif @language.repetitionHandler.get_repetition(pLine)
|
|
21
|
+
repetition_capture
|
|
22
|
+
else
|
|
23
|
+
return
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @see OOStructuredState
|
|
28
|
+
def class_capture
|
|
29
|
+
@language.rewind_state
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @see OOStructuredState
|
|
33
|
+
def conditional_capture
|
|
34
|
+
@language.flagFunctionBehaviour = StateMachine::METHOD_STATE
|
|
35
|
+
@language.set_state(@language.conditionalState)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @see OOStructuredState
|
|
39
|
+
def repetition_capture
|
|
40
|
+
@language.flagFunctionBehaviour = StateMachine::METHOD_STATE
|
|
41
|
+
@language.set_state(@language.repetitionState)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @see OOStructuredState
|
|
45
|
+
def execute(pElementFile, pLine)
|
|
46
|
+
methodElement = @language.methodHandler.get_function(pLine)
|
|
47
|
+
|
|
48
|
+
if (methodElement)
|
|
49
|
+
lastIndex = pElementFile.classes.length - 1 # We want the index
|
|
50
|
+
methodElement.comments = @language.string_comment_to_transfer
|
|
51
|
+
@language.string_comment_to_transfer = ""
|
|
52
|
+
pElementFile.classes[lastIndex].add_method(methodElement)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if (@language.endBlockHandler.has_end_of_block?(pLine))
|
|
56
|
+
class_capture
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
return pElementFile
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# End class
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# End OOStructuredFSM
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# End StateMachine
|
|
69
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require_relative 'oo_structured_state'
|
|
2
|
+
require_relative 'function_state'
|
|
3
|
+
require_relative 'class_state'
|
|
4
|
+
require_relative 'idle_state'
|
|
5
|
+
|
|
6
|
+
module StateMachine
|
|
7
|
+
|
|
8
|
+
module OOStructuredFSM
|
|
9
|
+
|
|
10
|
+
# Class responsible for handling Module state.
|
|
11
|
+
class ModuleState < OOStructuredState
|
|
12
|
+
|
|
13
|
+
@language
|
|
14
|
+
|
|
15
|
+
def initialize(pLanguage)
|
|
16
|
+
@language = pLanguage
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @see OOStructuredState
|
|
20
|
+
def handle_line(pLine)
|
|
21
|
+
if @language.classHandler.get_class(pLine)
|
|
22
|
+
class_capture
|
|
23
|
+
elsif @language.functionHandler.get_function(pLine)
|
|
24
|
+
function_capture
|
|
25
|
+
elsif @language.variableHandler.get_variable(pLine)
|
|
26
|
+
variable_capture
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @see OOStructuredState
|
|
31
|
+
def idle_capture
|
|
32
|
+
@language.set_state(@language.idleState)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @see OOStructuredState
|
|
36
|
+
def class_capture
|
|
37
|
+
@language.set_state(@language.classState)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @see OOStructuredState
|
|
41
|
+
def variable_capture
|
|
42
|
+
@language.set_state(@language.variableState)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @see OOStructuredState
|
|
46
|
+
def function_capture
|
|
47
|
+
@language.set_state(@language.functionState)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @see OOStructuredState
|
|
51
|
+
def execute(pElementFile, pLine)
|
|
52
|
+
|
|
53
|
+
moduleElement = @language.moduleHandler.get_module(pLine)
|
|
54
|
+
|
|
55
|
+
if moduleElement
|
|
56
|
+
pElementFile.add_modules(moduleElement)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
if @language.endBlockHandler.has_end_of_block?(pLine)
|
|
60
|
+
previous = @language.previousState.last
|
|
61
|
+
|
|
62
|
+
if (previous.is_a?(StateMachine::OOStructuredFSM::IdleState))
|
|
63
|
+
idle_capture
|
|
64
|
+
else
|
|
65
|
+
return pElementFile
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
return pElementFile
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# End class
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# End OOStructuredFSM
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# End StateMachine
|
|
79
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Responsible for keep different state machines.
|
|
2
|
+
module StateMachine
|
|
3
|
+
|
|
4
|
+
# Responsible for handling oriented object and structured paradigm.
|
|
5
|
+
module OOStructuredFSM
|
|
6
|
+
|
|
7
|
+
# @abstract State machine for oriented object and structured paradigm.
|
|
8
|
+
class OOStructuredState
|
|
9
|
+
|
|
10
|
+
# Method responsible each line, and decide which way to go inside state
|
|
11
|
+
# machine.
|
|
12
|
+
def handle_line(pLine)
|
|
13
|
+
raise NotImplementedError
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Handling class state, i.e, this state is enable when any class is match
|
|
17
|
+
def class_capture
|
|
18
|
+
raise NotImplementedError
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Handling method state, this state is enable only after class state.
|
|
22
|
+
def method_capture
|
|
23
|
+
raise NotImplementedError
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Handling constructor, only after class state.
|
|
27
|
+
def constructor_capture
|
|
28
|
+
raise NotImplementedError
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Handling attribute state.
|
|
32
|
+
def attribute_capture
|
|
33
|
+
raise NotImplementedError
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Handling module, it can be oriented object or structured.
|
|
37
|
+
def module_capture
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Handling function, it is related with structured state
|
|
42
|
+
# but not exclusively.
|
|
43
|
+
def function_capture
|
|
44
|
+
raise NotImplementedError
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Handling external include
|
|
48
|
+
def include_capture
|
|
49
|
+
raise NotImplementedError
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Handling variable
|
|
53
|
+
def variable_capture
|
|
54
|
+
raise NotImplementedError
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Idle state, waiting for action! =D
|
|
58
|
+
def idle_capture
|
|
59
|
+
raise NotImplementedError
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Handling conditional state
|
|
63
|
+
def conditional_capture
|
|
64
|
+
raise NotImplementedError
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Handling conditional state
|
|
68
|
+
def repetition_capture
|
|
69
|
+
raise NotImplementedError
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Handling comment
|
|
73
|
+
def comment_capture
|
|
74
|
+
raise NotImplementedError
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Method responsible for make the state machine go forward.
|
|
78
|
+
# @param pElementFile File to be improved.
|
|
79
|
+
# @param pLine Line for verify element.
|
|
80
|
+
# @return Return pElementFile with new elements, or with the same values.
|
|
81
|
+
def execute(pElementFile, pLine)
|
|
82
|
+
raise NotImplementedError
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# End class
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# End OOStructuredState
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# End StateMachine
|
|
92
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require_relative 'oo_structured_state'
|
|
2
|
+
|
|
3
|
+
module StateMachine
|
|
4
|
+
|
|
5
|
+
module OOStructuredFSM
|
|
6
|
+
|
|
7
|
+
# Class responsible for handling Repetition state.
|
|
8
|
+
class RepetitionState < OOStructuredState
|
|
9
|
+
|
|
10
|
+
@language
|
|
11
|
+
|
|
12
|
+
def initialize(pLanguage)
|
|
13
|
+
@language = pLanguage
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def handle_line(pLine)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @see OOStructuredState
|
|
20
|
+
def method_capture
|
|
21
|
+
reset_flag
|
|
22
|
+
@language.rewind_state
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @see OOStructuredState
|
|
26
|
+
def constructor_capture
|
|
27
|
+
reset_flag
|
|
28
|
+
@language.rewind_state
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @see OOStructuredState
|
|
32
|
+
def function_capture
|
|
33
|
+
reset_flag
|
|
34
|
+
@language.rewind_state
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @see OOStructuredState
|
|
38
|
+
def execute(pElementFile, pLine)
|
|
39
|
+
repetition = @language.repetitionHandler.get_repetition(pLine)
|
|
40
|
+
|
|
41
|
+
flag = @language.flagFunctionBehaviour
|
|
42
|
+
|
|
43
|
+
if (repetition)
|
|
44
|
+
#Function
|
|
45
|
+
if (flag == StateMachine::GLOBAL_FUNCTION_STATE)
|
|
46
|
+
pElementFile.global_functions.last.add_repetition(repetition)
|
|
47
|
+
#Method
|
|
48
|
+
elsif (flag == StateMachine::METHOD_STATE)
|
|
49
|
+
pElementFile.classes.last.methods.last.add_repetition(repetition)
|
|
50
|
+
#Constructor
|
|
51
|
+
elsif (flag == StateMachine::CONSTRUCTOR_STATE)
|
|
52
|
+
pElementFile.classes.last.constructors
|
|
53
|
+
.last.add_repetition(repetition)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if (@language.endBlockHandler.has_end_of_block?(pLine))
|
|
58
|
+
if (flag == StateMachine::GLOBAL_FUNCTION_STATE)
|
|
59
|
+
function_capture
|
|
60
|
+
elsif (flag == StateMachine::METHOD_STATE)
|
|
61
|
+
method_capture
|
|
62
|
+
elsif (flag == StateMachine::CONSTRUCTOR_STATE)
|
|
63
|
+
constructor_capture
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
return pElementFile
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
# @see OOStructuredState
|
|
74
|
+
def reset_flag
|
|
75
|
+
@language.flagFunctionBehaviour = StateMachine::NONE_HANDLING_STATE
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# End class
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# End OOStructuredFSM
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# End StateMachine
|
|
85
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require_relative 'oo_structured_state'
|
|
2
|
+
|
|
3
|
+
module StateMachine
|
|
4
|
+
|
|
5
|
+
module OOStructuredFSM
|
|
6
|
+
|
|
7
|
+
# Handling variable state.
|
|
8
|
+
class VariableState < OOStructuredState
|
|
9
|
+
|
|
10
|
+
@language
|
|
11
|
+
|
|
12
|
+
def initialize(pLanguage)
|
|
13
|
+
@language = pLanguage
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @see OOStructuredState
|
|
17
|
+
def handle_line(pLine)
|
|
18
|
+
idle_capture
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @see OOStructuredState
|
|
22
|
+
def idle_capture
|
|
23
|
+
@language.set_state(@language.idleState)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @see OOStructuredState
|
|
27
|
+
def execute(pElementFile, pLine)
|
|
28
|
+
variableList = @language.variableHandler.get_variable(pLine)
|
|
29
|
+
if variableList
|
|
30
|
+
variableList.each do |variable|
|
|
31
|
+
variable.comments = @language.string_comment_to_transfer
|
|
32
|
+
end
|
|
33
|
+
@language.string_comment_to_transfer = ""
|
|
34
|
+
pElementFile.add_global_variable(variableList)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# TODO: You have to handler the return state.
|
|
38
|
+
idle_capture
|
|
39
|
+
return pElementFile
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# End class
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# End OOStructuredFSM
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# End StateMachine
|
|
49
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require_relative 'logger'
|
|
2
|
+
|
|
3
|
+
module Util
|
|
4
|
+
|
|
5
|
+
# Handling HTML log.
|
|
6
|
+
class HtmlLogger < Logger
|
|
7
|
+
|
|
8
|
+
public
|
|
9
|
+
|
|
10
|
+
# @param pPath [String] Receives the path to save the log.
|
|
11
|
+
def initialize(pPath = "/tmp/kuniri_log.html")
|
|
12
|
+
super(pPath)
|
|
13
|
+
initialize_html_file
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @param pMessage [String] Log message to be write as .html
|
|
17
|
+
# documentation.
|
|
18
|
+
def write_log(pMessage)
|
|
19
|
+
File.open(@log_path, 'a') do |file|
|
|
20
|
+
file.write("<hr>\n")
|
|
21
|
+
file.write("<p>" + Time.now.strftime("%d/%m/%Y %H:%M:%S") + "</p>\n")
|
|
22
|
+
file.write("\t<i>#{pMessage}</i>\n")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def initialize_html_file
|
|
29
|
+
File.open(@log_path, 'a') do |file|
|
|
30
|
+
file.write("<html>\n")
|
|
31
|
+
file.write("\t<title>Kuniri log</title>\n\n")
|
|
32
|
+
#file.write("<body>\n")
|
|
33
|
+
#file.write("</body>\n")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Class
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Util
|
|
41
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Util provides classes, functions and constants which can be used for the
|
|
2
|
+
# entire system.
|
|
3
|
+
module Util
|
|
4
|
+
|
|
5
|
+
# Abstract class responsible for define the log strategy.
|
|
6
|
+
class Logger
|
|
7
|
+
|
|
8
|
+
# Create/open the log file, and save the path.
|
|
9
|
+
# @param pPath [String] Receives the path for save the log file. By default
|
|
10
|
+
# it is saved on /tmp with the name "kuniri".
|
|
11
|
+
def initialize(pPath = "/tmp/kuniri.log")
|
|
12
|
+
File.open(pPath, 'a')
|
|
13
|
+
@log_path = pPath
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
public
|
|
17
|
+
|
|
18
|
+
# Write log, based on the message and the path. The most important thing
|
|
19
|
+
# about this method, is related with the implementation in different
|
|
20
|
+
# formats. Ex.: write_log can be implemented as HTML, txt, XML, etc.
|
|
21
|
+
# @param pMessage to write in the log file.
|
|
22
|
+
def write_log(pMessage)
|
|
23
|
+
raise NotImplementedError
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
protected
|
|
27
|
+
|
|
28
|
+
@log_path # Saved path of the log file.
|
|
29
|
+
|
|
30
|
+
# Class
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Util
|
|
34
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
require_relative 'logger'
|
|
3
|
+
|
|
4
|
+
module Util
|
|
5
|
+
|
|
6
|
+
# Create log in a text format. This classes handling the correct way of
|
|
7
|
+
# generate the log in a .txt format.
|
|
8
|
+
class TxtLogger < Util::Logger
|
|
9
|
+
|
|
10
|
+
# @param pPath [String] Path for save the log. The default is /tmp/
|
|
11
|
+
def initialize(pPath = "/tmp/kuniri.log")
|
|
12
|
+
super(pPath)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Write a message as .txt file.
|
|
16
|
+
# @param pMessage [String] Massage to be write in the log file.
|
|
17
|
+
def write_log(pMessage)
|
|
18
|
+
File.open(@log_path, 'a') do |file|
|
|
19
|
+
file.write("="*10 + "\n")
|
|
20
|
+
file.write("time: " + Time.now.strftime("%d/%m/%Y %H:%M:%S") + "\n")
|
|
21
|
+
file.write("message: " + pMessage + "\n")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Class
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Util
|
|
29
|
+
end
|
data/lib/kuniri.rb
ADDED
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require_relative '../spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Kuniri::Kuniri do
|
|
4
|
+
|
|
5
|
+
context "When path for run_analysis is wrong." do
|
|
6
|
+
it "Wrong path to " do
|
|
7
|
+
@kuniriTest = Kuniri::Kuniri.new("wrong/path")
|
|
8
|
+
defaultPath = @kuniriTest.run_analysis
|
|
9
|
+
folderFiles = Dir[File.join("./", "**", "**.rb")]
|
|
10
|
+
expect(defaultPath).to match_array(folderFiles)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|