Class: SimpleCov::S3
- Inherits:
-
Object
- Object
- SimpleCov::S3
- Defined in:
- lib/simplecov-s3.rb,
lib/simplecov-s3/version.rb
Defined Under Namespace
Classes: Formatter
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ S3
constructor
A new instance of S3.
- #pull_merge_and_push_full ⇒ Object
- #push_full ⇒ Object
- #push_partial(opts = {}) ⇒ Object
Constructor Details
#initialize(opts) ⇒ S3
Returns a new instance of S3.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/simplecov-s3.rb', line 29 def initialize(opts) @connection = Fog::Storage.new(opts[:fog]) @public_url_base = opts[:public_url_base] @shared_secret = opts[:shared_secret] @assets_url = opts[:assets_url] @bucket_name = opts[:bucket_name] @build_units = opts[:build_units] @postback_url = opts[:postback_url] @build_unit = opts[:build_unit] @build_id = opts[:build_id] @job_id = opts[:job_id] @project_name = opts[:project_name] || "unknown" if @project_name.empty? @project_name = "unknown" end @history_limit = opts[:history_limit] || 15 end |
Class Method Details
.ensured(task_to_invoke, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/simplecov-s3.rb', line 11 def self.ensured(task_to_invoke, &block) Rake::Task[task_to_invoke].invoke ensure begin yield rescue => e puts e.inspect puts e.backtrace end end |
Instance Method Details
#pull_merge_and_push_full ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/simplecov-s3.rb', line 64 def pull_merge_and_push_full if(json_files.size < @build_units) puts "Expected to see #{@build_units} files" puts "currently only #{json_files.size}" require 'pp' pp json_files.map(&:key) puts "Assuming some other build unit will be the last to exit, and merge/post full coverage" return false end puts "Coverage combined from #{json_files.size} units" results = [] included_units = [] json_files.each do |f| parsed = JSON.parse(f.body) included_units << parsed.delete("BUILD_UNIT") results << SimpleCov::Result.new(parsed) end puts "Included units: #{included_units.sort_by(&:to_s).inspect}" merged = {} results.each do |result| merged = result.original_result.merge_resultset(merged) end result = SimpleCov::Result.new(merged) push_coverage_to("#{@project_name}-#{Time.now.to_i}-coverageRESULT/#{SecureRandom.urlsafe_base64(33)}", gen_body(result), result.covered_percent, @postback_url) cleanup_files end |
#push_full ⇒ Object
91 92 93 94 95 |
# File 'lib/simplecov-s3.rb', line 91 def push_full result = SimpleCov::ResultMerger.merged_result push_coverage_to("#{@project_name}-#{Time.now.to_i}-coverageRESULT/#{SecureRandom.urlsafe_base64(33)}", gen_body(result), result.covered_percent, @postback_url) cleanup_files end |
#push_partial(opts = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/simplecov-s3.rb', line 47 def push_partial(opts = {}) begin result = SimpleCov::ResultMerger.merged_result data_to_push = result.original_result.merge("BUILD_UNIT" => @build_unit).to_json put_file("#{@project_name}-#{commit_time}-coverageJSON/#{hashed_build_id}/#{@job_id}", data_to_push) rescue => e puts e.inspect puts e.backtrace puts "SOMEHTING WENT WRONG, PUSHING EMPTY COVERAGE FILE" put_file("#{@project_name}-#{commit_time}-coverageJSON/#{hashed_build_id}/#{@job_id}", {}.to_json) end if opts[:debug] debug_folder = "#{@project_name}-#{Time.now.to_i}-coverageDEBUG/#{hashed_build_id}-#{@job_id}" push_coverage_to(debug_folder, gen_body(result)) end end |