lib/inch/language/ruby/provider/yard/object/base.rb in inch-0.5.0.rc5 vs lib/inch/language/ruby/provider/yard/object/base.rb in inch-0.5.0.rc6
- old
+ new
@@ -1,6 +1,7 @@
-require "forwardable"
+require 'forwardable'
+require 'inch/utils/code_location'
module Inch
module Language
module Ruby
module Provider
@@ -57,12 +58,12 @@
# object or +nil+
def child(_name)
nil
end
- # @return [Array,nil] the full names of the children of the current
- # object
+ # @return [Array,nil] the full names of the children of the
+ # current object
def children_fullnames
[]
end
# To be overridden
@@ -73,15 +74,16 @@
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
+ 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
@@ -89,49 +91,42 @@
Encoding::UndefinedConversionError
Encoding::InvalidByteSequenceError
Encoding::ConverterNotFoundError Encoding::Converter RubyVM::Env
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
+ ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable
+ Marshal Math Process Process::UID Process::GID Process::Sys
+ Signal
)
def core?
RUBY_CORE.include?(name.to_s)
end
# @return [Docstring]
def docstring
@docstring ||= Docstring.new(object.docstring)
end
- # Returns all files declaring the object in the form of an Array of
- # Arrays containing the location of their declaration.
+ # Returns all files declaring the object in the form of an Array
+ # of Arrays containing the location of their declaration.
#
# @return [Array<CodeLocation>]
def files
object.files.map do |(filename, line_no)|
- CodeLocation.new(base_dir, filename, line_no)
+ Inch::Utils::CodeLocation.new(base_dir, filename, line_no)
end
rescue ::YARD::CodeObjects::ProxyMethodError
# this error is raised by YARD
# see broken.rb in test fixtures
[]
end
- # CodeLocation is a utility class to find declarations of objects in
- # files
- class CodeLocation < Struct.new(:base_dir, :relative_path, :line_no)
- def filename
- File.join(base_dir, relative_path)
- end
- end
-
# Returns the name of the file where the object is declared first
# @return [String] a filename
def filename
- # just checking the first file (which is the file where an object
- # is first declared)
+ # just checking the first file (which is the file where an
+ # object is first declared)
files.first && files.first.filename
end
def fullname
@fullname ||= object.path
@@ -180,12 +175,12 @@
#
# Foo::Bar::Baz#initialize
# ^ ^ ^ ^
# 1 << 2 << 3 << 4
#
- # +depth+ answers the question "how many layers of code objects are
- # above this one?"
+ # +depth+ answers the question "how many layers of code objects
+ # are above this one?"
#
# @note top-level counts, that's why Foo has depth 1!
#
# @return [Fixnum] the depth of the object in terms of namespace
def depth
@@ -240,11 +235,12 @@
def in_root?
depth == 1
end
- # @return [Boolean] +true+ if the object has no documentation at all
+ # @return [Boolean] +true+ if the object has no documentation at
+ # all
def undocumented?
original_docstring.empty?
end
def unconsidered_tag_count
@@ -268,11 +264,11 @@
end
attr_reader :private_tag
def private_api_tag?
- api_tag && api_tag.text == "private"
+ api_tag && api_tag.text == 'private'
end
def tag(name)
tags(name).first
end
@@ -284,10 +280,11 @@
# see broken.rb in test fixtures
[]
end
# @return [Array]
- # YARD tags that are not already covered by other wrapper methods
+ # YARD tags that are not already covered by other wrapper
+ # methods
def unconsidered_tags
@unconsidered_tags ||= tags.reject do |tag|
auto_generated_tag?(tag) ||
CONSIDERED_YARD_TAGS.include?(tag.tag_name)
end