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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e384a62338e0a43069f2369249a0da90e03acf21
4
- data.tar.gz: 65e34baf0401ade3ebbeb29aaa80342272b0daa8
2
+ SHA256:
3
+ metadata.gz: 3e89d20741cc0ba9cc98f9ec2397a512b4a32b61d6da9cadfbb686824e25fb0d
4
+ data.tar.gz: ed2a68684921b4bbc15d6455d0bf81ff5b09533bb9d16335c035a45fa8560382
5
5
  SHA512:
6
- metadata.gz: 1dcfa176a01240559c565ed716afeeb31a185c04e720aef6b58be0cedbc274a3ca31883a93f9bfd4f0df4644a1add5632dda60fc97d06f43978d856c67a284e9
7
- data.tar.gz: 67606b3f6dc765bc127896eca5a713cfb37e97978fb0b225ee8a75b67f77f5f5bf23490f4ede9807abe414ebd5ac7a9f5f6773febda949c0ad5ab080e7497c7f
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: 'sprockets.environment') do |application|
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('application/javascript', :'js_image_path.compile') do |input|
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
- images = context.environment.each_logical_path(->(_, path) { path.include? "images" })
11
- images.each_with_object({}) do |path, images|
12
- images[path] = context.asset_path(path)
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
@@ -0,0 +1,9 @@
1
+ module JsImagePaths
2
+ module Processor
3
+ def self.call(input)
4
+ JsImagePaths::Generator.context = input[:environment].context_class.new(input) if input[:name] == 'js_image_paths'
5
+
6
+ {data: input[:data]}
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module JsImagePaths
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "js_image_paths/version"
2
2
  require "js_image_paths/engine"
3
3
  require "js_image_paths/generator"
4
+ require "js_image_paths/processor"
4
5
  module JsImagePaths
5
6
  end
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.1.1
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: 2017-08-07 00:00:00.000000000 Z
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: '6.0'
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: '6.0'
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: '1.10'
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: '1.10'
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: '10.0'
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: '10.0'
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
- rubyforge_project:
108
- rubygems_version: 2.6.11
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: []