Class: Firehose

Inherits:
Object
  • Object
show all
Defined in:
app/services/firehose.rb

Class Method Summary collapse

Class Method Details

.new_version(project, platform, version_or_tag) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/firehose.rb', line 3

def new_version(project, platform, version_or_tag)
  return unless Rails.env.production?
  Typhoeus::Request.new('http://libfirehose.herokuapp.com/events',
    method: :post,
    params: {
      api_key: ENV['FIREHOSE_KEY']
    },
    body: Oj.dump({
      platform: platform,
      name: project.name,
      version: version_or_tag.number,
      package_manager_url: Repositories::Base.package_link(project, version_or_tag),
      published_at: version_or_tag.published_at,
      project: project.as_json(only: Project::API_FIELDS, methods: [:package_manager_url, :stars, :keywords])
    }, mode: :compat),
    headers: { 'Content-Type' => 'application/json' }).run
end