inch 0.5.0.rc3 → 0.5.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +94 -0
- data/CHANGELOG.md +26 -2
- data/Gemfile +5 -2
- data/README.md +3 -3
- data/Rakefile +6 -2
- data/bin/inch +3 -3
- data/config/{example.yml → .inch.yml.sample} +1 -0
- data/config/base.rb +53 -0
- data/config/elixir.rb +43 -0
- data/config/nodejs.rb +10 -0
- data/config/{defaults.rb → ruby.rb} +5 -54
- data/inch.gemspec +7 -7
- data/lib/inch.rb +14 -9
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +2 -3
- data/lib/inch/api/compare/codebases.rb +1 -1
- data/lib/inch/api/diff.rb +13 -16
- data/lib/inch/api/filter.rb +1 -1
- data/lib/inch/api/get.rb +2 -2
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/filter.rb +0 -4
- data/lib/inch/api/options/suggest.rb +2 -6
- data/lib/inch/api/stats.rb +0 -1
- data/lib/inch/api/suggest.rb +9 -10
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/arguments.rb +2 -2
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +30 -9
- data/lib/inch/cli/command/base_list.rb +2 -2
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +9 -9
- data/lib/inch/cli/command/inspect.rb +5 -4
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +17 -16
- data/lib/inch/cli/command/options/base_list.rb +9 -5
- data/lib/inch/cli/command/options/console.rb +4 -3
- data/lib/inch/cli/command/options/diff.rb +8 -6
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +3 -2
- data/lib/inch/cli/command/options/show.rb +2 -2
- data/lib/inch/cli/command/options/stats.rb +2 -1
- data/lib/inch/cli/command/options/suggest.rb +6 -3
- data/lib/inch/cli/command/output/base.rb +4 -6
- data/lib/inch/cli/command/output/console.rb +6 -7
- data/lib/inch/cli/command/output/diff.rb +6 -6
- data/lib/inch/cli/command/output/inspect.rb +6 -8
- data/lib/inch/cli/command/output/list.rb +0 -1
- data/lib/inch/cli/command/output/show.rb +4 -5
- data/lib/inch/cli/command/output/stats.rb +21 -21
- data/lib/inch/cli/command/output/suggest.rb +31 -28
- data/lib/inch/cli/command/show.rb +4 -4
- data/lib/inch/cli/command/stats.rb +4 -4
- data/lib/inch/cli/command/suggest.rb +6 -6
- data/lib/inch/cli/command_parser.rb +6 -5
- data/lib/inch/cli/sparkline_helper.rb +6 -6
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +4 -3
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/converter.rb +6 -8
- data/lib/inch/code_object/provider.rb +11 -11
- data/lib/inch/code_object/proxy.rb +61 -30
- data/lib/inch/codebase.rb +7 -8
- data/lib/inch/codebase/object.rb +60 -0
- data/lib/inch/codebase/objects.rb +8 -10
- data/lib/inch/codebase/objects_filter.rb +7 -5
- data/lib/inch/codebase/proxy.rb +4 -4
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +42 -11
- data/lib/inch/config/base.rb +8 -29
- data/lib/inch/config/codebase.rb +32 -7
- data/lib/inch/config/evaluation.rb +61 -0
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +13 -21
- data/lib/inch/evaluation/file.rb +4 -2
- data/lib/inch/evaluation/grade_list.rb +4 -4
- data/lib/inch/evaluation/priority_range.rb +3 -0
- data/lib/inch/evaluation/proxy.rb +139 -14
- data/lib/inch/evaluation/role.rb +99 -0
- data/lib/inch/language.rb +3 -0
- data/lib/inch/language/elixir/code_object/base.rb +197 -0
- data/lib/inch/language/elixir/code_object/function_object.rb +74 -0
- data/lib/inch/language/elixir/code_object/module_object.rb +23 -0
- data/lib/inch/language/elixir/code_object/type_object.rb +11 -0
- data/lib/inch/language/elixir/evaluation/base.rb +28 -0
- data/lib/inch/language/elixir/evaluation/function_object.rb +31 -0
- data/lib/inch/language/elixir/evaluation/module_object.rb +27 -0
- data/lib/inch/language/elixir/evaluation/type_object.rb +11 -0
- data/lib/inch/language/elixir/import.rb +24 -0
- data/lib/inch/language/elixir/provider/reader.rb +19 -0
- data/lib/inch/language/elixir/provider/reader/object.rb +63 -0
- data/lib/inch/language/elixir/provider/reader/object/base.rb +191 -0
- data/lib/inch/language/elixir/provider/reader/object/function_object.rb +26 -0
- data/lib/inch/language/elixir/provider/reader/object/module_object.rb +22 -0
- data/lib/inch/language/elixir/provider/reader/object/type_object.rb +15 -0
- data/lib/inch/language/elixir/provider/reader/parser.rb +55 -0
- data/lib/inch/language/elixir/roles/base.rb +32 -0
- data/lib/inch/language/elixir/roles/function.rb +112 -0
- data/lib/inch/language/elixir/roles/module.rb +64 -0
- data/lib/inch/language/elixir/roles/object.rb +76 -0
- data/lib/inch/language/elixir/roles/type.rb +13 -0
- data/lib/inch/language/nodejs/import.rb +8 -0
- data/lib/inch/language/nodejs/provider/jsdoc.rb +19 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object.rb +55 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +191 -0
- data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +59 -0
- data/lib/inch/language/ruby/code_object/base.rb +197 -0
- data/lib/inch/language/ruby/code_object/class_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/class_variable_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/constant_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/method_object.rb +85 -0
- data/lib/inch/language/ruby/code_object/method_parameter_object.rb +64 -0
- data/lib/inch/language/ruby/code_object/module_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/namespace_object.rb +35 -0
- data/lib/inch/language/ruby/evaluation/base.rb +45 -0
- data/lib/inch/language/ruby/evaluation/class_object.rb +10 -0
- data/lib/inch/language/ruby/evaluation/class_variable_object.rb +21 -0
- data/lib/inch/language/ruby/evaluation/constant_object.rb +21 -0
- data/lib/inch/language/ruby/evaluation/method_object.rb +74 -0
- data/lib/inch/language/ruby/evaluation/module_object.rb +10 -0
- data/lib/inch/language/ruby/evaluation/namespace_object.rb +30 -0
- data/lib/inch/language/ruby/import.rb +34 -0
- data/lib/inch/language/ruby/provider/yard.rb +58 -0
- data/lib/inch/language/ruby/provider/yard/docstring.rb +162 -0
- data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +97 -0
- data/lib/inch/language/ruby/provider/yard/object.rb +63 -0
- data/lib/inch/language/ruby/provider/yard/object/base.rb +325 -0
- data/lib/inch/language/ruby/provider/yard/object/class_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/class_variable_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/constant_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/method_object.rb +170 -0
- data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +94 -0
- data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +120 -0
- data/lib/inch/language/ruby/provider/yard/object/module_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +46 -0
- data/lib/inch/language/ruby/provider/yard/object/root_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/parser.rb +71 -0
- data/lib/inch/language/ruby/roles/base.rb +17 -0
- data/lib/inch/language/ruby/roles/class_variable.rb +53 -0
- data/lib/inch/language/ruby/roles/constant.rb +53 -0
- data/lib/inch/language/ruby/roles/method.rb +112 -0
- data/lib/inch/language/ruby/roles/method_parameter.rb +84 -0
- data/lib/inch/language/ruby/roles/missing.rb +24 -0
- data/lib/inch/language/ruby/roles/namespace.rb +89 -0
- data/lib/inch/language/ruby/roles/object.rb +120 -0
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +7 -2
- data/lib/inch/utils/buffered_ui.rb +16 -0
- data/lib/inch/utils/shell_helper.rb +1 -1
- data/lib/inch/utils/ui.rb +5 -5
- data/lib/inch/utils/weighted_list.rb +2 -3
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/{code_examples → ruby/code_examples}/lib/foo.rb +0 -0
- data/test/fixtures/{diff1 → ruby/diff1}/lib/diff1.rb +0 -0
- data/test/fixtures/{diff2 → ruby/diff2}/lib/diff2.rb +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/.inch.yml +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/bar.rb +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/vendor/base.rb +0 -0
- data/test/fixtures/{parameters → ruby/parameters}/lib/foo.rb +0 -0
- data/test/fixtures/{readme → ruby/readme}/lib/foo.rb +0 -0
- data/test/fixtures/{really_good → ruby/really_good}/lib/foo.rb +0 -0
- data/test/fixtures/{really_good_pedantic → ruby/really_good_pedantic}/lib/foo.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/README +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/broken.rb +11 -19
- data/test/fixtures/ruby/simple/lib/broken_ruby_2_0_features.rb +7 -0
- data/test/fixtures/ruby/simple/lib/directives.rb +8 -0
- data/test/fixtures/{simple → ruby/simple}/lib/foo.rb +22 -1
- data/test/fixtures/{simple → ruby/simple}/lib/nodoc.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/role_methods.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/role_namespaces.rb +0 -0
- data/test/fixtures/{visibility → ruby/visibility}/lib/foo.rb +0 -0
- data/test/fixtures/{yardopts → ruby/yardopts}/.yardopts +0 -0
- data/test/fixtures/{yardopts → ruby/yardopts}/foo/bar.rb +0 -0
- data/test/integration/api/compare/codebases.rb +3 -3
- data/test/integration/cli/command/console_test.rb +6 -6
- data/test/integration/cli/command/diff_test.rb +62 -0
- data/test/integration/cli/command/inspect_test.rb +5 -6
- data/test/integration/cli/command/list_test.rb +4 -5
- data/test/integration/cli/command/show_test.rb +5 -5
- data/test/integration/cli/command/stats_test.rb +3 -3
- data/test/integration/cli/command/suggest_test.rb +13 -13
- data/test/integration/stats_options_test.rb +4 -4
- data/test/integration/visibility_options_test.rb +14 -14
- data/test/shared/base_list.rb +4 -3
- data/test/test_helper.rb +13 -13
- data/test/unit/api/filter_test.rb +7 -7
- data/test/unit/api/get_test.rb +1 -1
- data/test/unit/api/list_test.rb +1 -1
- data/test/unit/api/options/base_test.rb +3 -3
- data/test/unit/api/stats_test.rb +1 -1
- data/test/unit/api/suggest_test.rb +3 -3
- data/test/unit/cli/arguments_test.rb +2 -2
- data/test/unit/cli/command/base_test.rb +1 -1
- data/test/unit/cli/command/options/base_list_test.rb +2 -2
- data/test/unit/cli/command/options/base_object_test.rb +1 -1
- data/test/unit/cli/command/options/base_test.rb +1 -1
- data/test/unit/cli/command_parser_test.rb +3 -3
- data/test/unit/cli/trace_helper_test.rb +1 -1
- data/test/unit/cli/yardopts_helper_test.rb +6 -5
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider_test.rb +2 -2
- data/test/unit/code_object/proxy_test.rb +2 -2
- data/test/unit/codebase/objects_test.rb +2 -2
- data/test/unit/codebase/proxy_test.rb +7 -5
- data/test/unit/config/codebase_test.rb +4 -4
- data/test/unit/config_test.rb +28 -0
- data/test/unit/evaluation/{role/base_test.rb → role_test.rb} +7 -7
- data/test/unit/{code_object/proxy → language/ruby/code_object}/method_object_test.rb +66 -21
- data/test/unit/{code_object → language/ruby}/provider/yard/docstring_test.rb +74 -38
- data/test/unit/{code_object → language/ruby}/provider/yard/nodoc_helper_test.rb +9 -7
- data/test/unit/{code_object → language/ruby}/provider/yard/object/method_object_test.rb +21 -11
- data/test/unit/language/ruby/provider/yard_test.rb +25 -0
- data/test/unit/utils/buffered_ui_test.rb +48 -0
- data/test/unit/utils/ui_test.rb +7 -7
- data/test/unit/utils/weighted_list_test.rb +7 -4
- metadata +139 -93
- data/lib/inch/code_object/provider/yard.rb +0 -57
- data/lib/inch/code_object/provider/yard/docstring.rb +0 -133
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +0 -93
- data/lib/inch/code_object/provider/yard/object.rb +0 -60
- data/lib/inch/code_object/provider/yard/object/base.rb +0 -302
- data/lib/inch/code_object/provider/yard/object/class_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/constant_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/method_object.rb +0 -153
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +0 -88
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +0 -114
- data/lib/inch/code_object/provider/yard/object/module_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +0 -47
- data/lib/inch/code_object/provider/yard/object/root_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/parser.rb +0 -62
- data/lib/inch/code_object/proxy/base.rb +0 -241
- data/lib/inch/code_object/proxy/class_object.rb +0 -8
- data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
- data/lib/inch/code_object/proxy/constant_object.rb +0 -8
- data/lib/inch/code_object/proxy/method_object.rb +0 -82
- data/lib/inch/code_object/proxy/method_parameter_object.rb +0 -60
- data/lib/inch/code_object/proxy/module_object.rb +0 -8
- data/lib/inch/code_object/proxy/namespace_object.rb +0 -33
- data/lib/inch/evaluation/object_schema.rb +0 -30
- data/lib/inch/evaluation/proxy/base.rb +0 -164
- data/lib/inch/evaluation/proxy/class_object.rb +0 -8
- data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
- data/lib/inch/evaluation/proxy/constant_object.rb +0 -19
- data/lib/inch/evaluation/proxy/method_object.rb +0 -65
- data/lib/inch/evaluation/proxy/module_object.rb +0 -8
- data/lib/inch/evaluation/proxy/namespace_object.rb +0 -27
- data/lib/inch/evaluation/role/base.rb +0 -92
- data/lib/inch/evaluation/role/class_variable.rb +0 -55
- data/lib/inch/evaluation/role/constant.rb +0 -55
- data/lib/inch/evaluation/role/method.rb +0 -126
- data/lib/inch/evaluation/role/method_parameter.rb +0 -91
- data/lib/inch/evaluation/role/missing.rb +0 -20
- data/lib/inch/evaluation/role/namespace.rb +0 -85
- data/lib/inch/evaluation/role/object.rb +0 -143
- data/test/unit/code_object/provider/yard_test.rb +0 -25
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "simplecov"
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "minitest/autorun"
|
6
|
+
require "bundler"
|
7
7
|
Bundler.require
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "inch"
|
9
|
+
require "inch/cli"
|
10
10
|
|
11
11
|
def assert_roles(object, expected, unexpected)
|
12
12
|
roles = object.roles.map(&:class)
|
@@ -28,8 +28,8 @@ def find_roles(object, role_class, object_name = nil)
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def fixture_path(name)
|
32
|
-
File.join(File.dirname(__FILE__), "fixtures", name.to_s)
|
31
|
+
def fixture_path(language, name)
|
32
|
+
File.join(File.dirname(__FILE__), "fixtures", language.to_s, name.to_s)
|
33
33
|
end
|
34
34
|
|
35
35
|
module Inch
|
@@ -37,19 +37,19 @@ module Inch
|
|
37
37
|
class << self
|
38
38
|
attr_accessor :object_providers
|
39
39
|
|
40
|
-
def codebase(name)
|
41
|
-
Inch::Codebase::Proxy.new object_provider(name)
|
40
|
+
def codebase(language, name)
|
41
|
+
Inch::Codebase::Proxy.new language, object_provider(language, name)
|
42
42
|
end
|
43
43
|
|
44
|
-
def object_provider(name)
|
44
|
+
def object_provider(language, name)
|
45
45
|
self.object_providers ||= {}
|
46
|
-
self.object_providers[name] ||= ::Inch::CodeObject::Provider.parse(fixture_path(name))
|
46
|
+
self.object_providers[name] ||= ::Inch::CodeObject::Provider.parse(fixture_path(language, name))
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_codebase(name)
|
53
|
-
codebase = Inch::Test.codebase(name)
|
53
|
+
codebase = Inch::Test.codebase(:ruby, name)
|
54
54
|
codebase
|
55
55
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::API::Filter do
|
4
4
|
before do
|
@@ -13,37 +13,37 @@ describe ::Inch::API::Filter do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should work with option: visibility == :public" do
|
16
|
-
@options = {:
|
16
|
+
@options = { visibility: [:public] }
|
17
17
|
@context = ::Inch::API::Filter.new @codebase, @options
|
18
18
|
assert @context.objects.all? { |o| o.public? }
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should work with option: visibility == :protected" do
|
22
|
-
@options = {:
|
22
|
+
@options = { visibility: [:protected] }
|
23
23
|
@context = ::Inch::API::Filter.new @codebase, @options
|
24
24
|
assert @context.objects.all? { |o| o.protected? }
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should work with option: visibility == :private" do
|
28
|
-
@options = {:
|
28
|
+
@options = { visibility: [:private] }
|
29
29
|
@context = ::Inch::API::Filter.new @codebase, @options
|
30
30
|
assert @context.objects.all? { |o| o.private? || o.tagged_as_private? }
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should work with option: namespaces == :only" do
|
34
|
-
@options = {:
|
34
|
+
@options = { namespaces: :only }
|
35
35
|
@context = ::Inch::API::Filter.new @codebase, @options
|
36
36
|
assert @context.objects.all? { |o| o.namespace? }
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should work with option: undocumented == :only" do
|
40
|
-
@options = {:
|
40
|
+
@options = { undocumented: :only }
|
41
41
|
@context = ::Inch::API::Filter.new @codebase, @options
|
42
42
|
assert @context.objects.all? { |o| o.undocumented? }
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should work with option: depth == 2" do
|
46
|
-
@options = {:
|
46
|
+
@options = { depth: 2 }
|
47
47
|
@context = ::Inch::API::Filter.new @codebase, @options
|
48
48
|
refute @context.objects.any? { |o| o.depth > 2 }
|
49
49
|
end
|
data/test/unit/api/get_test.rb
CHANGED
data/test/unit/api/list_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::API::Options::Base do
|
4
4
|
class APIOptionsTest < ::Inch::API::Options::Base
|
@@ -8,7 +8,7 @@ describe ::Inch::API::Options::Base do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should work with a Hash or Struct" do
|
11
|
-
@options_hash = {:
|
11
|
+
@options_hash = { foo: "foo", baz: 42 }
|
12
12
|
@options_struct = OpenStruct.new(@options_hash)
|
13
13
|
|
14
14
|
@options1 = APIOptionsTest.new @options_hash
|
@@ -21,7 +21,7 @@ describe ::Inch::API::Options::Base do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should return default values" do
|
24
|
-
@options_hash = {:
|
24
|
+
@options_hash = { baz: 42 }
|
25
25
|
@options = APIOptionsTest.new @options_hash
|
26
26
|
|
27
27
|
assert_equal :bar, @options.foo
|
data/test/unit/api/stats_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::API::Suggest do
|
4
4
|
before do
|
@@ -13,10 +13,10 @@ describe ::Inch::API::Suggest do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should work with option: object_count" do
|
16
|
-
@options = {:
|
16
|
+
@options = { object_count: 10 }
|
17
17
|
@context = ::Inch::API::Suggest.new @codebase, @options
|
18
18
|
|
19
|
-
@options2 = {:
|
19
|
+
@options2 = { object_count: 20 }
|
20
20
|
@context2 = ::Inch::API::Suggest.new @codebase, @options2
|
21
21
|
|
22
22
|
assert_equal 10, @context.objects.size
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CLI::Arguments do
|
4
4
|
before do
|
5
|
-
Dir.chdir fixture_path(:simple)
|
5
|
+
Dir.chdir fixture_path(:ruby, :simple)
|
6
6
|
assert File.file?("README")
|
7
7
|
end
|
8
8
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CLI::Command::Options::BaseList do
|
4
4
|
it "should run parse without errors" do
|
@@ -10,7 +10,7 @@ describe ::Inch::CLI::Command::Options::BaseList do
|
|
10
10
|
assert @options.undocumented.nil?
|
11
11
|
assert @options.depth.nil?
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should run parse twice without affecting the second run" do
|
15
15
|
@options = ::Inch::CLI::Command::Options::BaseList.new
|
16
16
|
@options.parse(["--no-public", "--no-protected", "--private"])
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CLI::CommandParser do
|
4
4
|
before do
|
5
|
-
Dir.chdir fixture_path(:simple)
|
5
|
+
Dir.chdir fixture_path(:ruby, :simple)
|
6
6
|
@command_parser = ::Inch::CLI::CommandParser
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should run without args" do
|
10
10
|
out, err = capture_io do
|
11
|
-
@command = @command_parser.run
|
11
|
+
@command = @command_parser.run
|
12
12
|
end
|
13
13
|
refute out.empty?, "there should be some output"
|
14
14
|
assert err.empty?, "there should be no errors"
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CLI::YardoptsHelper do
|
4
4
|
before do
|
5
|
-
Dir.chdir fixture_path(:yardopts)
|
5
|
+
Dir.chdir fixture_path(:ruby, :yardopts)
|
6
6
|
assert File.file?(".yardopts")
|
7
7
|
@command = ::Inch::CLI::Command::List
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should run without args" do
|
11
11
|
out, err = capture_io do
|
12
|
-
@command.run
|
12
|
+
@command.run
|
13
13
|
end
|
14
14
|
refute out.empty?, "there should be some output"
|
15
15
|
assert err.empty?, "there should be no errors"
|
@@ -56,14 +56,15 @@ describe ::Inch::CLI::YardoptsHelper do
|
|
56
56
|
end
|
57
57
|
refute out.empty?, "there should be some output"
|
58
58
|
assert_match /\bUsage\b.+list/, out
|
59
|
-
#assert_match /\b\-\-\[no\-\]yardopts\b/, out,
|
59
|
+
# assert_match /\b\-\-\[no\-\]yardopts\b/, out,
|
60
|
+
# "--[no-]yardopts should be mentioned"
|
60
61
|
assert err.empty?, "there should be no errors"
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
64
65
|
describe ::Inch::CLI::YardoptsHelper do
|
65
66
|
before do
|
66
|
-
Dir.chdir fixture_path(:simple)
|
67
|
+
Dir.chdir fixture_path(:ruby, :simple)
|
67
68
|
refute File.file?(".yardopts")
|
68
69
|
refute File.file?(".document")
|
69
70
|
@command = ::Inch::CLI::Command::List
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::CodeObject::Provider do
|
4
4
|
it "should parse all objects" do
|
5
5
|
Dir.chdir File.dirname(__FILE__)
|
6
|
-
@provider = ::Inch::CodeObject::Provider.parse(fixture_path(:simple))
|
6
|
+
@provider = ::Inch::CodeObject::Provider.parse(fixture_path(:ruby, :simple))
|
7
7
|
refute @provider.objects.empty?
|
8
8
|
end
|
9
9
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
|
-
describe ::Inch::CodeObject::Proxy
|
3
|
+
describe ::Inch::CodeObject::Proxy do
|
4
4
|
before do
|
5
5
|
@codebase = test_codebase(:code_examples)
|
6
6
|
@objects = @codebase.objects
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::Codebase::Objects do
|
4
4
|
before do
|
@@ -18,7 +18,7 @@ describe ::Inch::Codebase::Objects do
|
|
18
18
|
|
19
19
|
it "should support iteration" do
|
20
20
|
sum = 0
|
21
|
-
@objects.each do
|
21
|
+
@objects.each do
|
22
22
|
sum += 1
|
23
23
|
end
|
24
24
|
assert_equal @objects.size, sum
|
@@ -1,16 +1,18 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::Codebase::Proxy do
|
4
4
|
it "should parse all objects" do
|
5
|
-
dir = fixture_path(:simple)
|
6
|
-
config = Inch::Config::Codebase.new(["lib/**/*.rb"])
|
5
|
+
dir = fixture_path(:ruby, :simple)
|
6
|
+
config = Inch::Config::Codebase.new(:ruby, ["lib/**/*.rb"])
|
7
|
+
config.object_provider :YARD
|
7
8
|
@codebase = Inch::Codebase::Proxy.parse dir, config
|
8
9
|
refute_nil @codebase.objects
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should parse given paths" do
|
12
|
-
dir = fixture_path(:simple)
|
13
|
-
config = Inch::Config::Codebase.new(["app/**/*.rb"])
|
13
|
+
dir = fixture_path(:ruby, :simple)
|
14
|
+
config = Inch::Config::Codebase.new(:ruby, ["app/**/*.rb"])
|
15
|
+
config.object_provider :YARD
|
14
16
|
@codebase = Inch::Codebase::Proxy.parse dir, config
|
15
17
|
assert @codebase.objects.empty?
|
16
18
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
3
|
describe ::Inch::Config::Codebase do
|
4
4
|
it "should parse .inch.yml" do
|
5
|
-
dir = fixture_path(:simple)
|
5
|
+
dir = fixture_path(:ruby, :simple)
|
6
6
|
config = Inch::Config::Codebase.new
|
7
7
|
config.update_via_yaml(dir)
|
8
8
|
assert config.included_files.empty?
|
9
9
|
assert config.excluded_files.empty?
|
10
10
|
end
|
11
11
|
|
12
|
-
it "should parse .inch.yml" do
|
13
|
-
dir = fixture_path(:"inch-yml")
|
12
|
+
it "should parse .inch.yml if present" do
|
13
|
+
dir = fixture_path(:ruby, :"inch-yml")
|
14
14
|
config = Inch::Config::Codebase.new
|
15
15
|
config.update_via_yaml(dir)
|
16
16
|
refute config.included_files.empty?
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
2
|
+
|
3
|
+
describe ::Inch::Config do
|
4
|
+
it "should return config for :ruby" do
|
5
|
+
config = Inch::Config.for(:ruby)
|
6
|
+
refute config.codebase.included_files.empty?
|
7
|
+
assert config.codebase.excluded_files.empty?
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should parse .inch.yml if present" do
|
11
|
+
dir = fixture_path(:ruby, :"inch-yml")
|
12
|
+
config = Inch::Config.for(:ruby, dir)
|
13
|
+
refute config.codebase.included_files.empty?
|
14
|
+
refute config.codebase.excluded_files.empty?
|
15
|
+
|
16
|
+
# Assert that this is another conf, unaltered
|
17
|
+
# by the conf loading before
|
18
|
+
config = Inch::Config.for(:ruby)
|
19
|
+
refute config.codebase.included_files.empty?
|
20
|
+
assert config.codebase.excluded_files.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return config.evaluation for :ruby" do
|
24
|
+
config = Inch::Config.for(:ruby)
|
25
|
+
refute_nil config.evaluation.criteria_for(:MethodObject)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
2
|
|
3
|
-
class MockPrivateRole < ::Inch::Evaluation::Role
|
3
|
+
class MockPrivateRole < ::Inch::Evaluation::Role
|
4
4
|
applicable_if :private?
|
5
5
|
end
|
6
6
|
|
7
|
-
class MockNotPrivateRole < ::Inch::Evaluation::Role
|
7
|
+
class MockNotPrivateRole < ::Inch::Evaluation::Role
|
8
8
|
applicable_unless :private?
|
9
9
|
end
|
10
10
|
|
11
|
-
class MockPublicRole < ::Inch::Evaluation::Role
|
11
|
+
class MockPublicRole < ::Inch::Evaluation::Role
|
12
12
|
applicable_if { |o| o.public? }
|
13
13
|
end
|
14
14
|
|
15
|
-
class MockIndifferentRole < ::Inch::Evaluation::Role
|
16
|
-
def self.applicable?(
|
15
|
+
class MockIndifferentRole < ::Inch::Evaluation::Role
|
16
|
+
def self.applicable?(_object)
|
17
17
|
true
|
18
18
|
end
|
19
19
|
end
|
@@ -38,7 +38,7 @@ class MockPublicObject
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe ::Inch::Evaluation::Role
|
41
|
+
describe ::Inch::Evaluation::Role do
|
42
42
|
describe ".applicable" do
|
43
43
|
let(:private_object) { MockPrivateObject.new }
|
44
44
|
let(:public_object) { MockPublicObject.new }
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
|
2
2
|
|
3
|
-
describe ::Inch::CodeObject::
|
3
|
+
describe ::Inch::Language::Ruby::CodeObject::MethodObject do
|
4
4
|
before do
|
5
5
|
@codebase = test_codebase(:simple)
|
6
6
|
@objects = @codebase.objects
|
@@ -99,6 +99,15 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
99
99
|
refute m.has_doc?
|
100
100
|
refute m.has_parameters?
|
101
101
|
assert m.return_mentioned?
|
102
|
+
refute m.return_described?
|
103
|
+
|
104
|
+
assert m.score
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should handle unusable return value when only @return [void] is given" do
|
108
|
+
m = @objects.find("Foo::Bar#method_without_usable_return_value")
|
109
|
+
assert m.return_mentioned?
|
110
|
+
assert m.return_described?
|
102
111
|
|
103
112
|
assert m.score
|
104
113
|
end
|
@@ -129,6 +138,18 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
129
138
|
assert m.score
|
130
139
|
end
|
131
140
|
|
141
|
+
it "should handle yet other RDoc styles" do
|
142
|
+
m = @objects.find("Foo::Bar#method_with_yet_another_rdoc_doc")
|
143
|
+
assert m.has_doc?
|
144
|
+
assert m.has_parameters?
|
145
|
+
p = m.parameter(:param1)
|
146
|
+
assert p.mentioned? # mentioned in docs, correctly
|
147
|
+
p = m.parameter(:param2)
|
148
|
+
assert p.mentioned? # mentioned in docs, correctly
|
149
|
+
|
150
|
+
assert m.score
|
151
|
+
end
|
152
|
+
|
132
153
|
it "should handle unstructured doc styles" do
|
133
154
|
m = @objects.find("Foo::Bar#method_with_unstructured_doc")
|
134
155
|
assert m.has_doc?
|
@@ -151,7 +172,8 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
151
172
|
assert m.score
|
152
173
|
end
|
153
174
|
|
154
|
-
it "should handle methods (without parameters) that have only a docstring
|
175
|
+
it "should handle methods (without parameters) that have only a docstring" \
|
176
|
+
" (text comment)" do
|
155
177
|
m = @objects.find("Foo::Bar#method_without_params_or_return_type")
|
156
178
|
assert m.has_doc?
|
157
179
|
refute m.has_parameters?
|
@@ -203,7 +225,8 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
203
225
|
assert_equal 0, m.score
|
204
226
|
end
|
205
227
|
|
206
|
-
it "should recognize a getter in a getter/setter pair defined via
|
228
|
+
it "should recognize a getter in a getter/setter pair defined via" \
|
229
|
+
" attr_accessor" do
|
207
230
|
m = @objects.find("InchTest#attr_getset")
|
208
231
|
assert m.getter?, "should be a getter"
|
209
232
|
refute m.setter?
|
@@ -211,7 +234,8 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
211
234
|
assert_equal 0, m.score
|
212
235
|
end
|
213
236
|
|
214
|
-
it "should recognize a setter in a getter/setter pair defined via
|
237
|
+
it "should recognize a setter in a getter/setter pair defined via" \
|
238
|
+
" attr_accessor" do
|
215
239
|
m = @objects.find("InchTest#attr_getset=")
|
216
240
|
refute m.getter?
|
217
241
|
assert m.setter?, "should be a setter"
|
@@ -235,13 +259,15 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
235
259
|
assert_equal 0, m.score
|
236
260
|
end
|
237
261
|
|
238
|
-
it "should recognize docs on a getter in a getter/setter pair defined via
|
262
|
+
it "should recognize docs on a getter in a getter/setter pair defined via" \
|
263
|
+
" attr_accessor" do
|
239
264
|
m = @objects.find("Attributes#username")
|
240
265
|
refute_equal 0, m.score
|
241
266
|
refute m.undocumented?
|
242
267
|
end
|
243
268
|
|
244
|
-
it "should recognize docs on a setter in a getter/setter pair defined via
|
269
|
+
it "should recognize docs on a setter in a getter/setter pair defined via" \
|
270
|
+
" attr_accessor" do
|
245
271
|
m = @objects.find("Attributes#username=")
|
246
272
|
refute_equal 0, m.score
|
247
273
|
refute m.undocumented?
|
@@ -275,7 +301,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
275
301
|
it "should work as a writer" do
|
276
302
|
m = @objects.find("Attributes#email=")
|
277
303
|
refute_equal 0, m.score
|
278
|
-
#refute m.undocumented?
|
304
|
+
# refute m.undocumented?
|
279
305
|
# NOTE: this is undocumented since there is no original_docstring
|
280
306
|
end
|
281
307
|
end
|
@@ -302,18 +328,23 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
302
328
|
end
|
303
329
|
|
304
330
|
it "should work with several overload tags on the same method" do
|
331
|
+
skip
|
305
332
|
m = @objects.find("Overloading#many_overloads")
|
306
|
-
assert_equal 1, count_roles(
|
307
|
-
|
308
|
-
assert_equal 1, count_roles(
|
333
|
+
assert_equal 1, count_roles(
|
334
|
+
m, Inch::Language::Ruby::Evaluation::Role::Method::WithoutReturnDescription)
|
335
|
+
assert_equal 1, count_roles(
|
336
|
+
m, Inch::Language::Ruby::Evaluation::Role::Method::WithoutReturnType)
|
337
|
+
assert_equal 1, count_roles(
|
338
|
+
m, Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutMention, "block")
|
309
339
|
end
|
310
340
|
|
311
|
-
it "should work if @param tags are only present in the @overload tags,
|
341
|
+
it "should work if @param tags are only present in the @overload tags," \
|
342
|
+
" but not on the actual method" do
|
312
343
|
m = @objects.find("Overloading#params_only_in_overloads")
|
313
344
|
unexpected_roles = [
|
314
|
-
Inch::Evaluation::Role::Object::WithoutCodeExample,
|
315
|
-
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
316
|
-
Inch::Evaluation::Role::MethodParameter::WithoutType
|
345
|
+
Inch::Language::Ruby::Evaluation::Role::Object::WithoutCodeExample,
|
346
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutMention,
|
347
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutType
|
317
348
|
]
|
318
349
|
assert_roles m, [], unexpected_roles
|
319
350
|
end
|
@@ -321,11 +352,11 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
321
352
|
it "should work with one param missing in the overload tag" do
|
322
353
|
m = @objects.find("Overloading#one_param_missing_in_overload")
|
323
354
|
unexpected_roles = [
|
324
|
-
Inch::Evaluation::Role::Object::WithoutCodeExample
|
355
|
+
Inch::Language::Ruby::Evaluation::Role::Object::WithoutCodeExample
|
325
356
|
]
|
326
357
|
expected_roles = [
|
327
|
-
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
328
|
-
Inch::Evaluation::Role::MethodParameter::WithoutType
|
358
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutMention,
|
359
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutType
|
329
360
|
]
|
330
361
|
assert_roles m, expected_roles, unexpected_roles
|
331
362
|
end
|
@@ -334,10 +365,23 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
334
365
|
describe "MISC" do
|
335
366
|
#
|
336
367
|
it "should recognize named parameters in Ruby 2.1" do
|
368
|
+
skip # unless RUBY_VERSION =~ /^2/
|
369
|
+
|
337
370
|
m = @objects.find("Foo#method_with_named_parameter")
|
338
371
|
unexpected_roles = [
|
339
|
-
Inch::Evaluation::Role::MethodParameter::WithoutMention,
|
340
|
-
Inch::Evaluation::Role::MethodParameter::WithoutType
|
372
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutMention,
|
373
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutType
|
374
|
+
]
|
375
|
+
assert_roles m, [], unexpected_roles
|
376
|
+
end
|
377
|
+
|
378
|
+
it "should recognize indented parameter documentation" do
|
379
|
+
skip # YARD cannot parse this
|
380
|
+
|
381
|
+
m = @objects.find("Foo#method_with_indented_param_tag")
|
382
|
+
unexpected_roles = [
|
383
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutMention,
|
384
|
+
Inch::Language::Ruby::Evaluation::Role::MethodParameter::WithoutType
|
341
385
|
]
|
342
386
|
assert_roles m, [], unexpected_roles
|
343
387
|
end
|
@@ -401,7 +445,8 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
401
445
|
assert m.score >= 50 # TODO: don't use magic numbers
|
402
446
|
end
|
403
447
|
|
404
|
-
it "should recognize question mark methods with description and
|
448
|
+
it "should recognize question mark methods with description and" \
|
449
|
+
" parameters" do
|
405
450
|
m = @objects.find("InchTest#method_with_description_and_parameters?")
|
406
451
|
refute m.has_doc?
|
407
452
|
assert m.has_parameters?
|