inch 0.5.0.rc3 → 0.5.0.rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -0
  3. data/.rubocop_todo.yml +94 -0
  4. data/CHANGELOG.md +26 -2
  5. data/Gemfile +5 -2
  6. data/README.md +3 -3
  7. data/Rakefile +6 -2
  8. data/bin/inch +3 -3
  9. data/config/{example.yml → .inch.yml.sample} +1 -0
  10. data/config/base.rb +53 -0
  11. data/config/elixir.rb +43 -0
  12. data/config/nodejs.rb +10 -0
  13. data/config/{defaults.rb → ruby.rb} +5 -54
  14. data/inch.gemspec +7 -7
  15. data/lib/inch.rb +14 -9
  16. data/lib/inch/api.rb +10 -10
  17. data/lib/inch/api/compare.rb +2 -2
  18. data/lib/inch/api/compare/code_objects.rb +2 -3
  19. data/lib/inch/api/compare/codebases.rb +1 -1
  20. data/lib/inch/api/diff.rb +13 -16
  21. data/lib/inch/api/filter.rb +1 -1
  22. data/lib/inch/api/get.rb +2 -2
  23. data/lib/inch/api/options/base.rb +4 -4
  24. data/lib/inch/api/options/filter.rb +0 -4
  25. data/lib/inch/api/options/suggest.rb +2 -6
  26. data/lib/inch/api/stats.rb +0 -1
  27. data/lib/inch/api/suggest.rb +9 -10
  28. data/lib/inch/cli.rb +6 -6
  29. data/lib/inch/cli/arguments.rb +2 -2
  30. data/lib/inch/cli/command.rb +15 -15
  31. data/lib/inch/cli/command/base.rb +30 -9
  32. data/lib/inch/cli/command/base_list.rb +2 -2
  33. data/lib/inch/cli/command/console.rb +5 -5
  34. data/lib/inch/cli/command/diff.rb +9 -9
  35. data/lib/inch/cli/command/inspect.rb +5 -4
  36. data/lib/inch/cli/command/list.rb +4 -4
  37. data/lib/inch/cli/command/options/base.rb +17 -16
  38. data/lib/inch/cli/command/options/base_list.rb +9 -5
  39. data/lib/inch/cli/command/options/console.rb +4 -3
  40. data/lib/inch/cli/command/options/diff.rb +8 -6
  41. data/lib/inch/cli/command/options/inspect.rb +2 -2
  42. data/lib/inch/cli/command/options/list.rb +3 -2
  43. data/lib/inch/cli/command/options/show.rb +2 -2
  44. data/lib/inch/cli/command/options/stats.rb +2 -1
  45. data/lib/inch/cli/command/options/suggest.rb +6 -3
  46. data/lib/inch/cli/command/output/base.rb +4 -6
  47. data/lib/inch/cli/command/output/console.rb +6 -7
  48. data/lib/inch/cli/command/output/diff.rb +6 -6
  49. data/lib/inch/cli/command/output/inspect.rb +6 -8
  50. data/lib/inch/cli/command/output/list.rb +0 -1
  51. data/lib/inch/cli/command/output/show.rb +4 -5
  52. data/lib/inch/cli/command/output/stats.rb +21 -21
  53. data/lib/inch/cli/command/output/suggest.rb +31 -28
  54. data/lib/inch/cli/command/show.rb +4 -4
  55. data/lib/inch/cli/command/stats.rb +4 -4
  56. data/lib/inch/cli/command/suggest.rb +6 -6
  57. data/lib/inch/cli/command_parser.rb +6 -5
  58. data/lib/inch/cli/sparkline_helper.rb +6 -6
  59. data/lib/inch/cli/trace_helper.rb +1 -1
  60. data/lib/inch/cli/yardopts_helper.rb +4 -3
  61. data/lib/inch/code_object.rb +3 -3
  62. data/lib/inch/code_object/converter.rb +6 -8
  63. data/lib/inch/code_object/provider.rb +11 -11
  64. data/lib/inch/code_object/proxy.rb +61 -30
  65. data/lib/inch/codebase.rb +7 -8
  66. data/lib/inch/codebase/object.rb +60 -0
  67. data/lib/inch/codebase/objects.rb +8 -10
  68. data/lib/inch/codebase/objects_filter.rb +7 -5
  69. data/lib/inch/codebase/proxy.rb +4 -4
  70. data/lib/inch/codebase/serializer.rb +3 -3
  71. data/lib/inch/config.rb +42 -11
  72. data/lib/inch/config/base.rb +8 -29
  73. data/lib/inch/config/codebase.rb +32 -7
  74. data/lib/inch/config/evaluation.rb +61 -0
  75. data/lib/inch/core_ext.rb +1 -1
  76. data/lib/inch/core_ext/string.rb +1 -1
  77. data/lib/inch/evaluation.rb +13 -21
  78. data/lib/inch/evaluation/file.rb +4 -2
  79. data/lib/inch/evaluation/grade_list.rb +4 -4
  80. data/lib/inch/evaluation/priority_range.rb +3 -0
  81. data/lib/inch/evaluation/proxy.rb +139 -14
  82. data/lib/inch/evaluation/role.rb +99 -0
  83. data/lib/inch/language.rb +3 -0
  84. data/lib/inch/language/elixir/code_object/base.rb +197 -0
  85. data/lib/inch/language/elixir/code_object/function_object.rb +74 -0
  86. data/lib/inch/language/elixir/code_object/module_object.rb +23 -0
  87. data/lib/inch/language/elixir/code_object/type_object.rb +11 -0
  88. data/lib/inch/language/elixir/evaluation/base.rb +28 -0
  89. data/lib/inch/language/elixir/evaluation/function_object.rb +31 -0
  90. data/lib/inch/language/elixir/evaluation/module_object.rb +27 -0
  91. data/lib/inch/language/elixir/evaluation/type_object.rb +11 -0
  92. data/lib/inch/language/elixir/import.rb +24 -0
  93. data/lib/inch/language/elixir/provider/reader.rb +19 -0
  94. data/lib/inch/language/elixir/provider/reader/object.rb +63 -0
  95. data/lib/inch/language/elixir/provider/reader/object/base.rb +191 -0
  96. data/lib/inch/language/elixir/provider/reader/object/function_object.rb +26 -0
  97. data/lib/inch/language/elixir/provider/reader/object/module_object.rb +22 -0
  98. data/lib/inch/language/elixir/provider/reader/object/type_object.rb +15 -0
  99. data/lib/inch/language/elixir/provider/reader/parser.rb +55 -0
  100. data/lib/inch/language/elixir/roles/base.rb +32 -0
  101. data/lib/inch/language/elixir/roles/function.rb +112 -0
  102. data/lib/inch/language/elixir/roles/module.rb +64 -0
  103. data/lib/inch/language/elixir/roles/object.rb +76 -0
  104. data/lib/inch/language/elixir/roles/type.rb +13 -0
  105. data/lib/inch/language/nodejs/import.rb +8 -0
  106. data/lib/inch/language/nodejs/provider/jsdoc.rb +19 -0
  107. data/lib/inch/language/nodejs/provider/jsdoc/object.rb +55 -0
  108. data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +191 -0
  109. data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +59 -0
  110. data/lib/inch/language/ruby/code_object/base.rb +197 -0
  111. data/lib/inch/language/ruby/code_object/class_object.rb +10 -0
  112. data/lib/inch/language/ruby/code_object/class_variable_object.rb +10 -0
  113. data/lib/inch/language/ruby/code_object/constant_object.rb +10 -0
  114. data/lib/inch/language/ruby/code_object/method_object.rb +85 -0
  115. data/lib/inch/language/ruby/code_object/method_parameter_object.rb +64 -0
  116. data/lib/inch/language/ruby/code_object/module_object.rb +10 -0
  117. data/lib/inch/language/ruby/code_object/namespace_object.rb +35 -0
  118. data/lib/inch/language/ruby/evaluation/base.rb +45 -0
  119. data/lib/inch/language/ruby/evaluation/class_object.rb +10 -0
  120. data/lib/inch/language/ruby/evaluation/class_variable_object.rb +21 -0
  121. data/lib/inch/language/ruby/evaluation/constant_object.rb +21 -0
  122. data/lib/inch/language/ruby/evaluation/method_object.rb +74 -0
  123. data/lib/inch/language/ruby/evaluation/module_object.rb +10 -0
  124. data/lib/inch/language/ruby/evaluation/namespace_object.rb +30 -0
  125. data/lib/inch/language/ruby/import.rb +34 -0
  126. data/lib/inch/language/ruby/provider/yard.rb +58 -0
  127. data/lib/inch/language/ruby/provider/yard/docstring.rb +162 -0
  128. data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +97 -0
  129. data/lib/inch/language/ruby/provider/yard/object.rb +63 -0
  130. data/lib/inch/language/ruby/provider/yard/object/base.rb +325 -0
  131. data/lib/inch/language/ruby/provider/yard/object/class_object.rb +14 -0
  132. data/lib/inch/language/ruby/provider/yard/object/class_variable_object.rb +14 -0
  133. data/lib/inch/language/ruby/provider/yard/object/constant_object.rb +14 -0
  134. data/lib/inch/language/ruby/provider/yard/object/method_object.rb +170 -0
  135. data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +94 -0
  136. data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +120 -0
  137. data/lib/inch/language/ruby/provider/yard/object/module_object.rb +14 -0
  138. data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +46 -0
  139. data/lib/inch/language/ruby/provider/yard/object/root_object.rb +14 -0
  140. data/lib/inch/language/ruby/provider/yard/parser.rb +71 -0
  141. data/lib/inch/language/ruby/roles/base.rb +17 -0
  142. data/lib/inch/language/ruby/roles/class_variable.rb +53 -0
  143. data/lib/inch/language/ruby/roles/constant.rb +53 -0
  144. data/lib/inch/language/ruby/roles/method.rb +112 -0
  145. data/lib/inch/language/ruby/roles/method_parameter.rb +84 -0
  146. data/lib/inch/language/ruby/roles/missing.rb +24 -0
  147. data/lib/inch/language/ruby/roles/namespace.rb +89 -0
  148. data/lib/inch/language/ruby/roles/object.rb +120 -0
  149. data/lib/inch/rake.rb +2 -2
  150. data/lib/inch/rake/suggest.rb +7 -2
  151. data/lib/inch/utils/buffered_ui.rb +16 -0
  152. data/lib/inch/utils/shell_helper.rb +1 -1
  153. data/lib/inch/utils/ui.rb +5 -5
  154. data/lib/inch/utils/weighted_list.rb +2 -3
  155. data/lib/inch/version.rb +1 -1
  156. data/test/fixtures/{code_examples → ruby/code_examples}/lib/foo.rb +0 -0
  157. data/test/fixtures/{diff1 → ruby/diff1}/lib/diff1.rb +0 -0
  158. data/test/fixtures/{diff2 → ruby/diff2}/lib/diff2.rb +0 -0
  159. data/test/fixtures/{inch-yml → ruby/inch-yml}/.inch.yml +0 -0
  160. data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/bar.rb +0 -0
  161. data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/vendor/base.rb +0 -0
  162. data/test/fixtures/{parameters → ruby/parameters}/lib/foo.rb +0 -0
  163. data/test/fixtures/{readme → ruby/readme}/lib/foo.rb +0 -0
  164. data/test/fixtures/{really_good → ruby/really_good}/lib/foo.rb +0 -0
  165. data/test/fixtures/{really_good_pedantic → ruby/really_good_pedantic}/lib/foo.rb +0 -0
  166. data/test/fixtures/{simple → ruby/simple}/README +0 -0
  167. data/test/fixtures/{simple → ruby/simple}/lib/broken.rb +11 -19
  168. data/test/fixtures/ruby/simple/lib/broken_ruby_2_0_features.rb +7 -0
  169. data/test/fixtures/ruby/simple/lib/directives.rb +8 -0
  170. data/test/fixtures/{simple → ruby/simple}/lib/foo.rb +22 -1
  171. data/test/fixtures/{simple → ruby/simple}/lib/nodoc.rb +0 -0
  172. data/test/fixtures/{simple → ruby/simple}/lib/role_methods.rb +0 -0
  173. data/test/fixtures/{simple → ruby/simple}/lib/role_namespaces.rb +0 -0
  174. data/test/fixtures/{visibility → ruby/visibility}/lib/foo.rb +0 -0
  175. data/test/fixtures/{yardopts → ruby/yardopts}/.yardopts +0 -0
  176. data/test/fixtures/{yardopts → ruby/yardopts}/foo/bar.rb +0 -0
  177. data/test/integration/api/compare/codebases.rb +3 -3
  178. data/test/integration/cli/command/console_test.rb +6 -6
  179. data/test/integration/cli/command/diff_test.rb +62 -0
  180. data/test/integration/cli/command/inspect_test.rb +5 -6
  181. data/test/integration/cli/command/list_test.rb +4 -5
  182. data/test/integration/cli/command/show_test.rb +5 -5
  183. data/test/integration/cli/command/stats_test.rb +3 -3
  184. data/test/integration/cli/command/suggest_test.rb +13 -13
  185. data/test/integration/stats_options_test.rb +4 -4
  186. data/test/integration/visibility_options_test.rb +14 -14
  187. data/test/shared/base_list.rb +4 -3
  188. data/test/test_helper.rb +13 -13
  189. data/test/unit/api/filter_test.rb +7 -7
  190. data/test/unit/api/get_test.rb +1 -1
  191. data/test/unit/api/list_test.rb +1 -1
  192. data/test/unit/api/options/base_test.rb +3 -3
  193. data/test/unit/api/stats_test.rb +1 -1
  194. data/test/unit/api/suggest_test.rb +3 -3
  195. data/test/unit/cli/arguments_test.rb +2 -2
  196. data/test/unit/cli/command/base_test.rb +1 -1
  197. data/test/unit/cli/command/options/base_list_test.rb +2 -2
  198. data/test/unit/cli/command/options/base_object_test.rb +1 -1
  199. data/test/unit/cli/command/options/base_test.rb +1 -1
  200. data/test/unit/cli/command_parser_test.rb +3 -3
  201. data/test/unit/cli/trace_helper_test.rb +1 -1
  202. data/test/unit/cli/yardopts_helper_test.rb +6 -5
  203. data/test/unit/code_object/converter_test.rb +1 -1
  204. data/test/unit/code_object/provider_test.rb +2 -2
  205. data/test/unit/code_object/proxy_test.rb +2 -2
  206. data/test/unit/codebase/objects_test.rb +2 -2
  207. data/test/unit/codebase/proxy_test.rb +7 -5
  208. data/test/unit/config/codebase_test.rb +4 -4
  209. data/test/unit/config_test.rb +28 -0
  210. data/test/unit/evaluation/{role/base_test.rb → role_test.rb} +7 -7
  211. data/test/unit/{code_object/proxy → language/ruby/code_object}/method_object_test.rb +66 -21
  212. data/test/unit/{code_object → language/ruby}/provider/yard/docstring_test.rb +74 -38
  213. data/test/unit/{code_object → language/ruby}/provider/yard/nodoc_helper_test.rb +9 -7
  214. data/test/unit/{code_object → language/ruby}/provider/yard/object/method_object_test.rb +21 -11
  215. data/test/unit/language/ruby/provider/yard_test.rb +25 -0
  216. data/test/unit/utils/buffered_ui_test.rb +48 -0
  217. data/test/unit/utils/ui_test.rb +7 -7
  218. data/test/unit/utils/weighted_list_test.rb +7 -4
  219. metadata +139 -93
  220. data/lib/inch/code_object/provider/yard.rb +0 -57
  221. data/lib/inch/code_object/provider/yard/docstring.rb +0 -133
  222. data/lib/inch/code_object/provider/yard/nodoc_helper.rb +0 -93
  223. data/lib/inch/code_object/provider/yard/object.rb +0 -60
  224. data/lib/inch/code_object/provider/yard/object/base.rb +0 -302
  225. data/lib/inch/code_object/provider/yard/object/class_object.rb +0 -12
  226. data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
  227. data/lib/inch/code_object/provider/yard/object/constant_object.rb +0 -12
  228. data/lib/inch/code_object/provider/yard/object/method_object.rb +0 -153
  229. data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +0 -88
  230. data/lib/inch/code_object/provider/yard/object/method_signature.rb +0 -114
  231. data/lib/inch/code_object/provider/yard/object/module_object.rb +0 -12
  232. data/lib/inch/code_object/provider/yard/object/namespace_object.rb +0 -47
  233. data/lib/inch/code_object/provider/yard/object/root_object.rb +0 -12
  234. data/lib/inch/code_object/provider/yard/parser.rb +0 -62
  235. data/lib/inch/code_object/proxy/base.rb +0 -241
  236. data/lib/inch/code_object/proxy/class_object.rb +0 -8
  237. data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
  238. data/lib/inch/code_object/proxy/constant_object.rb +0 -8
  239. data/lib/inch/code_object/proxy/method_object.rb +0 -82
  240. data/lib/inch/code_object/proxy/method_parameter_object.rb +0 -60
  241. data/lib/inch/code_object/proxy/module_object.rb +0 -8
  242. data/lib/inch/code_object/proxy/namespace_object.rb +0 -33
  243. data/lib/inch/evaluation/object_schema.rb +0 -30
  244. data/lib/inch/evaluation/proxy/base.rb +0 -164
  245. data/lib/inch/evaluation/proxy/class_object.rb +0 -8
  246. data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
  247. data/lib/inch/evaluation/proxy/constant_object.rb +0 -19
  248. data/lib/inch/evaluation/proxy/method_object.rb +0 -65
  249. data/lib/inch/evaluation/proxy/module_object.rb +0 -8
  250. data/lib/inch/evaluation/proxy/namespace_object.rb +0 -27
  251. data/lib/inch/evaluation/role/base.rb +0 -92
  252. data/lib/inch/evaluation/role/class_variable.rb +0 -55
  253. data/lib/inch/evaluation/role/constant.rb +0 -55
  254. data/lib/inch/evaluation/role/method.rb +0 -126
  255. data/lib/inch/evaluation/role/method_parameter.rb +0 -91
  256. data/lib/inch/evaluation/role/missing.rb +0 -20
  257. data/lib/inch/evaluation/role/namespace.rb +0 -85
  258. data/lib/inch/evaluation/role/object.rb +0 -143
  259. 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
- config = Config::Codebase.new(@options.paths, @options.excluded)
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 'pry'
2
- require 'inch/cli/command/options/console'
3
- require 'inch/cli/command/output/console'
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
- 'Shows a console'
12
+ "Shows a console"
13
13
  end
14
14
 
15
15
  def usage
16
- 'Usage: inch console [paths] [OBJECT_NAME] [options]'
16
+ "Usage: inch console [paths] [OBJECT_NAME] [options]"
17
17
  end
18
18
 
19
19
  def run(*args)
@@ -1,6 +1,6 @@
1
- require 'pry'
2
- require 'inch/cli/command/options/diff'
3
- require 'inch/cli/command/output/diff'
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
- 'Shows a diff'
14
+ "Shows a diff"
15
15
  end
16
16
 
17
17
  def usage
18
- 'Usage: inch diff [REV..[REV]] [options]'
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, before_rev, after_rev)
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
- if rev
37
- git(work_dir, "rev-parse #{rev}").strip
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 'inch/cli/command/options/inspect'
2
- require 'inch/cli/command/output/inspect'
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
- 'Inspects an object'
11
+ "Inspects an object"
12
12
  end
13
13
 
14
14
  def usage
15
- 'Usage: inch inspect [paths] OBJECT_NAME [[OBJECT_NAME2] ...] [options]'
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 'inch/cli/command/options/list'
2
- require 'inch/cli/command/output/list'
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
- 'Lists all objects with their results'
11
+ "Lists all objects with their results"
12
12
  end
13
13
 
14
14
  def usage
15
- 'Usage: inch list [paths] [options]'
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 'optparse'
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(', ')}) are assigned and " +
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
- paths = @yard_files ? @yard_files : args.dup
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::coloring = v
124
+ Term::ANSIColor.coloring = v
130
125
  end
131
- opts.on_tail('-v', '--version', 'Show version.') do
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('-h', '--help', 'Show this help.') do
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::coloring = true
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
- alias :show_all? :show_all
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", "Only show namespaces (classes, modules)") do
52
+ opts.on("--only-namespaces",
53
+ "Only show namespaces (classes, modules)") do
54
54
  @namespaces = :only
55
55
  end
56
- opts.on("--no-namespaces", "Only show namespace children (methods, constants, attributes)") do
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]", "Only show objects up to a given DEPTH in the class tree") do |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: " + "$ inch console lib/**/*.rb Foo::Bar#initialize".color(:cyan),
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) + " returns the code object for OBJECT_NAME (if present)",
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 'inch/utils/shell_helper'
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", "Run diff against last commit (default)") do |count|
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", "Run diff against last pushed commit") do |count|
66
- @before_rev = get_pushed_rev
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
- # get_pushed_rev # => "origin/master"
75
- def get_pushed_rev
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: " + "$ inch inspect lib/**/*.rb Foo::Bar#initialize".color(:cyan),
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 documentation ordered by their grade.",
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 |depth|
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: " + "$ inch show lib/**/*.rb Foo::Bar#initialize".color(:cyan),
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,
@@ -9,7 +9,8 @@ module Inch
9
9
 
10
10
  def list_options(opts)
11
11
  super
12
- opts.on("-f", "--format [FORMAT]", FORMATS, "Set output FORMAT") do |format|
12
+ opts.on("-f", "--format [FORMAT]", FORMATS,
13
+ "Set output FORMAT") do |format|
13
14
  @format = format
14
15
  end
15
16
  end
@@ -26,9 +26,11 @@ module Inch
26
26
  def descriptions
27
27
  [
28
28
  "",
29
- "Suggests objects and files that can be improved regarding their documentation.",
29
+ "Suggests objects and files that can be improved regarding " \
30
+ "their documentation.",
30
31
  "",
31
- "Example: " + "$ inch suggest lib/**/*.rb --pedantic".color(:cyan),
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", "Be excessively concerned with minor details and rules") do |count|
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 'optparse'
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, _color)
27
+ def print_file_info(o, color)
30
28
  o.files.each do |f|
31
- echo "-> #{f.filename}:#{f.line_no}".color(_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::Base]
15
- # @param objects [Array<CodeObject::Proxy::Base>]
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
- alias :all :all_objects
39
- alias :ff :find_objects
40
- alias :f :find_object
41
- alias :o :object
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
- if !(added.empty? && improved.empty?)
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
- if !degraded.empty?
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 + " " + priority_arrow(o.priority)
64
+ change = before_grade + " -> ".dark + grade + " " +
65
+ priority_arrow(o.priority)
66
66
  ui.sub(" #{change} #{o.fullname}")
67
67
  end
68
- alias :puts_degraded :puts_improved
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.detect { |r| r.grade.to_sym == grade_symbol }
77
+ @grade_lists.find { |r| r.grade.to_sym == grade_symbol }
78
78
  end
79
79
 
80
80
  def rev_hint