execcsslint 12.03.19 → 13.07.01

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2012, Mint Digital, Daniel Holz
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- 1. Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
- 2. Redistributions in binary form must reproduce the above copyright notice,
10
- this list of conditions and the following disclaimer in the documentation
11
- and/or other materials provided with the distribution.
12
-
13
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ Copyright (c) 2012, Mint Digital, Daniel Holz
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -1,68 +1,77 @@
1
- ExecCSSLint
2
- ==========
3
-
4
- ExecCSSLint is a thin Ruby wrapper that uses ExecJS to execute [csslint]. It is heavily inspired by Dean Strelau's [https://github.com/mintdigital/execjslint][ExecJSLint].
5
-
6
- Install
7
- -------
8
-
9
- ```
10
- $ gem install execcsslint
11
- ```
12
-
13
- Usage
14
- -----
15
-
16
- ```ruby
17
- js = File.open('path/to/my.js')
18
- results = csslint.run(js)
19
- if result.valid?
20
- puts "Great job pal"
21
- else
22
- puts "Check your CSS"
23
- puts result.errors
24
- end
25
- ```
26
-
27
- If you're looking to use this in a Rails app, take a look at
28
- [examples/csslint.rake][rake].
29
-
30
- Requirements
31
- ------------
32
-
33
- You'll need one of the [supported ExecJS runtimes][execjs-runtimes]. OS X
34
- comes with JavaScriptCore by default, so you likely don't need to install
35
- anything.
36
-
37
- csslint Options
38
- --------------
39
-
40
- Right now, `ExecCSSLint` does not support setting global csslint options, so you'll
41
- have to include them in a `/*csslint */` comment at the top of each file.
42
- `csslint.js` will automatically parse and apply options specified like this. A
43
- full list of options is available on [csslint.net][csslint-options].
44
-
45
- Using an Alternate csslint.js
46
- ----------------------------
47
-
48
- ExecCSSLint depends on the `csslint-source` gem, which is a ruby packaging
49
- of the official [csslint.js][csslintjs]. By default, ExecCSSLint depends on the
50
- latest version of the `csslint-source` gem. As there are no official releases
51
- of csslint, `csslint-source` is versioned according to [the date at the top of
52
- csslint.js][csslint-date] (eg, `2012.03.16`). rubygems.org has a [full list of
53
- `csslint-source` gem versions][source-versions].
54
-
55
- To override this, you can specify an explicit dependency on `csslint-source`,
56
- for example, using bundler:
57
-
58
- ```
59
- gem 'execcsslint'
60
- gem 'csslint-source', '2012.03.17'
61
- ```
62
-
63
- You can also explicitly specify a local copy of `csslint.js` to use by setting
64
- the `CSSLINT_PATH` env variable.
65
-
66
- ```
67
- $ CSSLINT_PATH=../lib/csslint.js rake csslint
68
- ```
1
+ ExecCSSLint
2
+ ==========
3
+
4
+ ExecCSSLint is a thin Ruby wrapper that uses ExecJS to execute [csslint]. It is heavily inspired by Dean Strelau's [https://github.com/mintdigital/execjslint](ExecJSLint).
5
+
6
+ Install
7
+ -------
8
+
9
+ ```
10
+ $ gem install execcsslint
11
+ ```
12
+
13
+ Usage
14
+ -----
15
+
16
+ ```ruby
17
+ require 'execcsslint'
18
+
19
+ css = File.open('path/to/my.css')
20
+ results = CSSLint.run(css)
21
+ if !result.valid?
22
+ # There were errors
23
+ puts "Check your CSS"
24
+ puts result.error_messages
25
+ elsif !result.error_messages.empty?
26
+ # There were warnings
27
+ puts "You may want to take at look at your CSS"
28
+ puts result.error_messages
29
+ else
30
+ puts "Great job pal"
31
+ end
32
+ ```
33
+
34
+ `CSSLint.run` accepts an IO object (that responds to `read()`) or a string.
35
+
36
+ If you're looking to use this in a Rails app, take a look at
37
+ [examples/csslint.rake](the example rake task).
38
+
39
+ Requirements
40
+ ------------
41
+
42
+ You'll need one of the [execjs-runtimes](supported ExecJS runtimes). OS X
43
+ comes with JavaScriptCore by default, so you likely don't need to install
44
+ anything.
45
+
46
+ csslint Options
47
+ --------------
48
+
49
+ Right now, `ExecCSSLint` does not support setting global csslint options, so you'll
50
+ have to include them in a `/*csslint */` comment at the top of each file.
51
+ `csslint.js` will automatically parse and apply options specified like this. A
52
+ full list of options is available on [csslint.net].
53
+
54
+ Using an Alternate csslint.js
55
+ ----------------------------
56
+
57
+ ExecCSSLint depends on the `csslint-source` gem, which is a ruby packaging
58
+ of the official csslint.js. By default, ExecCSSLint depends on the
59
+ latest version of the `csslint-source` gem. As there are no official releases
60
+ of csslint, `csslint-source` is versioned according to [the date at the top of
61
+ csslint.js][csslint-date] (eg, `2012.03.16`). rubygems.org has a [full list of
62
+ `csslint-source` gem versions][source-versions].
63
+
64
+ To override this, you can specify an explicit dependency on `csslint-source`,
65
+ for example, using bundler:
66
+
67
+ ```
68
+ gem 'execcsslint'
69
+ gem 'csslint-source', '2012.03.17'
70
+ ```
71
+
72
+ You can also explicitly specify a local copy of `csslint.js` to use by setting
73
+ the `CSSLINT_PATH` env variable.
74
+
75
+ ```
76
+ $ CSSLINT_PATH=../lib/csslint.js rake csslint
77
+ ```
data/lib/csslint.rb CHANGED
@@ -1,82 +1,82 @@
1
- require 'execjs'
2
- require 'csslint/source'
3
-
4
- module CSSLint
5
- # Internal: The ExecJS Context in which to run csslint().
6
- #
7
- # Provides a small helper function CSSLINTR to return both the CSSLint()
8
- # return value and the CSSLint messages
9
- def self.context
10
- ExecJS.compile(
11
- CSSLint::Source.contents + <<-EOW
12
-
13
- function gatherRules(options){
14
- var ruleset,
15
- warnings = options.rules || options.warnings,
16
- errors = options.errors;
17
-
18
- if (warnings){
19
- ruleset = ruleset || {};
20
- for( var _i = 0, _len = warnings.length; _i < _len; _i++ ) {
21
- ruleset[warnings[_i]] = 1;
22
- };
23
- }
24
-
25
- if (errors){
26
- ruleset = ruleset || {};
27
- for( var _i = 0, _len = errors.length; _i < _len; _i++ ) {
28
- ruleset[errors[_i]] = 2;
29
- };
30
- }
31
-
32
- return ruleset;
33
- }
34
-
35
- function CSSLINTR(source, options) {
36
- var result = CSSLint.verify( source, gatherRules( options ) );
37
- var messages = result.messages || [];
38
- return [ messages ];
39
- };
40
- EOW
41
- )
42
- end
43
-
44
- # Public: Run CSSLint over some CSS text
45
- #
46
- # source - some String-like or IO-like CSS text
47
- # options - Hash of options passed directly to csslint (default: {})
48
- def self.run(source, options={})
49
- source = source.respond_to?(:read) ? source.read : source
50
- if source.respond_to?(:path)
51
- options[:fullPath] = File.expand_path( source.path )
52
- options[:filename] = source.path
53
- end
54
- Result.new(*context.call("CSSLINTR", source, options))
55
- end
56
-
57
- class Result
58
- def initialize(messages)
59
- @messages = messages
60
- end
61
-
62
- # Public: Did the CSS text pass CSSLint without messages?
63
- #
64
- # This is the return value of the CSSLint() function.
65
- #
66
- # Returns true iff CSSLint returned no error messages.
67
- def valid?
68
- @messages.select { |m| m['type'] == 'error' }.length == 0
69
- end
70
-
71
- # Public: A nicely formatted list of messages with their line number.
72
- #
73
- # Returns an Array of Strings.
74
- def error_messages
75
- # @messages may have a 'nil' as the last element if there was a catastrophic
76
- # error, so we 'compact'.
77
- @messages.compact.map {|e|
78
- "#{e['line']}:#{e['col']}: [#{ e['type'] }] #{e['message']}#{ e['evidence'] and " (#{ e['evidence'] })"}"
79
- }
80
- end
81
- end
82
- end
1
+ require 'execjs'
2
+ require 'csslint/source'
3
+
4
+ module CSSLint
5
+ # Internal: The ExecJS Context in which to run csslint().
6
+ #
7
+ # Provides a small helper function CSSLINTR to return both the CSSLint()
8
+ # return value and the CSSLint messages
9
+ def self.context
10
+ ExecJS.compile(
11
+ CSSLint::Source.contents + <<-EOW
12
+
13
+ function gatherRules(options){
14
+ var ruleset,
15
+ warnings = options.rules || options.warnings,
16
+ errors = options.errors;
17
+
18
+ if (warnings){
19
+ ruleset = ruleset || {};
20
+ for( var _i = 0, _len = warnings.length; _i < _len; _i++ ) {
21
+ ruleset[warnings[_i]] = 1;
22
+ };
23
+ }
24
+
25
+ if (errors){
26
+ ruleset = ruleset || {};
27
+ for( var _i = 0, _len = errors.length; _i < _len; _i++ ) {
28
+ ruleset[errors[_i]] = 2;
29
+ };
30
+ }
31
+
32
+ return ruleset;
33
+ }
34
+
35
+ function CSSLINTR(source, options) {
36
+ var result = CSSLint.verify( source, gatherRules( options ) );
37
+ var messages = result.messages || [];
38
+ return [ messages ];
39
+ };
40
+ EOW
41
+ )
42
+ end
43
+
44
+ # Public: Run CSSLint over some CSS text
45
+ #
46
+ # source - some String-like or IO-like CSS text
47
+ # options - Hash of options passed directly to csslint (default: {})
48
+ def self.run(source, options={})
49
+ source = source.respond_to?(:read) ? source.read : source
50
+ if source.respond_to?(:path)
51
+ options[:fullPath] = File.expand_path( source.path )
52
+ options[:filename] = source.path
53
+ end
54
+ Result.new(*context.call("CSSLINTR", source, options))
55
+ end
56
+
57
+ class Result
58
+ def initialize(messages)
59
+ @messages = messages
60
+ end
61
+
62
+ # Public: Did the CSS text pass CSSLint without messages?
63
+ #
64
+ # This is the return value of the CSSLint() function.
65
+ #
66
+ # Returns true iff CSSLint returned no error messages.
67
+ def valid?
68
+ @messages.select { |m| m['type'] == 'error' }.length == 0
69
+ end
70
+
71
+ # Public: A nicely formatted list of messages with their line number.
72
+ #
73
+ # Returns an Array of Strings.
74
+ def error_messages
75
+ # @messages may have a 'nil' as the last element if there was a catastrophic
76
+ # error, so we 'compact'.
77
+ @messages.compact.map {|e|
78
+ "#{e['line']}:#{e['col']}: [#{ e['type'] }] #{e['message']}#{ e['evidence'] and " (#{ e['evidence'] })"}"
79
+ }
80
+ end
81
+ end
82
+ end
@@ -1,61 +1,61 @@
1
- require 'rake'
2
- require 'csslint'
3
-
4
- module CSSLint
5
- class TestTask
6
- include Rake::DSL
7
-
8
- # Public: Gets/Sets the Array of JavaScript filenames as Strings, each of
9
- # which will be run through csslint. (default: Dir['**/*.css'])
10
- attr_accessor :file_list
11
-
12
- # Public: Gets/Sets the Hash of options that will be passed to each call
13
- # of csslint. See http://www.csslint.com/lint.html for allowed options.
14
- # (default: {})
15
- attr_accessor :options
16
-
17
- # Public: Define a new Rake task that runs CSSLint tests over several
18
- # JavaScript files.
19
- #
20
- # name - the name of the defined Rake Task. (default: 'csslint')
21
- #
22
- # Yields itself for configuration if a block is given.
23
- def initialize(name=:csslint)
24
- @name = name
25
- @file_list = Dir['**/*.css']
26
- @options = {}
27
- yield self if block_given?
28
-
29
- define_task
30
- end
31
-
32
- # Internal: Define the actual Rake task.
33
- def define_task
34
- desc "Run #{@name == :csslint ? '' : @name + ' '}CSSLint tests"
35
- task @name do
36
- t0 = Time.now
37
- errors = []
38
-
39
- @file_list.each do |f|
40
- result = CSSLint.run(File.open(f), @options )
41
- if result.valid?
42
- print '.'
43
- else
44
- errors << result.error_messages.map {|e| "#{f}:#{e}"}
45
- print 'F'
46
- end
47
- end
48
-
49
- puts
50
- puts
51
- if errors.any?
52
- puts *errors
53
- puts
54
- end
55
- puts "Finished in %.5f seconds" % [Time.now.to_f - t0.to_f]
56
- puts "%d files, %d errors" % [@file_list.length, errors.length]
57
- end
58
- end
59
-
60
- end
61
- end
1
+ require 'rake'
2
+ require 'csslint'
3
+
4
+ module CSSLint
5
+ class TestTask
6
+ include Rake::DSL
7
+
8
+ # Public: Gets/Sets the Array of JavaScript filenames as Strings, each of
9
+ # which will be run through csslint. (default: Dir['**/*.css'])
10
+ attr_accessor :file_list
11
+
12
+ # Public: Gets/Sets the Hash of options that will be passed to each call
13
+ # of csslint. See http://www.csslint.com/lint.html for allowed options.
14
+ # (default: {})
15
+ attr_accessor :options
16
+
17
+ # Public: Define a new Rake task that runs CSSLint tests over several
18
+ # JavaScript files.
19
+ #
20
+ # name - the name of the defined Rake Task. (default: 'csslint')
21
+ #
22
+ # Yields itself for configuration if a block is given.
23
+ def initialize(name=:csslint)
24
+ @name = name
25
+ @file_list = Dir['**/*.css']
26
+ @options = {}
27
+ yield self if block_given?
28
+
29
+ define_task
30
+ end
31
+
32
+ # Internal: Define the actual Rake task.
33
+ def define_task
34
+ desc "Run #{@name == :csslint ? '' : @name + ' '}CSSLint tests"
35
+ task @name do
36
+ t0 = Time.now
37
+ errors = []
38
+
39
+ @file_list.each do |f|
40
+ result = CSSLint.run(File.open(f), @options )
41
+ if result.valid?
42
+ print '.'
43
+ else
44
+ errors << result.error_messages.map {|e| "#{f}:#{e}"}
45
+ print 'F'
46
+ end
47
+ end
48
+
49
+ puts
50
+ puts
51
+ if errors.any?
52
+ puts *errors
53
+ puts
54
+ end
55
+ puts "Finished in %.5f seconds" % [Time.now.to_f - t0.to_f]
56
+ puts "%d files, %d errors" % [@file_list.length, errors.length]
57
+ end
58
+ end
59
+
60
+ end
61
+ end
data/lib/execcsslint.rb CHANGED
@@ -1 +1 @@
1
- require 'csslint'
1
+ require 'csslint'
metadata CHANGED
@@ -1,96 +1,116 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: execcsslint
3
- version: !ruby/object:Gem::Version
4
- version: 12.03.19
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 13
7
+ - 7
8
+ - 1
9
+ version: 13.07.01
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Dean Strelau
9
13
  - Daniel Holz
10
14
  autorequire:
11
15
  bindir: bin
12
16
  cert_chain: []
13
- date: 2012-03-19 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-07-01 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
16
22
  name: rake
17
- requirement: &21734580 !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 8
31
+ - 7
22
32
  version: 0.8.7
23
33
  type: :runtime
24
- prerelease: false
25
- version_requirements: *21734580
26
- - !ruby/object:Gem::Dependency
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
27
36
  name: csslint-source
28
- requirement: &21733944 !ruby/object:Gem::Requirement
29
- none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
37
  prerelease: false
36
- version_requirements: *21733944
37
- - !ruby/object:Gem::Dependency
38
- name: execjs
39
- requirement: &21733356 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ version: "0"
45
45
  type: :runtime
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: execjs
46
49
  prerelease: false
47
- version_requirements: *21733356
48
- - !ruby/object:Gem::Dependency
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id003
59
+ - !ruby/object:Gem::Dependency
49
60
  name: rspec
50
- requirement: &21732396 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ! '>='
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- type: :development
57
61
  prerelease: false
58
- version_requirements: *21732396
59
- description: ! ' A bridge to run CSSLint from Ruby via ExecJS.
60
-
61
- '
62
+ requirement: &id004 !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ type: :development
70
+ version_requirements: *id004
71
+ description: " A bridge to run CSSLint from Ruby via ExecJS.\n"
62
72
  email: dgholz@gmail.com
63
73
  executables: []
74
+
64
75
  extensions: []
76
+
65
77
  extra_rdoc_files: []
66
- files:
78
+
79
+ files:
67
80
  - lib/execcsslint.rb
68
81
  - lib/csslint.rb
69
82
  - lib/csslint/testtask.rb
70
83
  - LICENSE
71
84
  - README.md
85
+ has_rdoc: true
72
86
  homepage: http://github.com/dgholz/execcsslint
73
87
  licenses: []
88
+
74
89
  post_install_message:
75
90
  rdoc_options: []
76
- require_paths:
91
+
92
+ require_paths:
77
93
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ segments:
106
+ - 0
107
+ version: "0"
90
108
  requirements: []
109
+
91
110
  rubyforge_project:
92
- rubygems_version: 1.8.16
111
+ rubygems_version: 1.3.6
93
112
  signing_key:
94
113
  specification_version: 3
95
114
  summary: ExecJS CSSLint Bridge
96
115
  test_files: []
116
+