chusaku 1.3.0 → 1.4.0

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
  SHA256:
3
- metadata.gz: 48034ba3796c8cd1ab1a16b0db1065dcdf487ea5e6bc1b08a7fcd18db4ad1d33
4
- data.tar.gz: 65cf7dbbf5571f547aeb9cefc8cd804ccab9467b0765edcc00691c777c158554
3
+ metadata.gz: 6d38e9cae0023a682add1a559ef4c40e469247f55ef578b67fc190d81b35e824
4
+ data.tar.gz: d70d7f1d4aa61451fff49dd99ee1358c375db963db45728f08784827b7f6bfa1
5
5
  SHA512:
6
- metadata.gz: 83c00966e23c6d8a63f9b68e35cc48a975689f21473e83344927764ac200d9eb378274c6ad82fa90a0ac6a06d286763f45661f4b2433983f903cf93371158167
7
- data.tar.gz: 70afe36985465e34f3fa18e5eea3d51d130daaada6414a51b680a0e4f32f31e14a3e3225f8f70b594d19d8c23e9ad3b00ac9f43c4dd83c493bdd5befba483e8a
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/bin/chusaku CHANGED
@@ -1,18 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "rubygems"
4
+ require "bundler"
4
5
 
5
- begin
6
- # Use project's bundle.
7
- require "bundler"
8
- Bundler.setup
6
+ Bundler.setup
9
7
 
10
- # Use project's environment.
11
- require "rake"
12
- load "./Rakefile"
13
- Rake::Task[:environment].invoke
14
- rescue
15
- end
8
+ # Use project's environment.
9
+ require "rake"
10
+ load "./Rakefile"
11
+ Rake::Task[:environment].invoke
16
12
 
17
13
  require "chusaku/cli"
18
14
 
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.0"
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.0
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-05 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