Class: Gemnasium::DependencyFiles
- Inherits:
-
Object
- Object
- Gemnasium::DependencyFiles
- Defined in:
- lib/gemnasium/dependency_files.rb
Constant Summary collapse
- SUPPORTED_DEPENDENCY_FILES =
/(Gemfile|Gemfile\.lock|.*\.gemspec|package\.json|npm-shrinkwrap\.json|setup\.py|requirements\.txt|requires\.txt|composer\.json|composer\.lock)$/
Class Method Summary collapse
-
.get_content_to_upload(project_path, files_path) ⇒ Array
Get the content to upload to Gemnasium.
-
.get_sha1s_hash(project_path) ⇒ Hash
Get a Hash of sha1s for each file corresponding to the regex.
Class Method Details
.get_content_to_upload(project_path, files_path) ⇒ Array
Get the content to upload to Gemnasium.
24 25 26 27 28 |
# File 'lib/gemnasium/dependency_files.rb', line 24 def self.get_content_to_upload(project_path, files_path) files_path.inject([]) do |arr, file_path| arr << { filename: file_path, sha: calculate_sha1(file_path), content: File.open("#{project_path}/#{file_path}") {|io| io.read} } end end |
.get_sha1s_hash(project_path) ⇒ Hash
Get a Hash of sha1s for each file corresponding to the regex
12 13 14 15 16 17 18 |
# File 'lib/gemnasium/dependency_files.rb', line 12 def self.get_sha1s_hash(project_path) Dir.chdir(project_path) Dir.glob("**/**").grep(SUPPORTED_DEPENDENCY_FILES).inject({}) do |h, file_path| h[file_path] = calculate_sha1("#{project_path}/#{file_path}") unless is_ignored?(file_path) h end end |