kuniri 0.0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -7
- data/COPYING +160 -656
- data/Gemfile +4 -3
- data/README.md +57 -27
- data/Rakefile +3 -1
- data/bin/kuniri +50 -26
- data/data/aggregation_lang.rb +33 -0
- data/data/attribute_lang.rb +14 -87
- data/data/class_lang.rb +19 -41
- data/data/comment_lang.rb +52 -0
- data/data/conditional_lang.rb +14 -41
- data/data/constructor_lang.rb +4 -12
- data/data/end_block_lang.rb +7 -6
- data/data/extern_requirement_lang.rb +10 -17
- data/data/function_behavior_lang.rb +17 -66
- data/data/global_function_lang.rb +26 -0
- data/data/lang_syntax.rb +82 -49
- data/data/method_lang.rb +26 -0
- data/data/module_namespace_lang.rb +8 -13
- data/data/repetition_lang.rb +19 -32
- data/data/token_lang.rb +2 -44
- data/data/variable_behaviour_lang.rb +43 -0
- data/data/variable_global_lang.rb +13 -72
- data/kuniri.gemspec +4 -4
- data/lib/kuniri/core/configuration/language_available.rb +2 -2
- data/lib/kuniri/core/kuniri.rb +32 -24
- data/lib/kuniri/core/setting.rb +51 -85
- data/lib/kuniri/error/parser_error.rb +9 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/aggregation.rb +29 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +0 -40
- data/lib/kuniri/language/abstract_container/structured_and_oo/global_tokens.rb +20 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +9 -1
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +0 -35
- data/lib/kuniri/language/container_data/structured_and_oo/aggregation_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +4 -2
- data/lib/kuniri/language/container_data/structured_and_oo/basic_structure.rb +24 -0
- data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +13 -19
- data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +2 -0
- data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +11 -6
- data/lib/kuniri/language/container_data/structured_and_oo/{file_element.rb → file_element_data.rb} +11 -9
- data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +58 -11
- data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +3 -3
- data/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb +55 -0
- data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +5 -4
- data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +3 -1
- data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +2 -0
- data/lib/kuniri/language/language.rb +37 -11
- data/lib/kuniri/language/metadata.rb +29 -0
- data/lib/kuniri/language/ruby/aggregation_ruby.rb +37 -0
- data/lib/kuniri/language/ruby/attribute_ruby.rb +23 -38
- data/lib/kuniri/language/ruby/class_ruby.rb +2 -10
- data/lib/kuniri/language/ruby/conditional_ruby.rb +20 -6
- data/lib/kuniri/language/ruby/constructor_ruby.rb +5 -7
- data/lib/kuniri/language/ruby/end_block_ruby.rb +1 -1
- data/lib/kuniri/language/ruby/function_behavior_ruby.rb +1 -9
- data/lib/kuniri/language/ruby/global_function_ruby.rb +32 -0
- data/lib/kuniri/language/ruby/method_ruby.rb +33 -0
- data/lib/kuniri/language/ruby/repetition_ruby.rb +60 -14
- data/lib/kuniri/language/ruby/ruby_syntax.rb +76 -49
- data/lib/kuniri/parser/output_factory.rb +29 -0
- data/lib/kuniri/parser/output_format.rb +134 -0
- data/lib/kuniri/parser/parser.rb +3 -7
- data/lib/kuniri/parser/xml_builder_engine.rb +94 -0
- data/lib/kuniri/parser/xml_output_format.rb +143 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/aggregation_state.rb +45 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +0 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/basic_structure_state.rb +182 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +12 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +11 -68
- data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +7 -52
- data/lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb +86 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +2 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +8 -50
- data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +6 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +10 -59
- data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +4 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +0 -1
- data/lib/kuniri/version.rb +1 -1
- data/other/analyseFile.asta +0 -0
- data/spec/core/kuniri_spec.rb +2 -1
- data/spec/core/setting_spec.rb +35 -61
- data/spec/language/abstract_container/aggregation_spec.rb +13 -0
- data/spec/language/abstract_container/extern_requirement_spec.rb +13 -0
- data/spec/language/container_data/structured_and_oo/aggregation_data_spec.rb +29 -0
- data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +9 -2
- data/spec/language/container_data/structured_and_oo/class_data_spec.rb +1 -46
- data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +32 -2
- data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +31 -7
- data/spec/language/container_data/structured_and_oo/{file_element_spec.rb → file_element_data_spec.rb} +21 -5
- data/spec/language/container_data/structured_and_oo/function_abstract_spec.rb +213 -0
- data/spec/language/container_data/structured_and_oo/function_data_spec.rb +31 -2
- data/spec/language/container_data/structured_and_oo/manager_basic_structure_data_spec.rb +150 -0
- data/spec/language/container_data/structured_and_oo/method_data_spec.rb +80 -0
- data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +7 -1
- data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +9 -0
- data/spec/language/language_factory_spec.rb +1 -1
- data/spec/language/language_spec.rb +46 -9
- data/spec/language/ruby/aggregation_ruby_spec.rb +80 -0
- data/spec/language/ruby/class_ruby_spec.rb +66 -6
- data/spec/language/ruby/constructor_ruby_spec.rb +1 -1
- data/spec/language/ruby/end_block_ruby_spec.rb +11 -0
- data/spec/language/ruby/extern_requirement_ruby_spec.rb +59 -0
- data/spec/language/ruby/function_behavior_ruby_spec.rb +54 -2
- data/spec/language/ruby/global_test/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/complete_class_ruby_spec.rb +161 -0
- data/spec/language/ruby/global_test/conditional/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri1.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/conditional/a_lot_of_conditionals_spec.rb +92 -0
- data/spec/language/ruby/global_test/conditional/constructor_very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditional/function_with_conditional_spec.rb +94 -0
- data/spec/language/ruby/global_test/conditional/function_with_nested_conditional_spec.rb +56 -0
- data/spec/language/ruby/global_test/conditional/method_very_mix_conditional_spec.rb +109 -0
- data/spec/language/ruby/global_test/conditional/very_deep_conditional_structure_spec.rb +61 -0
- data/spec/language/ruby/global_test/conditional/very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/mix_conditional_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri7.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri8.yml +4 -0
- data/spec/language/ruby/global_test/repetition/complete_class_integrity.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_until_loop_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/complete_class_while_loop_spec.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_with_repetition_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/constructor_with_mix_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/method_with_mix_repetition_spec.rb +59 -0
- data/spec/language/ruby/global_test/repetition/very_mix_repetition_spec.rb +61 -0
- data/spec/language/ruby/global_test/repetition/very_nested_repetition_spec.rb +65 -0
- data/spec/language/ruby/method_ruby_spec.rb +52 -0
- data/spec/language/ruby/repetition_ruby_spec.rb +175 -8
- data/spec/language/ruby/ruby_syntax_spec.rb +213 -84
- data/spec/parser/output_factory_spec.rb +32 -0
- data/spec/parser/output_format_spec.rb +83 -0
- data/spec/parser/parser_spec.rb +7 -0
- data/spec/parser/xmlSchemaValidate/.kuniri1.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri2.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri3.yml +3 -0
- data/spec/parser/xmlSchemaValidate/class_data.xsd +99 -0
- data/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd +119 -0
- data/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd +146 -0
- data/spec/parser/xmlSchemaValidate/simpleFunction.xsd +25 -0
- data/spec/parser/xmlSchemaValidate/validate_xml_spec.rb +52 -0
- data/spec/parser/xml_builder_engine_spec.rb +258 -0
- data/spec/parser/xml_output_format_spec.rb +274 -0
- data/spec/samples/rubySyntaxParts/aggregation/classAggregation.rb +37 -0
- data/spec/samples/rubySyntaxParts/aggregation/constructorAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/methodAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/multipleAggregation.rb +59 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +7 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +2 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/aLotOfConditionals.rb +42 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/commonCasesOfConditionals.rb +47 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +1 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/methodMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/mixConditionalWithRepetition.rb +20 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +61 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryDeepConditionalStructure.rb +48 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryMixConditional.rb +37 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeTwo.rb +56 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeWithComments.rb +64 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +9 -1
- data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +2 -0
- data/spec/samples/rubySyntaxParts/repetition/beginWithWhileLoopInClass.rb +10 -0
- data/spec/samples/rubySyntaxParts/repetition/constructorWithMixRepetition.rb +22 -0
- data/spec/samples/rubySyntaxParts/repetition/forLoopInClass.rb +7 -0
- data/spec/samples/rubySyntaxParts/repetition/methodWithMixRepetition.rb +19 -0
- data/spec/samples/rubySyntaxParts/repetition/mixConditionalRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/untilLoopInClass.rb +16 -0
- data/spec/samples/rubySyntaxParts/repetition/veryMixRepetition.rb +28 -0
- data/spec/samples/rubySyntaxParts/repetition/veryNestedRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/whileLoopInClass.rb +12 -0
- data/spec/state_machine/OO_structured_fsm/aggregation_state_spec.rb +67 -0
- data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +15 -0
- data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +64 -0
- data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +3 -3
- data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +18 -0
- data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +27 -0
- metadata +195 -28
- data/lib/kuniri/core/configuration/monitor_available.rb +0 -13
- data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +0 -52
- data/lib/kuniri/parser/parser_xml.rb +0 -128
- data/spec/language/abstract_container/constructor_spec.rb +0 -13
- data/spec/util/html_logger_spec.rb +0 -31
- data/spec/util/logger_spec.rb +0 -20
- data/spec/util/txt_logger_spec.rb +0 -31
@@ -5,113 +5,54 @@ module Languages
|
|
5
5
|
|
6
6
|
module {LANG}
|
7
7
|
|
8
|
-
#
|
8
|
+
# VariableGlobal{LANG} Handling extern requirements.
|
9
9
|
class VariableGlobal{LANG} < Languages::VariableGlobal
|
10
10
|
|
11
11
|
public
|
12
12
|
|
13
|
+
# Get {LANG} variable.
|
14
|
+
# @see Languages::VariableGlobal
|
13
15
|
def get_variable(pLine)
|
14
|
-
|
15
|
-
return nil unless result
|
16
|
-
|
17
|
-
listOfVariable = []
|
18
|
-
|
19
|
-
# Separated by comma, equal or the common case
|
20
|
-
if result.split(",").size > 1
|
21
|
-
listOfVariable = handle_multiple_declaration_with_comma(result)
|
22
|
-
elsif result.split("=").size > 1
|
23
|
-
listOfVariable = handle_multiple_declaration_with_equal(result)
|
24
|
-
else
|
25
|
-
listOfVariable = handle_line_declaration(result)
|
26
|
-
end
|
27
|
-
|
28
|
-
return listOfVariable
|
16
|
+
# YOUR CODE HERE
|
29
17
|
end
|
30
18
|
|
31
19
|
protected
|
32
20
|
|
21
|
+
# Override
|
33
22
|
def detect_variable(pLine)
|
34
|
-
#
|
35
|
-
pLine.gsub!(/^\s*/, "")
|
36
|
-
pLine.gsub!(/\s*$/, "")
|
37
|
-
return nil if pLine =~ /end/
|
38
|
-
return nil if pLine =~ /^def\s+/
|
39
|
-
return pLine if pLine.split(",").size > 1
|
40
|
-
return pLine if pLine.split("=").size > 1
|
41
|
-
|
42
|
-
return nil if pLine.split(" ").size > 1
|
43
|
-
return pLine
|
23
|
+
# YOUR CODE HERE
|
44
24
|
end
|
45
25
|
|
26
|
+
# Override
|
46
27
|
def remove_unnecessary_information(pLine)
|
47
|
-
|
28
|
+
# YOUR CODE HERE
|
48
29
|
end
|
49
30
|
|
50
31
|
# Override
|
51
32
|
def prepare_final_string(pString)
|
52
|
-
|
53
|
-
return pString.gsub!(/\s+|:|@|=/,"")
|
54
|
-
end
|
55
|
-
return pString
|
33
|
+
# YOUR CODE HERE
|
56
34
|
end
|
57
35
|
|
58
36
|
# Override
|
59
37
|
def handle_multiple_declaration_with_comma(pString)
|
60
|
-
|
61
|
-
pString = pString.split(",")
|
62
|
-
pString.each do |variable|
|
63
|
-
return nil if variable.split("=").size > 2
|
64
|
-
|
65
|
-
variable = variable.scan(/.*=/).join("") if variable =~ /.*=/
|
66
|
-
|
67
|
-
return nil if variable =~ /\./
|
68
|
-
|
69
|
-
variable = prepare_final_string(variable)
|
70
|
-
globalVariable = Languages::VariableGlobalData.new(variable)
|
71
|
-
listOfVariable.push(globalVariable)
|
72
|
-
end
|
73
|
-
|
74
|
-
return listOfVariable
|
38
|
+
# YOUR CODE HERE
|
75
39
|
end
|
76
40
|
|
77
41
|
# Override
|
78
42
|
def handle_multiple_declaration_with_equal(pString)
|
79
|
-
|
80
|
-
pString = pString.split("=")
|
81
|
-
pString.each do |variable|
|
82
|
-
return nil if variable =~ /\./
|
83
|
-
|
84
|
-
variable = prepare_final_string(variable)
|
85
|
-
globalVariable = Languages::VariableGlobalData.new(variable)
|
86
|
-
listOfVariable.push(globalVariable)
|
87
|
-
end
|
88
|
-
value = listOfVariable.pop
|
89
|
-
|
90
|
-
return listOfVariable
|
43
|
+
# YOUR CODE HERE
|
91
44
|
end
|
92
45
|
|
93
46
|
# Override
|
94
47
|
def handle_line_declaration(pString)
|
95
|
-
|
96
|
-
if pString =~ /=/
|
97
|
-
pString = pString.scan(/.*=/).join("")
|
98
|
-
return nil if pString =~ /\./
|
99
|
-
end
|
100
|
-
|
101
|
-
return nil if pString =~ /\./
|
102
|
-
|
103
|
-
pString = prepare_final_string(pString)
|
104
|
-
globalVariable = Languages::VariableGlobalData.new(pString)
|
105
|
-
listOfVariable.push(globalVariable)
|
106
|
-
|
107
|
-
return listOfVariable
|
48
|
+
# YOUR CODE HERE
|
108
49
|
end
|
109
50
|
|
110
51
|
|
111
52
|
# Class
|
112
53
|
end
|
113
54
|
|
114
|
-
#
|
55
|
+
# Module
|
115
56
|
end
|
116
57
|
|
117
58
|
# Module
|
data/kuniri.gemspec
CHANGED
@@ -3,15 +3,15 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'kuniri/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |spec|
|
6
|
+
Gem::Specification.new 'kuniri', '0.2' do |spec|
|
7
7
|
spec.name = "kuniri"
|
8
8
|
spec.version = Kuniri::VERSION
|
9
9
|
spec.authors = ["Gustavo Jaruga", "Rodrigo Siqueira"]
|
10
|
-
spec.email = ["darksshades@hotmail.com", "
|
10
|
+
spec.email = ["darksshades@hotmail.com", "siqueira@kuniri.org"]
|
11
11
|
spec.summary = %q{Extract class information from code.}
|
12
12
|
spec.description = 'Generic parser'
|
13
13
|
spec.homepage = "http://kuniri.github.io/kuniri/"
|
14
|
-
spec.license = "
|
14
|
+
spec.license = "LGPLv3"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = ["kuniri"]
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rspec"
|
22
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_runtime_dependency 'nokogiri', '~> 1.6.6'
|
24
24
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Configuration
|
2
2
|
#Handling the languages available in the system.
|
3
|
-
class
|
3
|
+
class LanguageAvailable
|
4
4
|
public
|
5
|
-
LANGUAGES = ["ruby", "python", "
|
5
|
+
LANGUAGES = ["ruby", "python", "cplusplus", "c"] #Put here new language.
|
6
6
|
end
|
7
7
|
end
|
data/lib/kuniri/core/kuniri.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require_relative '../error/configuration_file_error'
|
2
2
|
require_relative '../parser/parser'
|
3
|
-
require_relative '../util/logger'
|
4
3
|
require_relative 'configuration/language_available'
|
5
|
-
require_relative 'configuration/monitor_available'
|
6
|
-
require_relative 'configuration/log_available'
|
7
4
|
require_relative 'setting'
|
8
5
|
|
9
6
|
# Kuniri module connect all the elements and use it in the proper sequence.
|
@@ -15,60 +12,71 @@ module Kuniri
|
|
15
12
|
|
16
13
|
public
|
17
14
|
|
15
|
+
attr_reader :configurationInfo # !@attribute Hash with configuration description
|
16
|
+
|
18
17
|
# @param pPath Receives the path of configuration file. If any element
|
19
18
|
# is given, it tries to find in the current folder.
|
20
|
-
def initialize
|
19
|
+
def initialize
|
21
20
|
@configurationInfo = {}
|
22
21
|
@filesPathProject = []
|
23
22
|
@parserFiles = []
|
24
23
|
@parser = nil
|
25
24
|
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_configuration_file(pPath = ".kuniri.yml")
|
26
28
|
@settings = Setting.create
|
27
29
|
@settings.initializate_settings(pPath)
|
28
|
-
@
|
30
|
+
@settings.read_configuration_file(pPath)
|
29
31
|
@configurationInfo = @settings.configurationInfo
|
32
|
+
end
|
30
33
|
|
31
|
-
|
34
|
+
def set_configuration(pSource, pLanguage, pOutput, pLevel)
|
35
|
+
@settings = Setting.create
|
36
|
+
@settings.initializate_settings
|
37
|
+
@settings.set_configuration(pSource, pLanguage, pOutput, pLanguage)
|
38
|
+
# XXX: Extremely "gambira" PLEASE, REMOVE METHOD BELOW!
|
39
|
+
@configurationInfo = @settings.configurationInfo
|
32
40
|
end
|
33
41
|
|
34
|
-
# Start Kuniri tasks based on configuration file. After read
|
42
|
+
# Start Kuniri tasks based on configuration file. After read
|
35
43
|
# configuration file, find all files in source directory.
|
36
44
|
def run_analysis()
|
37
|
-
@
|
38
|
-
@log.write_log("debug: ConfigurationInfo: #{@configurationInfo}")
|
39
|
-
|
40
|
-
@filesPathProject = get_project_file(@configurationInfo["source"])
|
45
|
+
@filesPathProject = get_project_file(@configurationInfo[:source])
|
41
46
|
unless @filesPathProject
|
42
|
-
puts "Problem on source path: #{@configurationInfo[
|
43
|
-
@log.write_log("Prolblem when tried to access source folder.")
|
47
|
+
puts "Problem on source path: #{@configurationInfo[:source]}"
|
44
48
|
return -1
|
45
49
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@parser.start_parser()
|
50
|
+
@parser = Parser::Parser.new(@filesPathProject,
|
51
|
+
@configurationInfo[:language])
|
52
|
+
@parser.start_parser()
|
50
53
|
end
|
51
|
-
|
54
|
+
|
52
55
|
def get_parser
|
53
56
|
@parser
|
54
57
|
end
|
55
58
|
|
56
59
|
private
|
57
60
|
|
58
|
-
@configurationInfo # !@attribute Hash with configuration description
|
59
61
|
@filesProject # !@attribute Array with object reference of all files
|
60
62
|
@parser # !@attribute Execute the parser based on settings.
|
61
63
|
@parserFiles # !@attribute Final output from parser.
|
62
|
-
@log # !@attribute Log reference.
|
63
64
|
|
64
65
|
# !@param pPath Relative path of the project.
|
65
66
|
# !@param pLanguage Language extension for make the parser.
|
66
67
|
def get_project_file(pPath="./", pLanguage="**.rb")
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
# Verify if path is a valid directory or file
|
69
|
+
return nil unless File.file?(pPath) or File.directory?(pPath)
|
70
|
+
|
71
|
+
# Handle single file
|
72
|
+
if (File.file?(pPath))
|
73
|
+
@filesProject = [pPath]
|
74
|
+
# Handle multiple files
|
75
|
+
else
|
76
|
+
@filesProject = Dir[File.join(pPath, "**", pLanguage)]
|
77
|
+
end
|
70
78
|
|
71
|
-
@filesProject
|
79
|
+
return @filesProject
|
72
80
|
end
|
73
81
|
|
74
82
|
# Class
|
data/lib/kuniri/core/setting.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
+
require 'yaml'
|
1
2
|
require_relative 'configuration/language_available'
|
2
|
-
require_relative 'configuration/monitor_available'
|
3
|
-
require_relative 'configuration/log_available'
|
4
|
-
|
5
|
-
require_relative '../util/html_logger'
|
6
|
-
require_relative '../util/txt_logger'
|
7
3
|
require_relative '../error/configuration_file_error'
|
8
4
|
|
9
5
|
module Kuniri
|
@@ -15,7 +11,6 @@ module Kuniri
|
|
15
11
|
|
16
12
|
private_class_method :new
|
17
13
|
attr_reader :configurationInfo
|
18
|
-
attr_reader :log
|
19
14
|
|
20
15
|
def initialize
|
21
16
|
initializate_settings
|
@@ -26,113 +21,84 @@ module Kuniri
|
|
26
21
|
return @@settings
|
27
22
|
end
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rescue Error::ConfigurationFileError
|
34
|
-
puts "You have a syntax problem on your configuration file."
|
35
|
-
abort
|
36
|
-
end
|
37
|
-
|
24
|
+
# TODO: Remove parameter and initialize_object. Useless.
|
25
|
+
def initializate_settings(pFilePath = ".kuniri.yml")
|
26
|
+
#@configurationInfo = read_configuration_file(pFilePath)
|
27
|
+
@configurationInfo = {}
|
38
28
|
end
|
39
|
-
|
40
|
-
# Read the configuration file and return a list with the configurations.
|
29
|
+
|
41
30
|
# In this method it is checked the configuration file syntax.
|
42
|
-
# @param pPath [String] Path to ".kuniri" file, it means, the
|
31
|
+
# @param pPath [String] Path to ".kuniri" file, it means, the
|
43
32
|
# configurations.
|
44
33
|
# @return [Hash] Return a Hash with the configurations read in ".kuniri",
|
45
34
|
# otherwise, raise an exception.
|
46
|
-
|
47
|
-
# @raise [type] Raised in the case of the path is wrong.
|
48
|
-
def read_configuration_file(pPath = ".kuniri")
|
49
|
-
configuration = {}
|
35
|
+
def read_configuration_file(pPath = ".kuniri.yml")
|
50
36
|
|
51
37
|
unless File.exists?(pPath)
|
52
|
-
|
53
|
-
configuration = default_configuration
|
38
|
+
set_default_configuration
|
54
39
|
else
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
# @log.write_log("First reading configuration file: #{configuration}")
|
59
|
-
|
60
|
-
validate_field(configuration, "language") do |language|
|
61
|
-
Configuration::Language_Available::LANGUAGES.include?(language)
|
62
|
-
end
|
63
|
-
|
64
|
-
validate_field(configuration, "source") do |sourcePath|
|
65
|
-
File.exists?(sourcePath)
|
66
|
-
end
|
67
|
-
|
68
|
-
validate_field(configuration, "output") do |outputPath|
|
69
|
-
File.exists?(outputPath)
|
70
|
-
end
|
71
|
-
|
72
|
-
validate_field(configuration, "extract") do |extract|
|
73
|
-
Configuration::Monitor_Available::MONITORS.include?(extract.downcase)
|
40
|
+
@configurationInfo = YAML.load(File.read(pPath))
|
41
|
+
verify_syntax
|
74
42
|
end
|
75
43
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
# @log.write_log("Debug: Configuration: #{configuration}")
|
44
|
+
return @configurationInfo
|
45
|
+
end
|
81
46
|
|
82
|
-
|
47
|
+
def set_configuration(pSource, pLanguage, pOutput, pLevel)
|
48
|
+
@configurationInfo[:source] = pSource
|
49
|
+
@configurationInfo[:language] = pLanguage
|
50
|
+
@configurationInfo[:output] = pOutput
|
51
|
+
@configurationInfo[:level] = pLevel
|
52
|
+
return @configurationInfo
|
83
53
|
end
|
84
54
|
|
85
55
|
private
|
86
56
|
|
87
57
|
@@settings = nil
|
88
58
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
"extract" => "uml",
|
94
|
-
"log" => "html"}
|
95
|
-
return configuration
|
59
|
+
def set_default_configuration
|
60
|
+
@configurationInfo = {:language => "ruby",
|
61
|
+
:source => "./",
|
62
|
+
:output => "./"}
|
96
63
|
end
|
97
64
|
|
98
|
-
def
|
99
|
-
|
100
|
-
|
101
|
-
# @log.write_log("Debug: Reading cofiguration file in: #{pPath}")
|
102
|
-
File.open(pPath, mode="r").each_line do |line|
|
103
|
-
parts = line.split(':').size
|
104
|
-
unless (parts == 2)
|
105
|
-
# @log.write_log("Syntax error on configuration file.")
|
106
|
-
raise Error::ConfigurationFileError
|
107
|
-
end
|
108
|
-
key = handling_basic_syntax(line, 0)
|
109
|
-
value = handling_basic_syntax(line, 1)
|
110
|
-
configuration[key] = value
|
65
|
+
def verify_syntax
|
66
|
+
unless @configurationInfo.is_a? Hash
|
67
|
+
raise Error::ConfigurationFileError
|
111
68
|
end
|
112
|
-
|
69
|
+
|
70
|
+
check_source
|
71
|
+
check_output
|
72
|
+
check_language
|
113
73
|
end
|
114
74
|
|
115
|
-
def
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
75
|
+
def check_source
|
76
|
+
unless @configurationInfo.has_key?:source
|
77
|
+
raise Error::ConfigurationFileError
|
78
|
+
else
|
79
|
+
source = @configurationInfo[:source]
|
80
|
+
result = (File.directory?source) || (File.exists?source)
|
81
|
+
unless result
|
82
|
+
raise Error::ConfigurationFileError
|
120
83
|
end
|
121
84
|
end
|
122
85
|
end
|
123
86
|
|
124
|
-
def
|
125
|
-
|
126
|
-
|
127
|
-
|
87
|
+
def check_output
|
88
|
+
unless @configurationInfo.has_key?:output
|
89
|
+
raise Error::ConfigurationFileError
|
90
|
+
end
|
128
91
|
end
|
129
92
|
|
130
|
-
def
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
93
|
+
def check_language
|
94
|
+
unless @configurationInfo.has_key?:language
|
95
|
+
raise Error::ConfigurationFileError
|
96
|
+
else
|
97
|
+
result = Configuration::LanguageAvailable::LANGUAGES.include?(
|
98
|
+
@configurationInfo[:language])
|
99
|
+
unless result
|
100
|
+
raise Error::ConfigurationFileError
|
101
|
+
end
|
136
102
|
end
|
137
103
|
end
|
138
104
|
|