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.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +43 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +18 -0
  5. data/.yardopts +1 -0
  6. data/COPYING +661 -0
  7. data/Gemfile +14 -0
  8. data/Guardfile +8 -0
  9. data/README.md +102 -0
  10. data/Rakefile +114 -0
  11. data/bin/kuniri +53 -0
  12. data/data/attribute_lang.rb +131 -0
  13. data/data/class_lang.rb +77 -0
  14. data/data/conditional_lang.rb +71 -0
  15. data/data/constructor_lang.rb +34 -0
  16. data/data/end_block_lang.rb +30 -0
  17. data/data/extern_requirement_lang.rb +45 -0
  18. data/data/function_behavior_lang.rb +113 -0
  19. data/data/lang_syntax.rb +111 -0
  20. data/data/module_namespace_lang.rb +43 -0
  21. data/data/repetition_lang.rb +62 -0
  22. data/data/token_lang.rb +55 -0
  23. data/data/variable_global_lang.rb +118 -0
  24. data/kuniri.gemspec +24 -0
  25. data/lib/kuniri/core/configuration/language_available.rb +7 -0
  26. data/lib/kuniri/core/configuration/log_available.rb +7 -0
  27. data/lib/kuniri/core/configuration/monitor_available.rb +13 -0
  28. data/lib/kuniri/core/kuniri.rb +78 -0
  29. data/lib/kuniri/core/setting.rb +143 -0
  30. data/lib/kuniri/error/configuration_file_error.rb +12 -0
  31. data/lib/kuniri/error/language_error.rb +12 -0
  32. data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +73 -0
  33. data/lib/kuniri/language/abstract_container/structured_and_oo/class.rb +51 -0
  34. data/lib/kuniri/language/abstract_container/structured_and_oo/comment.rb +57 -0
  35. data/lib/kuniri/language/abstract_container/structured_and_oo/conditional.rb +42 -0
  36. data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +52 -0
  37. data/lib/kuniri/language/abstract_container/structured_and_oo/end_block.rb +27 -0
  38. data/lib/kuniri/language/abstract_container/structured_and_oo/extern_requirement.rb +36 -0
  39. data/lib/kuniri/language/abstract_container/structured_and_oo/function_behavior.rb +55 -0
  40. data/lib/kuniri/language/abstract_container/structured_and_oo/module_namespace.rb +36 -0
  41. data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +42 -0
  42. data/lib/kuniri/language/abstract_container/structured_and_oo/variable_behaviour.rb +53 -0
  43. data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +67 -0
  44. data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +26 -0
  45. data/lib/kuniri/language/container_data/structured_and_oo/basic_data.rb +18 -0
  46. data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +77 -0
  47. data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +23 -0
  48. data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +18 -0
  49. data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +26 -0
  50. data/lib/kuniri/language/container_data/structured_and_oo/file_element.rb +77 -0
  51. data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +52 -0
  52. data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +21 -0
  53. data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +20 -0
  54. data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +18 -0
  55. data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +23 -0
  56. data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +22 -0
  57. data/lib/kuniri/language/language.rb +222 -0
  58. data/lib/kuniri/language/language_factory.rb +48 -0
  59. data/lib/kuniri/language/ruby/attribute_ruby.rb +134 -0
  60. data/lib/kuniri/language/ruby/class_ruby.rb +83 -0
  61. data/lib/kuniri/language/ruby/comment_ruby.rb +84 -0
  62. data/lib/kuniri/language/ruby/conditional_ruby.rb +77 -0
  63. data/lib/kuniri/language/ruby/constructor_ruby.rb +36 -0
  64. data/lib/kuniri/language/ruby/end_block_ruby.rb +33 -0
  65. data/lib/kuniri/language/ruby/extern_requirement_ruby.rb +49 -0
  66. data/lib/kuniri/language/ruby/function_behavior_ruby.rb +120 -0
  67. data/lib/kuniri/language/ruby/module_namespace_ruby.rb +47 -0
  68. data/lib/kuniri/language/ruby/repetition_ruby.rb +68 -0
  69. data/lib/kuniri/language/ruby/ruby_syntax.rb +117 -0
  70. data/lib/kuniri/language/ruby/token_ruby.rb +59 -0
  71. data/lib/kuniri/language/ruby/variable_behaviour_ruby.rb +83 -0
  72. data/lib/kuniri/language/ruby/variable_global_ruby.rb +123 -0
  73. data/lib/kuniri/parser/parser.rb +45 -0
  74. data/lib/kuniri/parser/parser_xml.rb +128 -0
  75. data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +51 -0
  76. data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +94 -0
  77. data/lib/kuniri/state_machine/OO_structured_fsm/comment_state.rb +76 -0
  78. data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +92 -0
  79. data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +71 -0
  80. data/lib/kuniri/state_machine/OO_structured_fsm/function_state.rb +82 -0
  81. data/lib/kuniri/state_machine/OO_structured_fsm/idle_state.rb +80 -0
  82. data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +59 -0
  83. data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +69 -0
  84. data/lib/kuniri/state_machine/OO_structured_fsm/module_state.rb +79 -0
  85. data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +92 -0
  86. data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +85 -0
  87. data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +8 -0
  88. data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +49 -0
  89. data/lib/kuniri/util/html_logger.rb +41 -0
  90. data/lib/kuniri/util/logger.rb +34 -0
  91. data/lib/kuniri/util/txt_logger.rb +29 -0
  92. data/lib/kuniri/version.rb +3 -0
  93. data/lib/kuniri.rb +5 -0
  94. data/other/analyseFile.asta +0 -0
  95. data/spec/core/kuniri_spec.rb +14 -0
  96. data/spec/core/setting_spec.rb +114 -0
  97. data/spec/language/abstract_container/attribute_spec.rb +13 -0
  98. data/spec/language/abstract_container/class_spec.rb +13 -0
  99. data/spec/language/abstract_container/comment_spec.rb +31 -0
  100. data/spec/language/abstract_container/conditional_spec.rb +13 -0
  101. data/spec/language/abstract_container/constructor_spec.rb +13 -0
  102. data/spec/language/abstract_container/end_block_spec.rb +14 -0
  103. data/spec/language/abstract_container/module_namespace_spec.rb +13 -0
  104. data/spec/language/abstract_container/repetition_spec.rb +13 -0
  105. data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +32 -0
  106. data/spec/language/container_data/structured_and_oo/class_data_spec.rb +121 -0
  107. data/spec/language/container_data/structured_and_oo/conditional_data_spec.rb +34 -0
  108. data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +46 -0
  109. data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +26 -0
  110. data/spec/language/container_data/structured_and_oo/file_element_spec.rb +91 -0
  111. data/spec/language/container_data/structured_and_oo/function_data_spec.rb +22 -0
  112. data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +20 -0
  113. data/spec/language/container_data/structured_and_oo/repetition_data_spec.rb +34 -0
  114. data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +39 -0
  115. data/spec/language/language_factory_spec.rb +64 -0
  116. data/spec/language/language_spec.rb +74 -0
  117. data/spec/language/ruby/attribute_ruby_spec.rb +126 -0
  118. data/spec/language/ruby/class_ruby_spec.rb +102 -0
  119. data/spec/language/ruby/comment_ruby_spec.rb +78 -0
  120. data/spec/language/ruby/conditional_ruby_spec.rb +106 -0
  121. data/spec/language/ruby/constructor_ruby_spec.rb +57 -0
  122. data/spec/language/ruby/end_block_ruby_spec.rb +62 -0
  123. data/spec/language/ruby/function_behavior_ruby_spec.rb +246 -0
  124. data/spec/language/ruby/module_namespace_ruby_spec.rb +55 -0
  125. data/spec/language/ruby/repetition_ruby_spec.rb +33 -0
  126. data/spec/language/ruby/ruby_syntax_spec.rb +482 -0
  127. data/spec/language/ruby/variable_ruby_spec.rb +134 -0
  128. data/spec/parser/parser_spec.rb +25 -0
  129. data/spec/samples/rubySyntaxParts/attribute/simpleAttribute.rb +15 -0
  130. data/spec/samples/rubySyntaxParts/class/simpleClass.rb +19 -0
  131. data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +33 -0
  132. data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_global.rb +20 -0
  133. data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +23 -0
  134. data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_global.rb +16 -0
  135. data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +28 -0
  136. data/spec/samples/rubySyntaxParts/conditionalStatment/methodConditional.rb +42 -0
  137. data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +0 -0
  138. data/spec/samples/rubySyntaxParts/conditionalStatment/simpleConditional.rb +43 -0
  139. data/spec/samples/rubySyntaxParts/constructor/simpleConstructor.rb +27 -0
  140. data/spec/samples/rubySyntaxParts/extern/multipleLineExternRequirement.rb +0 -0
  141. data/spec/samples/rubySyntaxParts/extern/requireRelative.rb +6 -0
  142. data/spec/samples/rubySyntaxParts/extern/simpleExternRequirement.rb +14 -0
  143. data/spec/samples/rubySyntaxParts/fullCode/simpleCodeWithConditional.rb +18 -0
  144. data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +19 -0
  145. data/spec/samples/rubySyntaxParts/function/simpleFunction.rb +29 -0
  146. data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +13 -0
  147. data/spec/samples/rubySyntaxParts/module/simpleModule.rb +12 -0
  148. data/spec/samples/rubySyntaxParts/repetition/simpleRepetition.rb +28 -0
  149. data/spec/samples/rubySyntaxParts/variable/simpleVariable.rb +13 -0
  150. data/spec/spec_helper.rb +20 -0
  151. data/spec/state_machine/OO_structured_fsm/attribute_state_spec.rb +44 -0
  152. data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +90 -0
  153. data/spec/state_machine/OO_structured_fsm/comment_state_spec.rb +30 -0
  154. data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +83 -0
  155. data/spec/state_machine/OO_structured_fsm/constructor_state_spec.rb +48 -0
  156. data/spec/state_machine/OO_structured_fsm/function_state_spec.rb +41 -0
  157. data/spec/state_machine/OO_structured_fsm/idle_state_spec.rb +101 -0
  158. data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +62 -0
  159. data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +42 -0
  160. data/spec/state_machine/OO_structured_fsm/module_state_spec.rb +54 -0
  161. data/spec/state_machine/OO_structured_fsm/oo_structured_state_spec.rb +0 -0
  162. data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +83 -0
  163. data/spec/state_machine/OO_structured_fsm/variable_state_spec.rb +40 -0
  164. data/spec/util/html_logger_spec.rb +31 -0
  165. data/spec/util/logger_spec.rb +20 -0
  166. data/spec/util/txt_logger_spec.rb +31 -0
  167. metadata +326 -0
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # Guardfile
2
+ guard 'rspec', cmd: "bundle exec rspec", :all_after_pass => false,
3
+ :failed_mode => :none do
4
+ watch(%r{\Aspec/.+_spec\.rb\z})
5
+ watch(%r{\Aapp/(.+)\.rb\z}) { |m| "spec/app/#{m[1]}_spec.rb" }
6
+ watch('spec/spec_helper.rb') { "spec" }
7
+ end
8
+
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # KUNIRI
2
+
3
+ ![alt text](https://github.com/kuniri/kuniri/wiki/logo/256px/with_round_border.png "Kuniri")
4
+
5
+ ----
6
+
7
+ [![Join the chat at https://gitter.im/rodrigosiqueira/kuniri](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rodrigosiqueira/kuniri?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
+
9
+ [![Build Status](https://travis-ci.org/Kuniri/kuniri.svg?branch=master)](https://travis-ci.org/Kuniri/kuniri)
10
+ [![Code Climate](https://codeclimate.com/github/Kuniri/kuniri/badges/gpa.svg)](https://codeclimate.com/github/Kuniri/kuniri)
11
+ [![Stories in Ready](https://badge.waffle.io/Kuniri/kuniri.svg?label=ready&title=Ready)](http://waffle.io/Kuniri/kuniri)
12
+ [![Coverage Status](https://coveralls.io/repos/Kuniri/kuniri/badge.svg?branch=master&service=github)](https://coveralls.io/github/Kuniri/kuniri?branch=master)
13
+ [![Inline docs](http://inch-ci.org/github/Kuniri/kuniri.svg?branch=master)](http://inch-ci.org/github/Kuniri/kuniri)
14
+ [![License](https://img.shields.io/badge/license-GPLv3-green.svg)](https://github.com/Kuniri/kuniri/blob/master/COPYING)
15
+
16
+ ----
17
+ # What is Kuniri?
18
+
19
+ > Briefly, the main goal of Kuniri is: parse any kind of language, and generate
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,
22
+ documentation, and so forth. Initially, the main objective of Kuniri was to
23
+ provide a way to dynamically generate diagrams and traceability based on code.
24
+ However, the parser proved much more useful for many other kinds of
25
+ applications; thus, the focus shifted to the parser creation.
26
+
27
+ > Kuniri will inspect the source code, and extract information to generate a
28
+ final output. This file is a XML file (and other types in the near future), and
29
+ follows a strong pattern. This feature gives flexibility to other tools read the
30
+ file and process anything they want.
31
+
32
+ > Additionally, Kuniri was designed to grow to two main directions: support for
33
+ different languages, and provide ways to select which kind of information to
34
+ extract from the code.
35
+
36
+ ----
37
+ ## What is the the meaning of "kuniri"?
38
+
39
+ > Kuniri is an Esperanto word, that means "go with" or "follow". This name was
40
+ chosen because of the idea to keep following your code project with diagrams,
41
+ traceability, code quality and others.
42
+
43
+ ----
44
+ # Development
45
+
46
+ * System Dependencies (Kubuntu/Ubuntu)
47
+ * YARD 0.8
48
+ * RSpec 3.1.7
49
+ * Rake 10.4
50
+ * Guard-rspec 4.2
51
+ * nokogiri 1.6.6
52
+ * Ruby version: 2.1
53
+ * Run test suit
54
+ * rake or spec
55
+ * YARD documentation
56
+ * yardoc
57
+
58
+ ----
59
+ # Install
60
+
61
+ First of all, you have to install all the required gems.
62
+ ```
63
+ bundle install
64
+ ```
65
+
66
+ Kuniri can be installed with:
67
+ ```
68
+ rake install
69
+ ```
70
+
71
+ After installing you can check the commands with
72
+ ```
73
+ kuniri -h
74
+ ```
75
+
76
+ ----
77
+ # How to use
78
+ If you want to use kuniri in your project, first you have to create ".kuniri"
79
+ file. The example below show the basic syntax:
80
+
81
+ ```
82
+ language:ruby
83
+ source:lib/
84
+ output:bin/
85
+ extract:uml
86
+ ```
87
+
88
+ Finally, you can run Kuniri in your project and extract the information with:
89
+
90
+ ```
91
+ kuniri -e [file_name_output.xml]
92
+ ```
93
+
94
+ -e means "extract mode". After you entered into iterative mode you can type:
95
+
96
+ ----
97
+ # Author
98
+
99
+ * Rodrigo Siqueira de Melo
100
+ * rodrigosiqueiramelo@gmail.com
101
+ * Gustavo Jaruga
102
+ * darksshades@hotmail.com
data/Rakefile ADDED
@@ -0,0 +1,114 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ require 'optparse'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ # If you want to make this the default task
8
+ task :default => :spec
9
+
10
+ namespace :parser do |args|
11
+ desc 'Creates a new parser for kuniri with parser:create'
12
+ task :create do
13
+ options = {}
14
+ OptionParser.new(args) do |opts|
15
+ opts.banner = "Usage: rake user:create [parser_name]"
16
+ end.parse!
17
+
18
+ if ARGV.length <= 1 then
19
+ puts 'Must use pass a parser name'
20
+ exit 0
21
+ end
22
+ parsername = ARGV[1]
23
+
24
+ if File.directory?("lib/kuniri/language/#{parsername.downcase}") then
25
+ puts "Error: A folder for this parser code already exists at lib/kuniri/language/#{parsername.downcase}"
26
+ exit 1
27
+ end
28
+
29
+ FileUtils.mkdir_p("lib/kuniri/language/#{parsername.downcase}")
30
+ Dir.glob( 'data/*.rb' ).select { |f| File.file?( f ) }.each do |f|
31
+ fdest = File.basename(f).gsub('lang', parsername.downcase)
32
+ dest = "lib/kuniri/language/#{parsername.downcase}/#{fdest}"
33
+ FileUtils.cp( f, dest )
34
+ p dest
35
+ end
36
+
37
+ Dir.glob( "lib/kuniri/language/#{parsername.downcase}/*.rb" ).select { |f| File.file?( f ) }.each do |f|
38
+ text = File.read(f)
39
+ formated_text = text.gsub('{LANG}', parsername.capitalize)
40
+ formated_text = formated_text.gsub('{lang}', parsername.downcase)
41
+ File.open(f, "w") { |file| file << formated_text }
42
+ end
43
+
44
+ f = 'lib/kuniri/language/language_factory.rb'
45
+ text = File.read(f)
46
+ relative = "require_relative '#{parsername.downcase}/#{parsername.downcase}_syntax'"
47
+
48
+ if text.include?(relative) then
49
+ puts "Error: the /lib/kuniri/language/language_factory.rb file already has the require for this parser"
50
+ exit 1
51
+ end
52
+
53
+ formated_text = relative + "\n" + text
54
+
55
+ condition = "pType.downcase!
56
+
57
+ if pType == '#{parsername.downcase}'
58
+ return Languages::#{parsername.capitalize}Syntax.new
59
+ end"
60
+
61
+ formated_text = formated_text.gsub("pType.downcase!\n", condition)
62
+ File.open(f, "w") { |file| file << formated_text }
63
+
64
+ exit 0
65
+ # End task parser:create
66
+ end
67
+
68
+ desc 'Removes a parser for kuniri with parser:remove'
69
+ task :remove do
70
+ options = {}
71
+ OptionParser.new(args) do |opts|
72
+ opts.banner = "Usage: rake user:remove [parser_name]"
73
+ end.parse!
74
+
75
+ if ARGV.length <= 1 then
76
+ puts 'Must use pass a parser name'
77
+ exit 0
78
+ end
79
+ parsername = ARGV[1]
80
+
81
+ input = ''
82
+ STDOUT.puts "This operation will delete all code related to the #{parsername} parser, are you sure(y/n)?"
83
+ input = STDIN.gets.chomp
84
+ exit 0 unless input.downcase == "y" or input.downcase == "yes"
85
+
86
+ if !File.directory?("lib/kuniri/language/#{parsername.downcase}") then
87
+ puts "Error: A folder for this parser code does not exists at lib/kuniri/language/#{parsername.downcase}"
88
+ exit 1
89
+ end
90
+
91
+ FileUtils.rm_rf("lib/kuniri/language/#{parsername.downcase}")
92
+
93
+ f = 'lib/kuniri/language/language_factory.rb'
94
+ text = File.read(f)
95
+ relative = "require_relative '#{parsername.downcase}/#{parsername.downcase}_syntax'\n"
96
+
97
+ if not text.include?(relative) then
98
+ puts "Warning: the /lib/kuniri/language/language_factory.rb file could not found the require for this parser"
99
+ end
100
+
101
+ formated_text = text.gsub(relative,'')
102
+
103
+ condition = "\n if pType == '#{parsername.downcase}'
104
+ return Languages::#{parsername.capitalize}Syntax.new
105
+ end"
106
+
107
+ formated_text = formated_text.gsub(condition, '')
108
+ File.open(f, "w") { |file| file << formated_text }
109
+ exit 0
110
+
111
+ # End task parser:remove
112
+ end
113
+ end
114
+
data/bin/kuniri ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'kuniri'
4
+ require 'optparse'
5
+ require 'kuniri/core/kuniri'
6
+ require 'kuniri/parser/parser_xml'
7
+
8
+ options = {}
9
+
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: example.rb [options]"
12
+ opts.version = Kuniri::VERSION
13
+
14
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
15
+ options[:verbose] = v
16
+ end
17
+
18
+ opts.on("--version", "Show Kuniri version") do |v|
19
+ puts opts.ver
20
+ exit
21
+ end
22
+
23
+ opts.on("-i", "Iterative mode") do |v|
24
+ puts "Iterative mode..."
25
+ kuniri = Kuniri::Kuniri.new
26
+ kuniri.run_analysis
27
+ kuniri.start_navigation_mode
28
+ end
29
+
30
+ opts.on("-p", "Parse project") do |v|
31
+ puts "PARSER..."
32
+ end
33
+
34
+ opts.on("-e", "--export [FILENAME]", "Export XML") do |f|
35
+ puts "Exporting XML..."
36
+ if(f)
37
+ options[:filename] = f
38
+ else
39
+ options[:filename] = 'kuniri.xml'
40
+ end
41
+
42
+ kuniri = Kuniri::Kuniri.new
43
+ kuniri.run_analysis
44
+
45
+ parser = Parser::XML.new
46
+ parser.set_path(options[:filename])
47
+ parser.create_all_data kuniri.get_parser()
48
+ end
49
+
50
+ end.parse!
51
+
52
+ p options
53
+ p ARGV
@@ -0,0 +1,131 @@
1
+ require_relative '../abstract_container/structured_and_oo/attribute.rb'
2
+ require_relative '../container_data/structured_and_oo/attribute_data.rb'
3
+ require_relative '../../util/html_logger'
4
+ require_relative '../../core/setting'
5
+
6
+ module Languages
7
+ # @module {LANG} Handling {LANG} attributes
8
+ module {LANG}
9
+
10
+ # Handle {LANG} attribute
11
+ class Attribute{LANG} < Languages::Attribute
12
+
13
+ public
14
+
15
+ def initialize
16
+ @log = @settings = Kuniri::Setting.create.log
17
+ @attributeList = []
18
+ end
19
+
20
+ def get_attribute(pLine)
21
+ result = detect_attribute(pLine)
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
44
+ end
45
+
46
+ protected
47
+
48
+ # Override
49
+ def detect_attribute(pLine)
50
+ regexExp = /^\s*(?:@|attr_(?:accessor|read|write))(.*)$/
51
+ return nil unless pLine =~ regexExp
52
+ return pLine.scan(regexExp)[0].join("")
53
+ end
54
+
55
+ # Override
56
+ def remove_unnecessary_information(pString)
57
+ return pString.gsub!(/\(.*\)/,"") if pString =~ /\(.*\)/
58
+ return pString
59
+ end
60
+
61
+ # Override
62
+ def prepare_final_string(pString)
63
+ if pString =~ /\s+|:|@|=/
64
+ return pString.gsub!(/\s+|:|@|=/,"")
65
+ end
66
+ return pString
67
+ end
68
+
69
+ # Override
70
+ def handle_multiple_declaration_with_comma(pString)
71
+ listOfAttributes = []
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
86
+ end
87
+
88
+ # Override
89
+ def handle_multiple_declaration_with_equal(pString)
90
+ listOfAttributes = []
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
118
+ end
119
+
120
+ private
121
+
122
+ @log
123
+ @attributeList
124
+
125
+ #Class
126
+ end
127
+
128
+ # {LANG}
129
+ end
130
+ #Language
131
+ end
@@ -0,0 +1,77 @@
1
+ require_relative '../abstract_container/structured_and_oo/class.rb'
2
+ require_relative '../container_data/structured_and_oo/class_data.rb'
3
+ require_relative '../../util/html_logger'
4
+ require_relative '../../core/setting'
5
+
6
+ module Languages
7
+
8
+ module {LANG}
9
+
10
+ class Class{LANG} < Languages::Class
11
+
12
+ public
13
+
14
+ def initialize
15
+ @log = @settings = Kuniri::Setting.create.log
16
+ end
17
+
18
+ def get_class(pLine)
19
+ result = detect_class(pLine)
20
+ return nil unless result
21
+
22
+ @log.write_log("Info: Detect class")
23
+
24
+ classCaptured = Languages::ClassData.new
25
+
26
+ inheritance = get_inheritance(result)
27
+ classCaptured.inheritances = inheritance if inheritance
28
+
29
+ result = prepare_final_string(result)
30
+ classCaptured.name = result
31
+
32
+ @log.write_log("Debug: Class: #{classCaptured.name}")
33
+
34
+ return classCaptured
35
+ end
36
+
37
+ protected
38
+
39
+ def detect_class(pLine)
40
+ regexExpression = /^\s*class\s+(.*)/
41
+ return nil unless pLine =~ regexExpression
42
+ return pLine.scan(regexExpression)[0].join("")
43
+ end
44
+
45
+ def get_inheritance(pString)
46
+ if pString =~ /</
47
+ partial = pString.scan(/<(.*)/)
48
+ return remove_unnecessary_information(partial)
49
+ end
50
+ return nil
51
+ end
52
+
53
+ def remove_unnecessary_information(pString)
54
+ return pString.gsub(/\s|</, "") if pString =~ /\s|</
55
+ return pString
56
+ end
57
+
58
+ def prepare_final_string(pString)
59
+ if pString =~ /\s|</
60
+ partial = pString.gsub(/<.*/,"")
61
+ return remove_unnecessary_information(partial)
62
+ end
63
+ return pString
64
+ end
65
+
66
+ private
67
+
68
+ @log
69
+
70
+ # class
71
+ end
72
+
73
+ # {LANG}
74
+ end
75
+
76
+ # Languages
77
+ end
@@ -0,0 +1,71 @@
1
+ require_relative '../abstract_container/structured_and_oo/conditional.rb'
2
+ require_relative '../container_data/structured_and_oo/conditional_data.rb'
3
+
4
+ module Languages
5
+
6
+ module {LANG}
7
+
8
+ class Conditional{LANG} < Languages::Conditional
9
+
10
+ public
11
+
12
+ def get_conditional(pLine)
13
+ result = detect_conditional(pLine)
14
+ return nil unless result
15
+
16
+ conditionalCaptured = Languages::ConditionalData.new
17
+ conditionalCaptured.type = conditional_type(pLine)
18
+
19
+ conditionalCaptured.expression = get_expression(result)
20
+
21
+ return conditionalCaptured
22
+ end
23
+
24
+ protected
25
+
26
+ def detect_conditional(pLine)
27
+ regexExp = /^\s*if\s+(.*)/
28
+ return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
29
+
30
+ regexExp = /^\s*case\s+(.*)/
31
+ return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
32
+
33
+ regexExp = /^\s*unless\s+(.*)/
34
+ return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
35
+
36
+ regexExp = /^\s*elsif\s+(.*)/
37
+ return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
38
+
39
+ return nil
40
+ end
41
+
42
+ def conditional_type(pString)
43
+ regexExp = /^\s+if|^if/
44
+ return "IF" if regexExp =~ pString
45
+
46
+ regexExp = /^\s+case|^case/
47
+ return "CASE" if regexExp =~ pString
48
+
49
+ regexExp = /^\s+unless|^unless/
50
+ return "UNLESS" if regexExp =~ pString
51
+
52
+ regexExp = /^\s+elsif|^elsif/
53
+ return "ELSIF" if regexExp =~ pString
54
+
55
+ return nil
56
+ end
57
+
58
+ def get_expression(pString)
59
+ leftStrip = pString.lstrip
60
+ rightStrip = leftStrip.rstrip
61
+ return rightStrip
62
+ end
63
+
64
+ # Class
65
+ end
66
+
67
+ # {LANG}
68
+ end
69
+
70
+ # Module
71
+ end
@@ -0,0 +1,34 @@
1
+ require_relative '../abstract_container/structured_and_oo/constructor'
2
+ require_relative '../container_data/structured_and_oo/constructor_data'
3
+ require_relative 'function_behavior_{lang}'
4
+
5
+ module Languages
6
+
7
+ module {LANG}
8
+
9
+ # Handling {LANG} constructor
10
+ class ConstructorRuby < Languages::{LANG}::FunctionBehavior{LANG}
11
+
12
+ public
13
+
14
+ def get_constructor(pLine, type = 'public')
15
+ result = get_function(pLine)
16
+ return nil unless result
17
+
18
+ if result.name =~ /initialize/
19
+ result.type = "CONSTRUCTOR"
20
+ else
21
+ return nil
22
+ end
23
+
24
+ return result
25
+ end
26
+
27
+ # Class
28
+ end
29
+
30
+ # {LANG}
31
+ end
32
+
33
+ # Language
34
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '../abstract_container/structured_and_oo/end_block'
2
+
3
+ module Languages
4
+
5
+ module {LANG}
6
+
7
+ class EndBlockRuby < Languages::EndBlock
8
+
9
+ public
10
+
11
+ def has_end_of_block?(pLine)
12
+ return detect_end(pLine)
13
+ end
14
+
15
+ protected
16
+
17
+ def detect_end(pLine)
18
+ #TODO: EXTREMELY SIMPLE HANDLING, IT HAVE TO BE IMPROVED!
19
+ return true if pLine =~ /^\s+end|^end/
20
+ return false
21
+ end
22
+
23
+ # Class
24
+ end
25
+
26
+ # {LANG}
27
+ end
28
+
29
+ # Module
30
+ end
@@ -0,0 +1,45 @@
1
+ require_relative '../abstract_container/structured_and_oo/extern_requirement'
2
+ require_relative '../container_data/structured_and_oo/extern_requirement_data'
3
+
4
+ module Languages
5
+
6
+ module {LANG}
7
+
8
+ # @class ExternRequirement Handling extern requirements.
9
+ class ExternRequirement{LANG} < Languages::ExternRequirement
10
+
11
+ public
12
+
13
+ def get_requirement(pLine)
14
+ detectExpression = detect_extern_requirement(pLine)
15
+ return nil unless detectExpression
16
+
17
+ detectExpression = remove_unnecessary_information(detectExpression)
18
+ # @requirement = detectExpression
19
+ name = File.basename(detectExpression, ".*")
20
+ externReference = ExternRequirementData.new(name)
21
+ return externReference
22
+ end
23
+
24
+ protected
25
+
26
+ def detect_extern_requirement(pLine)
27
+ regexExpression = /^\s*require(?:_relative)?\s+('|")(.*)\1/
28
+ return nil unless pLine =~ regexExpression
29
+ return pLine.scan(regexExpression).join("")
30
+ end
31
+
32
+ def remove_unnecessary_information(pLine)
33
+ regexClean = /\s+|"|'/
34
+ return pLine.gsub!(regexClean, "") if pLine =~ regexClean
35
+ return pLine
36
+ end
37
+
38
+ # Class
39
+ end
40
+
41
+ # {LANG}
42
+ end
43
+
44
+ # Module
45
+ end