lib/inch/code_object/proxy/base.rb in inch-0.1.4 vs lib/inch/code_object/proxy/base.rb in inch-0.2.0
- old
+ new
@@ -6,42 +6,49 @@
# @abstract
class Base
extend Forwardable
include NodocHelper
- # the actual (YARD) code object
+ # @return [YARD::CodeObjects::Base] the actual (YARD) code object
attr_accessor :object
# @return [Symbol]
# when objects are assigned to ScoreRanges, this grade is set to
# enable easier querying for objects of a certain grade
attr_writer :grade
# Tags considered by wrapper methods like {#has_code_example?}
- CONSIDERED_YARD_TAGS = %w(example param private return)
+ CONSIDERED_YARD_TAGS = %w(api example param private return)
# convenient shortcuts to (YARD) code object
def_delegators :object, :type, :path, :name, :namespace, :source, :source_type, :signature, :group, :dynamic, :visibility, :docstring
# convenient shortcuts to evalution object
def_delegators :evaluation, :score, :roles, :priority
+ # @param object [YARD::CodeObjects::Base] the actual (YARD) code object
def initialize(object)
self.object = object
end
+ def api_tag?
+ !object.tag(:api).nil? || (parent && parent.api_tag?)
+ end
+
# To be overridden
# @see Proxy::NamespaceObject
# @return [Array,nil] the children of the current object or +nil+
def children
nil
end
+ # @return [Docstring]
def docstring
@docstring ||= Docstring.new(object.docstring)
end
+ # @return [Evaluation::Base]
def evaluation
@evaluation ||= Evaluation.for(self)
end
# Returns the name of the file where the object is declared first
@@ -50,10 +57,11 @@
# just checking the first file (which is the file where an object
# is first declared)
files.size > 0 ? files[0][0] : nil
end
+ # @return [Symbol]
def grade
@grade ||= Evaluation.new_score_ranges.detect { |range|
range.range.include?(score)
}.grade
end
@@ -131,11 +139,18 @@
def private?
visibility == :private
end
+ # @return [Boolean]
+ # +true+ if the object or its parent is tagged as @private
def private_tag?
- !!object.tag(:private)
+ !object.tag(:private).nil? || (parent && parent.private_tag?)
+ end
+
+ def private_api_tag?
+ tag = object.tag(:api)
+ tag.text == 'private'
end
def protected?
visibility == :protected
end