Exception: LearnError
- Inherits:
-
StandardError
- Object
- StandardError
- LearnError
- Defined in:
- lib/learn-tool/learn-error.rb
Constant Summary collapse
- ESCAPES =
{ :green => "\033[32m", :yellow => "\033[33m", :red => "\033[31m", :reset => "\033[0m" }
Instance Attribute Summary collapse
-
#contributing_error ⇒ Object
Returns the value of attribute contributing_error.
-
#correct_yaml_content ⇒ Object
Returns the value of attribute correct_yaml_content.
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#license_error ⇒ Object
Returns the value of attribute license_error.
-
#present_contributing ⇒ Object
Returns the value of attribute present_contributing.
-
#present_learn ⇒ Object
Returns the value of attribute present_learn.
-
#present_license ⇒ Object
Returns the value of attribute present_license.
-
#present_readme ⇒ Object
Returns the value of attribute present_readme.
-
#readme_error ⇒ Object
Returns the value of attribute readme_error.
-
#valid_contributing ⇒ Object
Returns the value of attribute valid_contributing.
-
#valid_license ⇒ Object
Returns the value of attribute valid_license.
-
#valid_readme ⇒ Object
Returns the value of attribute valid_readme.
-
#valid_yaml ⇒ Object
Returns the value of attribute valid_yaml.
-
#yaml_error ⇒ Object
Returns the value of attribute yaml_error.
Instance Method Summary collapse
- #emit(opts = {}) ⇒ Object
-
#initialize ⇒ LearnError
constructor
A new instance of LearnError.
- #result_message ⇒ Object
- #result_output ⇒ Object
- #total_errors ⇒ Object
Constructor Details
#initialize ⇒ LearnError
Returns a new instance of LearnError.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/learn-tool/learn-error.rb', line 13 def initialize @yaml_error = {present_dotlearn: false, valid_yaml: false, valid_whitespace: false, attributes: false} @readme_error = {present_readme: false, valid_readme: false} @license_error = {present_license: false, valid_license: false} @contributing_error = {present_contributing: false, valid_contributing: false} @correct_yaml_content = {message: ".learn file must have 'languages' key", color: :red} @valid_yaml = {message: "invalid yaml", color: :red} @valid_license = {message: "invalid or missing license content", color: :yellow} @valid_readme = {message: [], color: :red} @valid_contributing = {message: "invalid or missing contributing content", color: :yellow} @present_learn = {message: "missing .learn file", color: :red} @present_license = {message: "missing LICENSE.md", color: :red} @present_readme = {message: "missing README.md", color: :red} @present_contributing = {message: "missing CONTRIBUTING.md", color: :red} end |
Instance Attribute Details
#contributing_error ⇒ Object
Returns the value of attribute contributing_error.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def contributing_error @contributing_error end |
#correct_yaml_content ⇒ Object
Returns the value of attribute correct_yaml_content.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def correct_yaml_content @correct_yaml_content end |
#filepath ⇒ Object
Returns the value of attribute filepath.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def filepath @filepath end |
#license_error ⇒ Object
Returns the value of attribute license_error.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def license_error @license_error end |
#present_contributing ⇒ Object
Returns the value of attribute present_contributing.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def present_contributing @present_contributing end |
#present_learn ⇒ Object
Returns the value of attribute present_learn.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def present_learn @present_learn end |
#present_license ⇒ Object
Returns the value of attribute present_license.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def present_license @present_license end |
#present_readme ⇒ Object
Returns the value of attribute present_readme.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def present_readme @present_readme end |
#readme_error ⇒ Object
Returns the value of attribute readme_error.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def readme_error @readme_error end |
#valid_contributing ⇒ Object
Returns the value of attribute valid_contributing.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def valid_contributing @valid_contributing end |
#valid_license ⇒ Object
Returns the value of attribute valid_license.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def valid_license @valid_license end |
#valid_readme ⇒ Object
Returns the value of attribute valid_readme.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def valid_readme @valid_readme end |
#valid_yaml ⇒ Object
Returns the value of attribute valid_yaml.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def valid_yaml @valid_yaml end |
#yaml_error ⇒ Object
Returns the value of attribute yaml_error.
2 3 4 |
# File 'lib/learn-tool/learn-error.rb', line 2 def yaml_error @yaml_error end |
Instance Method Details
#emit(opts = {}) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/learn-tool/learn-error.rb', line 33 def emit(opts={}) color = opts[:color] = opts[:message] print ESCAPES[color] print print ESCAPES[:reset] print "\n" end |
#result_message ⇒ Object
52 53 54 |
# File 'lib/learn-tool/learn-error.rb', line 52 def [present_learn, valid_yaml, correct_yaml_content, present_license, valid_license, present_readme, valid_readme, present_contributing, valid_contributing ] end |
#result_output ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/learn-tool/learn-error.rb', line 57 def result_output .each do |result| if result[:message].is_a?(Array) result[:message].each do || emit({message: , color: result[:color]}) end else emit(result) end end end |
#total_errors ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/learn-tool/learn-error.rb', line 42 def total_errors { dot_learn: yaml_error, license: license_error, readme: readme_error, contributing: contributing_error } end |