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/lib/inch.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require "inch/version"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
end
|
5
5
|
|
6
|
-
require
|
6
|
+
require "forwardable"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
8
|
+
require "inch/api"
|
9
|
+
require "inch/core_ext"
|
10
|
+
require "inch/codebase"
|
11
|
+
require "inch/code_object"
|
12
|
+
require "inch/evaluation"
|
13
13
|
|
14
|
-
require
|
15
|
-
|
14
|
+
require "inch/language"
|
15
|
+
|
16
|
+
require "inch/config"
|
17
|
+
require File.join(File.dirname(__FILE__), "..", "config", "base.rb")
|
18
|
+
require File.join(File.dirname(__FILE__), "..", "config", "ruby.rb")
|
19
|
+
require File.join(File.dirname(__FILE__), "..", "config", "nodejs.rb")
|
20
|
+
require File.join(File.dirname(__FILE__), "..", "config", "elixir.rb")
|
data/lib/inch/api.rb
CHANGED
@@ -23,14 +23,14 @@ module Inch
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
26
|
+
require "inch/api/options/base"
|
27
|
+
require "inch/api/options/filter"
|
28
|
+
require "inch/api/options/suggest"
|
29
29
|
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
30
|
+
require "inch/api/compare"
|
31
|
+
require "inch/api/filter"
|
32
|
+
require "inch/api/get"
|
33
|
+
require "inch/api/list"
|
34
|
+
require "inch/api/suggest"
|
35
|
+
require "inch/api/stats"
|
36
|
+
require "inch/api/diff"
|
data/lib/inch/api/compare.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "inch/api/compare/code_objects"
|
2
|
+
require "inch/api/compare/codebases"
|
@@ -3,11 +3,11 @@ module Inch
|
|
3
3
|
module Compare
|
4
4
|
class CodeObjects
|
5
5
|
attr_reader :before, :after
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(object1, object2)
|
8
8
|
@before, @after = object1, object2
|
9
9
|
if @before.object_id == @after.object_id
|
10
|
-
|
10
|
+
fail "@before and @after are identical ruby objects. this is bad."
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -23,7 +23,6 @@ module Inch
|
|
23
23
|
@after.grade
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
26
|
def added?
|
28
27
|
@before.nil? && !@after.nil?
|
29
28
|
end
|
data/lib/inch/api/diff.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "inch/utils/shell_helper"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module API
|
@@ -16,24 +16,24 @@ module Inch
|
|
16
16
|
# @param before_rev [String] the 'before' revision
|
17
17
|
# @param after_rev [String,nil] the 'after' revision that the 'before'
|
18
18
|
# one is compared against
|
19
|
-
def initialize(dir, before_rev, after_rev = nil)
|
19
|
+
def initialize(dir, config, before_rev, after_rev = nil)
|
20
20
|
@work_dir = dir
|
21
|
-
@codebase_old = codebase_for(before_rev)
|
21
|
+
@codebase_old = codebase_for(before_rev, config)
|
22
22
|
@codebase_new = if after_rev.nil?
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
Codebase.parse(work_dir, config)
|
24
|
+
else
|
25
|
+
codebase_for(after_rev, config)
|
26
|
+
end
|
27
27
|
@comparer = API::Compare::Codebases.new(@codebase_old, @codebase_new)
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def codebase_for(revision)
|
33
|
-
if cached = codebase_from_cache(revision)
|
32
|
+
def codebase_for(revision, config)
|
33
|
+
if (cached = codebase_from_cache(revision))
|
34
34
|
cached
|
35
35
|
else
|
36
|
-
codebase = codebase_from_copy(work_dir, revision)
|
36
|
+
codebase = codebase_from_copy(work_dir, config, revision)
|
37
37
|
filename = Codebase::Serializer.filename(revision)
|
38
38
|
Codebase::Serializer.save(codebase, filename)
|
39
39
|
codebase
|
@@ -42,17 +42,15 @@ module Inch
|
|
42
42
|
|
43
43
|
def codebase_from_cache(revision)
|
44
44
|
filename = Codebase::Serializer.filename(revision)
|
45
|
-
if File.exist?(filename)
|
46
|
-
Codebase::Serializer.load(filename)
|
47
|
-
end
|
45
|
+
Codebase::Serializer.load(filename) if File.exist?(filename)
|
48
46
|
end
|
49
47
|
|
50
|
-
def codebase_from_copy(original_dir, revision)
|
48
|
+
def codebase_from_copy(original_dir, config, revision)
|
51
49
|
codebase = nil
|
52
50
|
Dir.mktmpdir do |tmp_dir|
|
53
51
|
new_dir = copy_work_dir(original_dir, tmp_dir)
|
54
52
|
git_reset(new_dir, revision)
|
55
|
-
codebase = Codebase.parse(new_dir)
|
53
|
+
codebase = Codebase.parse(new_dir, config)
|
56
54
|
end
|
57
55
|
codebase
|
58
56
|
end
|
@@ -65,7 +63,6 @@ module Inch
|
|
65
63
|
def git_reset(dir, revision = nil)
|
66
64
|
git dir, "reset --hard #{revision}"
|
67
65
|
end
|
68
|
-
|
69
66
|
end
|
70
67
|
end
|
71
68
|
end
|
data/lib/inch/api/filter.rb
CHANGED
@@ -8,7 +8,7 @@ module Inch
|
|
8
8
|
|
9
9
|
def initialize(codebase, options)
|
10
10
|
@codebase = codebase
|
11
|
-
codebase.objects.filter! Options::Filter(options)
|
11
|
+
codebase.objects.filter! Options::Filter.new(options)
|
12
12
|
@objects = codebase.objects.to_a
|
13
13
|
@grade_lists = @codebase.grade_lists
|
14
14
|
end
|
data/lib/inch/api/get.rb
CHANGED
@@ -15,10 +15,10 @@ module Inch
|
|
15
15
|
# Returns all objects matching the given +object_names+
|
16
16
|
#
|
17
17
|
# @param object_names [Array<String>]
|
18
|
-
# @return [Array<CodeObject::Proxy
|
18
|
+
# @return [Array<CodeObject::Proxy>]
|
19
19
|
def find_objects_with_names(object_names)
|
20
20
|
object_names.map do |object_name|
|
21
|
-
if object = codebase.objects.find(object_name)
|
21
|
+
if (object = codebase.objects.find(object_name))
|
22
22
|
object
|
23
23
|
else
|
24
24
|
codebase.objects.starting_with(object_name)
|
@@ -33,10 +33,10 @@ module Inch
|
|
33
33
|
|
34
34
|
def read(options_or_hash, name)
|
35
35
|
value = if options_or_hash.is_a?(Hash)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
options_or_hash[name]
|
37
|
+
else
|
38
|
+
options_or_hash.send(name)
|
39
|
+
end
|
40
40
|
instance_variable_set("@#{name}", value)
|
41
41
|
end
|
42
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "inch/evaluation/proxy"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module API
|
@@ -14,7 +14,7 @@ module Inch
|
|
14
14
|
DEFAULT_GRADES_TO_DISPLAY = [:B, :C, :U]
|
15
15
|
DEFAULT_GRADE_WEIGHTS = [0.2, 0.4, 0.4]
|
16
16
|
DEFAULT_OBJECT_MIN_PRIORITY = 0
|
17
|
-
DEFAULT_OBJECT_MAX_SCORE = ::Inch::Evaluation::Proxy::
|
17
|
+
DEFAULT_OBJECT_MAX_SCORE = ::Inch::Evaluation::Proxy::MAX_SCORE
|
18
18
|
end
|
19
19
|
|
20
20
|
include DefaultAttributeValues
|
@@ -27,10 +27,6 @@ module Inch
|
|
27
27
|
attribute :object_min_priority, DEFAULT_OBJECT_MIN_PRIORITY
|
28
28
|
attribute :object_max_score, DEFAULT_OBJECT_MAX_SCORE
|
29
29
|
end
|
30
|
-
|
31
|
-
def self.Suggest(options_or_hash)
|
32
|
-
Suggest.new(options_or_hash)
|
33
|
-
end
|
34
30
|
end
|
35
31
|
end
|
36
32
|
end
|
data/lib/inch/api/stats.rb
CHANGED
data/lib/inch/api/suggest.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "inch/utils/weighted_list"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module API
|
5
5
|
class Suggest < Filter
|
6
6
|
def initialize(codebase, options)
|
7
7
|
super
|
8
|
-
@options = Options::Suggest(options)
|
8
|
+
@options = Options::Suggest.new(options)
|
9
9
|
end
|
10
10
|
|
11
11
|
def files
|
@@ -19,7 +19,6 @@ module Inch
|
|
19
19
|
filter_objects_to_display
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
22
|
# @return [Array] all the objects that match +@options+
|
24
23
|
def all_objects
|
25
24
|
relevant_objects
|
@@ -52,15 +51,13 @@ module Inch
|
|
52
51
|
|
53
52
|
list = Codebase::Objects.sort_by_priority(weighted_list.to_a.flatten)
|
54
53
|
|
55
|
-
if list.size > object_count
|
56
|
-
list = list[0...object_count]
|
57
|
-
end
|
54
|
+
list = list[0...object_count] if list.size > object_count
|
58
55
|
list
|
59
56
|
end
|
60
57
|
|
61
58
|
def files_sorted_by_importance
|
62
59
|
list = all_filenames(relevant_objects).uniq.map do |filename|
|
63
|
-
|
60
|
+
Evaluation::File.for(filename, relevant_objects)
|
64
61
|
end
|
65
62
|
|
66
63
|
priority_list = list.select do |f|
|
@@ -68,7 +65,8 @@ module Inch
|
|
68
65
|
relevant_priorities.include?(f.priority)
|
69
66
|
end
|
70
67
|
|
71
|
-
Codebase::Objects.sort_by_priority(
|
68
|
+
Codebase::Objects.sort_by_priority(
|
69
|
+
priority_list.empty? ? list : priority_list)
|
72
70
|
end
|
73
71
|
|
74
72
|
def all_filenames(objects)
|
@@ -87,7 +85,7 @@ module Inch
|
|
87
85
|
end
|
88
86
|
|
89
87
|
def grade_list(grade_symbol)
|
90
|
-
grade_lists.
|
88
|
+
grade_lists.find { |r| r.grade.to_sym == grade_symbol }
|
91
89
|
end
|
92
90
|
|
93
91
|
def select_by_priority(list, min_priority)
|
@@ -99,7 +97,8 @@ module Inch
|
|
99
97
|
end
|
100
98
|
|
101
99
|
def relevant_objects
|
102
|
-
@relevant_objects ||= select_by_priority(codebase.objects,
|
100
|
+
@relevant_objects ||= select_by_priority(codebase.objects,
|
101
|
+
@options.object_min_priority)
|
103
102
|
end
|
104
103
|
|
105
104
|
def relevant_priorities
|
data/lib/inch/cli.rb
CHANGED
@@ -11,7 +11,7 @@ module Inch
|
|
11
11
|
# @return [Fixnum]
|
12
12
|
def get_term_columns(default = 80)
|
13
13
|
str = `stty size`
|
14
|
-
rows_cols = str.split(
|
14
|
+
rows_cols = str.split(" ").map(&:to_i)
|
15
15
|
rows_cols[1] || default
|
16
16
|
rescue
|
17
17
|
default
|
@@ -21,9 +21,9 @@ module Inch
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
24
|
+
require "inch/cli/arguments"
|
25
|
+
require "inch/cli/sparkline_helper"
|
26
|
+
require "inch/cli/trace_helper"
|
27
|
+
require "inch/cli/yardopts_helper"
|
28
28
|
|
29
|
-
require
|
29
|
+
require "inch/cli/command"
|
data/lib/inch/cli/arguments.rb
CHANGED
@@ -28,10 +28,10 @@ module Inch
|
|
28
28
|
# @param args [Array<String>]
|
29
29
|
# @return [void]
|
30
30
|
def parse(args)
|
31
|
-
if first_non_file = args.find_index { |e| !glob_or_file?(e) }
|
31
|
+
if (first_non_file = args.find_index { |e| !glob_or_file?(e) })
|
32
32
|
@files = args[0...first_non_file]
|
33
33
|
rest = args[first_non_file..-1]
|
34
|
-
if first_switch = rest.find_index { |e| switch?(e) }
|
34
|
+
if (first_switch = rest.find_index { |e| switch?(e) })
|
35
35
|
@object_names = rest[0...first_switch]
|
36
36
|
@switches = rest[first_switch..-1]
|
37
37
|
else
|
data/lib/inch/cli/command.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "inch/cli/command/base"
|
2
|
+
require "inch/cli/command/base_list"
|
3
|
+
require "inch/cli/command/base_object"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "inch/cli/command/options/base"
|
6
|
+
require "inch/cli/command/options/base_list"
|
7
|
+
require "inch/cli/command/options/base_object"
|
8
8
|
|
9
|
-
require
|
9
|
+
require "inch/cli/command/output/base"
|
10
10
|
|
11
|
-
require
|
11
|
+
require "inch/cli/command_parser"
|
12
12
|
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
13
|
+
require "inch/cli/command/list"
|
14
|
+
require "inch/cli/command/show"
|
15
|
+
require "inch/cli/command/stats"
|
16
|
+
require "inch/cli/command/suggest"
|
17
|
+
require "inch/cli/command/console"
|
18
|
+
require "inch/cli/command/inspect"
|
19
|
+
require "inch/cli/command/diff"
|
@@ -45,7 +45,8 @@ module Inch
|
|
45
45
|
# @see #run
|
46
46
|
# @return [Command::Base] the instance that ran
|
47
47
|
def self.run(*args)
|
48
|
-
|
48
|
+
kwargs = args.last.is_a?(Hash) ? args.pop : {}
|
49
|
+
command = new(kwargs)
|
49
50
|
command.run(*args)
|
50
51
|
command
|
51
52
|
end
|
@@ -59,11 +60,9 @@ module Inch
|
|
59
60
|
CLI::CommandParser.commands[name] = self
|
60
61
|
end
|
61
62
|
|
62
|
-
def initialize
|
63
|
-
|
64
|
-
|
65
|
-
@options = options_class.new
|
66
|
-
@options.usage = usage
|
63
|
+
def initialize(kwargs = {})
|
64
|
+
@ui = kwargs[:ui] if kwargs[:ui]
|
65
|
+
initialize_cli_options
|
67
66
|
end
|
68
67
|
|
69
68
|
# Returns a description of the command
|
@@ -87,9 +86,9 @@ module Inch
|
|
87
86
|
#
|
88
87
|
# @abstract
|
89
88
|
# @note Override with implementation
|
90
|
-
# @param *
|
91
|
-
def run(*
|
92
|
-
|
89
|
+
# @param *_args [Array<String>]
|
90
|
+
def run(*_args)
|
91
|
+
fail NotImplementedError
|
93
92
|
end
|
94
93
|
|
95
94
|
# Returns a description of the command's usage pattern
|
@@ -98,6 +97,28 @@ module Inch
|
|
98
97
|
def usage
|
99
98
|
"Usage: inch #{name} [options]"
|
100
99
|
end
|
100
|
+
|
101
|
+
protected
|
102
|
+
|
103
|
+
def initialize_cli_options
|
104
|
+
name = self.class.to_s.split("::").last
|
105
|
+
options_class = Command::Options.const_get(name)
|
106
|
+
@options = options_class.new
|
107
|
+
@options.usage = usage
|
108
|
+
end
|
109
|
+
|
110
|
+
# Creates a Config::Codebase object and returns it
|
111
|
+
# (merges relevant values of a given +options+ object before).
|
112
|
+
#
|
113
|
+
# @param options [Options::Base]
|
114
|
+
# @return [Config::Codebase]
|
115
|
+
def to_config(options)
|
116
|
+
config = Config.for(@options.language, Dir.pwd).codebase
|
117
|
+
config.included_files = options.paths unless options.paths.empty?
|
118
|
+
config.excluded_files = options.excluded unless options.excluded.empty?
|
119
|
+
config.read_dump_file = options.read_dump_file
|
120
|
+
config
|
121
|
+
end
|
101
122
|
end
|
102
123
|
end
|
103
124
|
end
|