saddler 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +18 -2
- data/lib/saddler.rb +22 -2
- data/lib/saddler/cli.rb +43 -7
- data/lib/saddler/error.rb +5 -0
- data/lib/saddler/validator.rb +13 -0
- data/lib/saddler/version.rb +1 -1
- data/saddler.gemspec +11 -1
- metadata +5 -3
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0203a1f51349d4087bbec200c6dbad7905e4c5f
|
4
|
+
data.tar.gz: 40049df61fa576c5bcde61ac0c669a4ad722c3fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aeea7d80d28736a7618527414ba66f89e272f607809d3f5d903fea47aef20fa2ede61f8768c561f75bbd2e8918fe8a67d52121d1c32993e97aa8055b7d9b28b
|
7
|
+
data.tar.gz: 634660e5c7f571f863177591db94f95032c2fd7cf57cd7f6a9ce82413609e7bdfaa4b8224c9bdd228d1c336bb192e1456ce1364c566e1cbecab2eb6c71db373f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
### 0.1.1 (2015-03-01)
|
2
|
+
|
3
|
+
#### Features
|
4
|
+
|
5
|
+
* **logger:** add logger ([e56ec137](https://github.com/packsaddle/ruby-saddler/commit/e56ec137327fb0fe211d2379bad670313a45a5db))
|
6
|
+
* **validator:** add xml validator([d230440](https://github.com/packsaddle/ruby-saddler/commit/d230440d5dfc09bffb6553e37ef6a5a0fbe0cf47))
|
7
|
+
|
8
|
+
## 0.1.0 (2015-02-24)
|
9
|
+
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* **app:** release
|
data/README.md
CHANGED
@@ -5,15 +5,23 @@
|
|
5
5
|
|
6
6
|
**checkstyle2anywhere**, you can exec any lint, security checker and tools.
|
7
7
|
|
8
|
+
### Pull Request Review Comment
|
9
|
+
|
10
|
+
![Pull Request Review Comment](https://cloud.githubusercontent.com/assets/75448/6392012/842ba6e2-bdff-11e4-84c3-bc180ac199bc.png "Pull Request Review Comment")
|
11
|
+
|
12
|
+
### Pull Request Comment
|
13
|
+
|
14
|
+
![Pull Request Comment](https://cloud.githubusercontent.com/assets/75448/6392013/892d1e5a-bdff-11e4-8ffb-f8ca93507662.png "Pull Request Comment")
|
15
|
+
|
8
16
|
## Usage
|
9
17
|
|
10
18
|
```
|
11
|
-
git diff -z --name-only
|
19
|
+
git diff -z --name-only origin/master \
|
12
20
|
| xargs -0 rubocop-select \
|
13
21
|
| xargs rubocop \
|
14
22
|
--require rubocop/formatter/checkstyle_formatter \
|
15
23
|
--format RuboCop::Formatter::CheckstyleFormatter \
|
16
|
-
| checkstyle_filter-git diff
|
24
|
+
| checkstyle_filter-git diff origin/master \
|
17
25
|
| saddler report \
|
18
26
|
--require saddler/reporter/github \
|
19
27
|
--reporter Saddler::Reporter::Github::PullRequestReviewComment
|
@@ -28,6 +36,14 @@ You can run this from any CI Service (e.g. circle-ci, travis-ci, jenkins, etc).
|
|
28
36
|
* [saddler-reporter-text](https://github.com/packsaddle/ruby-saddler-reporter-text)
|
29
37
|
* [saddler-reporter-github](https://github.com/packsaddle/ruby-saddler-reporter-github)
|
30
38
|
|
39
|
+
## Examples and Demo
|
40
|
+
You can send pull request to repos below. Try this!
|
41
|
+
|
42
|
+
* [TravisCI with Pull Request Review Comment](https://github.com/packsaddle/example-travis_ci-pull_request_review)
|
43
|
+
* [TravisCI with Pull Request Comment](https://github.com/packsaddle/example-travis_ci-pull_request)
|
44
|
+
* [CircleCI with Pull Request Review Comment](https://github.com/packsaddle/example-circle_ci-pull_request_review)
|
45
|
+
* [CircleCI with Pull Request Comment](https://github.com/packsaddle/example-circle_ci-pull_request)
|
46
|
+
|
31
47
|
## Installation
|
32
48
|
|
33
49
|
Add this line to your application's Gemfile:
|
data/lib/saddler.rb
CHANGED
@@ -1,6 +1,26 @@
|
|
1
|
-
require '
|
1
|
+
require 'logger'
|
2
|
+
require 'saddler/reporter/text'
|
3
|
+
require 'rexml/document'
|
4
|
+
|
5
|
+
require 'saddler/error'
|
2
6
|
require 'saddler/reporter'
|
7
|
+
require 'saddler/validator'
|
8
|
+
require 'saddler/version'
|
3
9
|
|
4
10
|
module Saddler
|
5
|
-
|
11
|
+
def self.default_logger
|
12
|
+
logger = Logger.new(STDERR)
|
13
|
+
logger.progname = 'Saddler'
|
14
|
+
logger.level = Logger::WARN
|
15
|
+
logger
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.logger
|
19
|
+
return @logger if @logger
|
20
|
+
@logger = default_logger
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
attr_writer :logger
|
25
|
+
end
|
6
26
|
end
|
data/lib/saddler/cli.rb
CHANGED
@@ -19,8 +19,39 @@ module Saddler
|
|
19
19
|
option :options, type: :hash, default: {}
|
20
20
|
option :require
|
21
21
|
option :reporter
|
22
|
+
option :debug, type: :boolean, default: false
|
23
|
+
option :verbose, type: :boolean, default: false
|
22
24
|
def report
|
23
|
-
|
25
|
+
if options[:debug]
|
26
|
+
logger.level = Logger::DEBUG
|
27
|
+
elsif options[:verbose]
|
28
|
+
logger.level = Logger::INFO
|
29
|
+
end
|
30
|
+
logger.debug(options)
|
31
|
+
|
32
|
+
data = fetch_data(options)
|
33
|
+
Validator.valid?(data)
|
34
|
+
require options[:require] if options[:require]
|
35
|
+
reporter = add_reporter(options)
|
36
|
+
|
37
|
+
reporter.report(data, options[:options])
|
38
|
+
rescue StandardError => e
|
39
|
+
logger.error('options')
|
40
|
+
logger.error(options)
|
41
|
+
logger.error('input data')
|
42
|
+
logger.error(data)
|
43
|
+
logger.error('reporter')
|
44
|
+
logger.error(reporter)
|
45
|
+
raise e
|
46
|
+
end
|
47
|
+
|
48
|
+
no_commands do
|
49
|
+
def logger
|
50
|
+
::Saddler.logger
|
51
|
+
end
|
52
|
+
|
53
|
+
def fetch_data(options)
|
54
|
+
data = \
|
24
55
|
if options[:data]
|
25
56
|
options[:data]
|
26
57
|
elsif options[:file]
|
@@ -30,15 +61,20 @@ module Saddler
|
|
30
61
|
ARGF.read
|
31
62
|
end
|
32
63
|
|
33
|
-
|
64
|
+
logger.info('input data')
|
65
|
+
logger.info(data)
|
66
|
+
fail NoInputError if !data || data.empty?
|
34
67
|
|
35
|
-
|
36
|
-
if options[:reporter]
|
37
|
-
reporter = ::Saddler::Reporter.add_reporter(options[:reporter], $stdout)
|
68
|
+
data
|
38
69
|
end
|
39
70
|
|
40
|
-
|
41
|
-
|
71
|
+
def add_reporter(options)
|
72
|
+
reporter = Reporter.add_reporter(options[:reporter], $stdout) if options[:reporter]
|
73
|
+
fail NoReporterError unless reporter
|
74
|
+
logger.info('use reporter')
|
75
|
+
logger.info(reporter)
|
76
|
+
reporter
|
77
|
+
end
|
42
78
|
end
|
43
79
|
end
|
44
80
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Saddler
|
2
|
+
class Validator
|
3
|
+
# NOTE: This is easy check
|
4
|
+
def self.valid?(data)
|
5
|
+
REXML::Document.new(data)
|
6
|
+
true
|
7
|
+
rescue REXML::ParseException => e
|
8
|
+
exception = InvalidXMLError.new(e.message)
|
9
|
+
exception.set_backtrace(e.backtrace)
|
10
|
+
raise exception
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/saddler/version.rb
CHANGED
data/saddler.gemspec
CHANGED
@@ -14,7 +14,17 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/packsaddle/ruby-saddler'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files =
|
17
|
+
spec.files = \
|
18
|
+
`git ls-files -z`
|
19
|
+
.split("\x0")
|
20
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
.reject do |f|
|
22
|
+
[
|
23
|
+
'.travis.yml',
|
24
|
+
'circle.yml',
|
25
|
+
'.tachikoma.yml'
|
26
|
+
].include?(f)
|
27
|
+
end
|
18
28
|
spec.bindir = 'exe'
|
19
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
30
|
spec.require_paths = ['lib']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saddler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sanemat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -90,7 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
92
|
- ".rubocop.yml"
|
93
|
-
-
|
93
|
+
- CHANGELOG.md
|
94
94
|
- CODE_OF_CONDUCT.md
|
95
95
|
- Gemfile
|
96
96
|
- LICENSE.txt
|
@@ -104,7 +104,9 @@ files:
|
|
104
104
|
- exe/saddler
|
105
105
|
- lib/saddler.rb
|
106
106
|
- lib/saddler/cli.rb
|
107
|
+
- lib/saddler/error.rb
|
107
108
|
- lib/saddler/reporter.rb
|
109
|
+
- lib/saddler/validator.rb
|
108
110
|
- lib/saddler/version.rb
|
109
111
|
- saddler.gemspec
|
110
112
|
homepage: https://github.com/packsaddle/ruby-saddler
|