js_image_paths 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/js_image_paths/engine.rb +5 -8
- data/lib/js_image_paths/generator.rb +9 -3
- data/lib/js_image_paths/processor.rb +9 -0
- data/lib/js_image_paths/version.rb +1 -1
- data/lib/js_image_paths.rb +1 -0
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e89d20741cc0ba9cc98f9ec2397a512b4a32b61d6da9cadfbb686824e25fb0d
|
4
|
+
data.tar.gz: ed2a68684921b4bbc15d6455d0bf81ff5b09533bb9d16335c035a45fa8560382
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c75e5816064f839ce3d6b69d5e61b3836a17ba3182238aff85cf23b7789253c90f60dd829d25a8c8f4c90327f826fc911bdea6edf34acda588247091d9574584
|
7
|
+
data.tar.gz: e7b5f31979eb7f7fda17738bcd82a833cf4d029c7fc79bfbee6371e85e6828415074e09de614c0e00cbccce5db4d7388d5129b39eebbb3cb334c804e76e9abe2
|
@@ -3,15 +3,12 @@ module JsImagePaths
|
|
3
3
|
|
4
4
|
isolate_namespace(JsImagePaths)
|
5
5
|
|
6
|
-
initializer('js_image_paths.compile', after:
|
6
|
+
initializer('js_image_paths.compile', after: :engines_blank_point, before: :finisher_hook) do |application|
|
7
|
+
file_type = 'application/javascript'
|
8
|
+
file_type += '+ruby' if Gem::Version.new(::Sprockets::VERSION).segments[0] >= 4
|
9
|
+
|
7
10
|
sprockets_env = application.assets || Sprockets
|
8
|
-
sprockets_env.register_preprocessor(
|
9
|
-
context = input[:environment].context_class.new(input)
|
10
|
-
if context.logical_path == 'js_image_paths'
|
11
|
-
JsImagePaths::Generator.context = context
|
12
|
-
end
|
13
|
-
{data: input[:data]}
|
14
|
-
end
|
11
|
+
sprockets_env.register_preprocessor(file_type, JsImagePaths::Processor)
|
15
12
|
end
|
16
13
|
end
|
17
14
|
end
|
@@ -7,10 +7,16 @@ module JsImagePaths
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.image_hash
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
context.environment.each_file.each_with_object({}) do |path, images|
|
11
|
+
next unless path.start_with?(app_images_path)
|
12
|
+
|
13
|
+
asset = context.environment.find_asset(path)
|
14
|
+
images[asset.logical_path] = context.asset_path(asset.logical_path)
|
13
15
|
end
|
14
16
|
end
|
17
|
+
|
18
|
+
def self.app_images_path
|
19
|
+
@app_images_path ||= Rails.root.join('app/assets/images').to_s
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
data/lib/js_image_paths.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_image_paths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonne Haß
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: sprockets
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,30 +48,30 @@ dependencies:
|
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rake
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '0'
|
75
75
|
description: Easily access your image assets in your JavaScript code
|
76
76
|
email:
|
77
77
|
- me@jhass.eu
|
@@ -84,12 +84,13 @@ files:
|
|
84
84
|
- lib/js_image_paths.rb
|
85
85
|
- lib/js_image_paths/engine.rb
|
86
86
|
- lib/js_image_paths/generator.rb
|
87
|
+
- lib/js_image_paths/processor.rb
|
87
88
|
- lib/js_image_paths/version.rb
|
88
89
|
homepage: https://github.com/jhass/js_image_paths
|
89
90
|
licenses:
|
90
91
|
- MIT
|
91
92
|
metadata: {}
|
92
|
-
post_install_message:
|
93
|
+
post_install_message:
|
93
94
|
rdoc_options: []
|
94
95
|
require_paths:
|
95
96
|
- lib
|
@@ -104,9 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
105
|
- !ruby/object:Gem::Version
|
105
106
|
version: '0'
|
106
107
|
requirements: []
|
107
|
-
|
108
|
-
|
109
|
-
signing_key:
|
108
|
+
rubygems_version: 3.3.15
|
109
|
+
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Rails image paths in your JS
|
112
112
|
test_files: []
|