kuniri 0.0.1 → 0.2
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 +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
data/Gemfile
CHANGED
|
@@ -3,12 +3,13 @@ source 'https://rubygems.org'
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
5
|
group :development do
|
|
6
|
-
gem '
|
|
7
|
-
gem '
|
|
6
|
+
gem 'coveralls', require: false
|
|
7
|
+
gem 'rspec', '~> 3.1.0'
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
group :test do
|
|
11
11
|
gem 'coveralls', require: false
|
|
12
|
-
gem
|
|
12
|
+
gem 'codeclimate-test-reporter', group: :test, require: nil
|
|
13
13
|
gem 'rspec', '~> 3.1.0'
|
|
14
|
+
gem 'libxml-ruby'
|
|
14
15
|
end
|
data/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# KUNIRI
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-
|
|
5
3
|
----
|
|
6
4
|
|
|
7
5
|
[](https://gitter.im/rodrigosiqueira/kuniri?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
@@ -11,14 +9,16 @@
|
|
|
11
9
|
[](http://waffle.io/Kuniri/kuniri)
|
|
12
10
|
[](https://coveralls.io/github/Kuniri/kuniri?branch=master)
|
|
13
11
|
[](http://inch-ci.org/github/Kuniri/kuniri)
|
|
14
|
-
[](http://badge.fury.io/rb/kuniri)
|
|
13
|
+
[](https://github.com/Kuniri/kuniri/blob/master/COPYING)
|
|
15
14
|
|
|
16
15
|
----
|
|
17
16
|
# What is Kuniri?
|
|
18
17
|
|
|
18
|
+
<img src="https://github.com/kuniri/kuniri/wiki/logo/256px/with_round_border.png" alt="Kuniri" align="left" />
|
|
19
19
|
> Briefly, the main goal of Kuniri is: parse any kind of language, and generate
|
|
20
20
|
a common model file with code information. We believe that Kuniri can be a base
|
|
21
|
-
tool for other tools, like diagram generator, traceability, code quality,
|
|
21
|
+
tool for other tools, like a diagram generator, traceability, code quality,
|
|
22
22
|
documentation, and so forth. Initially, the main objective of Kuniri was to
|
|
23
23
|
provide a way to dynamically generate diagrams and traceability based on code.
|
|
24
24
|
However, the parser proved much more useful for many other kinds of
|
|
@@ -36,67 +36,97 @@ extract from the code.
|
|
|
36
36
|
----
|
|
37
37
|
## What is the the meaning of "kuniri"?
|
|
38
38
|
|
|
39
|
-
> Kuniri is an Esperanto word
|
|
39
|
+
> Kuniri is an Esperanto word which means "go with" or "follow". This name was
|
|
40
40
|
chosen because of the idea to keep following your code project with diagrams,
|
|
41
41
|
traceability, code quality and others.
|
|
42
42
|
|
|
43
43
|
----
|
|
44
44
|
# Development
|
|
45
45
|
|
|
46
|
-
* System Dependencies
|
|
46
|
+
* System Dependencies
|
|
47
47
|
* YARD 0.8
|
|
48
48
|
* RSpec 3.1.7
|
|
49
49
|
* Rake 10.4
|
|
50
50
|
* Guard-rspec 4.2
|
|
51
|
-
* nokogiri 1.6.6
|
|
52
51
|
* Ruby version: 2.1
|
|
53
|
-
* Run test suit
|
|
54
|
-
* rake or spec
|
|
55
|
-
* YARD documentation
|
|
56
|
-
* yardoc
|
|
57
52
|
|
|
58
53
|
----
|
|
59
54
|
# Install
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
bundle install
|
|
64
|
-
```
|
|
56
|
+
> Kuniri can be installed with:
|
|
65
57
|
|
|
66
|
-
Kuniri can be installed with:
|
|
67
58
|
```
|
|
68
59
|
rake install
|
|
69
60
|
```
|
|
70
61
|
|
|
71
|
-
After installing you can check the commands with
|
|
62
|
+
> After installing you can check the commands with:
|
|
63
|
+
|
|
72
64
|
```
|
|
73
65
|
kuniri -h
|
|
74
66
|
```
|
|
75
67
|
|
|
68
|
+
> Or you can install the stable version with:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
gem install kuniri
|
|
72
|
+
```
|
|
73
|
+
|
|
76
74
|
----
|
|
77
75
|
# How to use
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
|
|
77
|
+
> You have two different approaches to using kuniri: command line and
|
|
78
|
+
configuration file.
|
|
79
|
+
|
|
80
|
+
## Command line
|
|
81
|
+
|
|
82
|
+
> Command line is the practical and easy way to use kuniri. You just have to
|
|
83
|
+
use a similar command as the one described below:
|
|
80
84
|
|
|
81
85
|
```
|
|
82
|
-
|
|
83
|
-
source:lib/
|
|
84
|
-
output:bin/
|
|
85
|
-
extract:uml
|
|
86
|
+
kuniri path/to/your/source/code -o path/to/kuniri/output -l ruby
|
|
86
87
|
```
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
> First parameter is the source code path. ***"-o"***, means ***"output"*** and
|
|
90
|
+
you can indicate the path that you want to put the final output. Finally
|
|
91
|
+
***-l***, indicate which kind of language your project is.
|
|
92
|
+
|
|
93
|
+
## Using configuration file
|
|
94
|
+
|
|
95
|
+
> If you chose to use a configuration file, first you have to create
|
|
96
|
+
".kuniri.yml" file. The example below shows the basic syntax:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
:language: ruby
|
|
100
|
+
:source: lib/
|
|
101
|
+
:output: bin/
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> First parameter, ***"language"***, indicates what kind of language kuniri
|
|
105
|
+
will parse (unfortunately, we just have ruby language now). Second parameter
|
|
106
|
+
is ***"source"***, and it is used for specifying the target folder to be parsed
|
|
107
|
+
by kuniri. Finally the third parameter is ***"output"***, and you can use it to
|
|
108
|
+
indicate which folder kuniri will put the final output.
|
|
109
|
+
|
|
110
|
+
> Finally, you can execute kuniri with the command below:
|
|
89
111
|
|
|
90
112
|
```
|
|
91
113
|
kuniri -e [file_name_output.xml]
|
|
92
114
|
```
|
|
93
115
|
|
|
94
|
-
|
|
116
|
+
***-e*** means "extract mode".
|
|
117
|
+
|
|
118
|
+
# How to contact us?
|
|
119
|
+
|
|
120
|
+
You can contact us by:
|
|
121
|
+
|
|
122
|
+
1. Mailing list: https://groups.google.com/forum/#!forum/kuniri
|
|
123
|
+
2. Gitter: https://gitter.im/rodrigosiqueira/kuniri
|
|
124
|
+
3. Irc: Connect to freenode, at kuniri
|
|
95
125
|
|
|
96
126
|
----
|
|
97
127
|
# Author
|
|
98
128
|
|
|
99
129
|
* Rodrigo Siqueira de Melo
|
|
100
|
-
*
|
|
130
|
+
* siqueira@kuniri.org
|
|
101
131
|
* Gustavo Jaruga
|
|
102
|
-
*
|
|
132
|
+
* jaruga@kuniri.org
|
data/Rakefile
CHANGED
|
@@ -8,6 +8,7 @@ RSpec::Core::RakeTask.new('spec')
|
|
|
8
8
|
task :default => :spec
|
|
9
9
|
|
|
10
10
|
namespace :parser do |args|
|
|
11
|
+
|
|
11
12
|
desc 'Creates a new parser for kuniri with parser:create'
|
|
12
13
|
task :create do
|
|
13
14
|
options = {}
|
|
@@ -22,7 +23,8 @@ namespace :parser do |args|
|
|
|
22
23
|
parsername = ARGV[1]
|
|
23
24
|
|
|
24
25
|
if File.directory?("lib/kuniri/language/#{parsername.downcase}") then
|
|
25
|
-
puts "Error: A folder for this parser code already exists at
|
|
26
|
+
puts "Error: A folder for this parser code already exists at" +
|
|
27
|
+
"lib/kuniri/language/#{parsername.downcase}"
|
|
26
28
|
exit 1
|
|
27
29
|
end
|
|
28
30
|
|
data/bin/kuniri
CHANGED
|
@@ -3,51 +3,75 @@
|
|
|
3
3
|
require 'kuniri'
|
|
4
4
|
require 'optparse'
|
|
5
5
|
require 'kuniri/core/kuniri'
|
|
6
|
-
require 'kuniri/parser/
|
|
6
|
+
require 'kuniri/parser/xml_output_format'
|
|
7
7
|
|
|
8
|
-
options = {}
|
|
8
|
+
@options = {}
|
|
9
|
+
@options[:source] = ARGV[0]
|
|
9
10
|
|
|
10
|
-
OptionParser.new do |
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
optionParser = OptionParser.new do |buildOptions|
|
|
12
|
+
buildOptions.banner = "Usage: optionParser PATH [OPTIONS]"
|
|
13
|
+
buildOptions.version = Kuniri::VERSION
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
options[:verbose] =
|
|
15
|
+
buildOptions.on("-v", "--[no-]verbose", "Run verbosely") do |verboseMode|
|
|
16
|
+
@options[:verbose] = verboseMode
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
puts
|
|
19
|
+
buildOptions.on("--version", "Show Kuniri version") do |version|
|
|
20
|
+
puts buildOptions.version
|
|
20
21
|
exit
|
|
21
22
|
end
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
kuniri = Kuniri::Kuniri.new
|
|
26
|
-
kuniri.run_analysis
|
|
27
|
-
kuniri.start_navigation_mode
|
|
24
|
+
buildOptions.on("-o", "--output [DEST]", "Export") do |dest|
|
|
25
|
+
@options[:output] = dest
|
|
28
26
|
end
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
buildOptions.on("-O1", "--optimization 1,2,3", "Optimize", Numeric) do
|
|
29
|
+
|optimization|
|
|
30
|
+
@options[:optimization] = optimization
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
buildOptions.on("-l", "--language [languageType]", "Define language") do
|
|
34
|
+
|languageType|
|
|
35
|
+
@options[:languageType] = languageType
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
buildOptions.on("-e", "--export [FILENAME]", "Export XML") do
|
|
39
|
+
|configurationFile|
|
|
40
|
+
|
|
41
|
+
puts "Exporting..."
|
|
42
|
+
|
|
43
|
+
if(configurationFile)
|
|
44
|
+
path = configurationFile
|
|
38
45
|
else
|
|
39
|
-
|
|
46
|
+
path = '.kuniri.yml'
|
|
40
47
|
end
|
|
41
48
|
|
|
42
49
|
kuniri = Kuniri::Kuniri.new
|
|
50
|
+
kuniri.read_configuration_file(path)
|
|
43
51
|
kuniri.run_analysis
|
|
44
52
|
|
|
45
|
-
parser = Parser::
|
|
46
|
-
parser.
|
|
47
|
-
parser.create_all_data kuniri.get_parser()
|
|
53
|
+
parser = Parser::XMLOutputFormat.new
|
|
54
|
+
parser.create_all_data(kuniri.get_parser())
|
|
48
55
|
end
|
|
49
56
|
|
|
50
57
|
end.parse!
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
def startParser
|
|
60
|
+
puts "Exporting ..."
|
|
61
|
+
unless (@options[:output])
|
|
62
|
+
@options[:output] = 'outputKuniri/'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
kuniri = Kuniri::Kuniri.new
|
|
66
|
+
kuniri.set_configuration(@options[:source], @options[:languageType],
|
|
67
|
+
@options[:output], @options[:optimization])
|
|
68
|
+
kuniri.run_analysis
|
|
69
|
+
|
|
70
|
+
parser = Parser::XMLOutputFormat.new
|
|
71
|
+
parser.set_path(@options[:output])
|
|
72
|
+
parser.create_all_data(kuniri.get_parser())
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
if @options[:source] && @options[:output]
|
|
76
|
+
startParser
|
|
77
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
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 {LANG}
|
|
8
|
+
|
|
9
|
+
# {LANG} handling aggregation
|
|
10
|
+
class Aggregation{LANG} < Languages::Aggregation
|
|
11
|
+
|
|
12
|
+
public
|
|
13
|
+
|
|
14
|
+
# @param pLine Verify if line has a {LANG} aggregation.
|
|
15
|
+
# @return Return string or nil.
|
|
16
|
+
def get_aggregation(pLine)
|
|
17
|
+
# YOUR CODE HERE
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
# Override
|
|
23
|
+
def detect_aggregation(pLine)
|
|
24
|
+
# YOUR CODE HERE
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#Class
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# {LANG}
|
|
31
|
+
end
|
|
32
|
+
#Language
|
|
33
|
+
end
|
data/data/attribute_lang.rb
CHANGED
|
@@ -1,127 +1,54 @@
|
|
|
1
|
-
require_relative '../abstract_container/structured_and_oo/attribute
|
|
2
|
-
require_relative '../container_data/structured_and_oo/attribute_data
|
|
3
|
-
require_relative '../../util/html_logger'
|
|
1
|
+
require_relative '../abstract_container/structured_and_oo/attribute'
|
|
2
|
+
require_relative '../container_data/structured_and_oo/attribute_data'
|
|
4
3
|
require_relative '../../core/setting'
|
|
5
4
|
|
|
6
5
|
module Languages
|
|
7
|
-
|
|
6
|
+
|
|
8
7
|
module {LANG}
|
|
9
8
|
|
|
10
|
-
#
|
|
9
|
+
# Handling {LANG} attributes
|
|
11
10
|
class Attribute{LANG} < Languages::Attribute
|
|
12
11
|
|
|
13
12
|
public
|
|
14
13
|
|
|
15
14
|
def initialize
|
|
16
|
-
|
|
17
|
-
@attributeList = []
|
|
15
|
+
# YOUR CODE HERE
|
|
18
16
|
end
|
|
19
17
|
|
|
18
|
+
# Get {LANG} attribute.
|
|
19
|
+
# @param pLine Verify if line has a {LANG} attribute.
|
|
20
|
+
# @return Return AttributeData or nil.
|
|
20
21
|
def get_attribute(pLine)
|
|
21
|
-
|
|
22
|
-
return nil unless result
|
|
23
|
-
|
|
24
|
-
@log.write_log("Info: Prepare to get attribute.")
|
|
25
|
-
|
|
26
|
-
listOfAttributes = []
|
|
27
|
-
|
|
28
|
-
# Has comma? Split string by comma
|
|
29
|
-
result = remove_unnecessary_information(result)
|
|
30
|
-
|
|
31
|
-
# Separated by comma, equal or the common case
|
|
32
|
-
if result.scan(/,/).count >= 1
|
|
33
|
-
listOfAttributes = handle_multiple_declaration_with_comma(result)
|
|
34
|
-
@log.write_log("Debug: Declared with comma: #{listOfAttributes}")
|
|
35
|
-
elsif result.scan(/=/).count > 1
|
|
36
|
-
listOfAttributes = handle_multiple_declaration_with_equal(result)
|
|
37
|
-
@log.write_log("Debug: separed by comma: #{listOfAttributes}")
|
|
38
|
-
else
|
|
39
|
-
listOfAttributes = handle_line_declaration(result)
|
|
40
|
-
@log.write_log("Debug: One line declaration #{listOfAttributes}")
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
return listOfAttributes
|
|
22
|
+
# YOUR CODE HERE
|
|
44
23
|
end
|
|
45
24
|
|
|
46
25
|
protected
|
|
47
26
|
|
|
48
27
|
# Override
|
|
49
28
|
def detect_attribute(pLine)
|
|
50
|
-
|
|
51
|
-
return nil unless pLine =~ regexExp
|
|
52
|
-
return pLine.scan(regexExp)[0].join("")
|
|
29
|
+
# YOUR CODE HERE
|
|
53
30
|
end
|
|
54
31
|
|
|
55
32
|
# Override
|
|
56
33
|
def remove_unnecessary_information(pString)
|
|
57
|
-
|
|
58
|
-
return pString
|
|
34
|
+
# YOUR CODE HERE
|
|
59
35
|
end
|
|
60
36
|
|
|
61
37
|
# Override
|
|
62
38
|
def prepare_final_string(pString)
|
|
63
|
-
|
|
64
|
-
return pString.gsub!(/\s+|:|@|=/,"")
|
|
65
|
-
end
|
|
66
|
-
return pString
|
|
39
|
+
# YOUR CODE HERE
|
|
67
40
|
end
|
|
68
41
|
|
|
69
42
|
# Override
|
|
70
43
|
def handle_multiple_declaration_with_comma(pString)
|
|
71
|
-
|
|
72
|
-
pString = pString.split(",")
|
|
73
|
-
pString.each do |variable|
|
|
74
|
-
return nil if variable.scan(/=/).count > 1
|
|
75
|
-
|
|
76
|
-
variable = variable.scan(/.*=/).join("") if variable =~ /.*=/
|
|
77
|
-
|
|
78
|
-
return nil if variable =~ /\./
|
|
79
|
-
|
|
80
|
-
variable = prepare_final_string(variable)
|
|
81
|
-
attribute = Languages::AttributeData.new(variable)
|
|
82
|
-
listOfAttributes.push(attribute)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
return listOfAttributes
|
|
44
|
+
# YOUR CODE HERE
|
|
86
45
|
end
|
|
87
46
|
|
|
88
47
|
# Override
|
|
89
48
|
def handle_multiple_declaration_with_equal(pString)
|
|
90
|
-
|
|
91
|
-
pString = pString.split("=")
|
|
92
|
-
pString.each do |variable|
|
|
93
|
-
return nil if variable =~ /\./
|
|
94
|
-
|
|
95
|
-
variable = prepare_final_string(variable)
|
|
96
|
-
attribute = Languages::AttributeData.new(variable)
|
|
97
|
-
listOfAttributes.push(attribute)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
return listOfAttributes
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
# Override
|
|
104
|
-
def handle_line_declaration(pString)
|
|
105
|
-
listOfAttributes = []
|
|
106
|
-
if pString =~ /=/
|
|
107
|
-
pString = pString.scan(/.*=/).join("")
|
|
108
|
-
return nil if pString =~ /\./
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
return nil if pString =~ /\./
|
|
112
|
-
|
|
113
|
-
pString = prepare_final_string(pString)
|
|
114
|
-
attribute = Languages::AttributeData.new(pString)
|
|
115
|
-
listOfAttributes.push(attribute)
|
|
116
|
-
|
|
117
|
-
return listOfAttributes
|
|
49
|
+
# YOUR CODE HERE
|
|
118
50
|
end
|
|
119
51
|
|
|
120
|
-
private
|
|
121
|
-
|
|
122
|
-
@log
|
|
123
|
-
@attributeList
|
|
124
|
-
|
|
125
52
|
#Class
|
|
126
53
|
end
|
|
127
54
|
|