flickwerk 0.3.1 → 0.3.3

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: a3f767550c0a11caaa3f1fd9d2ceb95cebc12ed22d7b0a0f90891127364f2843
4
- data.tar.gz: 83d91c33bffa4f7f2a66ad22fe19c0e55a768ee0f88db1d6e03aec423e844740
3
+ metadata.gz: 3408516d5382df979190373fd3acb47eb26e91e6b52e9f9e770887a9e5c08382
4
+ data.tar.gz: d04f410971901f342e3baaffa3549eacefe03da60088babe2c9f7cb6cc85dc50
5
5
  SHA512:
6
- metadata.gz: 75ff28c2a648734224cf853f91bd27c2349c8fe57d6ac0d7637977ed55a13cb14fcee781cd15757d1c8a851d654c7cceadb849f03702fd713099ddf26e4b5edc
7
- data.tar.gz: '00192ccc657c51c20aab77b476dde7d0c2344ae03d0dadbc87697fa5f91691c7350dda66071ea373d40df00da53b42239035bf7d63177abff5716e04d21abb44'
6
+ metadata.gz: 9666d78b3dfb945fb959ad14ed966e9e7bca57f62a682c1f5cfae811a70fc0a30d1dcebfb841e0693dfceb90b31e92e13574a9ddad0615220f0245334b716f23
7
+ data.tar.gz: 4e62dc30ebe97aa88e0a6f3e5cda2d4b7b27342ff093196807e6d1ba74c2285bd11ec87c0f407d60cf0f51e83693cffacf909c92d7b6e52ef72d5e7ab83d2dbe
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)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "flickwerk/patch_finder"
4
4
  require "flickwerk/patch_loader"
5
+ require "rails/railtie"
5
6
 
6
7
  class Flickwerk::Railtie < Rails::Railtie
7
8
  initializer "flickwerk.add_paths", before: :set_autoload_paths do |app|
@@ -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.3"
5
5
  end
data/lib/flickwerk.rb CHANGED
@@ -13,7 +13,7 @@ module Flickwerk
13
13
 
14
14
  def self.included(engine)
15
15
  engine.root.glob("app/patches/*").each do |path|
16
- engine.patch_paths << path
16
+ Flickwerk.patch_paths << path
17
17
  end
18
18
  end
19
19
 
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.3
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-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties