checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b030f67bc8b5350ac6544628fd1e11f8ddbe50d
4
+ data.tar.gz: fd65be5a8bc2110f0362daab837f0b8927d7b219
5
+ SHA512:
6
+ metadata.gz: ddd4a23b1f1309a2ba5f20be8af26fc0a52bb3e4df085c8a174dda83e79eda91ff056e7f30c35de41a4a7bce73b4dca2eaad211b1e6dec3d967f9cdabe36b434
7
+ data.tar.gz: f30437246b38faa422a3055688a483db80c3ee7bf9e5f10a623c0592e35c8bb18eb9ec2a9ff4d6b92bd66c18fa79b18bd0d68168ceb530b77a258da47bb1d5f3
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
3
+
4
+ Metrics/LineLength:
5
+ Max: 100
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/DoubleNegation:
11
+ Enabled: false
12
+
13
+ Style/FileName:
14
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Yuku TAKAHASHI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # ActionView::RevManifest
2
+
3
+ Let Rails load rev-manifest.json generated by [gulp-rev](https://github.com/sindresorhus/gulp-rev).
4
+
5
+ ## Usage
6
+
7
+ Add to your Gemfile:
8
+
9
+ ```rb
10
+ gem "actionview-rev_manifest"
11
+ ```
12
+
13
+ Run:
14
+
15
+ ```
16
+ bundle install
17
+ ```
18
+
19
+ ## Setup
20
+
21
+ ```rb
22
+ # config/environments/production.rb
23
+
24
+ MyApp::Application.config do
25
+ config.rev_manifest.enable = true
26
+ end
27
+ ```
28
+
29
+ ### With Sprockets
30
+
31
+ If you want to serve some assets with RevManifest and rest of them with Sprockets, specify all
32
+ sources' name, which you want to serve with RevManifest, as `config.rev_manifest.sources`:
33
+
34
+ ```rb
35
+ MyApp::Application.config do
36
+ config.rev_manifest.sources = ["new_application.js", "new_application.css"]
37
+ end
38
+ ```
39
+
40
+ ## Sample gulpfile.coffee
41
+
42
+ ```coffee
43
+ gulp = require "gulp"
44
+ rev = require "gulp-rev"
45
+
46
+ gulp.task "precompile", ->
47
+ gulp.src([
48
+ "public/assets/javascripts/*.js",
49
+ "public/assets/stylesheets/*.css"
50
+ ], base: "public")
51
+ .pipe(rev())
52
+ .pipe(gulp.dest("public"))
53
+ .pipe(rev.manifest())
54
+ .pipe(gulp.dest("public/assets"))
55
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/actionview-rev_manifest.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ file = File.open(File.expand_path("../lib/rev_manifest/version.rb", __FILE__))
2
+ version = file.read.scan(/\d+\.\d+\.\d+/).first
3
+ file.close
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "actionview-rev_manifest"
7
+ spec.version = version
8
+ spec.authors = ["Yuku Takahashi"]
9
+ spec.email = ["yuku@qiita.com"]
10
+ spec.summary = "Let Rails load rev-manifest.json generated by gulp-rev"
11
+ spec.homepage = "https://github.com/yuku-t/actionview-rev_manifest"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_dependency "actionview"
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.7"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "rubocop", "~> 0.34.2"
22
+ end
data/lib/actionview-rev_manifest.rb ADDED
@@ -0,0 +1,73 @@
1
+ require "rev_manifest/railtie"
2
+ require "rev_manifest/version"
3
+
4
+ module RevManifest
5
+ DEFAULT_ASSET_PUBLIC_DIRECTORIES = {
6
+ audio: "/assets/audios",
7
+ font: "/assets/fonts",
8
+ image: "/assets/images",
9
+ javascript: "/assets/javascripts",
10
+ stylesheet: "/assets/stylesheets",
11
+ video: "/assets/videos"
12
+ }
13
+
14
+ DEFAULT_ASSET_PREFIXES = {
15
+ audio: "assets/audios/",
16
+ font: "assets/fonts/",
17
+ image: "assets/images/",
18
+ javascript: "assets/javascripts/",
19
+ stylesheet: "assets/stylesheets/",
20
+ video: "assets/videos/"
21
+ }
22
+
23
+ DEFAULT_ASSET_ROOT = "/"
24
+
25
+ DEFAULT_MANIFEST_PATH = "public/assets/rev-manifest.json"
26
+
27
+ class << self
28
+ attr_writer :enabled, :asset_prefixes, :asset_public_directories, :asset_root, :manifest_path,
29
+ :sources
30
+
31
+ # @return [true, false]
32
+ def enabled?
33
+ !!@enabled
34
+ end
35
+
36
+ # @return [Hash]
37
+ def asset_public_directories
38
+ @asset_public_directories || DEFAULT_ASSET_PUBLIC_DIRECTORIES
39
+ end
40
+
41
+ # @return [true, false]
42
+ def include?(source)
43
+ return false unless @sources
44
+ @sources == :all ? true : @sources.include?(source)
45
+ end
46
+
47
+ # @return [String]
48
+ def resolve(source, options)
49
+ asset_root + manifest[asset_prefixes[options[:type]] + source]
50
+ end
51
+
52
+ private
53
+
54
+ # @return [Hash]
55
+ def asset_prefixes
56
+ @asset_prefixes || DEFAULT_ASSET_PREFIXES
57
+ end
58
+
59
+ # @return [String]
60
+ def asset_root
61
+ @asset_root || DEFAULT_ASSET_ROOT
62
+ end
63
+
64
+ # @return [String]
65
+ def manifest_path
66
+ @manifest_path || Rails.root.join(DEFAULT_MANIFEST_PATH)
67
+ end
68
+
69
+ def manifest
70
+ @manifest ||= JSON.load(File.read(manifest_path))
71
+ end
72
+ end
73
+ end
data/lib/rev_manifest/helper.rb ADDED
@@ -0,0 +1,16 @@
1
+ module RevManifest
2
+ module Helper
3
+ def compute_asset_path(source, options = {})
4
+ if RevManifest.include?(source)
5
+ if RevManifest.enabled?
6
+ RevManifest.resolve(source, options)
7
+ else
8
+ dir = RevManifest.asset_public_directories[options[:type]] || ""
9
+ File.join(dir, source)
10
+ end
11
+ else
12
+ super
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/rev_manifest/railtie.rb ADDED
@@ -0,0 +1,16 @@
1
+ require "rev_manifest/helper"
2
+
3
+ module RevManifest
4
+ class Railtie < ::Rails::Railtie
5
+ config.rev_manifest = ActiveSupport::OrderedOptions.new
6
+
7
+ config.rev_manifest.enable = false
8
+ config.rev_manifest.sources = :all
9
+
10
+ initializer "rev_manifest.config", group: :all do |app|
11
+ RevManifest.enabled = app.config.rev_manifest.enable
12
+ RevManifest.sources = app.config.rev_manifest.sources
13
+ ActionView::Base.send(:prepend, RevManifest::Helper)
14
+ end
15
+ end
16
+ end
data/lib/rev_manifest/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module RevManifest
2
+ VERSION = "0.2.2"
3
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: actionview-rev_manifest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Yuku Takahashi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.34.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.34.2
69
+ description:
70
+ email:
71
+ - yuku@qiita.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rubocop.yml"
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - actionview-rev_manifest.gemspec
83
+ - lib/actionview-rev_manifest.rb
84
+ - lib/rev_manifest/helper.rb
85
+ - lib/rev_manifest/railtie.rb
86
+ - lib/rev_manifest/version.rb
87
+ homepage: https://github.com/yuku-t/actionview-rev_manifest
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.5.1
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Let Rails load rev-manifest.json generated by gulp-rev
111
+ test_files: []
112
+ has_rdoc: