middleman-scss-lint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +19 -0
- data/Gemfile +12 -0
- data/README.md +0 -0
- data/Rakefile +8 -0
- data/features/lint.feature +1 -0
- data/features/support/env.rb +7 -0
- data/fixtures/lint-app/config.rb +1 -0
- data/fixtures/lint-app/empty-config.yaml +10 -0
- data/fixtures/lint-app/source/stylesheets/site.css.scss +3 -0
- data/lib/middleman-scss-lint.rb +7 -0
- data/lib/middleman-scss-lint/extension.rb +102 -0
- data/lib/middleman-scss-lint/version.rb +5 -0
- data/middleman-scss-lint.gemspec +22 -0
- metadata +105 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 7ced6cb64fd1fc67f72b822d36bd843cfb3caf17
         | 
| 4 | 
            +
              data.tar.gz: 53a3decae36a0972724579040e018802487fb58e
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: a292db3d03697c40393a2dbac678a449eeea366ef5299d6fdea7551cb25f8cf52fe50cf46c42222786bf659ee2d23ef2c075a8ed6fbf10a3937c60b7875c6960
         | 
| 7 | 
            +
              data.tar.gz: 96701362cd916a9592ffd05a6523439cc7e80a7b4c0370517b4eed3306f44937ba8abba49900e5d2a6cf8b9cdd6f16aa8d76713f79730be534e2cb1e018c0106
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            language: ruby
         | 
| 2 | 
            +
            bundler_args: --without development
         | 
| 3 | 
            +
            rvm:
         | 
| 4 | 
            +
              - ruby-head
         | 
| 5 | 
            +
              - 2.2
         | 
| 6 | 
            +
              - 2.1
         | 
| 7 | 
            +
              - 2.0
         | 
| 8 | 
            +
              - 1.9.3
         | 
| 9 | 
            +
            os:
         | 
| 10 | 
            +
              - linux
         | 
| 11 | 
            +
              - osx
         | 
| 12 | 
            +
            cache: bundler
         | 
| 13 | 
            +
            sudo: false
         | 
| 14 | 
            +
            matrix:
         | 
| 15 | 
            +
              fast_finish: true
         | 
| 16 | 
            +
              allow_failures:
         | 
| 17 | 
            +
                - rvm: ruby-head
         | 
| 18 | 
            +
            env: TEST=true
         | 
| 19 | 
            +
            script: bundle exec rake test
         | 
    
        data/Gemfile
    ADDED
    
    | @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            source 'https://rubygems.org'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            gemspec
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            gem 'middleman-core', github: 'middleman/middleman', branch: 'master'
         | 
| 6 | 
            +
            gem 'middleman-cli', github: 'middleman/middleman', branch: 'master'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            gem 'cucumber',  '~> 2.0'
         | 
| 9 | 
            +
            gem 'aruba',     '~> 0.6'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            gem 'bundler',   '>= 1.6'
         | 
| 12 | 
            +
            gem 'rake',      '>= 10.3'
         | 
    
        data/README.md
    ADDED
    
    | 
            File without changes
         | 
    
        data/Rakefile
    ADDED
    
    
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            Feature: Scss Lint
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            activate :scss_lint#, fail_build: true, config: 'empty-config.yaml'
         | 
| @@ -0,0 +1,102 @@ | |
| 1 | 
            +
            module Middleman
         | 
| 2 | 
            +
              module ScssLint
         | 
| 3 | 
            +
                class Extension < ::Middleman::Extension
         | 
| 4 | 
            +
                  option :config, nil, 'Path to config file'
         | 
| 5 | 
            +
                  option :fail_build, false, 'If the build should fail if lint does not pass.'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def ready
         | 
| 8 | 
            +
                    require 'rainbow'
         | 
| 9 | 
            +
                    require 'rainbow/ext/string'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    result = run_once
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                    if app.build?
         | 
| 14 | 
            +
                      if options[:fail_build] && !result
         | 
| 15 | 
            +
                        logger.error "== SCSSLint failed"
         | 
| 16 | 
            +
                        exit(1)
         | 
| 17 | 
            +
                      end
         | 
| 18 | 
            +
                    else
         | 
| 19 | 
            +
                      logger.info "== SCSSLint succeeded" if result
         | 
| 20 | 
            +
                      watch_and_run
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def run_once
         | 
| 25 | 
            +
                    paths = app.sitemap.resources
         | 
| 26 | 
            +
                        .select { |r| File.extname(r.source_file) == '.scss' }
         | 
| 27 | 
            +
                        .map { |r| r.source_file }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    run_linter(paths)
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def watch_and_run
         | 
| 33 | 
            +
                    app.files.on_change :source do |changed|
         | 
| 34 | 
            +
                      changed_scss = changed.select do |f|
         | 
| 35 | 
            +
                        f[:full_path].extname == '.scss'
         | 
| 36 | 
            +
                      end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                      if changed_scss.length > 0
         | 
| 39 | 
            +
                        result = run_linter(changed_scss.map { |r| r[:full_path].to_s })
         | 
| 40 | 
            +
                        logger.info "== SCSSLint succeeded" if result
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  def run_linter(files_to_lint)
         | 
| 46 | 
            +
                    logger.info "== Linting SCSS"
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    cli_args = ['--format', 'JSON']
         | 
| 49 | 
            +
                    cli_args = cli_args + ['--config', options[:config]] if options[:config]
         | 
| 50 | 
            +
                    cli_args = cli_args + files_to_lint
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                    begin
         | 
| 53 | 
            +
                      output = ""
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                      ::IO.popen("bundle exec scss-lint #{cli_args.join(' ')}", 'r') do |pipe|
         | 
| 56 | 
            +
                        while buf = pipe.gets
         | 
| 57 | 
            +
                          output << buf
         | 
| 58 | 
            +
                        end
         | 
| 59 | 
            +
                      end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                      error_count = 0
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                      result = ::JSON.parse(output)
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                      result.each do |file_path, lints|
         | 
| 66 | 
            +
                        relative_path = file_path.sub(app.root, '')
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                        lints.each do |descr|
         | 
| 69 | 
            +
                          msg = "#{location(relative_path, descr)} #{type(descr)} #{message(descr)}"
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                          error_count += 1
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                          if descr["severity"] == "warning"
         | 
| 74 | 
            +
                            logger.warn msg
         | 
| 75 | 
            +
                          else
         | 
| 76 | 
            +
                            logger.error msg
         | 
| 77 | 
            +
                          end 
         | 
| 78 | 
            +
                        end
         | 
| 79 | 
            +
                      end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                      error_count <= 0
         | 
| 82 | 
            +
                    rescue ::Errno::ENOENT => e
         | 
| 83 | 
            +
                      logger.error "== SCSSLint: Command failed with message: #{e.message}"
         | 
| 84 | 
            +
                      exit(1)
         | 
| 85 | 
            +
                    end
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  def location(path, descr)
         | 
| 89 | 
            +
                    "#{path.color(:cyan)}:#{descr["line"].to_s.color(:magenta)}"
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  def type(descr)
         | 
| 93 | 
            +
                    descr["severity"] == "error" ? '[E]'.color(:red) : '[W]'.color(:yellow)
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  def message(descr)
         | 
| 97 | 
            +
                    linter_name = "#{descr["linter"]}: ".color(:green)
         | 
| 98 | 
            +
                    "#{linter_name}#{descr["reason"]}"
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
                end
         | 
| 101 | 
            +
              end
         | 
| 102 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'middleman-scss-lint/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = 'middleman-scss-lint'
         | 
| 8 | 
            +
              spec.version       = Middleman::ScssLint::VERSION
         | 
| 9 | 
            +
              spec.authors       = ['Thomas Reynolds']
         | 
| 10 | 
            +
              spec.email         = ['me@tdreyno.com']
         | 
| 11 | 
            +
              spec.summary       = 'ScssLint integration with Middleman'
         | 
| 12 | 
            +
              spec.homepage      = 'https://github.com/middleman/middleman-scss-lint'
         | 
| 13 | 
            +
              spec.license       = 'MIT'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              spec.files         = `git ls-files`.split($/)
         | 
| 16 | 
            +
              spec.test_files    = `git ls-files -- {features,fixtures}/*`.split($/)
         | 
| 17 | 
            +
              spec.require_paths = ['lib']
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              spec.add_dependency 'middleman-core', '>= 4.0.0'
         | 
| 20 | 
            +
              spec.add_dependency 'scss_lint', '~> 0.40'
         | 
| 21 | 
            +
              spec.add_dependency 'rainbow'
         | 
| 22 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,105 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: middleman-scss-lint
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Thomas Reynolds
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-12-16 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: middleman-core
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 4.0.0
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 4.0.0
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: scss_lint
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0.40'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0.40'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rainbow
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            description: 
         | 
| 56 | 
            +
            email:
         | 
| 57 | 
            +
            - me@tdreyno.com
         | 
| 58 | 
            +
            executables: []
         | 
| 59 | 
            +
            extensions: []
         | 
| 60 | 
            +
            extra_rdoc_files: []
         | 
| 61 | 
            +
            files:
         | 
| 62 | 
            +
            - ".gitignore"
         | 
| 63 | 
            +
            - ".travis.yml"
         | 
| 64 | 
            +
            - Gemfile
         | 
| 65 | 
            +
            - README.md
         | 
| 66 | 
            +
            - Rakefile
         | 
| 67 | 
            +
            - features/lint.feature
         | 
| 68 | 
            +
            - features/support/env.rb
         | 
| 69 | 
            +
            - fixtures/lint-app/config.rb
         | 
| 70 | 
            +
            - fixtures/lint-app/empty-config.yaml
         | 
| 71 | 
            +
            - fixtures/lint-app/source/stylesheets/site.css.scss
         | 
| 72 | 
            +
            - lib/middleman-scss-lint.rb
         | 
| 73 | 
            +
            - lib/middleman-scss-lint/extension.rb
         | 
| 74 | 
            +
            - lib/middleman-scss-lint/version.rb
         | 
| 75 | 
            +
            - middleman-scss-lint.gemspec
         | 
| 76 | 
            +
            homepage: https://github.com/middleman/middleman-scss-lint
         | 
| 77 | 
            +
            licenses:
         | 
| 78 | 
            +
            - MIT
         | 
| 79 | 
            +
            metadata: {}
         | 
| 80 | 
            +
            post_install_message: 
         | 
| 81 | 
            +
            rdoc_options: []
         | 
| 82 | 
            +
            require_paths:
         | 
| 83 | 
            +
            - lib
         | 
| 84 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 85 | 
            +
              requirements:
         | 
| 86 | 
            +
              - - ">="
         | 
| 87 | 
            +
                - !ruby/object:Gem::Version
         | 
| 88 | 
            +
                  version: '0'
         | 
| 89 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 90 | 
            +
              requirements:
         | 
| 91 | 
            +
              - - ">="
         | 
| 92 | 
            +
                - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                  version: '0'
         | 
| 94 | 
            +
            requirements: []
         | 
| 95 | 
            +
            rubyforge_project: 
         | 
| 96 | 
            +
            rubygems_version: 2.4.8
         | 
| 97 | 
            +
            signing_key: 
         | 
| 98 | 
            +
            specification_version: 4
         | 
| 99 | 
            +
            summary: ScssLint integration with Middleman
         | 
| 100 | 
            +
            test_files:
         | 
| 101 | 
            +
            - features/lint.feature
         | 
| 102 | 
            +
            - features/support/env.rb
         | 
| 103 | 
            +
            - fixtures/lint-app/config.rb
         | 
| 104 | 
            +
            - fixtures/lint-app/empty-config.yaml
         | 
| 105 | 
            +
            - fixtures/lint-app/source/stylesheets/site.css.scss
         |