Class: RspecGithubActionsSummary::TempFileResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_github_actions_summary/temp_file_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(notification) ⇒ TempFileResult

Returns a new instance of TempFileResult.



9
10
11
# File 'lib/rspec_github_actions_summary/temp_file_result.rb', line 9

def initialize(notification)
  @notification = notification
end

Instance Attribute Details

#notificationObject (readonly)

Returns the value of attribute notification.



7
8
9
# File 'lib/rspec_github_actions_summary/temp_file_result.rb', line 7

def notification
  @notification
end

Class Method Details

.root_pathObject



21
22
23
24
25
26
# File 'lib/rspec_github_actions_summary/temp_file_result.rb', line 21

def self.root_path
  return @root_path if defined? @root_path

  current_path_hash = Digest::MD5.hexdigest(Dir.pwd)
  @root_path = Pathname.new("/tmp/.rspec-github-summary/#{current_path_hash}/")
end

Instance Method Details

#write!Object



13
14
15
16
17
18
19
# File 'lib/rspec_github_actions_summary/temp_file_result.rb', line 13

def write!
  FileUtils.mkdir_p([root_path])

  File.open(path, 'w') do |f|
    f.write(result.to_json)
  end
end