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
@@ -21,9 +21,9 @@ module Inch
|
|
21
21
|
@options.parse(args)
|
22
22
|
@options.verify
|
23
23
|
|
24
|
-
|
25
|
-
@codebase = ::Inch::Codebase.parse(Dir.pwd, config)
|
24
|
+
@codebase = ::Inch::Codebase.parse(Dir.pwd, to_config(@options))
|
26
25
|
end
|
26
|
+
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "pry"
|
2
|
+
require "inch/cli/command/options/console"
|
3
|
+
require "inch/cli/command/output/console"
|
4
4
|
|
5
5
|
module Inch
|
6
6
|
module CLI
|
@@ -9,11 +9,11 @@ module Inch
|
|
9
9
|
register_command_as :console
|
10
10
|
|
11
11
|
def description
|
12
|
-
|
12
|
+
"Shows a console"
|
13
13
|
end
|
14
14
|
|
15
15
|
def usage
|
16
|
-
|
16
|
+
"Usage: inch console [paths] [OBJECT_NAME] [options]"
|
17
17
|
end
|
18
18
|
|
19
19
|
def run(*args)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "pry"
|
2
|
+
require "inch/cli/command/options/diff"
|
3
|
+
require "inch/cli/command/output/diff"
|
4
4
|
|
5
5
|
module Inch
|
6
6
|
module CLI
|
@@ -11,11 +11,11 @@ module Inch
|
|
11
11
|
register_command_as :diff
|
12
12
|
|
13
13
|
def description
|
14
|
-
|
14
|
+
"Shows a diff"
|
15
15
|
end
|
16
16
|
|
17
17
|
def usage
|
18
|
-
|
18
|
+
"Usage: inch diff [REV..[REV]] [options]"
|
19
19
|
end
|
20
20
|
|
21
21
|
def run(*args)
|
@@ -23,7 +23,8 @@ module Inch
|
|
23
23
|
@options.verify
|
24
24
|
|
25
25
|
before_rev, after_rev = revisions[0], revisions[1]
|
26
|
-
diff = API::Diff.new(work_dir,
|
26
|
+
diff = API::Diff.new(work_dir, to_config(@options),
|
27
|
+
before_rev, after_rev)
|
27
28
|
|
28
29
|
Output::Diff.new(@options, diff.comparer)
|
29
30
|
end
|
@@ -33,9 +34,8 @@ module Inch
|
|
33
34
|
# @return [Array<String>] the revisions passed in the command_line
|
34
35
|
def revisions
|
35
36
|
@revisions ||= @options.revisions.map do |rev|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
37
|
+
next unless rev
|
38
|
+
git(work_dir, "rev-parse #{rev}").strip
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "inch/cli/command/options/inspect"
|
2
|
+
require "inch/cli/command/output/inspect"
|
3
3
|
|
4
4
|
module Inch
|
5
5
|
module CLI
|
@@ -8,11 +8,12 @@ module Inch
|
|
8
8
|
register_command_as :inspect
|
9
9
|
|
10
10
|
def description
|
11
|
-
|
11
|
+
"Inspects an object"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
15
|
+
"Usage: inch inspect [paths] OBJECT_NAME [[OBJECT_NAME2] ...] " \
|
16
|
+
"[options]"
|
16
17
|
end
|
17
18
|
|
18
19
|
def run(*args)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "inch/cli/command/options/list"
|
2
|
+
require "inch/cli/command/output/list"
|
3
3
|
|
4
4
|
module Inch
|
5
5
|
module CLI
|
@@ -8,11 +8,11 @@ module Inch
|
|
8
8
|
register_command_as :list
|
9
9
|
|
10
10
|
def description
|
11
|
-
|
11
|
+
"Lists all objects with their results"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
15
|
+
"Usage: inch list [paths] [options]"
|
16
16
|
end
|
17
17
|
|
18
18
|
# Runs the commandline utility, parsing arguments and displaying a
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "optparse"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CLI
|
@@ -37,6 +37,8 @@ module Inch
|
|
37
37
|
end
|
38
38
|
|
39
39
|
attribute :usage, "" # usage description for the command
|
40
|
+
attribute :language, "ruby" # the programming language
|
41
|
+
attribute :read_dump_file, nil
|
40
42
|
attribute :paths, [] # the paths of the to-be-analysed sources
|
41
43
|
attribute :excluded, [] # paths to be excluded from the analysis
|
42
44
|
|
@@ -91,8 +93,8 @@ module Inch
|
|
91
93
|
#
|
92
94
|
# @return [String]
|
93
95
|
def description_hint_arrows
|
94
|
-
arrows = Evaluation::PriorityRange.all.map(&:arrow).join(
|
95
|
-
"Arrows (#{arrows}) hint at the importance of the object "
|
96
|
+
arrows = Evaluation::PriorityRange.all.map(&:arrow).join(" ")
|
97
|
+
"Arrows (#{arrows}) hint at the importance of the object " \
|
96
98
|
"being documented."
|
97
99
|
end
|
98
100
|
|
@@ -102,20 +104,13 @@ module Inch
|
|
102
104
|
# @return [String]
|
103
105
|
def description_hint_grades
|
104
106
|
grades = Evaluation::Grade.all
|
105
|
-
"School grades (#{grades.join(
|
107
|
+
"School grades (#{grades.join(", ")}) are assigned and " \
|
106
108
|
"displayed with each object."
|
107
109
|
end
|
108
110
|
|
109
|
-
DEFAULT_PATHS = ["{lib,app}/**/*.rb", "ext/**/*.c"]
|
110
|
-
|
111
111
|
def get_paths(args)
|
112
112
|
# @yard_files is assigned by YardoptsHelper#parse_yardopts_options
|
113
|
-
|
114
|
-
if paths.empty?
|
115
|
-
DEFAULT_PATHS
|
116
|
-
else
|
117
|
-
paths
|
118
|
-
end
|
113
|
+
@yard_files ? @yard_files : args.dup
|
119
114
|
end
|
120
115
|
|
121
116
|
# Adds a set of common options to the tail of the OptionParser
|
@@ -126,13 +121,19 @@ module Inch
|
|
126
121
|
opts.separator ""
|
127
122
|
opts.separator "Other options:"
|
128
123
|
opts.on("--[no-]color", "Run without color") do |v|
|
129
|
-
Term::ANSIColor
|
124
|
+
Term::ANSIColor.coloring = v
|
130
125
|
end
|
131
|
-
opts.on_tail(
|
126
|
+
opts.on_tail("-v", "--version", "Show version.") do
|
132
127
|
ui.trace "inch #{Inch::VERSION}"
|
133
128
|
exit
|
134
129
|
end
|
135
|
-
opts.on_tail(
|
130
|
+
opts.on_tail("-l", "--language [LANGUAGE]", "Set language (ruby|nodejs).") do |language|
|
131
|
+
@language = language
|
132
|
+
end
|
133
|
+
opts.on_tail("-r", "--read-from-dump [FILE]", "Read objects from dump.") do |file|
|
134
|
+
@read_dump_file = file
|
135
|
+
end
|
136
|
+
opts.on_tail("-h", "--help", "Show this help.") do
|
136
137
|
ui.trace opts
|
137
138
|
exit
|
138
139
|
end
|
@@ -165,7 +166,7 @@ module Inch
|
|
165
166
|
# Resets the command-line interface before each run
|
166
167
|
def reset
|
167
168
|
# color is enabled by default, can be turned of by switch --no-color
|
168
|
-
Term::ANSIColor
|
169
|
+
Term::ANSIColor.coloring = true
|
169
170
|
end
|
170
171
|
|
171
172
|
# Callback when an unrecognize option is parsed
|
@@ -11,7 +11,7 @@ module Inch
|
|
11
11
|
attribute :depth
|
12
12
|
|
13
13
|
attribute :show_all, false
|
14
|
-
|
14
|
+
alias_method :show_all?, :show_all
|
15
15
|
|
16
16
|
def parse(args)
|
17
17
|
opts = OptionParser.new
|
@@ -37,7 +37,6 @@ module Inch
|
|
37
37
|
|
38
38
|
protected
|
39
39
|
|
40
|
-
|
41
40
|
# Sets all list related options for the current Options object
|
42
41
|
#
|
43
42
|
# @param opts [OptionParser]
|
@@ -50,10 +49,13 @@ module Inch
|
|
50
49
|
@show_all = true
|
51
50
|
end
|
52
51
|
|
53
|
-
opts.on("--only-namespaces",
|
52
|
+
opts.on("--only-namespaces",
|
53
|
+
"Only show namespaces (classes, modules)") do
|
54
54
|
@namespaces = :only
|
55
55
|
end
|
56
|
-
opts.on("--no-namespaces",
|
56
|
+
opts.on("--no-namespaces",
|
57
|
+
"Only show namespace children (methods, constants, " \
|
58
|
+
"attributes)") do
|
57
59
|
@namespaces = :none
|
58
60
|
end
|
59
61
|
|
@@ -74,7 +76,9 @@ module Inch
|
|
74
76
|
@undocumented = :none
|
75
77
|
end
|
76
78
|
|
77
|
-
opts.on("--depth [DEPTH]",
|
79
|
+
opts.on("--depth [DEPTH]",
|
80
|
+
"Only show objects up to a given DEPTH " \
|
81
|
+
"in the class tree") do |depth|
|
78
82
|
@depth = depth.to_i
|
79
83
|
end
|
80
84
|
end
|
@@ -8,17 +8,18 @@ module Inch
|
|
8
8
|
"",
|
9
9
|
"Provides a PRY based REPL to inspect objects.",
|
10
10
|
"",
|
11
|
-
"Example: " +
|
11
|
+
"Example: " +
|
12
|
+
"$ inch console lib/**/*.rb Foo::Bar#initialize".color(:cyan),
|
12
13
|
"",
|
13
14
|
"Shortcut commands on the prompt are:",
|
14
15
|
"",
|
15
16
|
"all".ljust(5) + " returns all code objects",
|
16
17
|
"f".ljust(5) + " finds an object by its path",
|
17
18
|
"ff".ljust(5) + " finds all objects given a partial path",
|
18
|
-
"o".ljust(5) +
|
19
|
+
"o".ljust(5) +
|
20
|
+
" returns the code object for OBJECT_NAME (if present)"
|
19
21
|
]
|
20
22
|
end
|
21
|
-
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "inch/utils/shell_helper"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CLI
|
@@ -59,11 +59,13 @@ module Inch
|
|
59
59
|
opts.separator ""
|
60
60
|
opts.separator "Diff options:"
|
61
61
|
|
62
|
-
opts.on("--since-last-commit",
|
62
|
+
opts.on("--since-last-commit",
|
63
|
+
"Run diff against last commit (default)") do
|
63
64
|
@before_rev = "HEAD"
|
64
65
|
end
|
65
|
-
opts.on("-p", "--since-last-push",
|
66
|
-
|
66
|
+
opts.on("-p", "--since-last-push",
|
67
|
+
"Run diff against last pushed commit") do
|
68
|
+
@before_rev = pushed_rev
|
67
69
|
@since_last_push = true
|
68
70
|
end
|
69
71
|
end
|
@@ -71,8 +73,8 @@ module Inch
|
|
71
73
|
# @return [String] the reference for the pushed revision
|
72
74
|
#
|
73
75
|
# @example
|
74
|
-
#
|
75
|
-
def
|
76
|
+
# pushed_rev # => "origin/master"
|
77
|
+
def pushed_rev
|
76
78
|
"#{remote}/#{current_branch}"
|
77
79
|
end
|
78
80
|
|
@@ -3,11 +3,11 @@ module Inch
|
|
3
3
|
module Command
|
4
4
|
module Options
|
5
5
|
class Inspect < BaseObject
|
6
|
-
|
7
6
|
def descriptions
|
8
7
|
[
|
9
8
|
"",
|
10
|
-
"Example: " +
|
9
|
+
"Example: " +
|
10
|
+
"$ inch inspect lib/**/*.rb Foo::Bar#initialize".color(:cyan),
|
11
11
|
"",
|
12
12
|
"Shows one or more objects in detail."
|
13
13
|
]
|
@@ -8,7 +8,8 @@ module Inch
|
|
8
8
|
def descriptions
|
9
9
|
[
|
10
10
|
"",
|
11
|
-
"Lists objects that can be improved regarding their
|
11
|
+
"Lists objects that can be improved regarding their " \
|
12
|
+
"documentation ordered by their grade.",
|
12
13
|
"",
|
13
14
|
"Example: " + "$ inch list lib/**/*.rb --all".color(:cyan),
|
14
15
|
"",
|
@@ -19,7 +20,7 @@ module Inch
|
|
19
20
|
|
20
21
|
def list_options(opts)
|
21
22
|
super
|
22
|
-
opts.on("--numbers", "Show numbers instead of grades and arrows") do
|
23
|
+
opts.on("--numbers", "Show numbers instead of grades and arrows") do
|
23
24
|
@numbers = true
|
24
25
|
end
|
25
26
|
end
|
@@ -3,11 +3,11 @@ module Inch
|
|
3
3
|
module Command
|
4
4
|
module Options
|
5
5
|
class Show < BaseObject
|
6
|
-
|
7
6
|
def descriptions
|
8
7
|
[
|
9
8
|
"",
|
10
|
-
"Example: " +
|
9
|
+
"Example: " +
|
10
|
+
"$ inch show lib/**/*.rb Foo::Bar#initialize".color(:cyan),
|
11
11
|
"",
|
12
12
|
"Shows one or more objects in detail.",
|
13
13
|
description_hint_grades,
|
@@ -26,9 +26,11 @@ module Inch
|
|
26
26
|
def descriptions
|
27
27
|
[
|
28
28
|
"",
|
29
|
-
"Suggests objects and files that can be improved regarding
|
29
|
+
"Suggests objects and files that can be improved regarding " \
|
30
|
+
"their documentation.",
|
30
31
|
"",
|
31
|
-
"Example: " +
|
32
|
+
"Example: " +
|
33
|
+
"$ inch suggest lib/**/*.rb --pedantic".color(:cyan),
|
32
34
|
"",
|
33
35
|
description_hint_grades,
|
34
36
|
description_hint_arrows
|
@@ -44,7 +46,8 @@ module Inch
|
|
44
46
|
opts.on("-n", "--objects [COUNT]", "Show COUNT objects") do |count|
|
45
47
|
@object_count = count.to_i
|
46
48
|
end
|
47
|
-
opts.on("--pedantic",
|
49
|
+
opts.on("--pedantic",
|
50
|
+
"Be excessively concerned with minor details and rules") do
|
48
51
|
# all objects are considered a priority
|
49
52
|
@object_min_priority = -99
|
50
53
|
# only objects with the highest score are omitted from the list
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "optparse"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CLI
|
@@ -20,15 +20,13 @@ module Inch
|
|
20
20
|
|
21
21
|
def priority_arrow(priority, color = :white)
|
22
22
|
Evaluation::PriorityRange.all.each do |range|
|
23
|
-
if range.include?(priority)
|
24
|
-
return range.arrow.color(color).dark
|
25
|
-
end
|
23
|
+
return range.arrow.color(color).dark if range.include?(priority)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
def print_file_info(o,
|
27
|
+
def print_file_info(o, color)
|
30
28
|
o.files.each do |f|
|
31
|
-
echo "-> #{f.filename}:#{f.line_no}".color(
|
29
|
+
echo "-> #{f.filename}:#{f.line_no}".color(color)
|
32
30
|
end
|
33
31
|
echo separator
|
34
32
|
end
|
@@ -11,8 +11,8 @@ module Inch
|
|
11
11
|
BG_COLOR = :color207 # magenta-ish
|
12
12
|
|
13
13
|
# @param options [Options::Console]
|
14
|
-
# @param object [CodeObject::Proxy
|
15
|
-
# @param objects [Array<CodeObject::Proxy
|
14
|
+
# @param object [CodeObject::Proxy]
|
15
|
+
# @param objects [Array<CodeObject::Proxy>]
|
16
16
|
# @param codebase [Codebase::Proxy]
|
17
17
|
def initialize(options, object, objects, codebase)
|
18
18
|
@options = options
|
@@ -35,11 +35,10 @@ module Inch
|
|
35
35
|
@codebase.objects.find(fullname)
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
alias_method :all, :all_objects
|
39
|
+
alias_method :ff, :find_objects
|
40
|
+
alias_method :f, :find_object
|
41
|
+
alias_method :o, :object
|
43
42
|
|
44
43
|
def run
|
45
44
|
ui.trace
|
@@ -27,7 +27,7 @@ module Inch
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def show(added, improved, degraded)
|
30
|
-
|
30
|
+
unless added.empty? && improved.empty?
|
31
31
|
ui.trace
|
32
32
|
ui.header("Added or improved:", :green)
|
33
33
|
added.each do |compare|
|
@@ -38,7 +38,7 @@ module Inch
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
unless degraded.empty?
|
42
42
|
ui.trace
|
43
43
|
ui.header("Degraded:", :red)
|
44
44
|
degraded.each do |compare|
|
@@ -54,7 +54,6 @@ module Inch
|
|
54
54
|
|
55
55
|
def puts_added(o)
|
56
56
|
grade = colored_grade(o)
|
57
|
-
priority = o.priority
|
58
57
|
change = " + ".dark + grade + " " + priority_arrow(o.priority)
|
59
58
|
ui.sub(" #{change} #{o.fullname}")
|
60
59
|
end
|
@@ -62,10 +61,11 @@ module Inch
|
|
62
61
|
def puts_improved(before, o)
|
63
62
|
before_grade = colored_grade(before)
|
64
63
|
grade = colored_grade(o)
|
65
|
-
change = before_grade + " -> ".dark + grade + " " +
|
64
|
+
change = before_grade + " -> ".dark + grade + " " +
|
65
|
+
priority_arrow(o.priority)
|
66
66
|
ui.sub(" #{change} #{o.fullname}")
|
67
67
|
end
|
68
|
-
|
68
|
+
alias_method :puts_degraded, :puts_improved
|
69
69
|
|
70
70
|
def colored_grade(o)
|
71
71
|
r = grade_list(o.grade.to_sym)
|
@@ -74,7 +74,7 @@ module Inch
|
|
74
74
|
|
75
75
|
def grade_list(grade_symbol)
|
76
76
|
@grade_lists ||= Evaluation.new_grade_lists
|
77
|
-
@grade_lists.
|
77
|
+
@grade_lists.find { |r| r.grade.to_sym == grade_symbol }
|
78
78
|
end
|
79
79
|
|
80
80
|
def rev_hint
|