Class: Gitnesse::DependencyChecker
- Inherits:
-
Object
- Object
- Gitnesse::DependencyChecker
- Defined in:
- lib/gitnesse/dependency_checker.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #add_error(message) ⇒ Object
- #check ⇒ Object
-
#check_cucumber ⇒ Object
Checks that Cucumber is installed on the system.
- #check_features_dir_exists ⇒ Object
-
#check_git ⇒ Object
Checks that Git is installed on the system.
-
#check_identifier ⇒ Object
Checks that identifier is set in Gitnesse::Config, if annotate_results is set.
-
#check_repository_url ⇒ Object
Checks that repository_url is set in Gitnesse::Config.
- #display_errors ⇒ Object
-
#initialize ⇒ DependencyChecker
constructor
A new instance of DependencyChecker.
Constructor Details
#initialize ⇒ DependencyChecker
Returns a new instance of DependencyChecker.
5 6 7 |
# File 'lib/gitnesse/dependency_checker.rb', line 5 def initialize @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/gitnesse/dependency_checker.rb', line 3 def errors @errors end |
Instance Method Details
#add_error(message) ⇒ Object
19 20 21 |
# File 'lib/gitnesse/dependency_checker.rb', line 19 def add_error() @errors << end |
#check ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/gitnesse/dependency_checker.rb', line 9 def check check_git check_cucumber check_repository_url check_identifier check_features_dir_exists display_errors if @errors.any? end |
#check_cucumber ⇒ Object
Checks that Cucumber is installed on the system.
Returns true or raises DependencyNotMetError if Cucumber is broken
43 44 45 46 47 48 49 |
# File 'lib/gitnesse/dependency_checker.rb', line 43 def check_cucumber if system("cucumber --version &> /dev/null") true else add_error "Cucumber not found or not working" end end |
#check_features_dir_exists ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/gitnesse/dependency_checker.rb', line 77 def check_features_dir_exists dir = Gitnesse::Config.instance.features_dir if File.directory?(dir) true else add_error "The features directory './#{dir}' does not exist." end end |
#check_git ⇒ Object
Checks that Git is installed on the system.
Returns true or raises DependencyNotMetError if git is broken
32 33 34 35 36 37 38 |
# File 'lib/gitnesse/dependency_checker.rb', line 32 def check_git if system("git --version &> /dev/null") true else add_error "Git not found or not working" end end |
#check_identifier ⇒ Object
Checks that identifier is set in Gitnesse::Config, if annotate_results is set.
Returns true or raises DependencyNotMetError if identifier isn’t set
67 68 69 70 71 72 73 74 75 |
# File 'lib/gitnesse/dependency_checker.rb', line 67 def check_identifier return true unless Gitnesse::Config.instance.annotate_results identifier = Gitnesse::Config.instance.identifier if identifier.nil? || identifier.empty? add_error "You must specify identifier to use the annotate_results option" else true end end |
#check_repository_url ⇒ Object
Checks that repository_url is set in Gitnesse::Config.
Returns true or raises DependencyNotMetError if repository_url isn’t set
54 55 56 57 58 59 60 61 |
# File 'lib/gitnesse/dependency_checker.rb', line 54 def check_repository_url url = Gitnesse::Config.instance.repository_url if url.nil? || url.empty? add_error "You must specify a repository_url to run Gitnesse" else true end end |
#display_errors ⇒ Object
23 24 25 26 27 |
# File 'lib/gitnesse/dependency_checker.rb', line 23 def display_errors puts "Configuration errors were found!" @errors.each { |error| puts " - #{error}" } abort end |