goodcheck 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15aefd3f98836effe7e8ebb411d6429a34f52106
4
- data.tar.gz: e14fe493d3aa80f2efb184cd1b219804c240eb1f
3
+ metadata.gz: 655728b9b54f9f48689ab1537e36db901b6e0ce7
4
+ data.tar.gz: 58b694b053b4fdf26c96c4b7369d87fffdac05cb
5
5
  SHA512:
6
- metadata.gz: 1ce2020afbd45f6b8d67f35d2245b086d54d7f001d759b8cf04f75cc3b563f38ed09d042ff4b73f5e77c352f0438c7ce5becd0f438de43b24fbb1694bbf81498
7
- data.tar.gz: 042523304df5f10a8d614184df04f2b6c0d88c2a951353a542e9040b487902e1454b6d71ce00c7f477948fe23f509c7f619cd68e94e2feabbbf75433a53d0e3b
6
+ metadata.gz: 3241668c77b0b0fcea6a1bf1db06002a2e4df90a91c1bab4013fc15fbb51d65a036e5da91a8e6938019aa59ff3552eb2d13f79b2bf533067d6e04cf62e5f3f8d
7
+ data.tar.gz: b5d60bbef44eef2f3c97b23dbcd8ae8f7cf4d2203dcdad431e86e675c9c123170ad79cba50e926c52a43c3e21e4f744d10d64a2c6397c8c9bea3f8ff499879b9
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.1.0 (2018-06-16)
6
+
7
+ * Support `{}` syntax in glob. #11
8
+ * Add `case_insensitive` option for `token` pattern. #10
9
+
5
10
  ## 1.0.0 (2018-02-22)
6
11
 
7
12
  * Stop resolving realpath for symlinks. #6
@@ -0,0 +1,21 @@
1
+ FROM ruby:2.5.0-stretch
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
+
5
+ RUN apt-get update -y && \
6
+ apt-get install -y locales task-english && \
7
+ rm -rf /var/lib/apt/lists/*
8
+ RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && \
9
+ locale-gen en_US.UTF-8 && \
10
+ update-locale en_US.UTF-8
11
+ ENV LC_ALL=en_US.UTF-8 \
12
+ LANG=en_US.UTF-8 \
13
+ LANGUAGE=en_US.UTF-8
14
+
15
+ RUN mkdir /goodcheck
16
+ WORKDIR /goodcheck
17
+ COPY . /goodcheck/
18
+ RUN bundle install && bundle exec rake install
19
+
20
+ RUN mkdir /work
21
+ WORKDIR /work
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- goodcheck (1.0.0)
4
+ goodcheck (1.1.0)
5
5
  activesupport (~> 5.0)
6
6
  rainbow (~> 3.0.0)
7
7
  strong_json (~> 0.5.0)
@@ -9,20 +9,20 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (5.1.4)
12
+ activesupport (5.2.0)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (~> 0.7)
14
+ i18n (>= 0.7, < 2)
15
15
  minitest (~> 5.1)
16
16
  tzinfo (~> 1.1)
17
17
  concurrent-ruby (1.0.5)
18
- i18n (0.9.1)
18
+ i18n (1.0.1)
19
19
  concurrent-ruby (~> 1.0)
20
20
  minitest (5.10.3)
21
21
  rainbow (3.0.0)
22
22
  rake (10.5.0)
23
23
  strong_json (0.5.0)
24
24
  thread_safe (0.3.6)
25
- tzinfo (1.2.4)
25
+ tzinfo (1.2.5)
26
26
  thread_safe (~> 0.1)
27
27
 
28
28
  PLATFORMS
data/README.md CHANGED
@@ -20,6 +20,8 @@ $ gem install goodcheck
20
20
 
21
21
  Or you can use `bundler`!
22
22
 
23
+ If you would not like to install Goodcheck to system (e.g. you would not like to install Ruby 2.4 or higher), you can use a docker image. [See below](#docker-image).
24
+
23
25
  ## Quickstart
24
26
 
25
27
  ```bash
@@ -42,7 +44,7 @@ rules:
42
44
  pattern: Github
43
45
  message: |
44
46
  GitHub is GitHub, not Github
45
-
47
+
46
48
  You may misspelling the name of the service!
47
49
  justifications:
48
50
  - When you mean a service different from GitHub
@@ -72,7 +74,7 @@ A *pattern* can be a *literal pattern*, *regexp pattern*, *token pattern*, or a
72
74
  When a string is given, it is interpreted as a *literal pattern* with `case_insensitive: false`.
73
75
 
74
76
  #### *literal pattern*
75
-
77
+
76
78
  *literal pattern* allows you to construct a regexp which matches exactly to the `literal` string.
77
79
 
78
80
  ```yaml
@@ -102,7 +104,7 @@ justification:
102
104
  ```
103
105
 
104
106
  It accepts two optional attributes, `case_insensitive` and `multiline`.
105
- The default value of `case_insensitive` and `multiline` are `true` and `false` correspondingly.
107
+ The default values of `case_insensitive` and `multiline` are `false`.
106
108
 
107
109
  The regexp will be passed to `Regexp.compile`.
108
110
  The precise definition of regular expression can be found in the documentation for Ruby.
@@ -115,7 +117,8 @@ The precise definition of regular expression can be found in the documentation f
115
117
  id: com.sample.no-blink
116
118
  pattern:
117
119
  token: "<blink"
118
- message: Stop using <blink> tag
120
+ case_insensitive: true
121
+ message: Stop using <blink> tag
119
122
  glob: "**/*.html"
120
123
  justifications:
121
124
  - If Lynx is the major target of the web site
@@ -128,6 +131,9 @@ In that case, try using *regexp pattern*.
128
131
  The generated regexp of `<blink` is `<\s*blink\b`.
129
132
  It matches with `<blink />` and `< BLINK>`, but does not match with `https://www.chromium.org/blink`.
130
133
 
134
+ It accepts one optional attribute, `case_insensitive`.
135
+ The default value of `case_insensitive` is `false`.
136
+
131
137
  ### *glob*
132
138
 
133
139
  A *glob* can be a string, or a hash.
@@ -189,6 +195,19 @@ Available options is:
189
195
 
190
196
  * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
191
197
 
198
+ ## Docker image
199
+
200
+ You can use a docker image to use Goodcheck.
201
+
202
+ ```bash
203
+ $ git clone https://github.com/sideci/goodcheck
204
+ $ cd goodcheck
205
+ $ docker build -t goodcheck:latest .
206
+
207
+ $ cd /path/to/your/project
208
+ $ docker run -it --rm -v "$(pwd):/work" goodcheck:latest goodcheck check
209
+ ```
210
+
192
211
  ## Development
193
212
 
194
213
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
@@ -8,3 +8,9 @@ Rake::TestTask.new(:test) do |t|
8
8
  end
9
9
 
10
10
  task :default => :test
11
+
12
+ namespace :docker do
13
+ task :build do
14
+ sh 'docker', 'build', '-t', 'goodcheck:latest', '.'
15
+ end
16
+ end
@@ -13,7 +13,7 @@ module Goodcheck
13
13
  if rule.globs.empty?
14
14
  [rule, nil]
15
15
  else
16
- glob = rule.globs.find {|glob| path.fnmatch?(glob.pattern, File::FNM_PATHNAME) }
16
+ glob = rule.globs.find {|glob| path.fnmatch?(glob.pattern, File::FNM_PATHNAME | File::FNM_EXTGLOB) }
17
17
  if glob
18
18
  [rule, glob]
19
19
  end
@@ -7,7 +7,7 @@ module Goodcheck
7
7
  Schema = StrongJSON.new do
8
8
  let :regexp_pattern, object(regexp: string, case_insensitive: boolean?, multiline: boolean?)
9
9
  let :literal_pattern, object(literal: string, case_insensitive: boolean?)
10
- let :token_pattern, object(token: string)
10
+ let :token_pattern, object(token: string, case_insensitive: boolean?)
11
11
  let :pattern, enum(regexp_pattern, literal_pattern, token_pattern, string)
12
12
 
13
13
  let :encoding, enum(*Encoding.name_list.map {|name| literal(name) })
@@ -82,7 +82,8 @@ module Goodcheck
82
82
  Pattern.regexp(regexp, case_insensitive: ci, multiline: multiline)
83
83
  when pattern[:token]
84
84
  tok = pattern[:token]
85
- Pattern.token(tok)
85
+ ci = pattern[:case_insensitive]
86
+ Pattern.token(tok, case_insensitive: ci)
86
87
  end
87
88
  end
88
89
  end
@@ -20,11 +20,11 @@ module Goodcheck
20
20
  new(source: regexp, regexp: Regexp.compile(regexp, options))
21
21
  end
22
22
 
23
- def self.token(tokens)
24
- new(source: tokens, regexp: compile_tokens(tokens))
23
+ def self.token(tokens, case_insensitive:)
24
+ new(source: tokens, regexp: compile_tokens(tokens, case_insensitive: case_insensitive))
25
25
  end
26
26
 
27
- def self.compile_tokens(source)
27
+ def self.compile_tokens(source, case_insensitive:)
28
28
  tokens = []
29
29
  s = StringScanner.new(source)
30
30
 
@@ -51,7 +51,10 @@ module Goodcheck
51
51
  tokens.last << '\b'
52
52
  end
53
53
 
54
- Regexp.new(tokens.join('\s*').gsub(/\\s\*(\\s\+\\s\*)+/, '\s+'), Regexp::MULTILINE)
54
+ options = Regexp::MULTILINE
55
+ options |= Regexp::IGNORECASE if case_insensitive
56
+
57
+ Regexp.new(tokens.join('\s*').gsub(/\\s\*(\\s\+\\s\*)+/, '\s+'), options)
55
58
  end
56
59
  end
57
60
  end
@@ -1,3 +1,3 @@
1
1
  module Goodcheck
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-22 00:00:00.000000000 Z
11
+ date: 2018-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,6 +105,7 @@ files:
105
105
  - ".gitignore"
106
106
  - ".travis.yml"
107
107
  - CHANGELOG.md
108
+ - Dockerfile
108
109
  - Gemfile
109
110
  - Gemfile.lock
110
111
  - LICENSE