coffeelint 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/coffeelint ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'coffeelint'
4
+ require 'optparse'
5
+
6
+ options = {:recursive => false}
7
+ OptionParser.new do |opts|
8
+ opts.banner = "Usage: coffeelint [options] source [...]"
9
+
10
+ opts.on '-r', "Recursively lint .coffee files in subdirectories." do |f|
11
+ options[:recursive] = f
12
+ end
13
+ end.parse!
14
+
15
+ ARGV.each do |file|
16
+ if options[:recursive]
17
+ Coffeelint.run_test_suite(file)
18
+ else
19
+ Coffeelint.run_test(file)
20
+ end
21
+ end
data/lib/coffeelint.rb CHANGED
@@ -28,4 +28,36 @@ module Coffeelint
28
28
  end
29
29
  retval
30
30
  end
31
+
32
+ def self.display_test_results(name, errors)
33
+ name = name[2..-1]
34
+
35
+ good = "\u2713"
36
+ bad = "\u2717"
37
+
38
+ if errors.length == 0
39
+ puts " #{good} \e[1m\e[32m#{name}\e[0m"
40
+ return true
41
+ else
42
+ puts " #{bad} \e[1m\e[31m#{name}\e[0m"
43
+ errors.each do |error|
44
+ puts " #{bad} \e[31m##{error["lineNumber"]}\e[0m: #{error["message"]}, #{error["context"]}."
45
+ end
46
+ return false
47
+ end
48
+ end
49
+
50
+ def self.run_test(file)
51
+ result = Coffeelint.lint_file(file)
52
+ Coffeelint.display_test_results(file, result)
53
+ end
54
+
55
+ def self.run_test_suite(directory)
56
+ success = true
57
+ Coffeelint.lint_dir(directory) do |name, errors|
58
+ result = Coffeelint.display_test_results(name, errors)
59
+ success = false if not result
60
+ end
61
+ success
62
+ end
31
63
  end
@@ -1,3 +1,3 @@
1
1
  module Coffeelint
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,22 +1,4 @@
1
1
  desc "lint application javascript"
2
2
  task :coffeelint do
3
- success = true
4
- Coffeelint.lint_dir('.') do |name, errors|
5
- name = name[2..-1]
6
-
7
- good = "\u2713"
8
- bad = "\u2717"
9
-
10
- if errors.length == 0
11
- puts " #{good} \e[1m\e[32m#{name}\e[0m"
12
- else
13
- success = false
14
- puts " #{bad} \e[1m\e[31m#{name}\e[0m"
15
- errors.each do |error|
16
- puts " #{bad} \e[31m##{error["lineNumber"]}\e[0m: #{error["message"]}, #{error["context"]}."
17
- end
18
- end
19
- end
20
-
21
- fail "Lint!" unless success
3
+ fail 'Lint!' unless Coffeelint.run_test('.')
22
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coffeelint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -30,7 +30,8 @@ dependencies:
30
30
  description: Ruby bindings for coffeelint
31
31
  email:
32
32
  - zach@zmbush.com
33
- executables: []
33
+ executables:
34
+ - coffeelint
34
35
  extensions: []
35
36
  extra_rdoc_files: []
36
37
  files:
@@ -40,6 +41,7 @@ files:
40
41
  - LICENSE.txt
41
42
  - README.md
42
43
  - Rakefile
44
+ - bin/coffeelint
43
45
  - coffeelint.gemspec
44
46
  - lib/coffeelint.rb
45
47
  - lib/coffeelint/railtie.rb