Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Eckerstorfer committed Jun 9, 2015
0 parents commit dfba865
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg/*
Gemfile.lock
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gemspec

gem "scss-lint", ">= 0.32.0"
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# jUnit formatter for SCSS-Lint

[SCSS-Lint](https://github.com/causes/scss-lint)


## Requirements

Ruby gem: scss-lint >= 0.32.0


## Installation

```bash
gem install scss_lint_reporter_junit
```

Check the installation:
```bash
scss-lint --require=scss_lint_reporter_junit --show-formatter
```
Output is something like this
```
Installed formatters:
- JUnit
- Config
- Default
- Files
- JSON
```

## Usage

```bash
scss-lint --require=scss_lint_reporter_junit --format=JUnit foo.scss
```
[More detailed examples](https://github.com/causes/scss-lint/blob/master/README.md#usage)
31 changes: 31 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
begin
require 'bundler'
Bundler.setup
rescue LoadError
$stderr.puts 'You need to have Bundler installed to be able build this gem.'
end

gemspec = eval(File.read(Dir["*.gemspec"].first))


desc "Validate the gemspec"
task :validate do
gemspec.validate
end

desc "Build gem locally"
task :build => :validate do
system "gem build #{gemspec.name}.gemspec"
FileUtils.mkdir_p "pkg"
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
end

desc "Install gem locally"
task :install => :build do
system "gem install ./pkg/#{gemspec.name}-#{gemspec.version}.gem"
end

desc "Remove generated files"
task :clean do
FileUtils.rm_rf "pkg"
end
30 changes: 30 additions & 0 deletions lib/scss_lint_reporter_junit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module SCSSLint
class Reporter::JUnitReporter < Reporter
def report_lints
results = lints.group_by(&:filename)
output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"

output << "<testsuite name=\"scsslint\" failures=\"#{results.length}\">\n"
if !results.length
output << " <testcase name=\"Empty\"/>\n"
end
results.each do |file_name, errors|
output << " <testcase name=#{file_name.encode(xml: :attr)}>\n"
output << " <failure message=\"#{errors.length} SCSSLint Failure\">"

i = 1
errors.each do |error|
output << "#{i}. line #{error.location.line}, column #{error.location.column}-" \
"#{error.location.length}: [#{error.severity}] #{error.linter.name if error.linter}: "\
"#{error.description.encode(xml: :attr)}"
i += 1
end
output << "</failure>\n"
output << " </testcase>\n"
end
output << "</testsuite>\n"

output
end
end
end
16 changes: 16 additions & 0 deletions scss_lint_reporter_junit.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# coding: UTF-8

Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.license = "MIT"
s.name = "scss_lint_reporter_junit"
s.version = "0.1.0"
s.summary = "Extend the scss-lint with a jUnit formatter"
s.description = "This gem add a new formatter to the scss-lint which is compatible with the jUnit standard."
s.homepage = "https://github.com/florianeckerstorfer/scss_lint_reporter_junit"
s.authors = ["Florian Eckerstorfer"]
s.email = ["[email protected]"]
s.required_rubygems_version = ">= 1.3.6"
s.files = s.files = Dir['lib/**/*.rb']
s.require_path = ['lib']
end

0 comments on commit dfba865

Please sign in to comment.