Sha256: d80334a0f473dbd4040f5af1cdda0adc96471043b41cea86ef2be9412c1c961d

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

class AddParamHandler < YARD::Handlers::Ruby::MethodHandler

  handles method_call(:add_param)

  def process
    name = statement[1][0].source.gsub(/^:/, '')
    class_name = statement[1][1].source

    case class_name
      when "Strings"
        class_name = "Array<String>"
      when "Files"
        class_name = "Array<String> [Files]"
      when "Paths"
        class_name = "Array<String> [Paths]"
      when "Urls"
        class_name = "Array<String> [Urls]"
    end

    namespace.attributes[scope][name] ||= SymbolHash[:read => nil, :write => nil]

    {:read => name, :write => "#{name}="}.each do |type, meth|
        namespace.attributes[scope][name][type] = MethodObject.new(namespace, meth, scope) do |o|

          o.source = statement.source
          o.signature = method_signature(meth)
          o.docstring = statement.comments

          if type == :write
            o.parameters = [['value', nil]]
          else
            new_tag = YARD::Tags::Tag.new(:return, "An instance of #{class_name}", class_name)
            o.docstring.add_tag(new_tag) 
          end

          o.visibility = visibility
        end
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sprout-1.1.18.pre script/add_param_handler.rb
sprout-1.1.17.pre script/add_param_handler.rb
sprout-1.1.16.pre script/add_param_handler.rb
sprout-1.1.15.pre script/add_param_handler.rb
sprout-1.1.14.pre script/add_param_handler.rb
sprout-1.1.13.pre script/add_param_handler.rb
sprout-1.1.11.pre script/add_param_handler.rb
sprout-1.1.10.pre script/add_param_handler.rb
sprout-1.1.7.pre script/add_param_handler.rb
sprout-1.1.5.pre script/add_param_handler.rb
sprout-1.1.4.pre script/add_param_handler.rb
sprout-1.1.3.pre script/add_param_handler.rb
sprout-1.1.2.pre script/add_param_handler.rb
sprout-1.0.35.pre script/add_param_handler.rb