jlint 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b5d44e5a295d7ffe71e14f79daf5186ff8bea7d
4
- data.tar.gz: ff8476f35b72d659fc04ec092fdcafbae5f1592a
3
+ metadata.gz: ac58a70f61ad72118a655e61ce7344dbe4aeb162
4
+ data.tar.gz: c62d20259cef8cf7f5aecc578d3c54a16111fc0a
5
5
  SHA512:
6
- metadata.gz: 49969fd02dcbfb5e2162b53168a2a892dd3f356e1e2990f9b42ae1e038ddcd9e8a01d6efdf778cd3f71992e158fc0999fa712334eced3cb72b280a9d5cd66f83
7
- data.tar.gz: 19c1000afdea425a47f862787678469ff4c224805e1c6dd47e15f716d00f617b3cff2653a4b05e7e286129698e8d1453b08031f5b9ae7dde24c0c2698244224f
6
+ metadata.gz: 4b3719d2be30d246557136348841b52f1d30b9781fe1a70e5011164beb09c7b4f531e33f1c68ea82b83af17acf3ffc9ffd105954b26ab435c9f3121fac6931bc
7
+ data.tar.gz: e28edb10669f82f1afb4018ec3f1981247c0c03869b015d6d101281eff71f95e781fb8fd1cf2f0c88b2b505f494e6c3ca9eda8212ac78e000efc48b274944440
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jlint (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.4.2)
10
+ rake (10.3.2)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.5)
17
+ jlint!
18
+ minitest
19
+ rake
data/README.md CHANGED
@@ -18,6 +18,10 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install jlint
20
20
 
21
+ ## Dependency
22
+
23
+ 1. JRE
24
+
21
25
  ## Usage
22
26
 
23
27
  ```ruby
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/jlint/test_*.rb"
6
+ end
7
+
data/bin/checkstyle.jar CHANGED
File without changes
data/jlint.gemspec CHANGED
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
23
24
  end
data/lib/jlint.rb CHANGED
@@ -1,30 +1,10 @@
1
- class Jlint
2
- def self.lint file_path, config
3
- new.lint file_path, config
1
+ require 'jlint/base'
2
+ module Jlint
3
+ def self.lint content, config
4
+ Base.new.lint content, config
4
5
  end
5
6
 
6
- def initialize
7
- end
8
-
9
- def lint file_path, config
10
- parse `java -jar #{checkstyle_command} -c #{checkstyle_config} #{file_path}`
11
- end
12
-
13
- private
14
- def checkstyle_command
15
- File.join(File.dirname(__FILE__), '..', 'bin', 'checkstyle.jar')
16
- end
17
-
18
- def checkstyle_config
19
- File.join(File.dirname(__FILE__), '..', 'doc', 'sun_checks.xml')
20
- end
21
-
22
- def parse results
23
- array = results.split("\n")
24
- array.reject! { |s| s == 'Starting audit...' || s == 'Audit done.' }
25
- array.map! do |msg|
26
- msgs = msg.split(":")
27
- [msgs.last.strip, msgs[1]]
28
- end
7
+ def self.file_lint file_path, config
8
+ Base.new.file_lint file_path, config
29
9
  end
30
10
  end
data/lib/jlint/base.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'tempfile'
2
+
3
+ module Jlint
4
+ class Base
5
+ def initialize
6
+ end
7
+
8
+ def lint content, config
9
+ file = Tempfile.new(["temp", ".java"])
10
+ begin
11
+ file.puts content
12
+ file.rewind
13
+ file.close
14
+
15
+ file_lint file.path, config
16
+ ensure
17
+ file.unlink
18
+ end
19
+ end
20
+
21
+ def file_lint file_path, config
22
+ parse `java -jar #{checkstyle_command} -c #{checkstyle_config} #{file_path}`
23
+ end
24
+
25
+ private
26
+
27
+ def checkstyle_command
28
+ File.join(File.dirname(__FILE__), '..', '..', 'bin', 'checkstyle.jar')
29
+ end
30
+
31
+ def checkstyle_config
32
+ File.join(File.dirname(__FILE__), '..', '..', 'doc', 'sun_checks.xml')
33
+ end
34
+
35
+ def parse results
36
+ array = results.split("\n")
37
+ array.reject! { |s| s == 'Starting audit...' || s == 'Audit done.' }
38
+ array.map! do |msg|
39
+ msgs = msg.split(":")
40
+ [msgs.last.strip, msgs[1].to_i]
41
+ end
42
+ end
43
+ end
44
+ end
data/lib/jlint/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jlint
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,27 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Jlint do
4
+
5
+ it "should lint for file_path" do
6
+ file_path = File.join(File.dirname(__FILE__), "..", "support", "sample.java")
7
+ result = Jlint.file_lint(file_path, "")
8
+ assert result.is_a?(Array)
9
+ assert result.include?(["Missing package-info.java file.", 0])
10
+ end
11
+
12
+ it "should lint for file content with newline" do
13
+ content = %Q[public class Sample {
14
+ public static void Sample() {
15
+ }
16
+
17
+ public void hi(long name) {
18
+ system.out.printf("Hi, " + name);
19
+ }
20
+ }]
21
+ result = Jlint.lint(content, "")
22
+ assert result.is_a?(Array)
23
+ assert !result.include?(["File does not end with a newline.", 0])
24
+ assert result.include?(["Missing package-info.java file.", 0])
25
+ end
26
+
27
+ end
@@ -0,0 +1,8 @@
1
+ public class Sample {
2
+ public static void Sample() {
3
+ }
4
+
5
+ public void hi(long name) {
6
+ system.out.printf("Hi, " + name);
7
+ }
8
+ }
@@ -0,0 +1,5 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require "jlint"
5
+ require "minitest/autorun"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - soffolk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-20 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: 'Ruby Warp for CheckStyle: https://github.com/checkstyle/checkstyle'
42
56
  email:
43
57
  - zlx.star@gmail.com
@@ -48,6 +62,7 @@ extra_rdoc_files: []
48
62
  files:
49
63
  - .gitignore
50
64
  - Gemfile
65
+ - Gemfile.lock
51
66
  - LICENSE.txt
52
67
  - README.md
53
68
  - Rakefile
@@ -56,7 +71,11 @@ files:
56
71
  - doc/sun_checks.xml
57
72
  - jlint.gemspec
58
73
  - lib/jlint.rb
74
+ - lib/jlint/base.rb
59
75
  - lib/jlint/version.rb
76
+ - test/jlint/test_jlint.rb
77
+ - test/support/sample.java
78
+ - test/test_helper.rb
60
79
  homepage: ''
61
80
  licenses:
62
81
  - MIT
@@ -81,5 +100,8 @@ rubygems_version: 2.0.3
81
100
  signing_key:
82
101
  specification_version: 4
83
102
  summary: 'Ruby Warp for CheckStyle: https://github.com/checkstyle/checkstyle'
84
- test_files: []
103
+ test_files:
104
+ - test/jlint/test_jlint.rb
105
+ - test/support/sample.java
106
+ - test/test_helper.rb
85
107
  has_rdoc: