inch 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/TODOS.md +5 -3
  3. data/bin/inch +9 -4
  4. data/inch.gemspec +9 -4
  5. data/lib/inch.rb +1 -0
  6. data/lib/inch/cli.rb +6 -0
  7. data/lib/inch/cli/command.rb +0 -6
  8. data/lib/inch/cli/command_parser.rb +0 -2
  9. data/lib/inch/code_object/nodoc_helper.rb +1 -1
  10. data/lib/inch/code_object/proxy/base.rb +18 -3
  11. data/lib/inch/code_object/proxy/method_object.rb +5 -0
  12. data/lib/inch/config.rb +53 -0
  13. data/lib/inch/evaluation.rb +1 -1
  14. data/lib/inch/evaluation/base.rb +45 -1
  15. data/lib/inch/evaluation/constant_object.rb +10 -5
  16. data/lib/inch/evaluation/criteria.rb +38 -0
  17. data/lib/inch/evaluation/method_object.rb +50 -42
  18. data/lib/inch/evaluation/namespace_object.rb +38 -33
  19. data/lib/inch/evaluation/role/constant.rb +1 -0
  20. data/lib/inch/evaluation/role/method.rb +41 -10
  21. data/lib/inch/evaluation/role/method_parameter.rb +16 -1
  22. data/lib/inch/evaluation/role/namespace.rb +17 -5
  23. data/lib/inch/evaluation/role/object.rb +35 -0
  24. data/lib/inch/version.rb +1 -1
  25. data/test/fixtures/simple/lib/foo.rb +0 -37
  26. data/test/fixtures/simple/lib/nodoc.rb +45 -0
  27. data/test/fixtures/simple/lib/role_methods.rb +4 -0
  28. data/test/inch/code_object/nodoc_helper_test.rb +3 -1
  29. data/test/inch/code_object/proxy/method_object_test.rb +9 -0
  30. metadata +26 -32
  31. data/lib/inch/cli/command/console.rb +0 -22
  32. data/lib/inch/cli/command/inspect.rb +0 -20
  33. data/lib/inch/cli/command/options/console.rb +0 -26
  34. data/lib/inch/cli/command/options/inspect.rb +0 -25
  35. data/lib/inch/cli/command/output/console.rb +0 -49
  36. data/lib/inch/cli/command/output/inspect.rb +0 -129
  37. data/test/inch/cli/command/console_test.rb +0 -59
  38. data/test/inch/cli/command/inspect_test.rb +0 -68
@@ -1,9 +1,13 @@
1
1
  module Inch
2
2
  module Evaluation
3
3
  module Role
4
+ # Roles assigned to all objects
4
5
  module Object
6
+ # Role assigned to objects with a describing comment (docstring)
5
7
  class WithDoc < Base
6
8
  end
9
+
10
+ # Role assigned to objects without a docstring
7
11
  class WithoutDoc < Missing
8
12
  def suggestion
9
13
  "Add a comment describing the #{object_type}"
@@ -18,37 +22,68 @@ module Inch
18
22
  -1
19
23
  end
20
24
  end
25
+
26
+ # Role assigned to objects explicitly or implicitly tagged not to be
27
+ # documented.
28
+ #
29
+ # @see CodeObject::NodocHelper
21
30
  class TaggedAsNodoc < Base
22
31
  def priority
23
32
  -7
24
33
  end
25
34
  end
35
+
36
+ # Role assigned to objects explicitly or implicitly tagged to be part
37
+ # of an API. If the API is 'private' TaggedAsPrivateAPI is assigned
38
+ # instead.
39
+ class TaggedAsAPI < Base
40
+ end
41
+
42
+ # Role assigned to objects explicitly or implicitly tagged to be part
43
+ # of a private API.
44
+ class TaggedAsPrivateAPI < Base
45
+ def priority
46
+ -5
47
+ end
48
+ end
49
+
50
+ # Role assigned to objects declared in the top-level namespace
26
51
  class InRoot < Base
27
52
  def priority
28
53
  +3
29
54
  end
30
55
  end
31
56
 
57
+ # Role assigned to public objects
32
58
  class Public < Base
33
59
  def priority
34
60
  +2
35
61
  end
36
62
  end
63
+
64
+ # Role assigned to protected objects
37
65
  class Protected < Base
38
66
  def priority
39
67
  +1
40
68
  end
41
69
  end
70
+
71
+ # Role assigned to private objects
42
72
  class Private < Base
43
73
  def priority
44
74
  -2
45
75
  end
46
76
  end
47
77
 
78
+ # Role assigned to objects with a single code example
48
79
  class WithCodeExample < Base
49
80
  end
81
+
82
+ # Role assigned to objects with multiple code examples
50
83
  class WithMultipleCodeExamples < Base
51
84
  end
85
+
86
+ # Role assigned to objects without a code example
52
87
  class WithoutCodeExample < Missing
53
88
  def suggestion
54
89
  "Add a code example (optional)"
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -177,43 +177,6 @@ module Foo
177
177
  def method_with_missing_param_doc(param1, param2, param3)
178
178
  end
179
179
  end
180
-
181
- class Qux # :nodoc:
182
- def method_with_implicit_nodoc
183
- end
184
-
185
- DOCCED_VALUE = 42 # :doc:
186
-
187
- class Quux
188
- def method_without_nodoc
189
- end
190
-
191
- PUBLIC_VALUE = :foo
192
- PRIVATE_VALUE = :bar # :nodoc:
193
-
194
- # @private
195
- def method_with_private_tag
196
- end
197
-
198
- def method_with_explicit_nodoc # :nodoc:
199
- end
200
- end
201
- end
202
-
203
- class HiddenClass #:nodoc: all
204
- def some_value
205
- end
206
-
207
- class EvenMoreHiddenClass
208
- def method_with_implicit_nodoc
209
- end
210
-
211
- class SuddenlyVisibleClass # :doc:
212
- def method_with_implicit_doc
213
- end
214
- end
215
- end
216
- end
217
180
  end
218
181
 
219
182
  def top
@@ -0,0 +1,45 @@
1
+ module Foo
2
+ class Qux # :nodoc:
3
+ def method_with_implicit_nodoc
4
+ end
5
+
6
+ DOCCED_VALUE = 42 # :doc:
7
+
8
+ class Quux
9
+ def method_without_nodoc
10
+ end
11
+
12
+ PUBLIC_VALUE = :foo
13
+ PRIVATE_VALUE = :bar # :nodoc:
14
+
15
+ # @private
16
+ def method_with_private_tag
17
+ end
18
+
19
+ def method_with_explicit_nodoc # :nodoc:
20
+ end
21
+ end
22
+ end
23
+
24
+ class HiddenClass #:nodoc: all
25
+ def some_value
26
+ end
27
+
28
+ class EvenMoreHiddenClass
29
+ def method_with_implicit_nodoc
30
+ end
31
+
32
+ class SuddenlyVisibleClass # :doc:
33
+ def method_with_implicit_doc
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ # @private
40
+ class HiddenClassViaTag
41
+ # @api private
42
+ def some_value
43
+ end
44
+ end
45
+ end
@@ -21,6 +21,10 @@ module InchTest
21
21
  def question_mark_method_with_description?
22
22
  end
23
23
 
24
+ # @return [Boolean] something funny
25
+ def method_with_description_and_parameters?(user)
26
+ end
27
+
24
28
  def many_parameters_method(a,b,c,d,e,f)
25
29
  end
26
30
 
@@ -6,7 +6,7 @@ describe ::Inch::CodeObject::NodocHelper do
6
6
  @source_parser = Inch::SourceParser.run(["lib/**/*.rb"])
7
7
  end
8
8
 
9
- it "should return true for explicitly tagged objects" do
9
+ it "should return true for explicitly or implicitly tagged objects" do
10
10
  [
11
11
  "Foo::Qux",
12
12
  "Foo::Qux#method_with_implicit_nodoc",
@@ -16,6 +16,8 @@ describe ::Inch::CodeObject::NodocHelper do
16
16
  "Foo::HiddenClass",
17
17
  "Foo::HiddenClass::EvenMoreHiddenClass",
18
18
  "Foo::HiddenClass::EvenMoreHiddenClass#method_with_implicit_nodoc",
19
+ "Foo::HiddenClassViaTag",
20
+ "Foo::HiddenClassViaTag#some_value",
19
21
  ].each do |query|
20
22
  m = @source_parser.find_object(query)
21
23
  assert m.nodoc?, "nodoc? should return true for #{query}"
@@ -161,6 +161,15 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
161
161
  refute m.has_doc?
162
162
  refute m.has_parameters?
163
163
 
164
+ assert m.score > 0
165
+ assert m.score >= 50 # TODO: don't use magic numbers
166
+ end
167
+
168
+ def test_method_with_description_and_parameters
169
+ m = @source_parser.find_object("InchTest#method_with_description_and_parameters?")
170
+ refute m.has_doc?
171
+ assert m.has_parameters?
172
+
164
173
  assert m.score > 0
165
174
  end
166
175
  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.4
4
+ version: 0.2.0
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-02-01 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,27 +39,13 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: yard
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: 0.8.7
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 0.8.7
55
- - !ruby/object:Gem::Dependency
56
- name: term-ansicolor
42
+ name: pry
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - '>='
60
46
  - !ruby/object:Gem::Version
61
47
  version: '0'
62
- type: :runtime
48
+ type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
@@ -70,18 +56,18 @@ dependencies:
70
56
  name: sparkr
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ~>
59
+ - - '>='
74
60
  - !ruby/object:Gem::Version
75
61
  version: 0.2.0
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ~>
66
+ - - '>='
81
67
  - !ruby/object:Gem::Version
82
68
  version: 0.2.0
83
69
  - !ruby/object:Gem::Dependency
84
- name: pry
70
+ name: term-ansicolor
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - '>='
@@ -94,6 +80,20 @@ dependencies:
94
80
  - - '>='
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.7
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.7
97
97
  description: Documentation measurement tool for Ruby, based on YARD.
98
98
  email:
99
99
  - rf@bamaru.de
@@ -120,21 +120,15 @@ files:
120
120
  - lib/inch/cli/command/base.rb
121
121
  - lib/inch/cli/command/base_list.rb
122
122
  - lib/inch/cli/command/base_object.rb
123
- - lib/inch/cli/command/console.rb
124
- - lib/inch/cli/command/inspect.rb
125
123
  - lib/inch/cli/command/list.rb
126
124
  - lib/inch/cli/command/options/base.rb
127
125
  - lib/inch/cli/command/options/base_list.rb
128
126
  - lib/inch/cli/command/options/base_object.rb
129
- - lib/inch/cli/command/options/console.rb
130
- - lib/inch/cli/command/options/inspect.rb
131
127
  - lib/inch/cli/command/options/list.rb
132
128
  - lib/inch/cli/command/options/show.rb
133
129
  - lib/inch/cli/command/options/stats.rb
134
130
  - lib/inch/cli/command/options/suggest.rb
135
131
  - lib/inch/cli/command/output/base.rb
136
- - lib/inch/cli/command/output/console.rb
137
- - lib/inch/cli/command/output/inspect.rb
138
132
  - lib/inch/cli/command/output/list.rb
139
133
  - lib/inch/cli/command/output/show.rb
140
134
  - lib/inch/cli/command/output/stats.rb
@@ -157,6 +151,7 @@ files:
157
151
  - lib/inch/code_object/proxy/method_parameter_object.rb
158
152
  - lib/inch/code_object/proxy/module_object.rb
159
153
  - lib/inch/code_object/proxy/namespace_object.rb
154
+ - lib/inch/config.rb
160
155
  - lib/inch/core_ext.rb
161
156
  - lib/inch/core_ext/string.rb
162
157
  - lib/inch/core_ext/yard.rb
@@ -164,6 +159,7 @@ files:
164
159
  - lib/inch/evaluation/base.rb
165
160
  - lib/inch/evaluation/class_object.rb
166
161
  - lib/inch/evaluation/constant_object.rb
162
+ - lib/inch/evaluation/criteria.rb
167
163
  - lib/inch/evaluation/file.rb
168
164
  - lib/inch/evaluation/method_object.rb
169
165
  - lib/inch/evaluation/module_object.rb
@@ -185,6 +181,7 @@ files:
185
181
  - test/fixtures/simple/README
186
182
  - test/fixtures/simple/lib/broken.rb
187
183
  - test/fixtures/simple/lib/foo.rb
184
+ - test/fixtures/simple/lib/nodoc.rb
188
185
  - test/fixtures/simple/lib/role_methods.rb
189
186
  - test/fixtures/simple/lib/role_namespaces.rb
190
187
  - test/fixtures/visibility/lib/foo.rb
@@ -192,8 +189,6 @@ files:
192
189
  - test/fixtures/yardopts/foo/bar.rb
193
190
  - test/inch/cli/arguments_test.rb
194
191
  - test/inch/cli/command/base_test.rb
195
- - test/inch/cli/command/console_test.rb
196
- - test/inch/cli/command/inspect_test.rb
197
192
  - test/inch/cli/command/list_test.rb
198
193
  - test/inch/cli/command/options/base_list_test.rb
199
194
  - test/inch/cli/command/options/base_object_test.rb
@@ -232,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
227
  version: '0'
233
228
  requirements: []
234
229
  rubyforge_project:
235
- rubygems_version: 2.0.6
230
+ rubygems_version: 2.0.3
236
231
  signing_key:
237
232
  specification_version: 4
238
233
  summary: Documentation measurement tool for Ruby
@@ -242,6 +237,7 @@ test_files:
242
237
  - test/fixtures/simple/README
243
238
  - test/fixtures/simple/lib/broken.rb
244
239
  - test/fixtures/simple/lib/foo.rb
240
+ - test/fixtures/simple/lib/nodoc.rb
245
241
  - test/fixtures/simple/lib/role_methods.rb
246
242
  - test/fixtures/simple/lib/role_namespaces.rb
247
243
  - test/fixtures/visibility/lib/foo.rb
@@ -249,8 +245,6 @@ test_files:
249
245
  - test/fixtures/yardopts/foo/bar.rb
250
246
  - test/inch/cli/arguments_test.rb
251
247
  - test/inch/cli/command/base_test.rb
252
- - test/inch/cli/command/console_test.rb
253
- - test/inch/cli/command/inspect_test.rb
254
248
  - test/inch/cli/command/list_test.rb
255
249
  - test/inch/cli/command/options/base_list_test.rb
256
250
  - test/inch/cli/command/options/base_object_test.rb
@@ -1,22 +0,0 @@
1
- require 'pry'
2
-
3
- module Inch
4
- module CLI
5
- module Command
6
- class Console < BaseObject
7
- def description
8
- 'Shows a console'
9
- end
10
-
11
- def usage
12
- 'Usage: inch console [paths] [OBJECT_NAME] [options]'
13
- end
14
-
15
- def run(*args)
16
- prepare_objects(*args)
17
- Output::Console.new(@options, @object, @objects, source_parser)
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,20 +0,0 @@
1
- module Inch
2
- module CLI
3
- module Command
4
- class Inspect < BaseObject
5
- def description
6
- 'Inspects an object'
7
- end
8
-
9
- def usage
10
- 'Usage: inch inspect [paths] OBJECT_NAME [[OBJECT_NAME2] ...] [options]'
11
- end
12
-
13
- def run(*args)
14
- prepare_objects(*args)
15
- Output::Inspect.new(@options, objects)
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,26 +0,0 @@
1
- module Inch
2
- module CLI
3
- module Command
4
- module Options
5
- class Console < BaseObject
6
- def descriptions
7
- [
8
- "",
9
- "Provides a PRY based REPL to inspect objects.",
10
- "",
11
- "Example: " + "$ inch console lib/**/*.rb Foo::Bar#initialize".cyan,
12
- "",
13
- "Shortcut commands on the prompt are:",
14
- "",
15
- "all".ljust(5) + " returns all code objects",
16
- "f".ljust(5) + " finds an object by its path",
17
- "ff".ljust(5) + " finds all objects given a partial path",
18
- "o".ljust(5) + " returns the code object for OBJECT_NAME (if present)",
19
- ]
20
- end
21
-
22
- end
23
- end
24
- end
25
- end
26
- end