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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e3cbd21f10fa179c70115b166487b2801affe9f
4
- data.tar.gz: 7d52f4d658b072a55228af8bf7e6f7ad1b7c8734
3
+ metadata.gz: a0203a1f51349d4087bbec200c6dbad7905e4c5f
4
+ data.tar.gz: 40049df61fa576c5bcde61ac0c669a4ad722c3fd
5
5
  SHA512:
6
- metadata.gz: 3238a6968d4d42c80db96bde6f27646ae5a13355cdbae6826d53e71a2c60403f257a3ea48d64136a03ea1b802f6aa275c5b0a3ab7bdd0dd04640a0d69078bad6
7
- data.tar.gz: 7a049c9cc75960625608e315699cf7cb8b638035e4ae24dea1f4c853dba1c0b6e9805c057264989ffc21833e880eee8a36eca78953b7c06143004c7fd46d1cdb
6
+ metadata.gz: 7aeea7d80d28736a7618527414ba66f89e272f607809d3f5d903fea47aef20fa2ede61f8768c561f75bbd2e8918fe8a67d52121d1c32993e97aa8055b7d9b28b
7
+ data.tar.gz: 634660e5c7f571f863177591db94f95032c2fd7cf57cd7f6a9ce82413609e7bdfaa4b8224c9bdd228d1c336bb192e1456ce1364c566e1cbecab2eb6c71db373f
@@ -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 ..origin/master \
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 ..origin/master \
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:
@@ -1,6 +1,26 @@
1
- require 'saddler/version'
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
- # Your code goes here...
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
@@ -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
- data = \
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
- abort('no input') if !data || data.empty?
64
+ logger.info('input data')
65
+ logger.info(data)
66
+ fail NoInputError if !data || data.empty?
34
67
 
35
- require options[:require] if options[:require]
36
- if options[:reporter]
37
- reporter = ::Saddler::Reporter.add_reporter(options[:reporter], $stdout)
68
+ data
38
69
  end
39
70
 
40
- abort('no reporter') unless reporter
41
- reporter.report(data, options[:options])
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,5 @@
1
+ module Saddler
2
+ class NoInputError < StandardError; end
3
+ class NoReporterError < StandardError; end
4
+ class InvalidXMLError < StandardError; end
5
+ 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
@@ -1,3 +1,3 @@
1
1
  module Saddler
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -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 = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
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.0
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-02-24 00:00:00.000000000 Z
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
- - ".travis.yml"
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
@@ -1,15 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 1.9
5
- - 2.0
6
- - 2.1
7
- - 2.2
8
- before_install:
9
- - gem update bundler
10
- notifications:
11
- email:
12
- - ogataken@gmail.com
13
- branches:
14
- only:
15
- - master