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.
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
@@ -1,12 +1,12 @@
1
- require 'simplecov'
1
+ require "simplecov"
2
2
 
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
4
4
 
5
- require 'minitest/autorun'
6
- require 'bundler'
5
+ require "minitest/autorun"
6
+ require "bundler"
7
7
  Bundler.require
8
- require 'inch'
9
- require 'inch/cli'
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__) + '/../../test_helper')
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 = {:visibility => [:public]}
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 = {:visibility => [:protected]}
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 = {:visibility => [:private]}
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 = {:namespaces => :only}
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 = {:undocumented => :only}
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 = {:depth => 2}
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
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
2
 
3
3
  describe ::Inch::API::Get do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
2
 
3
3
  describe ::Inch::API::List do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
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 = {:foo => "foo", :baz => 42}
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 = {:baz => 42}
24
+ @options_hash = { baz: 42 }
25
25
  @options = APIOptionsTest.new @options_hash
26
26
 
27
27
  assert_equal :bar, @options.foo
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
2
 
3
3
  describe ::Inch::API::Stats do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
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 = {:object_count => 10}
16
+ @options = { object_count: 10 }
17
17
  @context = ::Inch::API::Suggest.new @codebase, @options
18
18
 
19
- @options2 = {:object_count => 20}
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__) + '/../../test_helper')
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__) + '/../../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../test_helper")
2
2
 
3
3
  describe ::Inch::CLI::Command::Console do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
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,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
2
2
 
3
3
  describe ::Inch::CLI::Command::Options::BaseObject do
4
4
  it "should run parse without errors" do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
2
2
 
3
3
  describe ::Inch::CLI::Command::Options::Base do
4
4
  it "should run parse without errors" do
@@ -1,14 +1,14 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
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,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
2
 
3
3
  class Tracer
4
4
  include ::Inch::CLI::TraceHelper
@@ -1,15 +1,15 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
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, "--[no-]yardopts should be mentioned"
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,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
2
 
3
3
  describe ::Inch::CodeObject::Converter do
4
4
  class MockObject
@@ -1,9 +1,9 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
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__) + '/../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
2
 
3
- describe ::Inch::CodeObject::Proxy::Base do
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__) + '/../../test_helper')
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 |o|
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__) + '/../../test_helper')
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__) + '/../../test_helper')
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__) + '/../../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
2
 
3
- class MockPrivateRole < ::Inch::Evaluation::Role::Base
3
+ class MockPrivateRole < ::Inch::Evaluation::Role
4
4
  applicable_if :private?
5
5
  end
6
6
 
7
- class MockNotPrivateRole < ::Inch::Evaluation::Role::Base
7
+ class MockNotPrivateRole < ::Inch::Evaluation::Role
8
8
  applicable_unless :private?
9
9
  end
10
10
 
11
- class MockPublicRole < ::Inch::Evaluation::Role::Base
11
+ class MockPublicRole < ::Inch::Evaluation::Role
12
12
  applicable_if { |o| o.public? }
13
13
  end
14
14
 
15
- class MockIndifferentRole < ::Inch::Evaluation::Role::Base
16
- def self.applicable?(object)
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::Base do
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__) + '/../../../test_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
2
2
 
3
- describe ::Inch::CodeObject::Proxy::MethodObject do
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 (text comment)" do
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 attr_accessor" do
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 attr_accessor" do
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 attr_accessor" do
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 attr_accessor" do
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(m, Inch::Evaluation::Role::Method::WithoutReturnDescription)
307
- assert_equal 1, count_roles(m, Inch::Evaluation::Role::Method::WithoutReturnType)
308
- assert_equal 1, count_roles(m, Inch::Evaluation::Role::MethodParameter::WithoutMention, 'block')
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, but not on the actual method" do
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 parameters" do
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?