Sha256: ad6b0d5daf859f08660a93eafd449e390088846c6c8cf23b65aa53de82e26d92

Contents?: true

Size: 797 Bytes

Versions: 64

Compression:

Stored size: 797 Bytes

Contents

namespace :ci do
  # Runs the Rails rake stats task (if using Rails) and converts counts into "metrics"
  # Usage: bundle exec rake ci:stats
  desc 'stats'
  task :stats do
    next unless Rake::Task.task_defined?('stats')

    @metrics ||= []

    summary_line = `bundle exec rake stats 2>/dev/null | tail -n 2 | head -n 1`
    matchdata = summary_line.match(/Code LOC: (\d+)\b\s+Test LOC: (\d+)\b/)
    code_loc = matchdata[1].to_i
    test_loc = matchdata[2].to_i
    test_ratio = 100.0 * test_loc / code_loc

    metrics = [
      { name: 'stats_code_loc', type: :gauge, value: code_loc },
      { name: 'stats_test_loc', type: :gauge, value: test_loc },
      { name: 'stats_test_ratio', type: :gauge, value: test_ratio }
    ]
    @metrics.concat(metrics)
    puts metrics.inspect
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
ndr_dev_support-5.4.5 lib/tasks/ci/stats.rake
ndr_dev_support-5.4.4 lib/tasks/ci/stats.rake
ndr_dev_support-5.4.3 lib/tasks/ci/stats.rake
ndr_dev_support-5.4.2 lib/tasks/ci/stats.rake
ndr_dev_support-5.4.1 lib/tasks/ci/stats.rake
ndr_dev_support-5.4.0 lib/tasks/ci/stats.rake
ndr_dev_support-5.3.1 lib/tasks/ci/stats.rake
ndr_dev_support-5.3.0 lib/tasks/ci/stats.rake
ndr_dev_support-5.2.0 lib/tasks/ci/stats.rake
ndr_dev_support-5.1.0 lib/tasks/ci/stats.rake
ndr_dev_support-5.0.1 lib/tasks/ci/stats.rake
ndr_dev_support-5.0.0 lib/tasks/ci/stats.rake
ndr_dev_support-4.2.1 lib/tasks/ci/stats.rake
ndr_dev_support-4.2.0 lib/tasks/ci/stats.rake
ndr_dev_support-4.1.3 lib/tasks/ci/stats.rake
ndr_dev_support-4.1.2 lib/tasks/ci/stats.rake
ndr_dev_support-4.1.1 lib/tasks/ci/stats.rake
ndr_dev_support-4.1.0 lib/tasks/ci/stats.rake
ndr_dev_support-4.0.0 lib/tasks/ci/stats.rake
ndr_dev_support-3.1.3 lib/tasks/ci/stats.rake