inch 0.1.3 → 0.1.4

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -6
  3. data/TODOS.md +7 -0
  4. data/lib/inch/cli/arguments.rb +36 -2
  5. data/lib/inch/cli/command/base.rb +56 -8
  6. data/lib/inch/cli/command/base_list.rb +17 -3
  7. data/lib/inch/cli/command/base_object.rb +17 -4
  8. data/lib/inch/cli/command/options/base.rb +55 -10
  9. data/lib/inch/cli/command/options/base_list.rb +25 -5
  10. data/lib/inch/cli/command/options/base_object.rb +0 -2
  11. data/lib/inch/cli/command/options/list.rb +2 -2
  12. data/lib/inch/cli/command/options/show.rb +2 -2
  13. data/lib/inch/cli/command/options/suggest.rb +2 -2
  14. data/lib/inch/cli/command/output/base.rb +9 -0
  15. data/lib/inch/cli/command/output/console.rb +4 -0
  16. data/lib/inch/cli/command/output/inspect.rb +2 -2
  17. data/lib/inch/cli/command/output/list.rb +1 -1
  18. data/lib/inch/cli/command_parser.rb +30 -9
  19. data/lib/inch/code_object/nodoc_helper.rb +23 -2
  20. data/lib/inch/code_object/proxy.rb +16 -2
  21. data/lib/inch/code_object/proxy/base.rb +2 -23
  22. data/lib/inch/code_object/proxy/method_object.rb +1 -0
  23. data/lib/inch/code_object/proxy/method_parameter_object.rb +4 -1
  24. data/lib/inch/evaluation.rb +0 -2
  25. data/lib/inch/evaluation/base.rb +1 -0
  26. data/lib/inch/evaluation/constant_object.rb +0 -3
  27. data/lib/inch/evaluation/file.rb +0 -4
  28. data/lib/inch/evaluation/namespace_object.rb +1 -7
  29. data/lib/inch/evaluation/role/base.rb +29 -5
  30. data/lib/inch/evaluation/role/constant.rb +0 -5
  31. data/lib/inch/evaluation/role/object.rb +1 -5
  32. data/lib/inch/evaluation/score_range.rb +12 -0
  33. data/lib/inch/rake/suggest.rb +3 -0
  34. data/lib/inch/source_parser.rb +27 -1
  35. data/lib/inch/version.rb +1 -1
  36. data/test/fixtures/simple/lib/foo.rb +6 -0
  37. data/test/fixtures/simple/lib/role_namespaces.rb +15 -3
  38. data/test/inch/cli/command/base_test.rb +15 -0
  39. data/test/inch/cli/command/inspect_test.rb +9 -0
  40. data/test/inch/cli/command/list_test.rb +3 -0
  41. data/test/inch/cli/command/options/base_list_test.rb +50 -0
  42. data/test/inch/cli/command/options/base_object_test.rb +14 -0
  43. data/test/inch/cli/command/options/base_test.rb +8 -0
  44. data/test/inch/cli/command/suggest_test.rb +11 -0
  45. data/test/inch/cli/trace_helper_test.rb +47 -0
  46. data/test/inch/code_object/proxy_test.rb +10 -0
  47. data/test/integration/visibility_options_test.rb +24 -17
  48. data/test/test_helper.rb +80 -0
  49. metadata +13 -3
@@ -1,21 +1,15 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
- #
4
- # Tests with the YARD specific --no-public, --no-protected and --private
5
- # switches can't be run in one test instance. The flags seem to add up after
6
- # being called. In combination with a random test order this resulted in ever
7
- # different failure outputs.
8
- #
9
- # Therefore, here are some integration tests:
10
- #
11
- describe ::Inch::CLI::Command::List do
3
+ describe ::Inch::CLI::Command do
12
4
  before do
13
5
  Dir.chdir fixture_path(:visibility)
14
- @command = "bundle exec inch list"
6
+ @command = ::Inch::CLI::Command::List
15
7
  end
16
8
 
17
9
  it "should run without visibility switches" do
18
- out = %x|#{@command} --all|
10
+ out, err = capture_io do
11
+ @command.run("--all")
12
+ end
19
13
  refute out.empty?, "there should be some output"
20
14
  assert_match /\bFoo#public_method\b/, out
21
15
  assert_match /\bFoo#protected_method\b/, out
@@ -24,7 +18,9 @@ describe ::Inch::CLI::Command::List do
24
18
  end
25
19
 
26
20
  it "should run with --no-protected switch" do
27
- out = %x|#{@command} --all --no-protected|
21
+ out, err = capture_io do
22
+ @command.run("--all", "--no-protected")
23
+ end
28
24
  refute out.empty?, "there should be some output"
29
25
  assert_match /\bFoo#public_method\b/, out
30
26
  refute_match /\bFoo#protected_method\b/, out
@@ -33,7 +29,9 @@ describe ::Inch::CLI::Command::List do
33
29
  end
34
30
 
35
31
  it "should run with --no-public switch" do
36
- out = %x|#{@command} --all --no-public|
32
+ out, err = capture_io do
33
+ @command.run(*%w|--all --no-public|)
34
+ end
37
35
  refute out.empty?, "there should be some output"
38
36
  refute_match /\bFoo#public_method\b/, out
39
37
  assert_match /\bFoo#protected_method\b/, out
@@ -42,7 +40,9 @@ describe ::Inch::CLI::Command::List do
42
40
  end
43
41
 
44
42
  it "should run with --no-public --no-protected switch" do
45
- out = %x|#{@command} --all --no-public --no-protected|
43
+ out, err = capture_io do
44
+ @command.run(*%w|--all --no-public --no-protected|)
45
+ end
46
46
  assert out.empty?, "there should be no output"
47
47
  refute_match /\bFoo#public_method\b/, out
48
48
  refute_match /\bFoo#protected_method\b/, out
@@ -51,7 +51,9 @@ describe ::Inch::CLI::Command::List do
51
51
  end
52
52
 
53
53
  it "should run with --no-public --no-protected --private switch" do
54
- out = %x|#{@command} --all --no-public --no-protected --private|
54
+ out, err = capture_io do
55
+ @command.run(*%w|--all --no-public --no-protected --private|)
56
+ end
55
57
  refute out.empty?, "there should be some output"
56
58
  refute_match /\bFoo#public_method\b/, out
57
59
  refute_match /\bFoo#protected_method\b/, out
@@ -60,7 +62,9 @@ describe ::Inch::CLI::Command::List do
60
62
  end
61
63
 
62
64
  it "should run with --no-public switch" do
63
- out = %x|#{@command} --all --no-public|
65
+ out, err = capture_io do
66
+ @command.run(*%w|--all --no-public|)
67
+ end
64
68
  refute out.empty?, "there should be some output"
65
69
  refute_match /\bFoo#public_method\b/, out
66
70
  assert_match /\bFoo#protected_method\b/, out
@@ -69,11 +73,14 @@ describe ::Inch::CLI::Command::List do
69
73
  end
70
74
 
71
75
  it "should run with --no-protected switch" do
72
- out = %x|#{@command} --all --no-protected|
76
+ out, err = capture_io do
77
+ @command.run(*%w|--all --no-protected|)
78
+ end
73
79
  refute out.empty?, "there should be some output"
74
80
  assert_match /\bFoo#public_method\b/, out
75
81
  refute_match /\bFoo#protected_method\b/, out
76
82
  refute_match /\bFoo#private_method\b/, out # has @private tag
77
83
  refute_match /\bFoo#method_with_private_tag\b/, out # has a @private tag, but is really :public
78
84
  end
85
+
79
86
  end
@@ -25,3 +25,83 @@ def in_fixture_path(name, &block)
25
25
  yield
26
26
  Dir.chdir old_dir
27
27
  end
28
+
29
+
30
+ module BaseListTests
31
+ def self.included(other)
32
+ other.instance_eval do
33
+ # these tests are added when BaseListTests is included inside a
34
+ # `describe` block
35
+
36
+ it "should give error when run with --unknown-switch" do
37
+ out, err = capture_io do
38
+ assert_raises(SystemExit) { @command.run("lib/foo.rb", "--unknown-switch") }
39
+ end
40
+ end
41
+
42
+ it "should run with --depth switch" do
43
+ out, err = capture_io do
44
+ @command.run("lib/foo.rb", "--depth=2")
45
+ end
46
+ refute out.empty?, "there should be some output"
47
+ assert err.empty?, "there should be no errors"
48
+ assert_match /\bFoo\b/, out
49
+ assert_match /\bFoo::Bar\b/, out
50
+ refute_match /\bFoo::Bar#method_with_full_doc\b/, out
51
+ refute_match /\bFoo::Bar#method_with_code_example\b/, out
52
+ end
53
+
54
+ it "should run with --only-namespaces switch" do
55
+ out, err = capture_io do
56
+ @command.run("lib/foo.rb", "--only-namespaces")
57
+ end
58
+ refute out.empty?, "there should be some output"
59
+ assert err.empty?, "there should be no errors"
60
+ assert_match /\bFoo\s/, out
61
+ assert_match /\bFoo::Bar\s/, out
62
+ refute_match /\bFoo::Bar\./, out
63
+ refute_match /\bFoo::Bar#/, out
64
+ end
65
+
66
+ it "should run with --no-namespaces switch" do
67
+ out, err = capture_io do
68
+ @command.run("lib/foo.rb", "--no-namespaces")
69
+ end
70
+ refute out.empty?, "there should be some output"
71
+ assert err.empty?, "there should be no errors"
72
+ refute_match /\bFoo\s/, out
73
+ refute_match /\bFoo::Bar\s/, out
74
+ assert_match /\bFoo::Bar#/, out
75
+ end
76
+
77
+
78
+ it "should run with --only-undocumented switch" do
79
+ skip
80
+ out, err = capture_io do
81
+ @command.run("lib/foo.rb", "--all", "--only-undocumented")
82
+ end
83
+ refute out.empty?, "there should be some output"
84
+ assert err.empty?, "there should be no errors"
85
+ refute_match /\bFoo\s/, out
86
+ refute_match /\bFoo::Bar#method_with_full_doc\b/, out
87
+ assert_match /\bFoo::Bar\s/, out
88
+ assert_match /\bFoo::Bar#method_without_doc\b/, out
89
+ end
90
+
91
+ it "should run with --no-undocumented switch" do
92
+ skip
93
+ out, err = capture_io do
94
+ @command.run("lib/foo.rb", "--all", "--no-undocumented")
95
+ end
96
+ refute out.empty?, "there should be some output"
97
+ assert err.empty?, "there should be no errors"
98
+ assert_match /\bFoo\s/, out
99
+ assert_match /\bFoo::Bar#method_with_full_doc\b/, out
100
+ refute_match /\bFoo::Bar\s/, out
101
+ refute_match /\bFoo::Bar#method_without_doc\b/, out
102
+ end
103
+
104
+
105
+ end
106
+ end
107
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -191,13 +191,18 @@ files:
191
191
  - test/fixtures/yardopts/.yardopts
192
192
  - test/fixtures/yardopts/foo/bar.rb
193
193
  - test/inch/cli/arguments_test.rb
194
+ - test/inch/cli/command/base_test.rb
194
195
  - test/inch/cli/command/console_test.rb
195
196
  - test/inch/cli/command/inspect_test.rb
196
197
  - test/inch/cli/command/list_test.rb
198
+ - test/inch/cli/command/options/base_list_test.rb
199
+ - test/inch/cli/command/options/base_object_test.rb
200
+ - test/inch/cli/command/options/base_test.rb
197
201
  - test/inch/cli/command/show_test.rb
198
202
  - test/inch/cli/command/stats_test.rb
199
203
  - test/inch/cli/command/suggest_test.rb
200
204
  - test/inch/cli/command_parser_test.rb
205
+ - test/inch/cli/trace_helper_test.rb
201
206
  - test/inch/cli/yardopts_helper_test.rb
202
207
  - test/inch/code_object/docstring_test.rb
203
208
  - test/inch/code_object/nodoc_helper_test.rb
@@ -227,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
232
  version: '0'
228
233
  requirements: []
229
234
  rubyforge_project:
230
- rubygems_version: 2.0.3
235
+ rubygems_version: 2.0.6
231
236
  signing_key:
232
237
  specification_version: 4
233
238
  summary: Documentation measurement tool for Ruby
@@ -243,13 +248,18 @@ test_files:
243
248
  - test/fixtures/yardopts/.yardopts
244
249
  - test/fixtures/yardopts/foo/bar.rb
245
250
  - test/inch/cli/arguments_test.rb
251
+ - test/inch/cli/command/base_test.rb
246
252
  - test/inch/cli/command/console_test.rb
247
253
  - test/inch/cli/command/inspect_test.rb
248
254
  - test/inch/cli/command/list_test.rb
255
+ - test/inch/cli/command/options/base_list_test.rb
256
+ - test/inch/cli/command/options/base_object_test.rb
257
+ - test/inch/cli/command/options/base_test.rb
249
258
  - test/inch/cli/command/show_test.rb
250
259
  - test/inch/cli/command/stats_test.rb
251
260
  - test/inch/cli/command/suggest_test.rb
252
261
  - test/inch/cli/command_parser_test.rb
262
+ - test/inch/cli/trace_helper_test.rb
253
263
  - test/inch/cli/yardopts_helper_test.rb
254
264
  - test/inch/code_object/docstring_test.rb
255
265
  - test/inch/code_object/nodoc_helper_test.rb