Sha256: b9ee1dd052b63223ce23c8243d329c0038388b4a0f7a425de1ccf23749bd2059

Contents?: true

Size: 1.9 KB

Versions: 15

Compression:

Stored size: 1.9 KB

Contents

require_relative './learn_linter/version'
require_relative './learn_linter/learn_error'
require_relative './learn_linter/license_linter'
require_relative './learn_linter/readme_linter'
require_relative './learn_linter/yaml_linter'
require_relative './learn_linter/contributing_linter'

class LearnLinter

  attr_accessor :filepath, :quiet


  def initialize(filepath, quiet=nil)
    @filepath = filepath
    @learn_error = LearnError.new
    @quiet = quiet
  end

  def lint_directory
    self.yaml_lint
    self.license_lint
    self.readme_lint
    self.contributing_lint
    unless quiet
      @learn_error.result_output
    end
    @learn_error.total_errors
  end

  def result_message
    @learn_error.result_message
  end

  def has_file?(file)
    Dir.entries(filepath).include?(file)
  end

  def yaml_lint
    if self.has_file?(".learn")
      @learn_error.yaml_error[:present_dotlearn] = true
      @learn_error.present_learn = {message: "present .learn file", color: :green}
      YamlLint.parse_file("#{filepath}/.learn", @learn_error)
    end
  end

  def license_lint
    if self.has_file?("LICENSE.md")
      @learn_error.license_error[:present_license] = true
      @learn_error.present_license = {message: "present LICENSE.md", color: :green}
      LicenseLinter.parse_file("#{filepath}/LICENSE.md", @learn_error)
    end
  end

  def readme_lint
    if self.has_file?("README.md")
      @learn_error.readme_error[:present_readme] = true
      @learn_error.present_readme = {message: "present README.md", color: :green}
      ReadmeLinter.parse_file("#{filepath}/README.md", @learn_error)
    end
  end

  def contributing_lint
    if self.has_file?("CONTRIBUTING.md")
      @learn_error.contributing_error[:present_contributing] = true
      @learn_error.present_contributing = {message: "present CONTRIBUTING.md", color: :green}
      ContributingLinter.parse_file("#{filepath}/CONTRIBUTING.md", @learn_error)
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
learn_linter-1.7.3 lib/learn_linter.rb
learn_linter-1.7.2 lib/learn_linter.rb
learn_linter-1.7.1 lib/learn_linter.rb
learn_linter-1.7.0 lib/learn_linter.rb
learn_linter-1.6.9 lib/learn_linter.rb
learn_linter-1.6.8 lib/learn_linter.rb
learn_linter-1.6.7 lib/learn_linter.rb
learn_linter-1.6.5 lib/learn_linter.rb
learn_linter-1.6.4 lib/learn_linter.rb
learn_linter-1.6.3 lib/learn_linter.rb
learn_linter-1.6.2 lib/learn_linter.rb
learn_linter-1.6.1 lib/learn_linter.rb
learn_linter-1.6.0 lib/learn_linter.rb
learn_linter-1.5.0 lib/learn_linter.rb
learn_linter-1.4.0 lib/learn_linter.rb