Class: LearnLinter
- Inherits:
-
Object
- Object
- LearnLinter
- Defined in:
- lib/learn_linter.rb,
lib/learn_linter/version.rb
Constant Summary collapse
- VERSION =
"0.6.0"
Instance Attribute Summary collapse
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
Instance Method Summary collapse
- #has_file?(file) ⇒ Boolean
-
#initialize(dir = nil, quiet = nil) ⇒ LearnLinter
constructor
A new instance of LearnLinter.
- #license_lint ⇒ Object
- #lint_directory ⇒ Object
- #readme_lint ⇒ Object
- #yaml_lint ⇒ Object
Constructor Details
#initialize(dir = nil, quiet = nil) ⇒ LearnLinter
Returns a new instance of LearnLinter.
12 13 14 15 16 |
# File 'lib/learn_linter.rb', line 12 def initialize(dir=nil, quiet=nil) @filepath = dir || Dir.pwd @learn_error = LearnError.new @quiet = quiet end |
Instance Attribute Details
#filepath ⇒ Object
Returns the value of attribute filepath.
9 10 11 |
# File 'lib/learn_linter.rb', line 9 def filepath @filepath end |
#quiet ⇒ Object
Returns the value of attribute quiet.
9 10 11 |
# File 'lib/learn_linter.rb', line 9 def quiet @quiet end |
Instance Method Details
#has_file?(file) ⇒ Boolean
30 31 32 |
# File 'lib/learn_linter.rb', line 30 def has_file?(file) Dir.entries(filepath).include?(file) end |
#license_lint ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/learn_linter.rb', line 42 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
18 19 20 21 22 23 24 25 26 |
# File 'lib/learn_linter.rb', line 18 def lint_directory self.yaml_lint self.license_lint self.readme_lint unless quiet @learn_error.result_output end @learn_error.total_errors end |
#readme_lint ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/learn_linter.rb', line 50 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 |
#yaml_lint ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/learn_linter.rb', line 34 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 |