js_image_paths-0.0.2/0000755000004100000410000000000012450764673014534 5ustar www-datawww-datajs_image_paths-0.0.2/LICENSE.txt0000644000004100000410000000205312450764673016357 0ustar www-datawww-dataCopyright (c) 2014 Jonne Haß MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. js_image_paths-0.0.2/lib/0000755000004100000410000000000012450764673015302 5ustar www-datawww-datajs_image_paths-0.0.2/lib/js_image_paths/0000755000004100000410000000000012450764673020257 5ustar www-datawww-datajs_image_paths-0.0.2/lib/js_image_paths/engine.rb0000644000004100000410000000070712450764673022055 0ustar www-datawww-datamodule JsImagePaths class Engine < Rails::Engine isolate_namespace(JsImagePaths) initializer('js_image_paths.compile', after: 'sprockets.environment') do |application| application.assets.register_preprocessor('application/javascript', :'js_image_path.compile') do |context, data| if context.logical_path == 'js_image_paths' JsImagePaths::Generator.context = context end data end end end end js_image_paths-0.0.2/lib/js_image_paths/version.rb0000644000004100000410000000005412450764673022270 0ustar www-datawww-datamodule JsImagePaths VERSION = "0.0.2" end js_image_paths-0.0.2/lib/js_image_paths/generator.rb0000644000004100000410000000056112450764673022574 0ustar www-datawww-datamodule JsImagePaths module Generator cattr_accessor :context def self.generate image_hash.to_json end def self.image_hash images = context.environment.each_logical_path(->(_, path) { path.include? "images" }) images.each_with_object({}) do |path, images| images[path] = context.asset_path(path) end end end end js_image_paths-0.0.2/lib/js_image_paths.rb0000644000004100000410000000017412450764673020606 0ustar www-datawww-datarequire "js_image_paths/version" require "js_image_paths/engine" require "js_image_paths/generator" module JsImagePaths end js_image_paths-0.0.2/metadata.yml0000644000004100000410000000425612450764673017046 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: js_image_paths version: !ruby/object:Gem::Version version: 0.0.2 platform: ruby authors: - Jonne Haß autorequire: bindir: bin cert_chain: [] date: 2014-12-31 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rails requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '4.0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '4.0' - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.7' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.7' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '10.0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '10.0' description: Easily access your image assets in your JavaScript code email: - me@jhass.eu executables: [] extensions: [] extra_rdoc_files: [] files: - LICENSE.txt - app/assets/javascripts/js_image_paths.js.erb - lib/js_image_paths.rb - lib/js_image_paths/engine.rb - lib/js_image_paths/generator.rb - lib/js_image_paths/version.rb homepage: https://github.com/jhass/js_image_paths licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.4.1 signing_key: specification_version: 4 summary: Rails image paths in your JS test_files: [] has_rdoc: js_image_paths-0.0.2/app/0000755000004100000410000000000012450764673015314 5ustar www-datawww-datajs_image_paths-0.0.2/app/assets/0000755000004100000410000000000012450764673016616 5ustar www-datawww-datajs_image_paths-0.0.2/app/assets/javascripts/0000755000004100000410000000000012450764673021147 5ustar www-datawww-datajs_image_paths-0.0.2/app/assets/javascripts/js_image_paths.js.erb0000644000004100000410000000023512450764673025231 0ustar www-datawww-datavar ImagePaths = (function(images) { return { get: function(name) { return images[name]; } }; })(<%= JsImagePaths::Generator.generate %>);