Class: PullReview::Coverage::LocalFileApi
- Inherits:
-
Object
- Object
- PullReview::Coverage::LocalFileApi
- Defined in:
- lib/pullreview/coverage/client_api.rb
Overview
Local file based implementation ease testing/debugging coverage report content generation
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ LocalFileApi
constructor
A new instance of LocalFileApi.
-
#publish(payload) ⇒ Object
generate a random file in tmp dir with the same json payload (except pretty formatted).
Constructor Details
#initialize(config) ⇒ LocalFileApi
Returns a new instance of LocalFileApi.
13 14 15 |
# File 'lib/pullreview/coverage/client_api.rb', line 13 def initialize(config) @config = config || Config.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/pullreview/coverage/client_api.rb', line 11 def config @config end |
Instance Method Details
#publish(payload) ⇒ Object
generate a random file in tmp dir with the same json payload (except pretty formatted)
18 19 20 21 22 23 |
# File 'lib/pullreview/coverage/client_api.rb', line 18 def publish(payload) file_path = File.join(Dir.tmpdir, "coverage-#{SecureRandom.uuid}.json") File.open(file_path, 'w') { |file| file.write(JSON.pretty_generate(payload)) } PullReview::Coverage.log(:info, "Generated #{file_path}") file_path end |