coveralls-0.7.0/0000755000175000017500000000000012305441752013041 5ustar miguelmiguelcoveralls-0.7.0/spec/0000755000175000017500000000000012305441752013773 5ustar miguelmiguelcoveralls-0.7.0/spec/coveralls/0000755000175000017500000000000012305441752015765 5ustar miguelmiguelcoveralls-0.7.0/spec/coveralls/coveralls_spec.rb0000644000175000017500000000432312305441752021320 0ustar miguelmiguelrequire 'spec_helper' describe Coveralls do before do SimpleCov.stub(:start) stub_api_post Coveralls.testing = true end describe "#will_run?" do it "checks CI environemnt variables" do Coveralls.will_run?.should be_true end context "with CI disabled" do before do @ci = ENV['CI'] ENV['CI'] = nil @coveralls_run_locally = ENV['COVERALLS_RUN_LOCALLY'] ENV['COVERALLS_RUN_LOCALLY'] = nil Coveralls.testing = false end after do ENV['CI'] = @ci ENV['COVERALLS_RUN_LOCALLY'] = @coveralls_run_locally end it "indicates no run" do Coveralls.will_run?.should be_false end end end describe "#should_run?" do it "outputs to stdout when running locally" do Coveralls.testing = false Coveralls.run_locally = true silence do Coveralls.should_run? end end end describe "#wear!" do it "receives block" do ::SimpleCov.should_receive(:start) silence do subject.wear! do add_filter 's' end end end it "uses string" do ::SimpleCov.should_receive(:start).with 'test_frameworks' silence do subject.wear! 'test_frameworks' end end it "uses default" do ::SimpleCov.should_receive(:start).with silence do subject.wear! end ::SimpleCov.filters.map(&:filter_argument).should include 'vendor' end end describe "#wear_merged!" do it "sets formatter to NilFormatter" do ::SimpleCov.should_receive(:start).with 'rails' silence do subject.wear_merged! 'rails' do add_filter "/spec/" end end ::SimpleCov.formatter.should be Coveralls::NilFormatter end end describe "#push!" do it "sends existings test results" do result = false silence do result = subject.push! end result.should be_true end end describe "#setup!" do it "sets SimpleCov adapter" do SimpleCovTmp = SimpleCov Object.send :remove_const, :SimpleCov silence { subject.setup! } SimpleCov = SimpleCovTmp end end after(:all) do setup_formatter end end coveralls-0.7.0/spec/coveralls/configuration_spec.rb0000644000175000017500000000026012305441752022171 0ustar miguelmiguelrequire 'spec_helper' describe Coveralls::Configuration do it "asserts true" do config = Coveralls::Configuration.configuration config.should_not be_nil end end coveralls-0.7.0/spec/coveralls/simplecov_spec.rb0000644000175000017500000000407412305441752021332 0ustar miguelmiguelrequire 'spec_helper' describe Coveralls::SimpleCov::Formatter do before do stub_api_post end def source_fixture(filename) File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', filename ) ) end let(:result) { SimpleCov::Result.new({ source_fixture( 'sample.rb' ) => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil], source_fixture( 'app/models/user.rb' ) => [nil, 1, 1, 1, 1, 0, 1, 0, nil, nil], source_fixture( 'app/models/robot.rb' ) => [1, 1, 1, 1, nil, nil, 1, 0, nil, nil], source_fixture( 'app/models/house.rb' ) => [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], source_fixture( 'app/models/airplane.rb' ) => [0, 0, 0, 0, 0], source_fixture( 'app/models/dog.rb' ) => [1, 1, 1, 1, 1], source_fixture( 'app/controllers/sample.rb' ) => [nil, 1, 1, 1, nil, nil, 0, 0, nil, nil] }) } describe "#format" do context "should run" do before do Coveralls.testing = true Coveralls.noisy = false end it "posts json" do result.files.should_not be_empty silence do Coveralls::SimpleCov::Formatter.new.format(result).should be_true end end end context "should not run, noisy" do it "only displays result" do silence do Coveralls::SimpleCov::Formatter.new.display_result(result).should be_true end end end context "no files" do let(:result) { SimpleCov::Result.new({}) } it "shows note that no files have been covered" do Coveralls.noisy = true Coveralls.testing = false silence do expect do Coveralls::SimpleCov::Formatter.new.format(result) end.not_to raise_error end end end context "with api error" do it "rescues" do e = RestClient::ResourceNotFound.new double('HTTP Response', :code => '502') silence do Coveralls::SimpleCov::Formatter.new.display_error(e).should be_false end end end end end coveralls-0.7.0/spec/coveralls/fixtures/0000755000175000017500000000000012305441752017636 5ustar miguelmiguelcoveralls-0.7.0/spec/coveralls/fixtures/app/0000755000175000017500000000000012305441752020416 5ustar miguelmiguelcoveralls-0.7.0/spec/coveralls/fixtures/app/controllers/0000755000175000017500000000000012305441752022764 5ustar miguelmiguelcoveralls-0.7.0/spec/coveralls/fixtures/app/controllers/sample.rb0000755000175000017500000000013512305441752024574 0ustar miguelmiguel# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.7.0/spec/coveralls/fixtures/app/vendor/0000755000175000017500000000000012305441752021713 5ustar miguelmiguelcoveralls-0.7.0/spec/coveralls/fixtures/app/vendor/vendored_gem.rb0000644000175000017500000000004112305441752024671 0ustar miguelmiguel# this file should not be coveredcoveralls-0.7.0/spec/coveralls/fixtures/app/models/0000755000175000017500000000000012305441752021701 5ustar miguelmiguelcoveralls-0.7.0/spec/coveralls/fixtures/app/models/airplane.rb0000755000175000017500000000013512305441752024023 0ustar miguelmiguel# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.7.0/spec/coveralls/fixtures/app/models/user.rb0000755000175000017500000000013512305441752023206 0ustar miguelmiguel# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.7.0/spec/coveralls/fixtures/app/models/dog.rb0000755000175000017500000000013512305441752023001 0ustar miguelmiguel# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.7.0/spec/coveralls/fixtures/app/models/robot.rb0000755000175000017500000000013512305441752023355 0ustar miguelmiguel# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.7.0/spec/coveralls/fixtures/app/models/house.rb0000755000175000017500000000013512305441752023353 0ustar miguelmiguel# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end endcoveralls-0.7.0/spec/coveralls/fixtures/sample.rb0000755000175000017500000000013412305441752021445 0ustar miguelmiguel# Foo class class Foo def initialize @foo = 'baz' end def bar @foo end end coveralls-0.7.0/spec/coveralls/output_spec.rb0000644000175000017500000000430412305441752020665 0ustar miguelmiguelrequire 'spec_helper' describe Coveralls::Output do it "defaults the IO to $stdout" do old_stdout = $stdout out = StringIO.new $stdout = out Coveralls::Output.puts "this is a test" expect(out.string).to eq "this is a test\n" $stdout = old_stdout end it "accepts an IO injection" do out = StringIO.new Coveralls::Output.output = out Coveralls::Output.puts "this is a test" expect(out.string).to eq "this is a test\n" end describe ".puts" do it "accepts an IO injection" do out = StringIO.new Coveralls::Output.puts "this is a test", :output => out expect(out.string).to eq "this is a test\n" end end describe ".print" do it "accepts an IO injection" do out = StringIO.new Coveralls::Output.print "this is a test", :output => out expect(out.string).to eq "this is a test" end end describe 'when silenced' do before do @original_stdout = $stdout @output = StringIO.new Coveralls::Output.silent = true $stdout = @output end it "should not puts" do Coveralls::Output.puts "foo" @output.rewind @output.read.should == "" end it "should not print" do Coveralls::Output.print "foo" @output.rewind @output.read.should == "" end after do $stdout = @original_stdout end end describe '.format' do it "accepts a color argument" do string = 'Hello' ansi_color_string = Term::ANSIColor.red(string) Coveralls::Output.format(string, :color => 'red').should eq(ansi_color_string) end it "also accepts no color arguments" do unformatted_string = "Hi Doggie!" Coveralls::Output.format(unformatted_string).should eq(unformatted_string) end it "rejects formats unrecognized by Term::ANSIColor" do string = 'Hi dog!' Coveralls::Output.format(string, :color => "not_a_real_color").should eq(string) end it "accepts more than 1 color argument" do string = 'Hi dog!' multi_formatted_string = Term::ANSIColor.red{ Term::ANSIColor.underline(string) } Coveralls::Output.format(string, :color => 'red underline').should eq(multi_formatted_string) end end end coveralls-0.7.0/spec/spec_helper.rb0000644000175000017500000000315412305441752016614 0ustar miguelmiguelrequire 'simplecov' require 'webmock' require 'vcr' class InceptionFormatter def format(result) Coveralls::SimpleCov::Formatter.new.format(result) end end def setup_formatter SimpleCov.formatter = if ENV['TRAVIS'] || ENV['COVERALLS_REPO_TOKEN'] InceptionFormatter else SimpleCov::Formatter::HTMLFormatter end # SimpleCov.start 'test_frameworks' SimpleCov.start do add_filter do |source_file| source_file.filename =~ /spec/ && !(source_file.filename =~ /fixture/) end end end setup_formatter require 'coveralls' VCR.config do |c| c.cassette_library_dir = 'fixtures/vcr_cassettes' c.stub_with :webmock end RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus config.include WebMock::API config.after(:suite) do WebMock.disable! end end def stub_api_post body = "{\"message\":\"\",\"url\":\"\"}" stub_request(:post, Coveralls::API::API_BASE+"/jobs").with( :body => /.+/, :headers => { 'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Content-Length'=>/.+/, 'Content-Type'=>/.+/, 'User-Agent'=>'Ruby' } ).to_return(:status => 200, :body => body, :headers => {}) end def silence return yield if ENV['silence'] == 'false' silence_stream(STDOUT) do yield end end module Kernel def silence_stream(stream) old_stream = stream.dup stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') stream.sync = true yield ensure stream.reopen(old_stream) end endcoveralls-0.7.0/.gitignore0000644000175000017500000000025612305441752015034 0ustar miguelmiguel*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp .DS_Store /vendor/ coveralls-0.7.0/Rakefile0000644000175000017500000000033612305441752014510 0ustar miguelmiguel#!/usr/bin/env rake require "bundler/gem_tasks" # Travis! require 'rubygems' require 'rake' require 'rspec/core/rake_task' desc "Run RSpec" RSpec::Core::RakeTask.new do |t| t.verbose = false end task :default => :speccoveralls-0.7.0/.ruby-version0000644000175000017500000000001112305441752015476 0ustar miguelmiguel2.0.0-p0 coveralls-0.7.0/LICENSE0000644000175000017500000000205412305441752014047 0ustar miguelmiguelCopyright (c) 2012 Wil Gieseler MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.coveralls-0.7.0/.travis.yml0000644000175000017500000000021712305441752015152 0ustar miguelmiguellanguage: ruby rvm: - rbx-19mode - jruby-19mode - 1.9.2 - 1.9.3 - 2.0.0 - ruby-head matrix: allow_failures: - rvm: ruby-head coveralls-0.7.0/bin/0000755000175000017500000000000012305441752013611 5ustar miguelmiguelcoveralls-0.7.0/bin/coveralls0000755000175000017500000000035312305441752015532 0ustar miguelmiguel#!/usr/bin/env ruby lib = File.expand_path(File.dirname(__FILE__) + '/../lib') $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib) require 'coveralls' require 'coveralls/command' Coveralls::CommandLine.startcoveralls-0.7.0/coveralls-ruby.gemspec0000644000175000017500000000233512305441752017362 0ustar miguelmiguel# -*- encoding: utf-8 -*- require File.expand_path('../lib/coveralls/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Nick Merwin", "Wil Gieseler"] gem.email = ["nick@lemurheavy.com", "supapuerco@gmail.com"] gem.description = "A Ruby implementation of the Coveralls API." gem.summary = "A Ruby implementation of the Coveralls API." gem.homepage = "https://coveralls.io" gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.name = "coveralls" gem.require_paths = ["lib"] gem.version = Coveralls::VERSION gem.add_dependency 'rest-client' gem.add_dependency 'term-ansicolor' gem.add_dependency 'multi_json', '~> 1.3' gem.add_dependency 'thor' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new("1.9") gem.add_dependency 'simplecov', ">= 0.7" end gem.add_runtime_dependency('jruby-openssl') if RUBY_PLATFORM == 'java' gem.add_development_dependency 'rspec' gem.add_development_dependency 'rake' gem.add_development_dependency 'webmock', '1.7' gem.add_development_dependency 'vcr', '1.11.3' end coveralls-0.7.0/README.md0000644000175000017500000000074412305441752014325 0ustar miguelmiguel# [Coveralls](http://coveralls.io) for Ruby [![Test Coverage](https://coveralls.io/repos/lemurheavy/coveralls-ruby/badge.png?branch=master)](https://coveralls.io/r/lemurheavy/coveralls-ruby) [![Build Status](https://secure.travis-ci.org/lemurheavy/coveralls-ruby.png?branch=master)](https://travis-ci.org/lemurheavy/coveralls-ruby) [![Gem Version](https://badge.fury.io/rb/coveralls.png)](http://badge.fury.io/rb/coveralls) ### [Read the docs →](https://coveralls.io/docs/ruby) coveralls-0.7.0/CHANGELOG.md0000644000175000017500000000072512305441752014656 0ustar miguelmiguel## 0.7.0 (September 18, 2013) [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.4...v0.7.0) Added: * output silencing (Thanks @elizabrock) * ruby warning fixes (Thanks @steveklabnik and @Nucc) ## 0.6.4 (April 2, 2013) [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.3...v0.6.4) Enhancements: * Support [Jenkins CI](http://jenkins-ci.org/) * Support VCR versions <= 2 * Add SimpleCov filter 'vendor' by default. coveralls-0.7.0/Gemfile0000644000175000017500000000020612305441752014332 0ustar miguelmiguelsource 'https://rubygems.org' # Specify your gem's dependencies in coveralls-ruby.gemspec gemspec gem 'simplecov', :require => falsecoveralls-0.7.0/checksums.yaml.gz0000444000175000017500000000041412305441752016326 0ustar miguelmiguelt9Re=R@F",?K:;{Oben,ons?b#^>aHBCsLU=Gm%e'yoN T|D*;r ?&I{z?Y%ٕqD?n8 Y h6z@ð l2x DD=h:qS)0ZUP0ѝGٿ΅A:8&%unX^$ٕ. coveralls-0.7.0/lib/0000755000175000017500000000000012305441752013607 5ustar miguelmiguelcoveralls-0.7.0/lib/coveralls/0000755000175000017500000000000012305441752015601 5ustar miguelmiguelcoveralls-0.7.0/lib/coveralls/version.rb0000644000175000017500000000005012305441752017606 0ustar miguelmiguelmodule Coveralls VERSION = "0.7.0" end coveralls-0.7.0/lib/coveralls/simplecov.rb0000644000175000017500000000647512305441752020143 0ustar miguelmiguelmodule Coveralls module SimpleCov class Formatter def display_result(result) # Log which files would be submitted. if result.files.length > 0 Coveralls::Output.puts "[Coveralls] Some handy coverage stats:" else Coveralls::Output.puts "[Coveralls] There are no covered files.", :color => "yellow" end result.files.each do |f| Coveralls::Output.print " * " Coveralls::Output.print short_filename(f.filename).to_s, :color => "cyan" Coveralls::Output.print " => ", :color => "white" cov = "#{f.covered_percent.round}%" if f.covered_percent > 90 Coveralls::Output.print cov, :color => "green" elsif f.covered_percent > 80 Coveralls::Output.print cov, :color => "yellow" else Coveralls::Output.print cov, :color => "red" end Coveralls::Output.puts "" end true end def format(result) unless Coveralls.should_run? if Coveralls.noisy? display_result result end return end # Gather the source files. source_files = [] result.files.each do |file| properties = {} # Get Source properties[:source] = File.open(file.filename, "rb:utf-8").read # Get the root-relative filename properties[:name] = short_filename(file.filename) # Get the coverage properties[:coverage] = file.coverage # Get the group # puts "result groups: #{result.groups}" # result.groups.each do |group_name, grouped_files| # puts "Checking #{grouped_files.map(&:filename)} for #{file.filename}" # if grouped_files.map(&:filename).include?(file.filename) # properties[:group] = group_name # break # end # end source_files << properties end # Log which files are being submitted. # puts "Submitting #{source_files.length} file#{source_files.length == 1 ? '' : 's'}:" # source_files.each do |f| # puts " => #{f[:name]}" # end # Post to Coveralls. API.post_json "jobs", {:source_files => source_files, :test_framework => result.command_name.downcase, :run_at => result.created_at} Coveralls::Output.puts output_message result true rescue Exception => e display_error e end def display_error(e) Coveralls::Output.puts "Coveralls encountered an exception:", :color => "red" Coveralls::Output.puts e.class.to_s, :color => "red" Coveralls::Output.puts e.message, :color => "red" e.backtrace.each do |line| Coveralls::Output.puts line, :color => "red" end if e.backtrace if e.respond_to?(:response) && e.response Coveralls::Output.puts e.response.to_s, :color => "red" end false end def output_message(result) "Coverage is at #{result.covered_percent.round(2) rescue result.covered_percent.round}%.\nCoverage report sent to Coveralls." end def short_filename(filename) filename = filename.gsub(::SimpleCov.root, '.').gsub(/^\.\//, '') if ::SimpleCov.root filename end end end end coveralls-0.7.0/lib/coveralls/api.rb0000644000175000017500000000450212305441752016700 0ustar miguelmiguelmodule Coveralls class API require 'multi_json' require 'rest_client' API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? "localhost:3000" : "coveralls.io" API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? "http" : "https" API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}" API_BASE = "#{API_DOMAIN}/api/v1" def self.post_json(endpoint, hash) disable_net_blockers! url = endpoint_to_url(endpoint) Coveralls::Output.puts("#{ MultiJson.dump(hash, :pretty => true) }", :color => "green") if ENV['COVERALLS_DEBUG'] hash = apified_hash hash Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", :color => "cyan") response = RestClient.post(url, :json_file => hash_to_file(hash)) response_hash = MultiJson.load(response.to_str) Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", :color => "cyan") if response_hash['message'] Coveralls::Output.puts("[Coveralls] #{ Coveralls::Output.format(response_hash['url'], :color => "underline") }", :color => "cyan") end rescue RestClient::ServiceUnavailable Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", :color => "red") rescue RestClient::InternalServerError Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", :color => "red") end private def self.disable_net_blockers! if defined?(WebMock) && allow = WebMock::Config.instance.allow || [] WebMock::Config.instance.allow = [*allow].push API_HOST end if defined?(VCR) VCR.send(VCR.version.major < 2 ? :config : :configure) do |c| c.ignore_hosts API_HOST end end end def self.endpoint_to_url(endpoint) "#{API_BASE}/#{endpoint}" end def self.hash_to_file(hash) file = nil Tempfile.open(['coveralls-upload', 'json']) do |f| f.write(MultiJson.dump hash) file = f end File.new(file.path, 'rb') end def self.apified_hash hash config = Coveralls::Configuration.configuration if ENV['CI'] || ENV['COVERALLS_DEBUG'] || Coveralls.testing Coveralls::Output.puts "[Coveralls] Submitting with config:", :color => "yellow" output = MultiJson.dump(config, :pretty => true).gsub(/"repo_token": "(.*?)"/,'"repo_token": "[secure]"') Coveralls::Output.puts output, :color => "yellow" end hash.merge(config) end end end coveralls-0.7.0/lib/coveralls/output.rb0000644000175000017500000000543412305441752017474 0ustar miguelmiguelmodule Coveralls # # Public: Methods for formatting strings with Term::ANSIColor. # Does not utilize monkey-patching and should play nicely when # included with other libraries. # # All methods are module methods and should be called on # the Coveralls::Output module. # # Examples # # Coveralls::Output.format("Hello World", :color => "cyan") # # => "\e[36mHello World\e[0m" # # Coveralls::Output.print("Hello World") # # Hello World => nil # # Coveralls::Output.puts("Hello World", :color => "underline") # # Hello World # # => nil # # To silence output completely: # # Coveralls::Output.silent = true # # or set this environment variable: # # COVERALLS_SILENT module Output require 'term/ansicolor' attr_accessor :silent attr_writer :output extend self def output (defined?(@output) && @output) || $stdout end # Public: Formats the given string with the specified color # through Term::ANSIColor # # string - the text to be formatted # options - The hash of options used for formatting the text: # :color - The color to be passed as a method to # Term::ANSIColor # # Examples # # Coveralls::Output.format("Hello World!", :color => "cyan") # # => "\e[36mHello World\e[0m" # # Returns the formatted string. def format(string, options = {}) if options[:color] options[:color].split(/\s/).reverse_each do |color| if Term::ANSIColor.respond_to?(color.to_sym) string = Term::ANSIColor.send(color.to_sym, string) end end end string end # Public: Passes .format to Kernel#puts # # string - the text to be formatted # options - The hash of options used for formatting the text: # :color - The color to be passed as a method to # Term::ANSIColor # # # Example # # Coveralls::Output.puts("Hello World", :color => "cyan") # # Returns nil. def puts(string, options = {}) return if silent? (options[:output] || output).puts self.format(string, options) end # Public: Passes .format to Kernel#print # # string - the text to be formatted # options - The hash of options used for formatting the text: # :color - The color to be passed as a method to # Term::ANSIColor # # Example # # Coveralls::Output.print("Hello World!", :color => "underline") # # Returns nil. def print(string, options = {}) return if silent? (options[:output] || output).print self.format(string, options) end def silent? ENV["COVERALLS_SILENT"] || (defined?(@silent) && @silent) end end end coveralls-0.7.0/lib/coveralls/rake/0000755000175000017500000000000012305441752016523 5ustar miguelmiguelcoveralls-0.7.0/lib/coveralls/rake/task.rb0000644000175000017500000000064312305441752020015 0ustar miguelmiguelrequire 'rake' require 'rake/tasklib' module Coveralls class RakeTask < ::Rake::TaskLib include ::Rake::DSL if defined?(::Rake::DSL) def initialize(*args, &task_block) namespace :coveralls do desc "Push latest coverage results to Coveralls.io" task :push do require 'coveralls' Coveralls.push! end end end # initialize end # class end # module coveralls-0.7.0/lib/coveralls/configuration.rb0000644000175000017500000001006012305441752020772 0ustar miguelmiguelmodule Coveralls module Configuration require 'yaml' def self.configuration config = { :environment => self.relevant_env, :git => git } yml = self.yaml_config if yml config[:configuration] = yml config[:repo_token] = yml['repo_token'] || yml['repo_secret_token'] end if ENV['COVERALLS_REPO_TOKEN'] config[:repo_token] = ENV['COVERALLS_REPO_TOKEN'] end if ENV['TRAVIS'] config[:service_job_id] = ENV['TRAVIS_JOB_ID'] config[:service_name] = (yml ? yml['service_name'] : nil) || 'travis-ci' elsif ENV['CIRCLECI'] config[:service_name] = 'circleci' config[:service_number] = ENV['CIRCLE_BUILD_NUM'] elsif ENV['SEMAPHORE'] config[:service_name] = 'semaphore' config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER'] elsif ENV['JENKINS_URL'] config[:service_name] = 'jenkins' config[:service_number] = ENV['BUILD_NUMBER'] elsif ENV["COVERALLS_RUN_LOCALLY"] || Coveralls.testing config[:service_job_id] = nil config[:service_name] = 'coveralls-ruby' config[:service_event_type] = 'manual' # standardized env vars elsif ENV['CI_NAME'] config[:service_name] = ENV['CI_NAME'] config[:service_number] = ENV['CI_BUILD_NUMBER'] config[:service_build_url] = ENV['CI_BUILD_URL'] config[:service_branch] = ENV['CI_BRANCH'] config[:service_pull_request] = ENV['CI_PULL_REQUEST'] end config end def self.yaml_config if self.configuration_path && File.exists?(self.configuration_path) YAML::load_file(self.configuration_path) end end def self.configuration_path File.expand_path(File.join(self.root, ".coveralls.yml")) if self.root end def self.root pwd end def self.pwd Dir.pwd end def self.simplecov_root if defined?(::SimpleCov) ::SimpleCov.root end end def self.rails_root Rails.root.to_s rescue nil end def self.git hash = {} Dir.chdir(root) do hash[:head] = { :id => `git log -1 --pretty=format:'%H'`, :author_name => `git log -1 --pretty=format:'%aN'`, :author_email => `git log -1 --pretty=format:'%ae'`, :committer_name => `git log -1 --pretty=format:'%cN'`, :committer_email => `git log -1 --pretty=format:'%ce'`, :message => `git log -1 --pretty=format:'%s'` } # Branch branch = `git branch`.split("\n").delete_if { |i| i[0] != "*" } hash[:branch] = [branch].flatten.first.gsub("* ","") # Remotes remotes = nil begin remotes = `git remote -v`.split(/\n/).map do |remote| splits = remote.split(" ").compact {:name => splits[0], :url => splits[1]} end.uniq rescue end hash[:remotes] = remotes end hash rescue Exception => e Coveralls::Output.puts "Coveralls git error:", :color => "red" Coveralls::Output.puts e.to_s, :color => "red" nil end def self.relevant_env hash = { :pwd => self.pwd, :rails_root => self.rails_root, :simplecov_root => simplecov_root, :gem_version => VERSION } hash.merge! begin if ENV['TRAVIS'] { :travis_job_id => ENV['TRAVIS_JOB_ID'], :travis_pull_request => ENV['TRAVIS_PULL_REQUEST'] } elsif ENV['CIRCLECI'] { :circleci_build_num => ENV['CIRCLE_BUILD_NUM'], :branch => ENV['CIRCLE_BRANCH'], :commit_sha => ENV['CIRCLE_SHA1'] } elsif ENV['JENKINS_URL'] { :jenkins_build_num => ENV['BUILD_NUMBER'], :jenkins_build_url => ENV['BUILD_URL'], :branch => ENV['GIT_BRANCH'], :commit_sha => ENV['GIT_COMMIT'] } else {} end end hash end end end coveralls-0.7.0/lib/coveralls/command.rb0000644000175000017500000000364012305441752017547 0ustar miguelmiguelmodule Coveralls require "thor" 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.exists?('.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 coveralls-0.7.0/lib/coveralls.rb0000644000175000017500000000532112305441752016127 0ustar miguelmiguelrequire "coveralls/version" require "coveralls/configuration" require "coveralls/api" require "coveralls/output" require "coveralls/simplecov" module Coveralls extend self class NilFormatter def format(result) end end attr_accessor :testing, :noisy, :run_locally def wear!(simplecov_setting=nil, &block) setup! start! simplecov_setting, &block end def wear_merged!(simplecov_setting=nil, &block) require 'simplecov' @@adapter = :simplecov ::SimpleCov.formatter = NilFormatter start! simplecov_setting, &block end def push! require 'simplecov' result = ::SimpleCov::ResultMerger.merged_result Coveralls::SimpleCov::Formatter.new.format result end def setup! # Try to load up SimpleCov. @@adapter = nil if defined?(::SimpleCov) @@adapter = :simplecov else begin require 'simplecov' @@adapter = :simplecov if defined?(::SimpleCov) rescue end end # Load the appropriate adapter. if @@adapter == :simplecov ::SimpleCov.formatter = Coveralls::SimpleCov::Formatter Coveralls::Output.puts("[Coveralls] Set up the SimpleCov formatter.", :color => "green") else Coveralls::Output.puts("[Coveralls] Couldn't find an appropriate adapter.", :color => "red") end end def start!(simplecov_setting = 'test_frameworks', &block) if @@adapter == :simplecov ::SimpleCov.add_filter 'vendor' if simplecov_setting Coveralls::Output.puts("[Coveralls] Using SimpleCov's '#{simplecov_setting}' settings.", :color => "green") if block_given? ::SimpleCov.start(simplecov_setting) { instance_eval(&block)} else ::SimpleCov.start(simplecov_setting) end elsif block Coveralls::Output.puts("[Coveralls] Using SimpleCov settings defined in block.", :color => "green") ::SimpleCov.start { instance_eval(&block) } else Coveralls::Output.puts("[Coveralls] Using SimpleCov's default settings.", :color => "green") ::SimpleCov.start end end end def should_run? # Fail early if we're not on a CI unless will_run? Coveralls::Output.puts("[Coveralls] Outside the Travis environment, not sending data.", :color => "yellow") return false end if ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@run_locally) && @run_locally) Coveralls::Output.puts("[Coveralls] Creating a new job on Coveralls from local coverage results.", :color => "cyan") end true end def will_run? ENV["CI"] || ENV["JENKINS_URL"] || ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@testing) && @testing) end def noisy? ENV["COVERALLS_NOISY"] || (defined?(@noisy) && @noisy) end end coveralls-0.7.0/metadata.yml0000644000175000017500000001300112305441752015337 0ustar miguelmiguel--- !ruby/object:Gem::Specification name: coveralls version: !ruby/object:Gem::Version version: 0.7.0 platform: ruby authors: - Nick Merwin - Wil Gieseler autorequire: bindir: bin cert_chain: [] date: 2013-09-18 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rest-client requirement: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: term-ansicolor requirement: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: multi_json requirement: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '1.3' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '1.3' - !ruby/object:Gem::Dependency name: thor requirement: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: simplecov requirement: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0.7' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0.7' - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: webmock requirement: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version version: '1.7' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version version: '1.7' - !ruby/object:Gem::Dependency name: vcr requirement: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version version: 1.11.3 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version version: 1.11.3 description: A Ruby implementation of the Coveralls API. email: - nick@lemurheavy.com - supapuerco@gmail.com executables: - coveralls extensions: [] extra_rdoc_files: [] files: - .gitignore - .rspec - .ruby-version - .travis.yml - CHANGELOG.md - Gemfile - LICENSE - README.md - Rakefile - bin/coveralls - coveralls-ruby.gemspec - lib/coveralls.rb - lib/coveralls/api.rb - lib/coveralls/command.rb - lib/coveralls/configuration.rb - lib/coveralls/output.rb - lib/coveralls/rake/task.rb - lib/coveralls/simplecov.rb - lib/coveralls/version.rb - spec/coveralls/configuration_spec.rb - spec/coveralls/coveralls_spec.rb - spec/coveralls/fixtures/app/controllers/sample.rb - spec/coveralls/fixtures/app/models/airplane.rb - spec/coveralls/fixtures/app/models/dog.rb - spec/coveralls/fixtures/app/models/house.rb - spec/coveralls/fixtures/app/models/robot.rb - spec/coveralls/fixtures/app/models/user.rb - spec/coveralls/fixtures/app/vendor/vendored_gem.rb - spec/coveralls/fixtures/sample.rb - spec/coveralls/output_spec.rb - spec/coveralls/simplecov_spec.rb - spec/spec_helper.rb homepage: https://coveralls.io licenses: [] metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.0.0 signing_key: specification_version: 4 summary: A Ruby implementation of the Coveralls API. test_files: - spec/coveralls/configuration_spec.rb - spec/coveralls/coveralls_spec.rb - spec/coveralls/fixtures/app/controllers/sample.rb - spec/coveralls/fixtures/app/models/airplane.rb - spec/coveralls/fixtures/app/models/dog.rb - spec/coveralls/fixtures/app/models/house.rb - spec/coveralls/fixtures/app/models/robot.rb - spec/coveralls/fixtures/app/models/user.rb - spec/coveralls/fixtures/app/vendor/vendored_gem.rb - spec/coveralls/fixtures/sample.rb - spec/coveralls/output_spec.rb - spec/coveralls/simplecov_spec.rb - spec/spec_helper.rb coveralls-0.7.0/.rspec0000644000175000017500000000001012305441752014145 0ustar miguelmiguel--color