asset_paths_from_manifest 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c5f06fd31cd6d7884b1fd4087ff4744e4fba23cb
4
+ data.tar.gz: 5dee65c2e008ad4879be0078e7be891a737a2f73
5
+ SHA512:
6
+ metadata.gz: b0104c5f4d5a93002d8fecacb41e3a52a156ac9ca84f26cf1319470319a3a118a19265eb2709560329a21dadb32d9592b9708bf8e78eb323bd0476ffe57a4839
7
+ data.tar.gz: 8abb2f02e4f13f9b61894519b7908cc68dbf70cfbce12148097af4a6a9deeeefc9c05a299440d6eef385d4d9d7becf0422a4c53f47b40e1dfb90937496449b08
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 izumin5210
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # AssetPathsFromManifest
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/asset_paths_from_manifest`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'asset_paths_from_manifest'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install asset_paths_from_manifest
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/asset_paths_from_manifest. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ require "asset_paths_from_manifest/version"
2
+
3
+ module AssetPathsFromManifest
4
+ attr_reader :manifest
5
+
6
+ def self.bootstrap
7
+ @manifest = Manifest.load
8
+ end
9
+ end
10
+
11
+ require "asset_paths_from_manifest/railtie" if defined?(Rails)
@@ -0,0 +1,23 @@
1
+ module AssetPathsFromManifest
2
+ class << self
3
+ def configuration
4
+ @config ||= Config.new
5
+ end
6
+
7
+ def configuration=(config)
8
+ @config = config
9
+ end
10
+
11
+ def configure
12
+ yield configuration
13
+ end
14
+ end
15
+
16
+ class Config
17
+ include ActiveSupport::Configurable
18
+
19
+ config_accessor :manifest_json_path do
20
+ Rails.root.join('public', 'assets', 'manifest.json')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ require "asset_paths_from_manifest/manifest"
2
+
3
+ module AssetPathsFromManifest
4
+ module Helper
5
+ def asset_path_from_manifest(name, **options)
6
+ asset_path(lookup(name), **options)
7
+ end
8
+
9
+ def javascript_include_tag_from_manifest(name, **options)
10
+ javascript_include_tag(lookup(name, type: :javascript), **options)
11
+ end
12
+
13
+ def stylesheet_link_tag_from_manifest(name, **options)
14
+ javascript_include_tag(lookup(name, type: :javascript), **options)
15
+ end
16
+
17
+ private
18
+
19
+ def lookup(name, type: nil)
20
+ name_with_extname = compute_asset_extname(name, type)
21
+ manifest.lookup(name_with_extname)
22
+ end
23
+
24
+ def manifest
25
+ AssetPathsFromManifest.manifest
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ require "asset_paths_from_manifest/config"
2
+
3
+ module AssetPathsFromManifest
4
+ class Manifest
5
+ class << self
6
+ def load
7
+ new(file_path)
8
+ end
9
+
10
+ def file_path
11
+ AssetPathsFromManifest::Config.manifest_json_path
12
+ end
13
+ end
14
+
15
+ def initializer(json_path)
16
+ @json_path = json_path
17
+ @data = load
18
+ end
19
+
20
+ def load
21
+ JSON.parse(File.read(@json_path))
22
+ end
23
+
24
+ def lookup(name)
25
+ @data[name]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ require "rails/railtie"
2
+
3
+ require "asset_paths_from_manifest/helper"
4
+
5
+ class AssetPathsFromManifest::Engine < ::Rails::Engine
6
+ initializer :asset_paths_from_manifest do |app|
7
+ ActiveSupport.on_load :action_controller do
8
+ ActionController::Base.helper AssetPathsFromManifest::Helper
9
+ end
10
+
11
+ ActiveSupport.on_load :action_view do
12
+ include AssetPathsFromManifest::Helper
13
+ end
14
+
15
+ AssetPathsFromManifest.bootstrap
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module AssetPathsFromManifest
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asset_paths_from_manifest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - izumin5210
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: meowcop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.10'
97
+ description: Provides view helpers to compute full paths for assets from manifest
98
+ json file
99
+ email:
100
+ - masayuki@izumin.info
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - MIT-LICENSE
106
+ - README.md
107
+ - Rakefile
108
+ - lib/asset_paths_from_manifest.rb
109
+ - lib/asset_paths_from_manifest/config.rb
110
+ - lib/asset_paths_from_manifest/helper.rb
111
+ - lib/asset_paths_from_manifest/manifest.rb
112
+ - lib/asset_paths_from_manifest/railtie.rb
113
+ - lib/asset_paths_from_manifest/version.rb
114
+ homepage: https://github.com/izumin5210/asset_paths_from_manifest
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.6.8
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Provides view helpers to compute full paths for assets from manifest json
138
+ file
139
+ test_files: []