inch 0.2.3 → 0.3.0.rc1
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.
- checksums.yaml +4 -4
- data/.simplecov +7 -0
- data/TODOS.md +0 -5
- data/config/defaults.rb +26 -1
- data/inch.gemspec +1 -0
- data/lib/inch.rb +2 -1
- data/lib/inch/api.rb +34 -0
- data/lib/inch/api/filter.rb +17 -0
- data/lib/inch/api/get.rb +30 -0
- data/lib/inch/api/list.rb +10 -0
- data/lib/inch/api/options/base.rb +45 -0
- data/lib/inch/api/options/filter.rb +25 -0
- data/lib/inch/api/options/suggest.rb +36 -0
- data/lib/inch/api/stats.rb +7 -0
- data/lib/inch/api/suggest.rb +110 -0
- data/lib/inch/cli.rb +4 -1
- data/lib/inch/cli/command/base.rb +1 -17
- data/lib/inch/cli/command/base_list.rb +3 -63
- data/lib/inch/cli/command/base_object.rb +6 -28
- data/lib/inch/cli/command/list.rb +3 -2
- data/lib/inch/cli/command/options/base.rb +1 -1
- data/lib/inch/cli/command/options/base_list.rb +4 -2
- data/lib/inch/cli/command/options/suggest.rb +9 -8
- data/lib/inch/cli/command/output/base.rb +9 -11
- data/lib/inch/cli/command/output/list.rb +2 -2
- data/lib/inch/cli/command/output/show.rb +2 -10
- data/lib/inch/cli/command/output/stats.rb +4 -3
- data/lib/inch/cli/command/output/suggest.rb +5 -5
- data/lib/inch/cli/command/stats.rb +4 -3
- data/lib/inch/cli/command/suggest.rb +4 -94
- data/lib/inch/code_object.rb +2 -2
- data/lib/inch/code_object/converter.rb +89 -0
- data/lib/inch/code_object/provider.rb +36 -0
- data/lib/inch/code_object/provider/yard.rb +19 -0
- data/lib/inch/code_object/provider/yard/docstring.rb +106 -0
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +93 -0
- data/lib/inch/code_object/provider/yard/object.rb +55 -0
- data/lib/inch/code_object/provider/yard/object/base.rb +262 -0
- data/lib/inch/code_object/provider/yard/object/class_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/constant_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/method_object.rb +126 -0
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +88 -0
- data/lib/inch/code_object/provider/yard/object/module_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +47 -0
- data/lib/inch/code_object/provider/yard/parser.rb +54 -0
- data/lib/inch/code_object/proxy.rb +5 -3
- data/lib/inch/code_object/proxy/base.rb +103 -110
- data/lib/inch/code_object/proxy/class_object.rb +0 -1
- data/lib/inch/code_object/proxy/method_object.rb +20 -99
- data/lib/inch/code_object/proxy/method_parameter_object.rb +15 -39
- data/lib/inch/code_object/proxy/namespace_object.rb +7 -18
- data/lib/inch/codebase.rb +19 -0
- data/lib/inch/codebase/objects.rb +73 -0
- data/lib/inch/codebase/objects_filter.rb +61 -0
- data/lib/inch/codebase/proxy.rb +22 -0
- data/lib/inch/config.rb +8 -1
- data/lib/inch/evaluation.rb +5 -7
- data/lib/inch/evaluation/file.rb +1 -1
- data/lib/inch/evaluation/grade.rb +1 -1
- data/lib/inch/evaluation/object_schema.rb +3 -1
- data/lib/inch/evaluation/priority_range.rb +44 -0
- data/lib/inch/evaluation/proxy.rb +25 -0
- data/lib/inch/evaluation/proxy/base.rb +146 -0
- data/lib/inch/evaluation/proxy/class_object.rb +8 -0
- data/lib/inch/evaluation/proxy/constant_object.rb +19 -0
- data/lib/inch/evaluation/proxy/method_object.rb +65 -0
- data/lib/inch/evaluation/proxy/module_object.rb +8 -0
- data/lib/inch/evaluation/proxy/namespace_object.rb +27 -0
- data/lib/inch/evaluation/role/base.rb +19 -0
- data/lib/inch/evaluation/role/constant.rb +16 -0
- data/lib/inch/evaluation/role/method.rb +22 -0
- data/lib/inch/evaluation/role/method_parameter.rb +31 -1
- data/lib/inch/evaluation/role/namespace.rb +15 -0
- data/lib/inch/evaluation/role/object.rb +24 -0
- data/lib/inch/rake/suggest.rb +1 -0
- data/lib/inch/utils/read_write_methods.rb +44 -0
- data/lib/inch/{cli → utils}/weighted_list.rb +1 -1
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +8 -0
- data/test/inch/api/filter_test.rb +51 -0
- data/test/inch/api/get_test.rb +22 -0
- data/test/inch/api/list_test.rb +15 -0
- data/test/inch/api/options/base_test.rb +30 -0
- data/test/inch/api/stats_test.rb +15 -0
- data/test/inch/api/suggest_test.rb +26 -0
- data/test/inch/cli/command/list_test.rb +2 -1
- data/test/inch/code_object/converter_test.rb +29 -0
- data/test/inch/code_object/{docstring_test.rb → provider/yard/docstring_test.rb} +13 -13
- data/test/inch/code_object/{nodoc_helper_test.rb → provider/yard/nodoc_helper_test.rb} +6 -6
- data/test/inch/code_object/provider/yard_test.rb +11 -0
- data/test/inch/code_object/provider_test.rb +9 -0
- data/test/inch/code_object/proxy/method_object_test.rb +22 -22
- data/test/inch/code_object/proxy_test.rb +10 -10
- data/test/inch/codebase/objects_test.rb +28 -0
- data/test/inch/codebase/proxy_test.rb +17 -0
- data/test/inch/evaluation/role/base_test.rb +71 -0
- data/test/inch/{cli → utils}/weighted_list_test.rb +2 -2
- data/test/shared/base_list.rb +73 -0
- data/test/test_helper.rb +0 -95
- metadata +89 -24
- data/lib/inch/code_object/docstring.rb +0 -102
- data/lib/inch/code_object/nodoc_helper.rb +0 -107
- data/lib/inch/evaluation/base.rb +0 -157
- data/lib/inch/evaluation/class_object.rb +0 -6
- data/lib/inch/evaluation/constant_object.rb +0 -33
- data/lib/inch/evaluation/method_object.rb +0 -105
- data/lib/inch/evaluation/module_object.rb +0 -6
- data/lib/inch/evaluation/namespace_object.rb +0 -52
- data/lib/inch/evaluation/read_write_methods.rb +0 -21
- data/lib/inch/source_parser.rb +0 -62
- data/test/inch/source_parser_test.rb +0 -23
@@ -1,52 +0,0 @@
|
|
1
|
-
module Inch
|
2
|
-
module Evaluation
|
3
|
-
# a namespace object can have methods and other namespace objects
|
4
|
-
# inside itself (e.g. classes and modules)
|
5
|
-
class NamespaceObject < Base
|
6
|
-
RUBY_CORE = %w(Array Bignum BasicObject Object Module Class Complex NilClass Numeric String Float Fiber FiberError Continuation Dir File Encoding Enumerator StopIteration Enumerator::Generator Enumerator::Yielder Exception SystemExit SignalException Interrupt StandardError TypeError ArgumentError IndexError KeyError RangeError ScriptError SyntaxError LoadError NotImplementedError NameError NoMethodError RuntimeError SecurityError NoMemoryError EncodingError SystemCallError Encoding::CompatibilityError File::Stat IO Hash ENV IOError EOFError ARGF RubyVM RubyVM::InstructionSequence Math::DomainError ZeroDivisionError FloatDomainError Integer Fixnum Data TrueClass FalseClass Mutex Thread Proc LocalJumpError SystemStackError Method UnboundMethod Binding Process::Status Random Range Rational RegexpError Regexp MatchData Symbol Struct ThreadGroup ThreadError Time Encoding::UndefinedConversionError Encoding::InvalidByteSequenceError Encoding::ConverterNotFoundError Encoding::Converter RubyVM::Env) +
|
7
|
-
%w(Comparable Kernel File::Constants Enumerable Errno FileTest GC ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable Marshal Math Process Process::UID Process::GID Process::Sys Signal)
|
8
|
-
|
9
|
-
def evaluate
|
10
|
-
eval_doc
|
11
|
-
eval_code_example
|
12
|
-
eval_visibility
|
13
|
-
eval_tags
|
14
|
-
|
15
|
-
eval_children
|
16
|
-
eval_namespace
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def eval_namespace
|
22
|
-
if RUBY_CORE.include?(object.path)
|
23
|
-
add_role Role::Namespace::Core.new(object)
|
24
|
-
end
|
25
|
-
if object.has_many_attributes?
|
26
|
-
add_role Role::Namespace::WithManyAttributes.new(object)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def eval_children
|
31
|
-
if children.empty?
|
32
|
-
add_role Role::Namespace::WithoutChildren.new(object)
|
33
|
-
else
|
34
|
-
add_role Role::Namespace::WithChildren.new(object, children.map(&:score).min)
|
35
|
-
if object.pure_namespace?
|
36
|
-
add_role Role::Namespace::Pure.new(object)
|
37
|
-
end
|
38
|
-
if object.no_methods?
|
39
|
-
add_role Role::Namespace::WithoutMethods.new(object)
|
40
|
-
end
|
41
|
-
if object.has_many_children?
|
42
|
-
add_role Role::Namespace::WithManyChildren.new(object)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def children
|
48
|
-
@children ||= object.children.map(&:evaluation)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Inch
|
2
|
-
module Evaluation
|
3
|
-
module ReadWriteMethods
|
4
|
-
def rw_method(name)
|
5
|
-
class_eval """
|
6
|
-
def #{name}(value = nil)
|
7
|
-
if value.nil?
|
8
|
-
@#{name}
|
9
|
-
else
|
10
|
-
@#{name} = value
|
11
|
-
end
|
12
|
-
end
|
13
|
-
"""
|
14
|
-
end
|
15
|
-
|
16
|
-
def rw_methods(*names)
|
17
|
-
[names].flatten.each { |name| rw_method(name) }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/inch/source_parser.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module Inch
|
2
|
-
# Parses the source tree (using YARD)
|
3
|
-
class SourceParser
|
4
|
-
# Helper method to run an instance with the given +args+
|
5
|
-
#
|
6
|
-
# @see #run
|
7
|
-
# @return [SourceParser] the instance that ran
|
8
|
-
def self.run(*args)
|
9
|
-
parser = self.new
|
10
|
-
parser.run(*args)
|
11
|
-
parser
|
12
|
-
end
|
13
|
-
|
14
|
-
# Returns all parsed objects as code object proxies
|
15
|
-
#
|
16
|
-
# @see CodeObject::Proxy.for
|
17
|
-
# @return [Array<CodeObject::Proxy::Base>]
|
18
|
-
def all_objects
|
19
|
-
@all_objects ||= all_parsed_objects.map do |o|
|
20
|
-
CodeObject::Proxy.for(o)
|
21
|
-
end.sort_by(&:path)
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns the object with the given +path+
|
25
|
-
#
|
26
|
-
# @example
|
27
|
-
#
|
28
|
-
# SourceParser.find_objects("Foo#bar")
|
29
|
-
# # => returns code object proxy for Foo#bar
|
30
|
-
#
|
31
|
-
# @param path [String] partial path/name of an object
|
32
|
-
# @return [CodeObject::Proxy::Base]
|
33
|
-
def find_object(path)
|
34
|
-
all_objects.detect { |o| o.path == path }
|
35
|
-
end
|
36
|
-
alias :[] :find_object
|
37
|
-
|
38
|
-
# Returns all objects where the +path+ starts_with the given +path+
|
39
|
-
#
|
40
|
-
# @example
|
41
|
-
#
|
42
|
-
# SourceParser.find_objects("Foo#")
|
43
|
-
# # => returns code object proxies for all instance methods of Foo
|
44
|
-
#
|
45
|
-
# @param path [String] partial path/name of an object
|
46
|
-
# @return [Array<CodeObject::Proxy::Base>]
|
47
|
-
def find_objects(path)
|
48
|
-
all_objects.select { |o| o.path.start_with?(path) }
|
49
|
-
end
|
50
|
-
|
51
|
-
def run(paths, excluded = [])
|
52
|
-
YARD::Registry.clear
|
53
|
-
YARD.parse(paths, excluded)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def all_parsed_objects
|
59
|
-
YARD::Registry.all
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
-
|
3
|
-
describe ::Inch::SourceParser do
|
4
|
-
before do
|
5
|
-
Dir.chdir fixture_path(:simple)
|
6
|
-
@source_parser = Inch::SourceParser.run(["lib/**/*.rb"])
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should parse all objects" do
|
10
|
-
refute_nil @source_parser.find_object("Foo")
|
11
|
-
refute_nil @source_parser.find_object("Foo::Bar")
|
12
|
-
refute_nil @source_parser.find_object("Foo::Bar#method_without_doc")
|
13
|
-
refute_nil @source_parser.find_object("Foo::Bar#method_with_missing_param_doc")
|
14
|
-
refute_nil @source_parser.find_object("Foo::Bar#method_with_wrong_doc")
|
15
|
-
refute_nil @source_parser.find_object("Foo::Bar#method_with_full_doc")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should return the correct depth for each object" do
|
19
|
-
assert_equal 1, @source_parser.find_object("Foo").depth
|
20
|
-
assert_equal 2, @source_parser.find_object("Foo::Bar").depth
|
21
|
-
assert_equal 3, @source_parser.find_object("Foo::Bar#method_without_doc").depth
|
22
|
-
end
|
23
|
-
end
|