chusaku 1.3.1 → 1.4.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
  SHA256:
3
- metadata.gz: 9fc7761a52fc52267ce095f244df85330fa5044b92d69ddaf3f2b409257f357b
4
- data.tar.gz: 4fd118b0690ae446de0ab98201ac2db5bb6d8589dc115b403c53469b20301b9f
3
+ metadata.gz: 6d38e9cae0023a682add1a559ef4c40e469247f55ef578b67fc190d81b35e824
4
+ data.tar.gz: d70d7f1d4aa61451fff49dd99ee1358c375db963db45728f08784827b7f6bfa1
5
5
  SHA512:
6
- metadata.gz: cd2f6047be4ab26822df52175958a9c920c7b8a68b6266f77930a976d4ff34f4aa65e011c0e18e5895f501614257b40dc1e240ad5a1996a21d677f6a9ca6cf7f
7
- data.tar.gz: 64f87d171ea0cbdedb5c2c09fc7daa7681291e98fe5f393eba17b731a1873f29036908c57d9597333b929abafbe00ced1c76019c61c853514a342053c7fc5817
6
+ metadata.gz: b4d2aab917c320e5b821d4e53386b65d5017347e089fe2e62099c94838af14b1824fcde11f2c13c2b97a3af4417764849337a4e577d400d49410ce88e74e34ba
7
+ data.tar.gz: 67fc92a8285bc86f0d46ff76da41ec425385d131a088be4f76d18892cfc80aeeea2cc8bbdda3cbc2bb458901788711427162a620d3f18f62c1664795b2bcf32b
data/README.md CHANGED
@@ -53,6 +53,7 @@ Usage: chusaku [options]
53
53
  --dry-run Run without file modifications
54
54
  --exit-with-error-on-annotation Fail if any file was annotated
55
55
  -c, --controllers-pattern=GLOB Specify alternative controller files glob pattern
56
+ -e, --exclusion-pattern=GLOB Specify controller files exclusion glob pattern
56
57
  --verbose Print all annotated files
57
58
  -v, --version Show Chusaku version number and quit
58
59
  -h, --help Show this help message and quit
data/lib/chusaku/cli.rb CHANGED
@@ -42,7 +42,7 @@ module Chusaku
42
42
  # @return [void]
43
43
  def check_for_rails_project
44
44
  controllers_pattern = options[:controllers_pattern] || DEFAULT_CONTROLLERS_PATTERN
45
- has_controllers = !Dir.glob(Rails.root.join(controllers_pattern)).empty?
45
+ has_controllers = FileList.new(Rails.root.join(controllers_pattern)).any?
46
46
  has_rakefile = File.exist?("./Rakefile")
47
47
  raise NotARailsProject unless has_controllers && has_rakefile
48
48
  end
@@ -57,6 +57,7 @@ module Chusaku
57
57
  add_dry_run_flag(opts)
58
58
  add_error_on_annotation_flag(opts)
59
59
  add_controllers_pattern_flag(opts)
60
+ add_exclusion_pattern_flag(opts)
60
61
  add_verbose_flag(opts)
61
62
  add_version_flag(opts)
62
63
  add_help_flag(opts)
@@ -93,6 +94,16 @@ module Chusaku
93
94
  end
94
95
  end
95
96
 
97
+ # Adds `--exclusion-pattern` flag.
98
+ #
99
+ # @param opts [OptionParser] OptionParser instance
100
+ # @return [void]
101
+ def add_exclusion_pattern_flag(opts)
102
+ opts.on("-e", "--exclusion-pattern", "=GLOB", "Specify controller files exclusion glob pattern") do |value|
103
+ @options[:exclusion_pattern] = value
104
+ end
105
+ end
106
+
96
107
  # Adds `--verbose` flag.
97
108
  #
98
109
  # @param opts [OptionParser] OptionParser instance
@@ -1,3 +1,3 @@
1
1
  module Chusaku
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
data/lib/chusaku.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "rake"
1
2
  require "chusaku/version"
2
3
  require "chusaku/parser"
3
4
  require "chusaku/routes"
@@ -5,6 +6,7 @@ require "chusaku/routes"
5
6
  # Handles core functionality of annotating projects.
6
7
  module Chusaku
7
8
  DEFAULT_CONTROLLERS_PATTERN = "**/*_controller.rb".freeze
9
+ DEFAULT_EXCLUSION_PATTERN = "vendor/**/*_controller.rb".freeze
8
10
 
9
11
  class << self
10
12
  # The main method to run Chusaku. Annotate all actions in a Rails project as
@@ -22,7 +24,10 @@ module Chusaku
22
24
  @routes = Chusaku::Routes.call
23
25
  @changed_files = []
24
26
  controllers_pattern = @flags[:controllers_pattern] || DEFAULT_CONTROLLERS_PATTERN
25
- controllers_paths = Dir.glob(Rails.root.join(controllers_pattern))
27
+ exclusion_pattern = @flags[:exclusion_pattern] || DEFAULT_EXCLUSION_PATTERN
28
+ controllers_paths = FileList
29
+ .new(Rails.root.join(controllers_pattern))
30
+ .exclude(Rails.root.join(exclusion_pattern))
26
31
 
27
32
  @routes.each do |controller, actions|
28
33
  next unless controller
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chusaku
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nishiki Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
11
+ date: 2024-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler