archruby 0.2.0 → 0.3.0
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/.travis.yml +3 -0
- data/README.md +1 -1
- data/Rakefile +46 -0
- data/TODO.rtf +20 -0
- data/architecture.yml +51 -0
- data/archruby.gemspec +3 -0
- data/bin/archruby +1 -0
- data/lib/archruby.rb +14 -2
- data/lib/archruby/architecture/architecture.rb +6 -6
- data/lib/archruby/architecture/config_definition.rb +13 -13
- data/lib/archruby/architecture/constraint_break.rb +1 -1
- data/lib/archruby/architecture/dependency.rb +3 -1
- data/lib/archruby/architecture/file_content.rb +2 -2
- data/lib/archruby/architecture/module_definition.rb +33 -20
- data/lib/archruby/architecture/parser.rb +25 -11
- data/lib/archruby/architecture/type_inference_checker.rb +29 -13
- data/lib/archruby/presenters/dsm.rb +163 -0
- data/lib/archruby/presenters/dsm/cell_dsm.rb +17 -0
- data/lib/archruby/presenters/dsm/dsm_css.css +77 -0
- data/lib/archruby/presenters/graph.rb +12 -9
- data/lib/archruby/ruby/parser.rb +131 -125
- data/lib/archruby/ruby/type_inference/dependency_organizer.rb +53 -0
- data/lib/archruby/ruby/type_inference/ruby/class_dependency.rb +22 -0
- data/lib/archruby/ruby/type_inference/ruby/internal_method_invocation.rb +20 -0
- data/lib/archruby/ruby/type_inference/ruby/method_definition.rb +20 -0
- data/lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb +537 -0
- data/lib/archruby/ruby/type_inference/ruby/process_method_arguments.rb +155 -0
- data/lib/archruby/ruby/type_inference/ruby/process_method_body.rb +427 -0
- data/lib/archruby/ruby/type_inference/ruby/process_method_params.rb +276 -0
- data/lib/archruby/ruby/type_inference/type_inference_checker.rb +126 -0
- data/lib/archruby/version.rb +1 -1
- data/spec/architecture/file_content_spec.rb +2 -1
- data/spec/architecture/module_definition_spec.rb +9 -9
- data/spec/dummy_app/lib/teste_class.rb +6 -0
- data/spec/ruby/type_inference/dependency_organizer_spec.rb +20 -0
- data/spec/ruby/type_inference/fixtures/homebrew_bottles_class.rb +139 -0
- data/spec/ruby/type_inference/fixtures/homebrew_brew_teste.rb +1323 -0
- data/spec/ruby/type_inference/fixtures/rails_action_view_class_teste.rb +89 -0
- data/spec/ruby/type_inference/fixtures/rails_active_record_class.rb +99 -0
- data/spec/ruby/type_inference/fixtures/rails_teste_active_record.rb +55 -0
- data/spec/ruby/type_inference/fixtures/teste2.rb +16 -0
- data/spec/ruby/type_inference/fixtures/teste_class_and_args.rb +49 -0
- data/spec/ruby/type_inference/fixtures/teste_class_and_args2.rb +11 -0
- data/spec/ruby/type_inference/parser_for_typeinference_spec.rb +69 -0
- data/spec/ruby/type_inference/type_inference_checker_spec.rb +47 -0
- metadata +84 -3
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'active_support/core_ext/module/attr_internal'
|
2
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
3
|
+
require 'active_support/ordered_options'
|
4
|
+
require 'action_view/log_subscriber'
|
5
|
+
require 'action_view/helpers'
|
6
|
+
require 'action_view/context'
|
7
|
+
require 'action_view/template'
|
8
|
+
require 'action_view/lookup_context'
|
9
|
+
|
10
|
+
module ActionView #:nodoc:
|
11
|
+
class Base
|
12
|
+
include Helpers, ::ERB::Util, Context
|
13
|
+
|
14
|
+
# Specify the proc used to decorate input tags that refer to attributes with errors.
|
15
|
+
cattr_accessor :field_error_proc
|
16
|
+
@@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
|
17
|
+
|
18
|
+
# How to complete the streaming when an exception occurs.
|
19
|
+
# This is our best guess: first try to close the attribute, then the tag.
|
20
|
+
cattr_accessor :streaming_completion_on_exception
|
21
|
+
@@streaming_completion_on_exception = %("><script>window.location = "/500.html"</script></html>)
|
22
|
+
|
23
|
+
# Specify whether rendering within namespaced controllers should prefix
|
24
|
+
# the partial paths for ActiveModel objects with the namespace.
|
25
|
+
# (e.g., an Admin::PostsController would render @post using /admin/posts/_post.erb)
|
26
|
+
cattr_accessor :prefix_partial_path_with_controller_namespace
|
27
|
+
@@prefix_partial_path_with_controller_namespace = true
|
28
|
+
|
29
|
+
# Specify default_formats that can be rendered.
|
30
|
+
cattr_accessor :default_formats
|
31
|
+
|
32
|
+
# Specify whether an error should be raised for missing translations
|
33
|
+
cattr_accessor :raise_on_missing_translations
|
34
|
+
@@raise_on_missing_translations = false
|
35
|
+
|
36
|
+
# Specify whether submit_tag should automatically disable on click
|
37
|
+
cattr_accessor :automatically_disable_submit_tag
|
38
|
+
@@automatically_disable_submit_tag = true
|
39
|
+
|
40
|
+
class_attribute :_routes
|
41
|
+
class_attribute :logger
|
42
|
+
|
43
|
+
class << self
|
44
|
+
delegate :erb_trim_mode=, :to => 'ActionView::Template::Handlers::ERB'
|
45
|
+
|
46
|
+
def cache_template_loading
|
47
|
+
ActionView::Resolver.caching?
|
48
|
+
end
|
49
|
+
|
50
|
+
def cache_template_loading=(value)
|
51
|
+
ActionView::Resolver.caching = value
|
52
|
+
end
|
53
|
+
|
54
|
+
def xss_safe? #:nodoc:
|
55
|
+
true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_accessor :view_renderer
|
60
|
+
attr_internal :config, :assigns
|
61
|
+
|
62
|
+
delegate :lookup_context, :to => :view_renderer
|
63
|
+
delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :to => :lookup_context
|
64
|
+
|
65
|
+
def assign(new_assigns) # :nodoc:
|
66
|
+
@_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
|
67
|
+
end
|
68
|
+
|
69
|
+
def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:nodoc:
|
70
|
+
@_config = ActiveSupport::InheritableOptions.new
|
71
|
+
|
72
|
+
if context.is_a?(ActionView::Renderer)
|
73
|
+
@view_renderer = context
|
74
|
+
else
|
75
|
+
lookup_context = context.is_a?(ActionView::LookupContext) ?
|
76
|
+
context : ActionView::LookupContext.new(context)
|
77
|
+
lookup_context.formats = formats if formats
|
78
|
+
lookup_context.prefixes = controller._prefixes if controller
|
79
|
+
@view_renderer = ActionView::Renderer.new(lookup_context)
|
80
|
+
end
|
81
|
+
|
82
|
+
assign(assigns)
|
83
|
+
assign_controller(controller)
|
84
|
+
_prepare_context
|
85
|
+
end
|
86
|
+
|
87
|
+
ActiveSupport.run_load_hooks(:action_view, self)
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'active_model/forbidden_attributes_protection'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module AttributeAssignment
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
include ActiveModel::AttributeAssignment
|
7
|
+
|
8
|
+
# Alias for `assign_attributes`. See +ActiveModel::AttributeAssignment+.
|
9
|
+
def attributes=(attributes)
|
10
|
+
assign_attributes(attributes)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def _assign_attributes(attributes) # :nodoc:
|
16
|
+
multi_parameter_attributes = {}
|
17
|
+
nested_parameter_attributes = {}
|
18
|
+
|
19
|
+
attributes.each do |k, v|
|
20
|
+
if k.include?("(")
|
21
|
+
multi_parameter_attributes[k] = attributes.delete(k)
|
22
|
+
elsif v.is_a?(Hash)
|
23
|
+
nested_parameter_attributes[k] = attributes.delete(k)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
super(attributes)
|
27
|
+
|
28
|
+
assign_nested_parameter_attributes(nested_parameter_attributes) unless nested_parameter_attributes.empty?
|
29
|
+
assign_multiparameter_attributes(multi_parameter_attributes) unless multi_parameter_attributes.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
# Tries to assign given value to given attribute.
|
33
|
+
# In case of an error, re-raises with the ActiveRecord constant.
|
34
|
+
def _assign_attribute(k, v) # :nodoc:
|
35
|
+
super
|
36
|
+
rescue ActiveModel::UnknownAttributeError
|
37
|
+
raise UnknownAttributeError.new(self, k)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Assign any deferred nested attributes after the base attributes have been set.
|
41
|
+
def assign_nested_parameter_attributes(pairs)
|
42
|
+
pairs.each { |k, v| _assign_attribute(k, v) }
|
43
|
+
end
|
44
|
+
|
45
|
+
# Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
|
46
|
+
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
|
47
|
+
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
|
48
|
+
# written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
|
49
|
+
# parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum and
|
50
|
+
# f for Float. If all the values for a given attribute are empty, the attribute will be set to +nil+.
|
51
|
+
def assign_multiparameter_attributes(pairs)
|
52
|
+
execute_callstack_for_multiparameter_attributes(
|
53
|
+
extract_callstack_for_multiparameter_attributes(pairs)
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute_callstack_for_multiparameter_attributes(callstack)
|
58
|
+
errors = []
|
59
|
+
callstack.each do |name, values_with_empty_parameters|
|
60
|
+
begin
|
61
|
+
if values_with_empty_parameters.each_value.all?(&:nil?)
|
62
|
+
values = nil
|
63
|
+
else
|
64
|
+
values = values_with_empty_parameters
|
65
|
+
end
|
66
|
+
send("#{name}=", values)
|
67
|
+
rescue => ex
|
68
|
+
errors << AttributeAssignmentError.new("error on assignment #{values_with_empty_parameters.values.inspect} to #{name} (#{ex.message})", ex, name)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
unless errors.empty?
|
72
|
+
error_descriptions = errors.map(&:message).join(",")
|
73
|
+
raise MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes [#{error_descriptions}]"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def extract_callstack_for_multiparameter_attributes(pairs)
|
78
|
+
attributes = {}
|
79
|
+
|
80
|
+
pairs.each do |(multiparameter_name, value)|
|
81
|
+
attribute_name = multiparameter_name.split("(").first
|
82
|
+
attributes[attribute_name] ||= {}
|
83
|
+
|
84
|
+
parameter_value = value.empty? ? nil : type_cast_attribute_value(multiparameter_name, value)
|
85
|
+
attributes[attribute_name][find_parameter_position(multiparameter_name)] ||= parameter_value
|
86
|
+
end
|
87
|
+
|
88
|
+
attributes
|
89
|
+
end
|
90
|
+
|
91
|
+
def type_cast_attribute_value(multiparameter_name, value)
|
92
|
+
multiparameter_name =~ /\([0-9]*([if])\)/ ? value.send("to_" + $1) : value
|
93
|
+
end
|
94
|
+
|
95
|
+
def find_parameter_position(multiparameter_name)
|
96
|
+
multiparameter_name.scan(/\(([0-9]*).*\)/).first.first.to_i
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module AttributeMethods
|
3
|
+
module Serialization
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
# If you have an attribute that needs to be saved to the database as an
|
8
|
+
# object, and retrieved as the same object, then specify the name of that
|
9
|
+
# attribute using this method and it will be handled automatically. The
|
10
|
+
# serialization is done through YAML. If +class_name+ is specified, the
|
11
|
+
# serialized object must be of that class on assignment and retrieval.
|
12
|
+
# Otherwise <tt>SerializationTypeMismatch</tt> will be raised.
|
13
|
+
#
|
14
|
+
# ==== Parameters
|
15
|
+
#
|
16
|
+
# * +attr_name+ - The field name that should be serialized.
|
17
|
+
# * +class_name_or_coder+ - Optional, a coder object, which responds to `.load` / `.dump`
|
18
|
+
# or a class name that the object type should be equal to.
|
19
|
+
#
|
20
|
+
# ==== Example
|
21
|
+
#
|
22
|
+
# # Serialize a preferences attribute.
|
23
|
+
# class User < ActiveRecord::Base
|
24
|
+
# serialize :preferences
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# # Serialize preferences using JSON as coder.
|
28
|
+
# class User < ActiveRecord::Base
|
29
|
+
# serialize :preferences, JSON
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # Serialize preferences as Hash using YAML coder.
|
33
|
+
# class User < ActiveRecord::Base
|
34
|
+
# serialize :preferences, Hash
|
35
|
+
# end
|
36
|
+
def serialize(attr_name, class_name_or_coder = Object)
|
37
|
+
# When ::JSON is used, force it to go through the Active Support JSON encoder
|
38
|
+
# to ensure special objects (e.g. Active Record models) are dumped correctly
|
39
|
+
# using the #as_json hook.
|
40
|
+
coder = if class_name_or_coder == ::JSON
|
41
|
+
Coders::JSON
|
42
|
+
elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
|
43
|
+
class_name_or_coder
|
44
|
+
else
|
45
|
+
Coders::YAMLColumn.new(class_name_or_coder)
|
46
|
+
end
|
47
|
+
|
48
|
+
decorate_attribute_type(attr_name, :serialize) do |type|
|
49
|
+
Type::Serialized.new(type, coder)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Teste
|
2
|
+
def a(param1=Professor.new, param2=Student.new)
|
3
|
+
b = School.new
|
4
|
+
b.some_method(param1)
|
5
|
+
c = Exame.new
|
6
|
+
c.another_method(b)
|
7
|
+
s = QI.new
|
8
|
+
s.some_other_method(A::T)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Teste2
|
13
|
+
def teste(a = Teste, b = RubyTeste)
|
14
|
+
a = 1
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
a = 2
|
2
|
+
puts a
|
3
|
+
a.send(:+, 'b')
|
4
|
+
|
5
|
+
z = Teste.new
|
6
|
+
|
7
|
+
|
8
|
+
class Teste
|
9
|
+
def a(param1=D::A::Z.new, param2=Z::A.new)
|
10
|
+
h = Sergio.call
|
11
|
+
b = C::D.new
|
12
|
+
b.some_method(param1)
|
13
|
+
c = Z.new
|
14
|
+
c.another_method(b)
|
15
|
+
s = S.new
|
16
|
+
s.some_other_method(A::T)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Teste
|
21
|
+
def b (arg1, arg2)
|
22
|
+
a = FoundText.new
|
23
|
+
puts a.get_text
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Teste2
|
29
|
+
def teste(a = Teste, b = RubyTeste)
|
30
|
+
a = 1
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Teste3
|
35
|
+
def b
|
36
|
+
y = Y.new
|
37
|
+
g = G.new
|
38
|
+
class_teste = Teste.new
|
39
|
+
class_teste.a(y, g)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
a = [A.new, B.new]
|
45
|
+
# b = B.new
|
46
|
+
# c = C.new
|
47
|
+
#
|
48
|
+
# t = Teste.new
|
49
|
+
# t.a(c,b)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ActionView #:nodoc:
|
2
|
+
class Base
|
3
|
+
def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:nodoc:
|
4
|
+
lookup_context = context.is_a?(ActionView::LookupContext) ?
|
5
|
+
context : ActionView::LookupContext.new(context)
|
6
|
+
@view_renderer = ActionView::Renderer.new(lookup_context)
|
7
|
+
end
|
8
|
+
|
9
|
+
ActiveSupport.run_load_hooks(:action_view, self)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference do
|
4
|
+
before do
|
5
|
+
@fixtures_path = File.expand_path('../fixtures', __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "parse the file correctly" do
|
9
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
10
|
+
file_content = File.read("#{@fixtures_path}/teste_class_and_args.rb")
|
11
|
+
dependencies, methods = parser.parse(file_content)
|
12
|
+
first_parsed_class = methods[0]
|
13
|
+
expect(first_parsed_class.class_name).to eql("Teste")
|
14
|
+
expect(first_parsed_class.method_calls.count).to eql(7)
|
15
|
+
method_calls = first_parsed_class.method_calls
|
16
|
+
expect(method_calls[2].class_name).to eql("C::D")
|
17
|
+
expect(method_calls[2].method_name).to eql(:some_method)
|
18
|
+
expect(method_calls[2].params[0]).to eql(:param1)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "parse the file correctly 2" do
|
22
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
23
|
+
file_content = File.read("#{@fixtures_path}/teste_class_and_args2.rb")
|
24
|
+
dependencies, methods = parser.parse(file_content)
|
25
|
+
expect(dependencies.size).to be_eql(2)
|
26
|
+
expect(methods.size).to be_eql(1)
|
27
|
+
method = methods[0]
|
28
|
+
expect(method.method_name).to be_eql(:initialize)
|
29
|
+
method_calls = method.method_calls
|
30
|
+
expect(method_calls.size).to be_eql(3)
|
31
|
+
expect(method_calls[0].method_name).to be_eql(:is_a?)
|
32
|
+
expect(method_calls[0].params).to include("ActionView::LookupContext")
|
33
|
+
expect(method_calls[1].method_name).to be_eql(:new)
|
34
|
+
expect(method_calls[1].params).to include(:context)
|
35
|
+
expect(method_calls[2].method_name).to be_eql(:new)
|
36
|
+
expect(method_calls[2].params).to include("ActionView::LookupContext")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "parse the file correctly 3" do
|
40
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
41
|
+
file_content = File.read("#{@fixtures_path}/rails_action_view_class_teste.rb")
|
42
|
+
dependencies, methods = parser.parse(file_content)
|
43
|
+
expect(dependencies.first.dependencies).to include("Helpers")
|
44
|
+
expect(dependencies[8].dependencies).to include("ActiveSupport::InheritableOptions")
|
45
|
+
expect(dependencies[8].dependencies).to include("ActionView::LookupContext")
|
46
|
+
expect(dependencies[8].dependencies).to include("ActionView::Renderer")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "parse the file correctly 4" do
|
50
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
51
|
+
file_content = File.read("#{@fixtures_path}/rails_active_record_class.rb")
|
52
|
+
dependencies, methods = parser.parse(file_content)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "parse the file correclty 5" do
|
56
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
57
|
+
file_content = File.read("#{@fixtures_path}/homebrew_bottles_class.rb")
|
58
|
+
dependencies, methods = parser.parse(file_content)
|
59
|
+
expect(dependencies.last.dependencies).to include("MacOS::Version")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "parse the file correclty 6" do
|
63
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
64
|
+
file_content = File.read("#{@fixtures_path}/homebrew_brew_teste.rb")
|
65
|
+
dependencies, methods = parser.parse(file_content)
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Archruby::Ruby::TypeInference::TypeInferenceChecker do
|
4
|
+
before do
|
5
|
+
@fixtures_path = File.expand_path('../fixtures', __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "mantains the dependencies and methods invocations correctly" do
|
9
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
10
|
+
file_content = File.read("#{@fixtures_path}/teste_class_and_args.rb")
|
11
|
+
dependencies, methods_calls = parser.parse(file_content)
|
12
|
+
dependency_organizer = Archruby::Ruby::TypeInference::DependencyOrganizer.new
|
13
|
+
dependency_organizer.add_dependencies(dependencies)
|
14
|
+
dependency_organizer.add_method_calls(methods_calls)
|
15
|
+
verify_type = Archruby::Ruby::TypeInference::TypeInferenceChecker.new(
|
16
|
+
dependency_organizer.dependencies,
|
17
|
+
dependency_organizer.method_definitions
|
18
|
+
)
|
19
|
+
verify_type.add_dependency_based_on_calls
|
20
|
+
verify_type.add_dependency_based_on_internal_calls
|
21
|
+
new_deps = verify_type.dependencies
|
22
|
+
new_methods = verify_type.method_definitions
|
23
|
+
expect(new_deps["Teste"]).to include("Y")
|
24
|
+
expect(new_deps["Teste"]).to include("G")
|
25
|
+
expect(new_deps["C::D"]).to include("Y")
|
26
|
+
expect(new_methods["Teste"].first.args[:param1]).to include("Y")
|
27
|
+
expect(new_methods["Teste"].first.args[:param2]).to include("G")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "return the number of dependencies correctly" do
|
31
|
+
parser = Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference.new
|
32
|
+
file_content = File.read("#{@fixtures_path}/teste_class_and_args.rb")
|
33
|
+
dependencies, methods_calls = parser.parse(file_content)
|
34
|
+
dependency_organizer = Archruby::Ruby::TypeInference::DependencyOrganizer.new
|
35
|
+
dependency_organizer.add_dependencies(dependencies)
|
36
|
+
dependency_organizer.add_method_calls(methods_calls)
|
37
|
+
verify_type = Archruby::Ruby::TypeInference::TypeInferenceChecker.new(
|
38
|
+
dependency_organizer.dependencies,
|
39
|
+
dependency_organizer.method_definitions
|
40
|
+
)
|
41
|
+
expect(verify_type.total_deps).to eql(12)
|
42
|
+
verify_type.add_dependency_based_on_calls
|
43
|
+
verify_type.add_dependency_based_on_internal_calls
|
44
|
+
expect(verify_type.total_deps).to eql(18)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Henrique
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: ruby_parser
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,34 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: imgkit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: wkhtmltoimage-binary
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
97
139
|
description: Compliance and Architectural Visualization in Ruby systems
|
98
140
|
email:
|
99
141
|
- sergiohenriquetp@gmail.com
|
@@ -103,11 +145,14 @@ extensions: []
|
|
103
145
|
extra_rdoc_files: []
|
104
146
|
files:
|
105
147
|
- ".gitignore"
|
148
|
+
- ".travis.yml"
|
106
149
|
- CHANGELOG.md
|
107
150
|
- Gemfile
|
108
151
|
- LICENSE.txt
|
109
152
|
- README.md
|
110
153
|
- Rakefile
|
154
|
+
- TODO.rtf
|
155
|
+
- architecture.yml
|
111
156
|
- archruby.gemspec
|
112
157
|
- bin/archruby
|
113
158
|
- lib/archruby.rb
|
@@ -119,12 +164,24 @@ files:
|
|
119
164
|
- lib/archruby/architecture/module_definition.rb
|
120
165
|
- lib/archruby/architecture/parser.rb
|
121
166
|
- lib/archruby/architecture/type_inference_checker.rb
|
167
|
+
- lib/archruby/presenters/dsm.rb
|
168
|
+
- lib/archruby/presenters/dsm/cell_dsm.rb
|
169
|
+
- lib/archruby/presenters/dsm/dsm_css.css
|
122
170
|
- lib/archruby/presenters/graph.rb
|
123
171
|
- lib/archruby/presenters/text.rb
|
124
172
|
- lib/archruby/presenters/yaml.rb
|
125
173
|
- lib/archruby/ruby/core_library.rb
|
126
174
|
- lib/archruby/ruby/parser.rb
|
127
175
|
- lib/archruby/ruby/std_library.rb
|
176
|
+
- lib/archruby/ruby/type_inference/dependency_organizer.rb
|
177
|
+
- lib/archruby/ruby/type_inference/ruby/class_dependency.rb
|
178
|
+
- lib/archruby/ruby/type_inference/ruby/internal_method_invocation.rb
|
179
|
+
- lib/archruby/ruby/type_inference/ruby/method_definition.rb
|
180
|
+
- lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb
|
181
|
+
- lib/archruby/ruby/type_inference/ruby/process_method_arguments.rb
|
182
|
+
- lib/archruby/ruby/type_inference/ruby/process_method_body.rb
|
183
|
+
- lib/archruby/ruby/type_inference/ruby/process_method_params.rb
|
184
|
+
- lib/archruby/ruby/type_inference/type_inference_checker.rb
|
128
185
|
- lib/archruby/ruby/type_inference_dep.rb
|
129
186
|
- lib/archruby/ruby/var_propagation.rb
|
130
187
|
- lib/archruby/version.rb
|
@@ -178,6 +235,7 @@ files:
|
|
178
235
|
- spec/dummy_app/lib/fetch_facebook_info.rb
|
179
236
|
- spec/dummy_app/lib/integracao_twitter.rb
|
180
237
|
- spec/dummy_app/lib/tasks/.keep
|
238
|
+
- spec/dummy_app/lib/teste_class.rb
|
181
239
|
- spec/dummy_app/log/.keep
|
182
240
|
- spec/dummy_app/public/404.html
|
183
241
|
- spec/dummy_app/public/422.html
|
@@ -197,6 +255,17 @@ files:
|
|
197
255
|
- spec/fixtures/ruby_example.rb
|
198
256
|
- spec/fixtures/ruby_example_typeinference.rb
|
199
257
|
- spec/ruby/parser_spec.rb
|
258
|
+
- spec/ruby/type_inference/dependency_organizer_spec.rb
|
259
|
+
- spec/ruby/type_inference/fixtures/homebrew_bottles_class.rb
|
260
|
+
- spec/ruby/type_inference/fixtures/homebrew_brew_teste.rb
|
261
|
+
- spec/ruby/type_inference/fixtures/rails_action_view_class_teste.rb
|
262
|
+
- spec/ruby/type_inference/fixtures/rails_active_record_class.rb
|
263
|
+
- spec/ruby/type_inference/fixtures/rails_teste_active_record.rb
|
264
|
+
- spec/ruby/type_inference/fixtures/teste2.rb
|
265
|
+
- spec/ruby/type_inference/fixtures/teste_class_and_args.rb
|
266
|
+
- spec/ruby/type_inference/fixtures/teste_class_and_args2.rb
|
267
|
+
- spec/ruby/type_inference/parser_for_typeinference_spec.rb
|
268
|
+
- spec/ruby/type_inference/type_inference_checker_spec.rb
|
200
269
|
- spec/ruby/var_propagation_spec.rb
|
201
270
|
- spec/spec_helper.rb
|
202
271
|
homepage: http://aserg.labsoft.dcc.ufmg.br/archruby/
|
@@ -219,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
288
|
version: '0'
|
220
289
|
requirements: []
|
221
290
|
rubyforge_project:
|
222
|
-
rubygems_version: 2.
|
291
|
+
rubygems_version: 2.4.5
|
223
292
|
signing_key:
|
224
293
|
specification_version: 4
|
225
294
|
summary: Compliance and Architectural Visualization in Ruby systems
|
@@ -274,6 +343,7 @@ test_files:
|
|
274
343
|
- spec/dummy_app/lib/fetch_facebook_info.rb
|
275
344
|
- spec/dummy_app/lib/integracao_twitter.rb
|
276
345
|
- spec/dummy_app/lib/tasks/.keep
|
346
|
+
- spec/dummy_app/lib/teste_class.rb
|
277
347
|
- spec/dummy_app/log/.keep
|
278
348
|
- spec/dummy_app/public/404.html
|
279
349
|
- spec/dummy_app/public/422.html
|
@@ -293,5 +363,16 @@ test_files:
|
|
293
363
|
- spec/fixtures/ruby_example.rb
|
294
364
|
- spec/fixtures/ruby_example_typeinference.rb
|
295
365
|
- spec/ruby/parser_spec.rb
|
366
|
+
- spec/ruby/type_inference/dependency_organizer_spec.rb
|
367
|
+
- spec/ruby/type_inference/fixtures/homebrew_bottles_class.rb
|
368
|
+
- spec/ruby/type_inference/fixtures/homebrew_brew_teste.rb
|
369
|
+
- spec/ruby/type_inference/fixtures/rails_action_view_class_teste.rb
|
370
|
+
- spec/ruby/type_inference/fixtures/rails_active_record_class.rb
|
371
|
+
- spec/ruby/type_inference/fixtures/rails_teste_active_record.rb
|
372
|
+
- spec/ruby/type_inference/fixtures/teste2.rb
|
373
|
+
- spec/ruby/type_inference/fixtures/teste_class_and_args.rb
|
374
|
+
- spec/ruby/type_inference/fixtures/teste_class_and_args2.rb
|
375
|
+
- spec/ruby/type_inference/parser_for_typeinference_spec.rb
|
376
|
+
- spec/ruby/type_inference/type_inference_checker_spec.rb
|
296
377
|
- spec/ruby/var_propagation_spec.rb
|
297
378
|
- spec/spec_helper.rb
|