Class: Skunk::Command::StatusSharer

Inherits:
StatusReporter
  • Object
show all
Defined in:
lib/skunk/commands/status_sharer.rb

Overview

Knows how to share status to an API

Constant Summary collapse

DEFAULT_URL =
"https://skunk.fastruby.io"

Constants inherited from StatusReporter

Skunk::Command::StatusReporter::HEADINGS, Skunk::Command::StatusReporter::HEADINGS_WITHOUT_FILE, Skunk::Command::StatusReporter::HEADINGS_WITHOUT_FILE_WIDTH, Skunk::Command::StatusReporter::TEMPLATE

Instance Attribute Summary collapse

Attributes inherited from StatusReporter

#analysed_modules

Instance Method Summary collapse

Methods inherited from StatusReporter

#update_status_message

Instance Attribute Details

#status_messageObject (readonly)

Returns the value of attribute status_message.



13
14
15
# File 'lib/skunk/commands/status_sharer.rb', line 13

def status_message
  @status_message
end

Instance Method Details

#shareObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/skunk/commands/status_sharer.rb', line 20

def share
  return "" if not_sharing?

  response = post_payload

  @status_message =
    if Net::HTTPOK === response
      data = JSON.parse response.body
      "Shared at: #{File.join(base_url, data['id'])}"
    else
      "Error sharing report: #{response}"
    end
end

#status_reporter=(status_reporter) ⇒ Object



16
17
18
# File 'lib/skunk/commands/status_sharer.rb', line 16

def status_reporter=(status_reporter)
  self.analysed_modules = status_reporter.analysed_modules
end