yiffspace-core 0.2.0 → 0.2.1

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: 616274421a5c76dd24f3280528dba48846a7d8ffdbf2b6b77a8a9bc6ba243f5e
4
- data.tar.gz: 49ef59c885784dc479dcc475a4bf55e24bf208a53e9a4288354a68072b2cfd1b
3
+ metadata.gz: d9e70befbca65b0155e1a317149268f3c4b88812312e6c382c331d306b04816e
4
+ data.tar.gz: 2bf60d4c568ac65d5dc97a6699b6f5d4e94a9066d9d4d7f3bd5808a3481b03d6
5
5
  SHA512:
6
- metadata.gz: ae0ca898066aeb4781fc565f168189a42601476610b234bdf3fb3431a97dc275e2163a19db67fff2b10718b549bead50a715bcd721635f461d11028ae8b931d4
7
- data.tar.gz: 7b358ed2a0c766ded8b197596eb768bcdfdc062d1f523f19bb271eda4259f484ce2aeaa7c48192600b1c11d44b91136772eae108a3a9ca594bb445305d475b70
6
+ metadata.gz: 86cc77b00d1b2308afddd100d3cc20ad8194669bb0e030ea2e44763e798c703560b321a58162b4acd09d5502777fde4283f57e981d5dcc7662dd5932037c8a77
7
+ data.tar.gz: a77cb9429d123a90b4d290934a453d55790c2978c50a03cdacb4804eb70dddfb6afd05ba9e38cb404b250f0b848e03dda36190044b81af697e5c6a28017906b6
data/CHANGELOG.md CHANGED
@@ -32,6 +32,18 @@
32
32
  - The dummy test app no longer needs Postgres - only the fixes table's
33
33
  `nulls_not_distinct` index required it, and that lives in `yiffspace-fixers`
34
34
  now. Back to plain sqlite3, `docker-compose.yml` removed.
35
+ - Fixed `YiffSpace::Utils::Helpers`/`Routes` (`Helpers`/`Routes` under
36
+ `yiffspace-include`) dropping keyword arguments: their `method_missing` used
37
+ a bare `*, &` splat, which isn't `ruby2_keywords`-aware, so a call like
38
+ `h.some_helper(post, tags: tags)` arrived with the `tags:` hash flattened
39
+ into a positional argument instead of a keyword - silently landing in
40
+ whatever parameter came next rather than raising. Both now use `...` to
41
+ forward positional, keyword, and block arguments correctly.
42
+ - `YiffSpace::Utils::Helpers` (`Helpers`) now also makes the app's route
43
+ `_path`/`_url` helpers available *inside* the helper methods it proxies to,
44
+ not just to callers going through it directly - a helper that itself calls
45
+ `some_path(...)` (with no receiver) now works the same way it would from a
46
+ real view, instead of raising `NoMethodError`.
35
47
 
36
48
  ## 0.1.0
37
49
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YiffSpace
4
4
  module Core
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -10,16 +10,40 @@ module YiffSpace
10
10
  # `h.some_helper`), including ones marked private in their helper module - private only
11
11
  # restricts calling with an explicit receiver, and normal view rendering (which invokes
12
12
  # helpers without one) isn't affected either way.
13
- def method_missing(name, *, &)
14
- helpers = YiffSpace.config.application_controller_class.helpers
15
- return helpers.send(name, *, &) if helpers.respond_to?(name, true)
13
+ def method_missing(name, ...)
14
+ helpers = target
15
+ return helpers.send(name, ...) if helpers.respond_to?(name, true)
16
16
 
17
17
  super
18
18
  end
19
19
 
20
20
  def respond_to_missing?(name, include_private = false)
21
- YiffSpace.config.application_controller_class.helpers.respond_to?(name, true) || super
21
+ target.respond_to?(name, true) || super
22
+ end
23
+
24
+ # ApplicationController.helpers behaves like a view for registered helper modules, but
25
+ # (unlike an actual view) doesn't include the app's route url_helpers - so a helper method
26
+ # invoked through this proxy couldn't call `some_path`/`some_url` itself. Extend the shared
27
+ # proxy once so route helpers are available from inside helper methods too, not just to
28
+ # callers going through this module directly.
29
+ #
30
+ # `extend`ing the generated url_helpers module only grants the path/url helper methods
31
+ # themselves - they're written to call `url_options`/`_routes`/`optimize_routes_generation?`
32
+ # on whatever they're called on, and the module only defines those three on its own
33
+ # singleton class (so it works standalone), not as instance methods `extend` would carry
34
+ # over. Delegate them by hand so the extended methods have what they need to run.
35
+ def target
36
+ helpers = YiffSpace.config.application_controller_class.helpers
37
+ url_helpers = Rails.application.routes.url_helpers
38
+ unless helpers.is_a?(url_helpers)
39
+ helpers.define_singleton_method(:url_options) { url_helpers.url_options }
40
+ helpers.define_singleton_method(:_routes) { url_helpers._routes }
41
+ helpers.define_singleton_method(:optimize_routes_generation?) { url_helpers.optimize_routes_generation? }
42
+ helpers.extend(url_helpers)
43
+ end
44
+ helpers
22
45
  end
46
+ private_class_method(:target)
23
47
  end
24
48
  end
25
49
  end
@@ -13,9 +13,9 @@ module YiffSpace
13
13
  module Routes
14
14
  module_function
15
15
 
16
- def method_missing(name, *, &)
16
+ def method_missing(name, ...)
17
17
  url_helpers = Rails.application.routes.url_helpers
18
- return url_helpers.public_send(name, *, &) if url_helpers.respond_to?(name)
18
+ return url_helpers.public_send(name, ...) if url_helpers.respond_to?(name)
19
19
 
20
20
  super
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yiffspace-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan_DMC