Module: Reviser::Helpers::Project
- Included in:
- Criteria::CodeAnalysis, Extensions::WebValidators
- Defined in:
- lib/reviser/helpers/project.rb
Overview
Provide useful methods for projects evaluation as well as a naming module for custom regexes
Defined Under Namespace
Modules: Naming
Instance Method Summary collapse
-
#files ⇒ Object
All the files in the project's folder.
-
#manufacture(&block) ⇒ Object
Yields a new Result for the criteria to define an out value for each format.
-
#missing_files ⇒ Object
Check if the project has all files needed.
-
#prepare ⇒ Object
For interpreted languages We only check for missing files.
-
#sources ⇒ Object
All the files matching the project's language extension(s).
Instance Method Details
#files ⇒ Object
Returns all the files in the project's folder.
63 64 65 |
# File 'lib/reviser/helpers/project.rb', line 63 def files Dir.glob("**/*").select { |f| (File.file?(f)) } end |
#manufacture(&block) ⇒ Object
Yields a new Result for the criteria to define an out value for each format
78 79 80 81 82 83 |
# File 'lib/reviser/helpers/project.rb', line 78 def manufacture &block format = Result.new block.call format format end |
#missing_files ⇒ Object
Check if the project has all files needed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/reviser/helpers/project.rb', line 43 def missing_files dir = Dir['*'] # # Check if there is any regexp # If it's the case, if any file # matches, we delete the entry # for diff to work properly # Cfg[:required_files].each_with_index do |e, i| if dir.any? { |f| (e.respond_to?(:match)) && (e =~ f) } Cfg[:required_files].delete_at i end end Cfg[:required_files] - dir end |
#prepare ⇒ Object
For interpreted languages We only check for missing files
38 39 40 |
# File 'lib/reviser/helpers/project.rb', line 38 def prepare missing_files.empty? && 'None' || res end |
#sources ⇒ Object
Returns all the files matching the project's language extension(s).
70 71 72 |
# File 'lib/reviser/helpers/project.rb', line 70 def sources files.select { |f| Cfg[:extension].include? File.extname(f) } end |