Sha256: 40b1f7c801c0c7d9b595488152a642157bfdb252b5e0248524aa8867b43c5965

Contents?: true

Size: 839 Bytes

Versions: 7

Compression:

Stored size: 839 Bytes

Contents

require 'zlib'
require 'base64'
require 'net/http'
require 'uri'

module RepoAnalyzer
  class PostExtractedInfoJob < ApplicationJob
    def perform(repo_name, project_info)
      encoded_project_info = encode_project_info(project_info)
      response = post_project_info(repo_name, encoded_project_info)
      response.is_a?(Net::HTTPCreated)
    end

    private

    def post_project_info(repo_name, encoded_project_info)
      uri = URI(RepoAnalyzer.post_extracted_info_endpoint)
      data = { repo_name: repo_name, project_info: encoded_project_info }.to_json
      headers = { "Content-Type" => "application/json" }
      Net::HTTP.post(uri, data, headers)
    end

    def encode_project_info(project_info)
      compressed_data = Zlib::Deflate.deflate(project_info.to_json)
      Base64.encode64(compressed_data)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
repo_analyzer-1.6.0 app/jobs/repo_analyzer/post_extracted_info_job.rb
repo_analyzer-1.5.0 app/jobs/repo_analyzer/post_extracted_info_job.rb
repo_analyzer-1.4.0 app/jobs/repo_analyzer/post_extracted_info_job.rb
repo_analyzer-1.3.0 app/jobs/repo_analyzer/post_extracted_info_job.rb
repo_analyzer-1.2.0 app/jobs/repo_analyzer/post_extracted_info_job.rb
repo_analyzer-1.1.0 app/jobs/repo_analyzer/post_extracted_info_job.rb
repo_analyzer-1.0.0 app/jobs/repo_analyzer/post_extracted_info_job.rb