Sha256: 6de38c527ea71f5988db3d828a3f3a50146f77b1b5d1a29c0f75c1d433ca4981

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

module MPatch

  module Include

    module Method

      def get_comments

        var= self.source_location.map{|obj| obj.class <= String ? File.absolute_path(obj) : obj }

        file_obj= File.open(var[0],"r")
        file_data= [] #> [*File.open(var[0],"r")]
        var[1].times{ file_data.push file_obj.gets }
        file_data.reverse!

        desc_array= []

        first= true
        file_data.each { |new_string_line|

          if first == true
            first= false
            next
          end

          if new_string_line =~ /^[\s\t]*(#[\s\S]*)?$/

            unless new_string_line.scan(/^[\s\t]*(#\s*)([\s\S]*)?$/).empty?
              new_string_line.replace new_string_line.scan(/^[\s\t]*(#\s*)([\s\S]*)?$/)[0][1]
            end

            if new_string_line.chomp =~ /^\s*$/
              next
            end

            desc_array.push new_string_line.chomp

          else
            break
          end

        }

        #remove nils
        desc_array.compact!

        # return
        return desc_array.join("\n")

      end

      alias :get_description :get_comments

    end

  end

  require File.join 'mpatch','injector'

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mpatch-2.12.2 lib/mpatch/method.rb
mpatch-2.12.1 lib/mpatch/method.rb
mpatch-2.12.0 lib/mpatch/method.rb
mpatch-2.11.0 lib/mpatch/method.rb
mpatch-2.9.0 lib/mpatch/method.rb
mpatch-2.8.1 lib/mpatch/method.rb
mpatch-2.8.0 lib/mpatch/method.rb