hype_assets 0.0.0
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/hype_assets.gemspec +29 -0
- data/lib/hype_assets.rb +6 -0
- data/lib/hype_assets/hype_template.rb +90 -0
- data/lib/hype_assets/version.rb +3 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 62ec5f515f9341a1f3e50f24dda60caf22b6de88
|
4
|
+
data.tar.gz: b0163cd6546514e59de9bd6870ba663691aa8c3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 940d55c356cac5484ecb04b13ffcf272a35510a3803b29ba320eb3ca59619097d17fe29f13ee6f8261f2036369d85520d7e838e77dca6851904763b32eaeb6a7
|
7
|
+
data.tar.gz: e16e279278724026325a28e9d956a2da2875c0351462954e8ccba98bd23806b47eab9e51d4e354a514bc40c8587bb4a53c64a07bc185195d1d7c24b950a7f6f0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# HypeAssets
|
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/hype_assets`. 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 'hype_assets'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install hype_assets
|
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]/hype_assets.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hype_assets"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/hype_assets.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hype_assets/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hype_assets"
|
8
|
+
spec.version = HypeAssets::VERSION
|
9
|
+
spec.authors = ["Noach Magedman"]
|
10
|
+
spec.email = ["nmagedman@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Integrate Tumult Hype animation files into the Asset Pipeline}
|
13
|
+
spec.description = %q{Append `.hype` to your hype_generated_script.js and we take care of the rest!}
|
14
|
+
spec.homepage = "https://github.com/nmagedman/hype_assets"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
|
25
|
+
### Tilt has been DEPRECATED. NOW they tell me.....
|
26
|
+
spec.add_runtime_dependency 'tilt', '~> 2.0' # baseclass for Sprockets preprocessors
|
27
|
+
|
28
|
+
spec.add_runtime_dependency 'sprockets', '~> 3.0'
|
29
|
+
end
|
data/lib/hype_assets.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
class HypeAssets::HypeTemplate < ::Tilt::Template
|
4
|
+
|
5
|
+
def asset_url (resource)
|
6
|
+
### Wrapper function around the Sprockets helper,
|
7
|
+
### since it's not clear how best to invoke it.
|
8
|
+
ApplicationController.helpers.asset_url resource
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def prepare
|
13
|
+
## Apparently this *must* be defined explicitly.
|
14
|
+
## There is no default no-op implementation.
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def evaluate (scope, locals)
|
19
|
+
## The original *_hype_generated_script.js.hype file is
|
20
|
+
## slurped into `data`, defined by ::Tilt::Template.
|
21
|
+
## Massage it to include the digested/CDN'd filenames,
|
22
|
+
## and return it.
|
23
|
+
|
24
|
+
folder = nil
|
25
|
+
|
26
|
+
## THE BASE URL:
|
27
|
+
## Replace: var f="animation_name.hyperesources"
|
28
|
+
## With: var f="https://my.cdn.com/assets/animation_name.hyperesources"
|
29
|
+
data.sub!(/var f="([^"]+)"/) {
|
30
|
+
folder = $1
|
31
|
+
## TODO: Don't hardcode `assets`. Get it dynamically from the config.
|
32
|
+
path = asset_url "assets/#{folder}"
|
33
|
+
%Q[var f="#{path}"]
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
## The HYPE Library:
|
38
|
+
## Replace: "HYPE-466.full.min.js":"HYPE-466.thin.min.js"
|
39
|
+
## With: "HYPE-466.full.min-1234567890abcdef.js":"HYPE-466.thin.min-1234567890abcdef.js"
|
40
|
+
data.sub!(/"(HYPE-\d+.full.min.js)":"(HYPE-\d+.thin.min.js)"/) {
|
41
|
+
full = digested_asset_filename "#{folder}/#{$1}"
|
42
|
+
thin = digested_asset_filename "#{folder}/#{$2}"
|
43
|
+
%Q["#{full}":"#{thin}"]
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
## INDIVIDUAL FILENAMES:
|
48
|
+
## Replace: n:"my_image.png"
|
49
|
+
## With: n:"my_image-1234567890abcdef.png"
|
50
|
+
## TODO: A big difficulty here is choosing which instances of `n:""` to modify:
|
51
|
+
## n is used both for filenames and for free-form, scene names.
|
52
|
+
## Currently, I assume the filenames have a dot (reasonable, because they have extensions)
|
53
|
+
## and that scene names do not (not so reasonable, since a human types them in).
|
54
|
+
## With tighter pattern matching, we may be able to support scene-names containing dots.
|
55
|
+
## For example, all the filenames are grouped together in a hash which is the third
|
56
|
+
## argument to `new HYPE_466()`. Of course, that could change from version to version
|
57
|
+
## of Hype!
|
58
|
+
data.gsub!(/\bn:"([^"]+\.[^"]+)"/) {
|
59
|
+
n = digested_asset_filename "#{folder}/#{$1}"
|
60
|
+
%Q[n:"#{n}"]
|
61
|
+
}
|
62
|
+
|
63
|
+
"// Pre-Processed with HypeAssets::HypeTemplate\n" + data
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def digested_asset_filename (resource)
|
68
|
+
### @returns the digested version of an asset's filename.
|
69
|
+
### It returns *just* the filename itself (i.e. the basename),
|
70
|
+
### since Hype's script internally concatenates the filename
|
71
|
+
### onto a base URL.
|
72
|
+
### NOTE: The Hype *_hype_generated_script.js percent-encodes the filename.
|
73
|
+
### Incidentally, it encodes `@`, even though this is a safe character, AFAICT.
|
74
|
+
### URI.encode does *not* re-encode the `@`, but that doesn't seem to break things.
|
75
|
+
|
76
|
+
## Not sure which code arrangement is easiest to read:
|
77
|
+
|
78
|
+
## Individual steps:
|
79
|
+
# decoded_resource = URI.decode resource
|
80
|
+
# path = ApplicationHelper.asset_path decoded_resource
|
81
|
+
# basename = File.basename path
|
82
|
+
# re_encoded_name = URI.encode basename
|
83
|
+
|
84
|
+
## Chained:
|
85
|
+
# URI.encode(File.basename(asset_url(URI.decode(resource))))
|
86
|
+
|
87
|
+
## Chained without parens:
|
88
|
+
URI.encode File.basename asset_url URI.decode resource
|
89
|
+
end
|
90
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hype_assets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Noach Magedman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tilt
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sprockets
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: Append `.hype` to your hype_generated_script.js and we take care of the
|
84
|
+
rest!
|
85
|
+
email:
|
86
|
+
- nmagedman@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- hype_assets.gemspec
|
100
|
+
- lib/hype_assets.rb
|
101
|
+
- lib/hype_assets/hype_template.rb
|
102
|
+
- lib/hype_assets/version.rb
|
103
|
+
homepage: https://github.com/nmagedman/hype_assets
|
104
|
+
licenses: []
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.5.1
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Integrate Tumult Hype animation files into the Asset Pipeline
|
126
|
+
test_files: []
|