hype_assets 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +21 -6
- data/lib/hype_assets/hype_template.rb +60 -15
- data/lib/hype_assets/version.rb +1 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b84085bc71de2a6048ecdce56fc05deb45fec949
|
4
|
+
data.tar.gz: d84ef8991f6d3129826658ecb64721f0036b1628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adbbf4b2865c718822c4d98e34333cf0dcae39f8392cbbe9bd9252cac40c00d7997c78202e9ae30798a693743cfc60e4c9bac18b3379c1785f7a46a3e71fa881
|
7
|
+
data.tar.gz: ad2cfcd14d1364111790e33c17468f6b0558b2142b65a081d3c36e5323029e83a3b42f59f3ad011ffb2360a47fe276721eae28e349351cc1e49b9d6f1b4ed199
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
3
|
|
4
|
+
## 0.1.1 2016-03-28
|
5
|
+
* Issue #5: Force a recompile of the `*.hype` file whenever a dependency changes,
|
6
|
+
including an external image file and the gem itself.
|
7
|
+
|
8
|
+
|
4
9
|
## 0.1.0 2016-03-20
|
5
10
|
* Milestone: The basic idea is implemented!
|
6
11
|
You can now add your .hyperesource folders into the assets folder,
|
data/README.md
CHANGED
@@ -2,15 +2,26 @@
|
|
2
2
|
|
3
3
|
HypeAssets provides Rails Asset Pipeline integration for Tumult Hype animations.
|
4
4
|
|
5
|
-
[Tumult Hype]
|
5
|
+
[Tumult Hype](http://tumult.com/hype/) is a tool for producing animations and
|
6
|
+
interactive content implemented as HTML5 javascripts and images. Integrating these
|
7
|
+
into the
|
8
|
+
[Rails Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html)
|
9
|
+
would enable serving these resources from a
|
10
|
+
[CDN](http://guides.rubyonrails.org/asset_pipeline.html#cdns)
|
11
|
+
and versioning them with
|
12
|
+
[Digest Fingerprinting](http://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark).
|
13
|
+
That integration is, unfortunately, difficult to do.
|
14
|
+
Rails expects that all file references be encapsulated with `asset_path()` calls within
|
15
|
+
[ERB](http://guides.rubyonrails.org/asset_pipeline.html#javascript-coffeescript-and-erb)
|
16
|
+
tags, while Tumult Hype produces a minified javascript file containing image filenames
|
17
|
+
that are each concatenated client-side onto a single base URL.
|
6
18
|
|
7
19
|
HypeAssets makes Rails Asset Pipeline integration easy by automatically modifying the foo_hype_generated_script.js file with the correct file references.
|
8
20
|
|
9
21
|
|
10
|
-
|
11
22
|
## Installation
|
12
23
|
|
13
|
-
Add this line to your application
|
24
|
+
Add this line to your application‘s Gemfile:
|
14
25
|
|
15
26
|
```ruby
|
16
27
|
gem 'hype_assets'
|
@@ -18,7 +29,8 @@ gem 'hype_assets'
|
|
18
29
|
|
19
30
|
And then execute:
|
20
31
|
|
21
|
-
|
32
|
+
$ bundle
|
33
|
+
|
22
34
|
|
23
35
|
|
24
36
|
|
@@ -30,15 +42,18 @@ And then execute:
|
|
30
42
|
|
31
43
|
3. Append a `.hype` extension to your hype scripts:
|
32
44
|
|
45
|
+
```
|
33
46
|
$ cd app/assets/hype/foo.hyperesources
|
34
47
|
$ mv foo_hype_generated_script.js foo_hype_generated_script.js.hype
|
48
|
+
```
|
35
49
|
|
36
|
-
|
50
|
+
NOTE: Do NOT rename your other javascript files, e.g. HYPE-123.full.min.js.
|
37
51
|
|
38
52
|
4. In your HTML, reference your hype animation script with
|
39
53
|
|
54
|
+
```
|
40
55
|
<%= javascript_include_tag "foo.hyperesources/foo_hype_generated_script.js" %>
|
41
|
-
|
56
|
+
```
|
42
57
|
|
43
58
|
|
44
59
|
## Contributing
|
@@ -1,14 +1,33 @@
|
|
1
1
|
class HypeAssets::HypeTemplate
|
2
2
|
|
3
|
+
|
4
|
+
def self.cache_key
|
5
|
+
### Sprockets stores our processor's cache key along with the compiled asset.
|
6
|
+
### If we change the key, the compiled asset is invalidated and recompiled.
|
7
|
+
### Grep for @cache_key within the sprockets gem for examples of its definition.
|
8
|
+
### Things we might include here:
|
9
|
+
### * gem or class name
|
10
|
+
### * gem version
|
11
|
+
### * version of any external libraries used
|
12
|
+
### * configuration options, as `DigestUtils.digest(options)`
|
13
|
+
@cache_key ||= "#{name}:#{::HypeAssets::VERSION}"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
3
17
|
def self.call (input)
|
4
18
|
### Massage the raw foo.hyperesources/foo_hype_generated_script.js.hype file
|
5
|
-
###
|
6
|
-
### @input [Hash] See http://www.rubydoc.info/gems/sprockets/3.5.2#Processor_Interface
|
19
|
+
### to use digested filenames, stored potentially on a CDN.
|
20
|
+
### @param input [Hash] See http://www.rubydoc.info/gems/sprockets/3.5.2#Processor_Interface
|
7
21
|
### for a description of input's fields.
|
8
|
-
### @
|
9
|
-
|
10
|
-
hype_script
|
11
|
-
|
22
|
+
### @return [Hash] :data is the post-processed content. All other fields are merged into the :metadata hash. See lib/sprockets/processor_utils.rb#call_processors()
|
23
|
+
|
24
|
+
hype_script = input[:data]
|
25
|
+
sprockets = input[:environment]
|
26
|
+
dependencies = Set.new(input[:metadata][:dependencies]) # may be nil
|
27
|
+
folder = nil
|
28
|
+
|
29
|
+
sprockets.logger.info "HypeAssets: Processing #{input[:name]} @ #{Time.now}"
|
30
|
+
|
12
31
|
|
13
32
|
## THE BASE URL:
|
14
33
|
## Replace: var f="animation_name.hyperesources"
|
@@ -25,8 +44,8 @@ puts "HypeAssets: Processing #{input[:name]} @ #{Time.now}"
|
|
25
44
|
## Replace: "HYPE-466.full.min.js":"HYPE-466.thin.min.js"
|
26
45
|
## With: "HYPE-466.full.min-1234567890abcdef.js":"HYPE-466.thin.min-1234567890abcdef.js"
|
27
46
|
hype_script.sub!(/"(HYPE-\d+.full.min.js)":"(HYPE-\d+.thin.min.js)"/) {
|
28
|
-
full = digested_asset_filename "#{folder}/#{$1}"
|
29
|
-
thin = digested_asset_filename "#{folder}/#{$2}"
|
47
|
+
full = digested_asset_filename "#{folder}/#{$1}", dependencies, sprockets
|
48
|
+
thin = digested_asset_filename "#{folder}/#{$2}", dependencies, sprockets
|
30
49
|
%Q["#{full}":"#{thin}"]
|
31
50
|
}
|
32
51
|
|
@@ -43,19 +62,28 @@ puts "HypeAssets: Processing #{input[:name]} @ #{Time.now}"
|
|
43
62
|
## argument to `new HYPE_466()`. Of course, that could change from version to version
|
44
63
|
## of Hype!
|
45
64
|
hype_script.gsub!(/\bn:"([^"]+\.[^"]+)"/) {
|
46
|
-
n = digested_asset_filename "#{folder}/#{$1}"
|
65
|
+
n = digested_asset_filename "#{folder}/#{$1}", dependencies, sprockets
|
47
66
|
%Q[n:"#{n}"]
|
48
67
|
}
|
49
68
|
|
50
|
-
"// Pre-Processed with HypeAssets v#{::HypeAssets::VERSION} @ #{Time.now}\n#{hype_script}"
|
69
|
+
hype_script = "// Pre-Processed with HypeAssets v#{::HypeAssets::VERSION} @ #{Time.now}\n #{hype_script}"
|
70
|
+
|
71
|
+
|
72
|
+
{
|
73
|
+
data: hype_script,
|
74
|
+
dependencies: dependencies,
|
75
|
+
}
|
51
76
|
end
|
52
77
|
|
53
78
|
|
54
|
-
def self.digested_asset_filename (resource)
|
55
|
-
### @
|
56
|
-
###
|
57
|
-
###
|
58
|
-
###
|
79
|
+
def self.digested_asset_filename (resource, dependencies, sprockets)
|
80
|
+
### @param resource [String] uri-encoded asset, e.g. "folder/file%402x.jpg"
|
81
|
+
### @param dependencies [Set] (mutated) resource is added to the set
|
82
|
+
### @param sprockets [Sprockets::Environment] needed for its helper functions
|
83
|
+
### @return digested version of the asset's filename.
|
84
|
+
### Returns *just* the filename itself (i.e. the basename),
|
85
|
+
### since Hype's script internally concatenates the filename
|
86
|
+
### onto a base URL.
|
59
87
|
### NOTE: The Hype *_hype_generated_script.js percent-encodes the filename.
|
60
88
|
### Incidentally, it encodes `@`, even though this is a safe character, AFAICT.
|
61
89
|
### URI.encode does *not* re-encode the `@`, but that doesn't seem to break things.
|
@@ -64,6 +92,23 @@ puts "HypeAssets: Processing #{input[:name]} @ #{Time.now}"
|
|
64
92
|
digested_path = digest_path decoded_resource
|
65
93
|
basename = File.basename digested_path
|
66
94
|
re_encoded_name = URI.encode basename
|
95
|
+
|
96
|
+
|
97
|
+
## Ensure our .hype file will be recompiled if any of our images change.
|
98
|
+
## The Sprockets documentation is sorely lacking in explaining how to do this.
|
99
|
+
## From experimentation, we need an absolute file-digest:// URI:
|
100
|
+
## "file-digest:///absolute/path/to/foo.hyperesources/file"
|
101
|
+
## Anything less will be silently ignored, including:
|
102
|
+
## "foo.hyperesources/file"
|
103
|
+
## "file-digest:///foo.hyperesources/file"
|
104
|
+
## "/absolute/path/to/foo.hyperesources/file"
|
105
|
+
absolute_path = sprockets.resolve(decoded_resource)
|
106
|
+
file_digest_uri = sprockets.build_file_digest_uri(absolute_path)
|
107
|
+
## NOTE: build_file_digest_uri just tacks on a file-digest:// prefix.
|
108
|
+
## It does //not// generate a digest hashcode.
|
109
|
+
dependencies << file_digest_uri
|
110
|
+
|
111
|
+
re_encoded_name
|
67
112
|
end
|
68
113
|
|
69
114
|
|
data/lib/hype_assets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hype_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noach Magedman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|