Class: SimpleCov::S3::Codeclimate
- Inherits:
-
Object
- Object
- SimpleCov::S3::Codeclimate
- Defined in:
- lib/simplecov_s3_codeclimate.rb,
lib/simplecov_s3_codeclimate/version.rb
Constant Summary collapse
- VERSION =
'0.3'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Codeclimate
constructor
A new instance of Codeclimate.
- #pull_merge_and_push_full ⇒ Object
- #push_partial ⇒ Object
Constructor Details
#initialize(opts) ⇒ Codeclimate
Returns a new instance of Codeclimate.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simplecov_s3_codeclimate.rb', line 23 def initialize(opts) @connection = Fog::Storage.new(opts[:fog]) @shared_secret = opts[:shared_secret] @bucket_name = opts[:bucket_name] @subfolder = opts[:subfolder] || '' @build_units = opts[:build_units].to_i @build_unit = opts[:build_unit] @build_id = opts[:build_id] @project_name = opts[:project_name] || 'unknown' @project_name = 'unknown' if @project_name.empty? @history_limit = opts[:history_limit] || 15 end |
Class Method Details
.ensured(task_to_invoke, &_block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/simplecov_s3_codeclimate.rb', line 12 def self.ensured(task_to_invoke, &_block) Rake::Task[task_to_invoke].invoke ensure begin yield rescue => exception puts exception.inspect puts exception.backtrace end end |
Instance Method Details
#pull_merge_and_push_full ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/simplecov_s3_codeclimate.rb', line 47 def pull_merge_and_push_full json_files_size = json_files.size 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 |file| parsed = JSON.parse(file.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) CodeClimate::TestReporter::Formatter.new.format(result) cleanup_files end |
#push_partial ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/simplecov_s3_codeclimate.rb', line 36 def push_partial 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}/#{@build_unit}", data_to_push) rescue => exception puts exception.inspect puts exception.backtrace puts 'SOMEHTING WENT WRONG, PUSHING EMPTY COVERAGE FILE' put_file("#{@project_name}-#{commit_time}-coverageJSON/#{hashed_build_id}/#{@build_unit}", {}.to_json) end |