goodcheck 2.4.4 → 2.6.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -2
  3. data/README.md +107 -50
  4. data/lib/goodcheck.rb +4 -3
  5. data/lib/goodcheck/buffer.rb +44 -1
  6. data/lib/goodcheck/cli.rb +78 -54
  7. data/lib/goodcheck/commands/check.rb +20 -1
  8. data/lib/goodcheck/commands/config_loading.rb +19 -2
  9. data/lib/goodcheck/commands/init.rb +4 -2
  10. data/lib/goodcheck/commands/pattern.rb +2 -1
  11. data/lib/goodcheck/commands/test.rb +5 -4
  12. data/lib/goodcheck/config_loader.rb +6 -5
  13. data/lib/goodcheck/error.rb +3 -0
  14. data/lib/goodcheck/exit_status.rb +6 -0
  15. data/lib/goodcheck/glob.rb +14 -3
  16. data/lib/goodcheck/import_loader.rb +42 -10
  17. data/lib/goodcheck/version.rb +1 -1
  18. metadata +8 -70
  19. data/.gitignore +0 -13
  20. data/.rubocop.yml +0 -5
  21. data/.travis.yml +0 -11
  22. data/Dockerfile +0 -13
  23. data/Gemfile +0 -6
  24. data/Rakefile +0 -50
  25. data/bin/console +0 -14
  26. data/bin/setup +0 -8
  27. data/cheatsheet.pdf +0 -0
  28. data/docusaurus/.dockerignore +0 -2
  29. data/docusaurus/.gitignore +0 -12
  30. data/docusaurus/Dockerfile +0 -10
  31. data/docusaurus/docker-compose.yml +0 -18
  32. data/docusaurus/docs/commands.md +0 -69
  33. data/docusaurus/docs/configuration.md +0 -300
  34. data/docusaurus/docs/development.md +0 -15
  35. data/docusaurus/docs/getstarted.md +0 -46
  36. data/docusaurus/docs/rules.md +0 -79
  37. data/docusaurus/website/README.md +0 -193
  38. data/docusaurus/website/core/Footer.js +0 -100
  39. data/docusaurus/website/package.json +0 -14
  40. data/docusaurus/website/pages/en/index.js +0 -207
  41. data/docusaurus/website/pages/en/versions.js +0 -118
  42. data/docusaurus/website/sidebars.json +0 -11
  43. data/docusaurus/website/siteConfig.js +0 -171
  44. data/docusaurus/website/static/css/code-block-buttons.css +0 -39
  45. data/docusaurus/website/static/css/custom.css +0 -245
  46. data/docusaurus/website/static/img/favicon.ico +0 -0
  47. data/docusaurus/website/static/js/code-block-buttons.js +0 -47
  48. data/docusaurus/website/versioned_docs/version-1.0.0/commands.md +0 -70
  49. data/docusaurus/website/versioned_docs/version-1.0.0/configuration.md +0 -296
  50. data/docusaurus/website/versioned_docs/version-1.0.0/development.md +0 -16
  51. data/docusaurus/website/versioned_docs/version-1.0.0/getstarted.md +0 -47
  52. data/docusaurus/website/versioned_docs/version-1.0.0/rules.md +0 -81
  53. data/docusaurus/website/versioned_docs/version-1.0.2/rules.md +0 -79
  54. data/docusaurus/website/versioned_docs/version-2.4.0/configuration.md +0 -301
  55. data/docusaurus/website/versioned_docs/version-2.4.3/rules.md +0 -80
  56. data/docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  57. data/docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json +0 -11
  58. data/docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json +0 -11
  59. data/docusaurus/website/versions.json +0 -8
  60. data/docusaurus/website/yarn.lock +0 -6844
  61. data/goodcheck.gemspec +0 -36
  62. data/goodcheck.yml +0 -10
  63. data/logo/GoodCheck Horizontal.pdf +0 -899
  64. data/logo/GoodCheck Horizontal.png +0 -0
  65. data/logo/GoodCheck Horizontal.svg +0 -55
  66. data/logo/GoodCheck logo.png +0 -0
  67. data/logo/GoodCheck vertical.png +0 -0
  68. data/sample.yml +0 -57
@@ -1,13 +1,23 @@
1
1
  module Goodcheck
2
2
  class ImportLoader
3
- class UnexpectedSchemaError < StandardError
3
+ class UnexpectedSchemaError < Error
4
4
  attr_reader :uri
5
5
 
6
6
  def initialize(uri)
7
+ super("Unexpected URI schema: #{uri.scheme}")
7
8
  @uri = uri
8
9
  end
9
10
  end
10
11
 
12
+ class FileNotFound < Error
13
+ attr_reader :path
14
+
15
+ def initialize(path)
16
+ super("No such a file: #{path}")
17
+ @path = path
18
+ end
19
+ end
20
+
11
21
  attr_reader :cache_path
12
22
  attr_reader :expires_in
13
23
  attr_reader :force_download
@@ -24,20 +34,26 @@ module Goodcheck
24
34
  uri = URI.parse(name)
25
35
 
26
36
  case uri.scheme
27
- when nil, "file"
28
- load_file uri, &block
37
+ when nil
38
+ load_file name, &block
39
+ when "file"
40
+ load_file uri.path, &block
29
41
  when "http", "https"
30
42
  load_http uri, &block
31
43
  else
32
- raise UnexpectedSchemaError.new("Unexpected URI schema: #{uri.class.name}")
44
+ raise UnexpectedSchemaError.new(uri)
33
45
  end
34
46
  end
35
47
 
36
- def load_file(uri)
37
- path = (config_path.parent + uri.path)
38
-
39
- begin
40
- yield path.read
48
+ def load_file(path)
49
+ files = Dir.glob(File.join(config_path.parent.to_path, path), File::FNM_DOTMATCH | File::FNM_EXTGLOB).sort
50
+ if files.empty?
51
+ raise FileNotFound.new(path)
52
+ else
53
+ files.each do |file|
54
+ Goodcheck.logger.info "Reading file: #{file}"
55
+ yield File.read(file)
56
+ end
41
57
  end
42
58
  end
43
59
 
@@ -71,7 +87,7 @@ module Goodcheck
71
87
  if download
72
88
  path.rmtree if path.exist?
73
89
  Goodcheck.logger.info "Downloading content..."
74
- content = HTTPClient.new.get_content(uri)
90
+ content = http_get uri
75
91
  Goodcheck.logger.debug "Downloaded content: #{content[0, 1024].inspect}#{content.size > 1024 ? "..." : ""}"
76
92
  yield content
77
93
  write_cache uri, content
@@ -85,5 +101,21 @@ module Goodcheck
85
101
  path = cache_path + cache_name(uri)
86
102
  path.write(content)
87
103
  end
104
+
105
+ # @see https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html#class-Net::HTTP-label-Following+Redirection
106
+ def http_get(uri, limit = 10)
107
+ raise ArgumentError, "Too many HTTP redirects" if limit == 0
108
+
109
+ res = Net::HTTP.get_response URI(uri)
110
+ case res
111
+ when Net::HTTPSuccess
112
+ res.body
113
+ when Net::HTTPRedirection
114
+ location = res['Location']
115
+ http_get location, limit - 1
116
+ else
117
+ raise "Error: HTTP GET #{uri.inspect} #{res.inspect}"
118
+ end
119
+ end
88
120
  end
89
121
  end
@@ -1,3 +1,3 @@
1
1
  module Goodcheck
2
- VERSION = "2.4.4"
2
+ VERSION = "2.6.0".freeze
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: 2.4.4
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2020-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,20 +120,6 @@ dependencies:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
122
  version: 3.0.0
123
- - !ruby/object:Gem::Dependency
124
- name: httpclient
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: 2.8.3
130
- type: :runtime
131
- prerelease: false
132
- version_requirements: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: 2.8.3
137
123
  - !ruby/object:Gem::Dependency
138
124
  name: psych
139
125
  requirement: !ruby/object:Gem::Requirement
@@ -162,54 +148,10 @@ executables:
162
148
  extensions: []
163
149
  extra_rdoc_files: []
164
150
  files:
165
- - ".gitignore"
166
- - ".rubocop.yml"
167
- - ".travis.yml"
168
151
  - CHANGELOG.md
169
- - Dockerfile
170
- - Gemfile
171
152
  - LICENSE
172
153
  - README.md
173
- - Rakefile
174
- - bin/console
175
- - bin/setup
176
- - cheatsheet.pdf
177
- - docusaurus/.dockerignore
178
- - docusaurus/.gitignore
179
- - docusaurus/Dockerfile
180
- - docusaurus/docker-compose.yml
181
- - docusaurus/docs/commands.md
182
- - docusaurus/docs/configuration.md
183
- - docusaurus/docs/development.md
184
- - docusaurus/docs/getstarted.md
185
- - docusaurus/docs/rules.md
186
- - docusaurus/website/README.md
187
- - docusaurus/website/core/Footer.js
188
- - docusaurus/website/package.json
189
- - docusaurus/website/pages/en/index.js
190
- - docusaurus/website/pages/en/versions.js
191
- - docusaurus/website/sidebars.json
192
- - docusaurus/website/siteConfig.js
193
- - docusaurus/website/static/css/code-block-buttons.css
194
- - docusaurus/website/static/css/custom.css
195
- - docusaurus/website/static/img/favicon.ico
196
- - docusaurus/website/static/js/code-block-buttons.js
197
- - docusaurus/website/versioned_docs/version-1.0.0/commands.md
198
- - docusaurus/website/versioned_docs/version-1.0.0/configuration.md
199
- - docusaurus/website/versioned_docs/version-1.0.0/development.md
200
- - docusaurus/website/versioned_docs/version-1.0.0/getstarted.md
201
- - docusaurus/website/versioned_docs/version-1.0.0/rules.md
202
- - docusaurus/website/versioned_docs/version-1.0.2/rules.md
203
- - docusaurus/website/versioned_docs/version-2.4.0/configuration.md
204
- - docusaurus/website/versioned_docs/version-2.4.3/rules.md
205
- - docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json
206
- - docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json
207
- - docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json
208
- - docusaurus/website/versions.json
209
- - docusaurus/website/yarn.lock
210
154
  - exe/goodcheck
211
- - goodcheck.gemspec
212
- - goodcheck.yml
213
155
  - lib/goodcheck.rb
214
156
  - lib/goodcheck/analyzer.rb
215
157
  - lib/goodcheck/array_helper.rb
@@ -222,6 +164,8 @@ files:
222
164
  - lib/goodcheck/commands/test.rb
223
165
  - lib/goodcheck/config.rb
224
166
  - lib/goodcheck/config_loader.rb
167
+ - lib/goodcheck/error.rb
168
+ - lib/goodcheck/exit_status.rb
225
169
  - lib/goodcheck/glob.rb
226
170
  - lib/goodcheck/home_path.rb
227
171
  - lib/goodcheck/import_loader.rb
@@ -234,17 +178,11 @@ files:
234
178
  - lib/goodcheck/rule.rb
235
179
  - lib/goodcheck/trigger.rb
236
180
  - lib/goodcheck/version.rb
237
- - logo/GoodCheck Horizontal.pdf
238
- - logo/GoodCheck Horizontal.png
239
- - logo/GoodCheck Horizontal.svg
240
- - logo/GoodCheck logo.png
241
- - logo/GoodCheck vertical.png
242
- - sample.yml
243
181
  homepage: https://github.com/sider/goodcheck
244
182
  licenses:
245
183
  - MIT
246
184
  metadata: {}
247
- post_install_message:
185
+ post_install_message:
248
186
  rdoc_options: []
249
187
  require_paths:
250
188
  - lib
@@ -259,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
197
  - !ruby/object:Gem::Version
260
198
  version: '0'
261
199
  requirements: []
262
- rubygems_version: 3.0.3
263
- signing_key:
200
+ rubygems_version: 3.1.4
201
+ signing_key:
264
202
  specification_version: 4
265
203
  summary: Regexp based customizable linter
266
204
  test_files: []
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /vendor/bundle/
3
- /.yardoc
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /.idea
11
- /Gemfile.lock
12
- /.ruby-version
13
- .DS_Store
@@ -1,5 +0,0 @@
1
- # We don't use RuboCop.
2
- # If you really believe a Cop should be enabled, open pull requests for each Cop and explain why it matters.
3
-
4
- AllCops:
5
- DisabledByDefault: true
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.9
4
- - 2.5.7
5
- - 2.6.5
6
- script:
7
- - bundle exec rake
8
- - bundle exec rake docs:build
9
- branches:
10
- only:
11
- - master
data/Dockerfile DELETED
@@ -1,13 +0,0 @@
1
- FROM rubylang/ruby:2.6.3-bionic
2
-
3
- ENV DEBIAN_FRONTEND=noninteractive
4
-
5
- RUN mkdir /goodcheck
6
- WORKDIR /goodcheck
7
- COPY . /goodcheck/
8
- RUN rake install
9
-
10
- RUN mkdir /work
11
- WORKDIR /work
12
-
13
- ENTRYPOINT ["goodcheck"]
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in goodcheck.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,50 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task :default => :test
11
-
12
- namespace :docker do
13
- task :build do
14
- sh 'docker', 'build', '-t', 'sider/goodcheck:dev', '.'
15
- end
16
- end
17
-
18
- namespace :docs do
19
- desc "Install dependencies for the documentation website"
20
- task :install_deps do
21
- on_docs_dir do
22
- sh "yarn", "install"
23
- end
24
- end
25
-
26
- desc "Build the documentation website"
27
- task :build => [:install_deps] do
28
- on_docs_dir do
29
- sh "yarn", "run", "build"
30
- end
31
- end
32
-
33
- desc "Update the version of the documentation website"
34
- task :update_version => [:install_deps] do
35
- on_docs_dir do
36
- sh "yarn", "run", "version", Goodcheck::VERSION
37
- end
38
- end
39
-
40
- desc "Publish the documentation website"
41
- task :publish => [:build] do
42
- on_docs_dir do
43
- sh "yarn", "run", "publish-gh-pages"
44
- end
45
- end
46
-
47
- def on_docs_dir(&block)
48
- Dir.chdir "docusaurus/website", &block
49
- end
50
- end
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "goodcheck"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
Binary file
@@ -1,2 +0,0 @@
1
- */node_modules
2
- *.log
@@ -1,12 +0,0 @@
1
- .DS_Store
2
-
3
- node_modules
4
-
5
- lib/core/metadata.js
6
- lib/core/MetadataBlog.js
7
-
8
- website/translated_docs
9
- website/build/
10
- website/package-lock.json
11
- website/node_modules
12
- website/i18n/*
@@ -1,10 +0,0 @@
1
- FROM node:8.11.4
2
-
3
- WORKDIR /app/website
4
-
5
- EXPOSE 3000 35729
6
- COPY ./docs /app/docs
7
- COPY ./website /app/website
8
- RUN yarn install
9
-
10
- CMD ["yarn", "start"]
@@ -1,18 +0,0 @@
1
- version: "3"
2
-
3
- services:
4
- docusaurus:
5
- build: .
6
- ports:
7
- - 3000:3000
8
- - 35729:35729
9
- volumes:
10
- - ./docs:/app/docs
11
- - ./website/blog:/app/website/blog
12
- - ./website/core:/app/website/core
13
- - ./website/i18n:/app/website/i18n
14
- - ./website/pages:/app/website/pages
15
- - ./website/static:/app/website/static
16
- - ./website/sidebars.json:/app/website/sidebars.json
17
- - ./website/siteConfig.js:/app/website/siteConfig.js
18
- working_dir: /app/website
@@ -1,69 +0,0 @@
1
- ---
2
- id: commands
3
- title: Commands
4
- sidebar_label: Commands
5
- ---
6
-
7
-
8
- ## `goodcheck init [options]`
9
-
10
- The `init` command generates an example of a configuration file.
11
-
12
- Available options are:
13
-
14
- * `-c=[CONFIG]`, `--config=[CONFIG]` to specify the configuration file name to generate.
15
- * `--force` to allow overwriting of an existing config file.
16
-
17
- ## `goodcheck check [options] targets...`
18
-
19
- The `check` command checks your programs under `targets...`.
20
- You can pass:
21
-
22
- * Directory paths, or
23
- * Paths to files.
24
-
25
- When you omit `targets`, it checks all files in `.`.
26
-
27
- Available options are:
28
-
29
- * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
30
- * `-R [rule]`, `--rule=[rule]` to specify the rules you want to check.
31
- * `--format=[text|json]` to specify output format.
32
- * `-v`, `--verbose` to be verbose.
33
- * `--debug` to print all debug messages.
34
- * `--force` to ignore downloaded caches.
35
-
36
- `goodcheck check` exits with:
37
-
38
- * `0` when it does not find any matching text fragment.
39
- * `2` when it finds some matching text.
40
- * `1` when it finds some error.
41
-
42
- You can check its exit status to identify if the tool finds some pattern or not.
43
-
44
- ## `goodcheck test [options]`
45
-
46
- The `test` command tests rules.
47
- The test contains:
48
-
49
- * Validation of rule `id` uniqueness.
50
- * If `pass` examples does not match with any of `pattern`s.
51
- * If `fail` examples matches with some of `pattern`s.
52
-
53
- Use `test` command when you add a new rule to be sure you are writing rules correctly.
54
-
55
- Available options are:
56
-
57
- * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
58
- * `-v`, `--verbose` to be verbose.
59
- * `--debug` to print all debug messages.
60
- * `--force` to ignore downloaded caches
61
-
62
- ## `goodcheck pattern [options] ids...`
63
-
64
- The `pattern` command prints the regular expressions generated from the patterns.
65
- The command is for debugging patterns, especially token patterns.
66
-
67
- The available option is:
68
-
69
- * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.