Class: LearnLinter
- Inherits:
-
Object
- Object
- LearnLinter
- Defined in:
- lib/learn_linter.rb,
lib/learn_linter/version.rb
Constant Summary collapse
- VERSION =
"1.6.7"
Instance Attribute Summary collapse
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
Instance Method Summary collapse
- #contributing_lint ⇒ Object
- #has_file?(file) ⇒ Boolean
-
#initialize(filepath, quiet = nil) ⇒ LearnLinter
constructor
A new instance of LearnLinter.
- #license_lint ⇒ Object
- #lint_directory ⇒ Object
- #readme_lint ⇒ Object
- #result_message ⇒ Object
- #yaml_lint ⇒ Object
Constructor Details
#initialize(filepath, quiet = nil) ⇒ LearnLinter
Returns a new instance of LearnLinter.
13 14 15 16 17 |
# File 'lib/learn_linter.rb', line 13 def initialize(filepath, quiet=nil) @filepath = filepath @learn_error = LearnError.new @quiet = quiet end |
Instance Attribute Details
#filepath ⇒ Object
Returns the value of attribute filepath.
10 11 12 |
# File 'lib/learn_linter.rb', line 10 def filepath @filepath end |
#quiet ⇒ Object
Returns the value of attribute quiet.
10 11 12 |
# File 'lib/learn_linter.rb', line 10 def quiet @quiet end |
Instance Method Details
#contributing_lint ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/learn_linter.rb', line 62 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 |
#has_file?(file) ⇒ Boolean
34 35 36 |
# File 'lib/learn_linter.rb', line 34 def has_file?(file) Dir.entries(filepath).include?(file) end |
#license_lint ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/learn_linter.rb', line 46 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 |
#lint_directory ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/learn_linter.rb', line 19 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 |
#readme_lint ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/learn_linter.rb', line 54 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 |
#result_message ⇒ Object
30 31 32 |
# File 'lib/learn_linter.rb', line 30 def @learn_error. end |
#yaml_lint ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/learn_linter.rb', line 38 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 |