Sha256: e4e287e8187d5997cbb017cdcf0e26f23678d965d806ad1534cc4bad029a1c31

Contents?: true

Size: 1.9 KB

Versions: 20

Compression:

Stored size: 1.9 KB

Contents

require "thor"

module Coveralls
  class CommandLine < Thor

    desc "push", "Runs your test suite and pushes the coverage results to Coveralls."
    def push
      return unless ensure_can_run_locally!
      ENV["COVERALLS_RUN_LOCALLY"] = "true"
      cmd = "bundle exec rake"
      if File.exist?('.travis.yml')
        cmd = YAML.load_file('.travis.yml')["script"] || cmd rescue cmd
      end
      exec cmd
      ENV["COVERALLS_RUN_LOCALLY"] = nil
    end

    desc "report", "Runs your test suite locally and displays coverage statistics."
    def report
      ENV["COVERALLS_NOISY"] = "true"
      exec "bundle exec rake"
      ENV["COVERALLS_NOISY"] = nil
    end

    desc "open", "View this repository on Coveralls."
    def open
      open_token_based_url "https://coveralls.io/repos/%@"
    end

    desc "service", "View this repository on your CI service's website."
    def service
      open_token_based_url "https://coveralls.io/repos/%@/service"
    end

    desc "last", "View the last build for this repository on Coveralls."
    def last
      open_token_based_url "https://coveralls.io/repos/%@/last_build"
    end

    desc "version", "See version"
    def version
      Coveralls::Output.puts Coveralls::VERSION
    end

    private

    def open_token_based_url url
      config = Coveralls::Configuration.configuration
      if config[:repo_token]
        url = url.gsub("%@", config[:repo_token])
        `open #{url}`
      else
        Coveralls::Output.puts "No repo_token configured."
      end
    end

    def ensure_can_run_locally!
      config = Coveralls::Configuration.configuration
      if config[:repo_token].nil?
        Coveralls::Output.puts "Coveralls cannot run locally because no repo_secret_token is set in .coveralls.yml", :color => "red"
        Coveralls::Output.puts "Please try again when you get your act together.", :color => "red"

        return false
      end
      true
    end

  end
end

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
coveralls-0.8.13 lib/coveralls/command.rb
coveralls-0.8.12 lib/coveralls/command.rb
coveralls-0.8.11 lib/coveralls/command.rb
coveralls-0.8.10 lib/coveralls/command.rb
coveralls-0.8.9 lib/coveralls/command.rb
coveralls-0.8.8 lib/coveralls/command.rb
coveralls-0.8.7 lib/coveralls/command.rb
coveralls-0.8.6 lib/coveralls/command.rb
coveralls-0.8.5 lib/coveralls/command.rb
suzuko-0.1.8 vendor/bundle/ruby/2.0.0/gems/coveralls-0.8.3/lib/coveralls/command.rb
suzuko-0.1.7 vendor/bundle/ruby/2.0.0/gems/coveralls-0.8.3/lib/coveralls/command.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/coveralls-0.8.3/lib/coveralls/command.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/coveralls-0.8.3/lib/coveralls/command.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/coveralls-0.8.3/lib/coveralls/command.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/coveralls-0.8.3/lib/coveralls/command.rb
coveralls-0.8.3 lib/coveralls/command.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/coveralls-0.8.2/lib/coveralls/command.rb
coveralls-0.8.2 lib/coveralls/command.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/coveralls-0.8.1/lib/coveralls/command.rb
coveralls-0.8.1 lib/coveralls/command.rb