Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit e40f348

Browse files
committed
initial commit
0 parents  commit e40f348

File tree

12 files changed

+172
-0
lines changed

12 files changed

+172
-0
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
.idea/
20+
.idea_modules/
21+
22+
.DS_Store
23+
/vendor/

Gemfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec
4+
5+
gem 'rake', '>= 10.4'
6+
gem 'rspec', '>= 3.2'
7+
gem 'simplecov', :require => false
8+
gem 'truthy', '>= 1'
9+
gem 'vcr', '>= 2.9'
10+
gem 'webmock', '>= 1.20'
11+

bin/codacy-coverage

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 'codacy'
7+
require 'codacy/cli'
8+
9+
Codacy::CommandLine.start

codacy-ruby.gemspec

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
lib = File.expand_path('../lib', __FILE__)
2+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3+
require 'codacy/version'
4+
5+
Gem::Specification.new do |gem|
6+
gem.authors = ["Nuno Teixeira"]
7+
gem.email = ["[email protected]"]
8+
gem.description = "Post code coverage results to Codacy."
9+
gem.summary = "Post code coverage results to Codacy."
10+
gem.homepage = "https://codacy.com"
11+
gem.license = "MIT"
12+
13+
gem.files = `git ls-files`.split($\)
14+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16+
gem.name = "codacy-coverage"
17+
gem.require_paths = ["lib"]
18+
gem.version = Codacy::VERSION
19+
20+
gem.required_ruby_version = '>= 1.8.7'
21+
22+
gem.add_dependency 'simplecov', '~> 0.10.0'
23+
24+
gem.add_development_dependency 'bundler', '~> 1.7'
25+
end

lib/codacy.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require "codacy/configuration"
2+
require "codacy/git"
3+
require "codacy/version"

lib/codacy/cli.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require "thor"
2+
3+
module Codacy
4+
class CommandLine < Thor
5+
6+
desc "push", "Push coverage information to Codacy"
7+
def push
8+
logger.info("Pushing coverage")
9+
puts Codacy::Git.commit_id
10+
end
11+
12+
desc "version", "Reporter version"
13+
def version
14+
logger.info("Requesting version")
15+
puts Codacy::VERSION
16+
end
17+
18+
private
19+
20+
def logger
21+
Codacy::Configuration::logger
22+
end
23+
24+
end
25+
end

lib/codacy/configuration.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'logger'
2+
3+
module Codacy
4+
module Configuration
5+
6+
def self.logger
7+
log = Logger.new($stdout)
8+
log.level = Logger::INFO
9+
10+
log
11+
end
12+
13+
end
14+
end

lib/codacy/git.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module Codacy
2+
class Git
3+
def self.commit_id
4+
5+
commit = ENV['TRAVIS_COMMIT'] ||
6+
ENV['DRONE_COMMIT'] ||
7+
ENV['GIT_COMMIT'] ||
8+
ENV['CIRCLE_SHA1'] ||
9+
ENV['CI_COMMIT_ID'] ||
10+
ENV['WERCKER_GIT_COMMIT'] ||
11+
git_commit
12+
13+
commit
14+
end
15+
16+
private
17+
18+
def self.git_commit
19+
git("log -1 --pretty=format:'%H'")
20+
end
21+
22+
def self.git_dir
23+
return '.'
24+
end
25+
26+
def self.git(command)
27+
`git --git-dir="#{git_dir}/.git" #{command}`
28+
end
29+
end
30+
end

lib/codacy/parser.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Codacy
2+
module Parser
3+
4+
5+
end
6+
end

lib/codacy/version.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Codacy
2+
VERSION = '0.0.1'
3+
end

0 commit comments

Comments
 (0)