coveralls-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 31c420172a756993b584da37c042cecb6443efadd0233403dc725762cc54dd19
4
+ data.tar.gz: f0b0d7fb3c690979ccf0be344fa0f6882397b4934baeef497bce7088972b264f
5
+ SHA512:
6
+ metadata.gz: a54005348739b5f1b80ee4b8c4535a13b5cd86251c5a7ef0f9a4866ac9dba9d523488dc13fe1fa29c68a193cbcdc8297049f32b5e29ccc2545d4925a633be9fa
7
+ data.tar.gz: b47d2d5c427777ec55d41739656a29507d6b34fef1d6077833afdbbeae1a680abf52c5e177afad1afb0d00e71960711882272a1f10c0af131ed2ee2792cb9731
data/.github/stale.yml ADDED
@@ -0,0 +1,60 @@
1
+ # Configuration for probot-stale - https://github.com/probot/stale
2
+
3
+ # Number of days of inactivity before an Issue or Pull Request becomes stale
4
+ daysUntilStale: 457
5
+
6
+ # Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7
+ # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8
+ daysUntilClose: 7
9
+
10
+ # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11
+ onlyLabels: []
12
+
13
+ # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14
+ exemptLabels:
15
+ - enhancement
16
+
17
+ # Set to true to ignore issues in a project (defaults to false)
18
+ exemptProjects: false
19
+
20
+ # Set to true to ignore issues in a milestone (defaults to false)
21
+ exemptMilestones: false
22
+
23
+ # Set to true to ignore issues with an assignee (defaults to false)
24
+ exemptAssignees: false
25
+
26
+ # Label to use when marking as stale
27
+ staleLabel: marked-for-closure
28
+
29
+ # Comment to post when marking as stale. Set to `false` to disable
30
+ markComment: >
31
+ This issue has been automatically marked for closure because it has not had
32
+ recent activity. It will be closed if no further activity occurs.
33
+ If your issue is still active please add a comment and we’ll review as soon as we can.
34
+ Thank you for your contributions.
35
+
36
+ # Comment to post when removing the stale label.
37
+ # unmarkComment: >
38
+ # Your comment here.
39
+
40
+ # Comment to post when closing a stale Issue or Pull Request.
41
+ # closeComment: >
42
+ # Your comment here.
43
+
44
+ # Limit the number of actions per hour, from 1-30. Default is 30
45
+ limitPerRun: 30
46
+
47
+ # Limit to only `issues` or `pulls`
48
+ # only: issues
49
+
50
+ # Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
51
+ # pulls:
52
+ # daysUntilStale: 30
53
+ # markComment: >
54
+ # This pull request has been automatically marked as stale because it has not had
55
+ # recent activity. It will be closed if no further activity occurs. Thank you
56
+ # for your contributions.
57
+
58
+ # issues:
59
+ # exemptLabels:
60
+ # - confirmed
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ .DS_Store
20
+ /vendor/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --warn
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.3
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
5
+ sudo: false
6
+
7
+ before_install:
8
+ - gem update --system
9
+ - gem install bundler
10
+
11
+ rvm:
12
+ - 2.3
13
+ - 2.4
14
+ - 2.5
15
+ - ruby-head
16
+ - jruby
17
+
18
+ matrix:
19
+ allow_failures:
20
+ - rvm: ruby-head
21
+ - rvm: jruby
22
+ fast_finish: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ### Please see Github Releases section for current releases.
4
+
5
+ ## 0.7.0 (September 18, 2013)
6
+
7
+ [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.4...v0.7.0)
8
+
9
+ Added:
10
+ * output silencing (Thanks @elizabrock)
11
+ * ruby warning fixes (Thanks @steveklabnik and @Nucc)
12
+
13
+ ## 0.6.4 (April 2, 2013)
14
+
15
+ [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.3...v0.6.4)
16
+
17
+ Enhancements:
18
+
19
+ * Support [Jenkins CI](http://jenkins-ci.org/)
20
+ * Support VCR versions <= 2
21
+ * Add SimpleCov filter 'vendor' by default.
data/Gemfile ADDED
@@ -0,0 +1,41 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in coveralls-ruby.gemspec
4
+ gemspec
5
+
6
+ gem 'rake', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3') ? '~> 10.3' : '>= 10.3'
7
+ gem 'rspec', '>= 3.2'
8
+ gem 'simplecov', :require => false
9
+ gem 'truthy', '>= 1'
10
+
11
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9')
12
+ gem 'vcr', '~> 2.9'
13
+ gem 'webmock', '~> 1.20'
14
+ else
15
+ gem 'vcr', '>= 2.9'
16
+ gem 'webmock', '>= 1.20'
17
+ end
18
+
19
+ platforms :ruby_18 do
20
+ gem 'addressable', '~> 2.3.8', :group => :test
21
+ gem 'mime-types', '~> 1.25'
22
+ end
23
+
24
+ platforms :ruby_18, :ruby_19 do
25
+ gem 'json', '~> 1.8'
26
+ gem 'term-ansicolor', '~> 1.3.0'
27
+ gem 'tins', '~> 1.6.0'
28
+ end
29
+
30
+ platforms :jruby do
31
+ gem 'jruby-openssl'
32
+ end
33
+
34
+ platform :rbx do
35
+ gem 'rubysl', '~> 2.0'
36
+ gem 'rubinius-developer_tools'
37
+ end
38
+
39
+ group :test do
40
+ gem 'pry'
41
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Wil Gieseler
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # [Coveralls](http://coveralls.io) for Ruby [![Test Coverage](https://coveralls.io/repos/lemurheavy/coveralls-ruby/badge.svg?branch=master)](https://coveralls.io/r/lemurheavy/coveralls-ruby) [![Build Status](https://secure.travis-ci.org/lemurheavy/coveralls-ruby.svg?branch=master)](https://travis-ci.org/lemurheavy/coveralls-ruby) [![Gem Version](https://badge.fury.io/rb/coveralls.svg)](http://badge.fury.io/rb/coveralls)
2
+
3
+ This gem is used as a development dependency for [graphql_devise](https://github.com/graphql-devise/graphql_devise).
4
+ We simply added what we needed as the official gem is not maintained anymore.
5
+
6
+ ### [Read the docs &rarr;](https://docs.coveralls.io/ruby-on-rails)
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ # Travis!
5
+ require 'rubygems'
6
+ require 'rake'
7
+ require 'rspec/core/rake_task'
8
+
9
+ desc "Run RSpec"
10
+ RSpec::Core::RakeTask.new do |t|
11
+ t.verbose = false
12
+ end
13
+
14
+ task :default => :spec
data/bin/coveralls ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'coveralls'
7
+ require 'coveralls/command'
8
+
9
+ Coveralls::CommandLine.start
@@ -0,0 +1,32 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'coveralls/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ["Nick Merwin", "Wil Gieseler"]
7
+ gem.email = ["nick@lemurheavy.com", "supapuerco@gmail.com"]
8
+ gem.description = "A Ruby implementation of the Coveralls API."
9
+ gem.summary = "A Ruby implementation of the Coveralls API."
10
+ gem.homepage = "https://coveralls.io"
11
+ gem.license = "MIT"
12
+
13
+ gem.metadata['homepage_uri'] = gem.homepage
14
+ gem.metadata['source_code_uri'] = 'https://github.com/graphql-devise/coveralls-ruby'
15
+
16
+ gem.files = `git ls-files`.split($\)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.name = "coveralls-ruby"
20
+ gem.require_paths = ["lib"]
21
+ gem.version = Coveralls::VERSION
22
+
23
+ gem.required_ruby_version = '>= 1.8.7'
24
+
25
+ gem.add_dependency 'json', '>= 1.8', '< 3'
26
+ gem.add_dependency 'simplecov', '~> 0.16.1'
27
+ gem.add_dependency 'tins', '~> 1.6'
28
+ gem.add_dependency 'term-ansicolor', '~> 1.3'
29
+ gem.add_dependency 'thor', '>= 0.19.4', '< 2.0'
30
+
31
+ gem.add_development_dependency 'bundler', '~> 2.0'
32
+ end
data/lib/coveralls.rb ADDED
@@ -0,0 +1,101 @@
1
+ require "coveralls/version"
2
+ require "coveralls/configuration"
3
+ require "coveralls/api"
4
+ require "coveralls/output"
5
+ require "coveralls/simplecov"
6
+
7
+ module Coveralls
8
+ extend self
9
+
10
+ class NilFormatter
11
+ def format(result)
12
+ end
13
+ end
14
+
15
+ attr_accessor :testing, :noisy, :run_locally
16
+
17
+ def wear!(simplecov_setting=nil, &block)
18
+ setup!
19
+ start! simplecov_setting, &block
20
+ end
21
+
22
+ def wear_merged!(simplecov_setting=nil, &block)
23
+ require 'simplecov'
24
+ @@adapter = :simplecov
25
+ ::SimpleCov.formatter = NilFormatter
26
+ start! simplecov_setting, &block
27
+ end
28
+
29
+ def push!
30
+ require 'simplecov'
31
+ result = ::SimpleCov::ResultMerger.merged_result
32
+ Coveralls::SimpleCov::Formatter.new.format result
33
+ end
34
+
35
+ def setup!
36
+ # Try to load up SimpleCov.
37
+ @@adapter = nil
38
+ if defined?(::SimpleCov)
39
+ @@adapter = :simplecov
40
+ else
41
+ begin
42
+ require 'simplecov'
43
+ @@adapter = :simplecov if defined?(::SimpleCov)
44
+ rescue
45
+ end
46
+ end
47
+
48
+ # Load the appropriate adapter.
49
+ if @@adapter == :simplecov
50
+ ::SimpleCov.formatter = Coveralls::SimpleCov::Formatter
51
+ Coveralls::Output.puts("[Coveralls] Set up the SimpleCov formatter.", :color => "green")
52
+ else
53
+ Coveralls::Output.puts("[Coveralls] Couldn't find an appropriate adapter.", :color => "red")
54
+ end
55
+
56
+ end
57
+
58
+ def start!(simplecov_setting = 'test_frameworks', &block)
59
+ if @@adapter == :simplecov
60
+ ::SimpleCov.add_filter 'vendor'
61
+
62
+ if simplecov_setting
63
+ Coveralls::Output.puts("[Coveralls] Using SimpleCov's '#{simplecov_setting}' settings.", :color => "green")
64
+ if block_given?
65
+ ::SimpleCov.start(simplecov_setting) { instance_eval(&block)}
66
+ else
67
+ ::SimpleCov.start(simplecov_setting)
68
+ end
69
+ elsif block
70
+ Coveralls::Output.puts("[Coveralls] Using SimpleCov settings defined in block.", :color => "green")
71
+ ::SimpleCov.start { instance_eval(&block) }
72
+ else
73
+ Coveralls::Output.puts("[Coveralls] Using SimpleCov's default settings.", :color => "green")
74
+ ::SimpleCov.start
75
+ end
76
+ end
77
+ end
78
+
79
+ def should_run?
80
+ # Fail early if we're not on a CI
81
+ unless will_run?
82
+ Coveralls::Output.puts("[Coveralls] Outside the CI environment, not sending data.", :color => "yellow")
83
+ return false
84
+ end
85
+
86
+ if ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@run_locally) && @run_locally)
87
+ Coveralls::Output.puts("[Coveralls] Creating a new job on Coveralls from local coverage results.", :color => "cyan")
88
+ end
89
+
90
+ true
91
+ end
92
+
93
+ def will_run?
94
+ ENV["CI"] || ENV["JENKINS_URL"] || ENV['TDDIUM'] ||
95
+ ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@testing) && @testing)
96
+ end
97
+
98
+ def noisy?
99
+ ENV["COVERALLS_NOISY"] || (defined?(@noisy) && @noisy)
100
+ end
101
+ end
@@ -0,0 +1,128 @@
1
+ require 'json'
2
+ require 'net/https'
3
+ require 'tempfile'
4
+
5
+ module Coveralls
6
+ class API
7
+ if ENV['COVERALLS_ENDPOINT']
8
+ API_HOST = ENV['COVERALLS_ENDPOINT']
9
+ API_DOMAIN = ENV['COVERALLS_ENDPOINT']
10
+ else
11
+ API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? "localhost:3000" : "coveralls.io"
12
+ API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? "http" : "https"
13
+ API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
14
+ end
15
+
16
+ API_BASE = "#{API_DOMAIN}/api/v1"
17
+
18
+ def self.post_json(endpoint, hash)
19
+ disable_net_blockers!
20
+
21
+ uri = endpoint_to_uri(endpoint)
22
+
23
+ Coveralls::Output.puts("#{ JSON.pretty_generate(hash) }", :color => "green") if ENV['COVERALLS_DEBUG']
24
+ Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", :color => "cyan")
25
+
26
+ client = build_client(uri)
27
+ request = build_request(uri.path, hash)
28
+
29
+ response = client.request(request)
30
+
31
+ response_hash = JSON.load(response.body.to_str)
32
+
33
+ if response_hash['message']
34
+ Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", :color => "cyan")
35
+ end
36
+
37
+ if response_hash['url']
38
+ Coveralls::Output.puts("[Coveralls] #{ Coveralls::Output.format(response_hash['url'], :color => "underline") }", :color => "cyan")
39
+ end
40
+
41
+ case response
42
+ when Net::HTTPServiceUnavailable
43
+ Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", :color => "red")
44
+ when Net::HTTPInternalServerError
45
+ Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", :color => "red")
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def self.disable_net_blockers!
52
+ begin
53
+ require 'webmock'
54
+
55
+ allow = WebMock::Config.instance.allow || []
56
+ WebMock::Config.instance.allow = [*allow].push API_HOST
57
+ rescue LoadError
58
+ end
59
+
60
+ begin
61
+ require 'vcr'
62
+
63
+ VCR.send(VCR.version.major < 2 ? :config : :configure) do |c|
64
+ c.ignore_hosts API_HOST
65
+ end
66
+ rescue LoadError
67
+ end
68
+ end
69
+
70
+ def self.endpoint_to_uri(endpoint)
71
+ URI.parse("#{API_BASE}/#{endpoint}")
72
+ end
73
+
74
+ def self.build_client(uri)
75
+ client = Net::HTTP.new(uri.host, uri.port)
76
+ client.use_ssl = true if uri.port == 443
77
+ client.verify_mode = OpenSSL::SSL::VERIFY_NONE
78
+
79
+ unless client.respond_to?(:ssl_version=)
80
+ Net::HTTP.ssl_context_accessor("ssl_version")
81
+ end
82
+
83
+ client.ssl_version = 'TLSv1'
84
+
85
+ client
86
+ end
87
+
88
+ def self.build_request(path, hash)
89
+ request = Net::HTTP::Post.new(path)
90
+ boundary = rand(1_000_000).to_s
91
+
92
+ request.body = build_request_body(hash, boundary)
93
+ request.content_type = "multipart/form-data, boundary=#{boundary}"
94
+
95
+ request
96
+ end
97
+
98
+ def self.build_request_body(hash, boundary)
99
+ hash = apified_hash(hash)
100
+ file = hash_to_file(hash)
101
+
102
+ "--#{boundary}\r\n" \
103
+ "Content-Disposition: form-data; name=\"json_file\"; filename=\"#{File.basename(file.path)}\"\r\n" \
104
+ "Content-Type: text/plain\r\n\r\n" +
105
+ File.read(file.path) +
106
+ "\r\n--#{boundary}--\r\n"
107
+ end
108
+
109
+ def self.hash_to_file(hash)
110
+ file = nil
111
+ Tempfile.open(['coveralls-upload', 'json']) do |f|
112
+ f.write(JSON.dump hash)
113
+ file = f
114
+ end
115
+ File.new(file.path, 'rb')
116
+ end
117
+
118
+ def self.apified_hash hash
119
+ config = Coveralls::Configuration.configuration
120
+ if ENV['COVERALLS_DEBUG'] || Coveralls.testing
121
+ Coveralls::Output.puts "[Coveralls] Submitting with config:", :color => "yellow"
122
+ output = JSON.pretty_generate(config).gsub(/"repo_token": ?"(.*?)"/,'"repo_token": "[secure]"')
123
+ Coveralls::Output.puts output, :color => "yellow"
124
+ end
125
+ hash.merge(config)
126
+ end
127
+ end
128
+ end