flickwerk 0.3.1 → 0.3.2

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: a3f767550c0a11caaa3f1fd9d2ceb95cebc12ed22d7b0a0f90891127364f2843
4
- data.tar.gz: 83d91c33bffa4f7f2a66ad22fe19c0e55a768ee0f88db1d6e03aec423e844740
3
+ metadata.gz: 345f0a2e87adf7c5b68542723b564d9cd84de0991a7c52f100ed20cf3cf712e0
4
+ data.tar.gz: 31d4905e5d5b9ca8f5bd967d07a66ace54b1b963a12d619462cfa34cc8732fa6
5
5
  SHA512:
6
- metadata.gz: 75ff28c2a648734224cf853f91bd27c2349c8fe57d6ac0d7637977ed55a13cb14fcee781cd15757d1c8a851d654c7cceadb849f03702fd713099ddf26e4b5edc
7
- data.tar.gz: '00192ccc657c51c20aab77b476dde7d0c2344ae03d0dadbc87697fa5f91691c7350dda66071ea373d40df00da53b42239035bf7d63177abff5716e04d21abb44'
6
+ metadata.gz: f066e5ec937af4c9544928f38dd17454ecbb396c594096087e66271f6d985ac84622296be5261e2fb86ca519ee062cda7ec8b77b90b49cc2060f7439bfb614c6
7
+ data.tar.gz: 7813581a4e322803963a25e9af118101b0b72dbed06e8a19b66d9675307b7e23d4e3f4f0e5b438dd1beb80aafeef095446288c34dde747c18794ce4acd5441aa
data/README.md CHANGED
@@ -190,7 +190,13 @@ Flickwerk will now move your decorators and rename them.
190
190
  If your patches currently live in `app/overrides`, use an argument:
191
191
 
192
192
  ```sh
193
- bundle exec flickwerk patchify overrides
193
+ bundle exec flickwerk patchify app/overrides
194
+ ```
195
+
196
+ If you have patches in `lib`, they can be moved to `lib/patches`:
197
+
198
+ ```sh
199
+ bundle exec flickwerk patchify lib/decorators lib/patches
194
200
  ```
195
201
 
196
202
  Now, run your tests and make sure your patches comply with Flickwerk's requirements.
data/exe/flickwerk CHANGED
@@ -7,7 +7,7 @@ require "flickwerk/patchify"
7
7
 
8
8
  case ARGV[0]
9
9
  when "patchify"
10
- Flickwerk::Patchify.call(ARGV[1])
10
+ Flickwerk::Patchify.call(decorator_dir: ARGV[1] || "app/decorators", patches_dir: ARGV[2] || "app/patches")
11
11
  else
12
12
  raise ArgumentError, "Unknown command #{ARGV[0]}. Please use `patchify`."
13
13
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Flickwerk
4
4
  class PatchFinder
5
- DECORATED_CLASS_PATTERN = /(?:::)?(?<decorated_class>[\w.:]+)\.prepend[\s(]/
5
+ DECORATED_CLASS_PATTERN = /(?:::)?(?<decorated_class>[\w.:]+?)(?:\.singleton_class)?\.prepend[\s(]/
6
6
 
7
7
  attr_reader :path, :autoloader
8
8
 
@@ -1,20 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support"
3
4
  require "active_support/core_ext/string"
4
5
 
5
6
  module Flickwerk
6
7
  class Patchify
7
- PATCHES_DIR = "app/patches"
8
- def self.call(directory_name)
9
- directory_name ||= "decorators"
10
- source_dir = "app/#{directory_name}"
8
+ def self.call(decorator_dir:, patches_dir:)
9
+ directory_name = decorator_dir.split("/").last
11
10
  suffix = directory_name.singularize
12
11
  constant = suffix.camelize
13
12
 
14
- Dir.glob("#{source_dir}/**/*_#{suffix}.rb").each do |file|
15
- relative_path = file.sub(/^#{source_dir}\//, "")
13
+ Dir.glob("#{decorator_dir}/**/*_#{suffix}.rb").each do |file|
14
+ relative_path = file.sub(/^#{decorator_dir}\//, "")
16
15
  target_file = relative_path.sub("_#{suffix}.rb", "_patch.rb")
17
- target_path = File.join(PATCHES_DIR, File.dirname(relative_path))
16
+ target_path = File.join(patches_dir, File.dirname(relative_path))
18
17
 
19
18
  # Create target directory if it doesn't exist
20
19
  FileUtils.mkdir_p(target_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flickwerk
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
11
+ date: 2025-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties