Sha256: 6791b8e255654cc167871dd3becc3a0ca87b72a4075743e67be2a861a1b98945

Contents?: true

Size: 1.36 KB

Versions: 12

Compression:

Stored size: 1.36 KB

Contents

require 'colored'
##
# YardChecker checks the output for undocumented classes and methods
#
# @author dmasur
class YardChecker
  ##
  # Gives the Checkresult
  #
  # @return [Hash] Checkresult
  # @author dmasur
  def result
    @shell_output = begin
      `yardoc`
    rescue Errno::ENOENT
      "Yardoc not found"
    end
    { type: :yard, check_output: output, status: status }
  end

  private
    ##
    # Color the Coverage
    #
    # @return [String] colored Coverage
    # @author dmasur
    def color_coverage
      @coverage = case @coverage
      when 0..60 then "#{@coverage}%".red
      when 60..90 then "#{@coverage}%".yellow
      when 90..100 then "#{@coverage}%".green
      end
    end

    ##
    # Parse the Code coverage
    #
    # @return [String] colored Codecoverage
    # @author dmasur
    def calc_yard_coverage
      @coverage = /(\d+\.\d+)% documented/.match(@shell_output)[1].to_f
      color_coverage
    end

    ##
    # Gives the Check Status
    #
    # @return [String] Checkstatus
    # @author dmasur
    def status
      if @shell_output.include? 'documented'
        calc_yard_coverage
        "#{@coverage} documented"
      else
        'N/A'
      end
    end

    ##
    # Gives the check output
    #
    # @return [String] Output
    # @author dmasur
    def output
      @shell_output.include?('documented') ? '' : @shell_output
    end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rake_check-0.3.5 lib/rake_check/yard_checker.rb
rake_check-0.3.4 lib/rake_check/yard_checker.rb
rake_check-0.3.3 lib/rake_check/yard_checker.rb
rake_check-0.3.2 lib/rake_check/yard_checker.rb
rake_check-0.3.1 lib/rake_check/yard_checker.rb
rake_check-0.3.0 lib/rake_check/yard_checker.rb
rake_check-0.2.2 lib/rake_check/yard_checker.rb
rake_check-0.2.1 lib/rake_check/yard_checker.rb
rake_check-0.2 lib/rake_check/yard_checker.rb
rake_check-0.1.11 lib/rake_check/yard_checker.rb
rake_check-0.1.10 lib/rake_check/yard_checker.rb
rake_check-0.1.9 lib/rake_check/yard_checker.rb