flickwerk 0.3.0 → 0.3.2

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: a2282cc97b8ee8bb05493ba03cf1ed27690fdffacf62bb8ff203b6db3bf6c36c
4
- data.tar.gz: 943a5ae6ec43be5b7139ba5b578335339564cb0ab832a0038250a58e005e46cc
3
+ metadata.gz: 345f0a2e87adf7c5b68542723b564d9cd84de0991a7c52f100ed20cf3cf712e0
4
+ data.tar.gz: 31d4905e5d5b9ca8f5bd967d07a66ace54b1b963a12d619462cfa34cc8732fa6
5
5
  SHA512:
6
- metadata.gz: 7a93c5ffc75887ee60dde2635995ac097b70fe6b068106be82a173106eeb9c8d122e38053f9e42880940434fde943adf6b2bc02fab3965da252819c1880f2a89
7
- data.tar.gz: 28891d06643e9cc430a5b793704abe65baa14825af3bf49a52bcc07fa9e4c32bcdce56a97e0b8f16f70ce3b125c9dcf3efaf64d09b8e0cf21e44b18191b3cc5b
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)
@@ -11,7 +11,7 @@ class Flickwerk::Railtie < Rails::Railtie
11
11
  end
12
12
 
13
13
  initializer "flickwerk.find_patches" do |app|
14
- app.config.to_prepare do
14
+ app.reloader.to_prepare do
15
15
  Flickwerk.patch_paths.each do |path|
16
16
  Flickwerk::PatchFinder.new(path).call
17
17
  end
@@ -19,7 +19,7 @@ class Flickwerk::Railtie < Rails::Railtie
19
19
  end
20
20
 
21
21
  initializer "flickwerk.add_patches", after: "flickwerk.find_patches" do |app|
22
- app.config.to_prepare do
22
+ app.reloader.to_prepare do
23
23
  Flickwerk::PatchLoader.call
24
24
  end
25
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flickwerk
4
- VERSION = "0.3.0"
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.0
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