pakyow-assets 0.1.2 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +3 -19
  3. data/lib/pakyow/assets.rb +19 -0
  4. data/lib/pakyow/assets/actions/process.rb +63 -0
  5. data/lib/pakyow/assets/actions/public.rb +75 -0
  6. data/lib/pakyow/assets/asset.rb +238 -0
  7. data/lib/pakyow/assets/babel.rb +34 -0
  8. data/lib/pakyow/assets/behavior/assets.rb +45 -0
  9. data/lib/pakyow/assets/behavior/config.rb +137 -0
  10. data/lib/pakyow/assets/behavior/externals.rb +58 -0
  11. data/lib/pakyow/assets/behavior/packs.rb +162 -0
  12. data/lib/pakyow/assets/behavior/prelaunching.rb +19 -0
  13. data/lib/pakyow/assets/behavior/processing.rb +27 -0
  14. data/lib/pakyow/assets/behavior/rendering/install_assets.rb +39 -0
  15. data/lib/pakyow/assets/behavior/silencing.rb +35 -0
  16. data/lib/pakyow/assets/behavior/watching.rb +25 -0
  17. data/lib/pakyow/assets/errors.rb +16 -0
  18. data/lib/pakyow/assets/external.rb +103 -0
  19. data/lib/pakyow/assets/framework.rb +52 -0
  20. data/lib/pakyow/assets/pack.rb +171 -0
  21. data/lib/pakyow/assets/precompiler.rb +63 -0
  22. data/lib/pakyow/assets/source_map.rb +99 -0
  23. data/lib/pakyow/assets/tasks/precompile.rake +9 -0
  24. data/lib/pakyow/assets/tasks/update.rake +20 -0
  25. data/lib/pakyow/assets/types/css.rb +45 -0
  26. data/lib/pakyow/assets/types/js.rb +98 -0
  27. data/lib/pakyow/assets/types/sass.rb +69 -0
  28. data/lib/pakyow/assets/types/scss.rb +14 -0
  29. data/src/@babel/standalone@7.3.1/babel.min.js +165 -0
  30. data/src/@babel/standalone@7.4.5/babel.min.js +92359 -0
  31. metadata +146 -46
  32. data/CHANGELOG.md +0 -18
  33. data/README.md +0 -58
  34. data/lib/assets.rb +0 -221
  35. data/lib/config.rb +0 -37
  36. data/lib/middleware.rb +0 -42
  37. data/lib/pakyow-assets.rb +0 -31
  38. data/lib/preprocessors/css-preprocessor.rb +0 -16
  39. data/lib/preprocessors/image-preprocessor.rb +0 -1
  40. data/lib/preprocessors/javascript-preprocessor.rb +0 -16
  41. data/lib/preprocessors/sass-preprocessor.rb +0 -23
  42. data/lib/version.rb +0 -5
  43. data/pakyow-assets.gemspec +0 -21
metadata CHANGED
@@ -1,107 +1,207 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakyow-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pakyow-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0.rc1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0.rc1
27
+ - !ruby/object:Gem::Dependency
28
+ name: pakyow-presenter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0.rc1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0.rc1
41
+ - !ruby/object:Gem::Dependency
42
+ name: pakyow-routing
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0.rc1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0.rc1
13
55
  - !ruby/object:Gem::Dependency
14
56
  name: pakyow-support
15
57
  requirement: !ruby/object:Gem::Requirement
16
58
  requirements:
17
- - - ~>
59
+ - - '='
18
60
  - !ruby/object:Gem::Version
19
- version: '0'
61
+ version: 1.0.0.rc1
20
62
  type: :runtime
21
63
  prerelease: false
22
64
  version_requirements: !ruby/object:Gem::Requirement
23
65
  requirements:
24
- - - ~>
66
+ - - '='
25
67
  - !ruby/object:Gem::Version
26
- version: '0'
68
+ version: 1.0.0.rc1
27
69
  - !ruby/object:Gem::Dependency
28
- name: pakyow-core
70
+ name: execjs
29
71
  requirement: !ruby/object:Gem::Requirement
30
72
  requirements:
31
- - - ~>
73
+ - - "~>"
32
74
  - !ruby/object:Gem::Version
33
- version: '0'
75
+ version: '2.7'
34
76
  type: :runtime
35
77
  prerelease: false
36
78
  version_requirements: !ruby/object:Gem::Requirement
37
79
  requirements:
38
- - - ~>
80
+ - - "~>"
39
81
  - !ruby/object:Gem::Version
40
- version: '0'
82
+ version: '2.7'
41
83
  - !ruby/object:Gem::Dependency
42
- name: pakyow-presenter
84
+ name: http
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mini_mime
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mini_racer
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.2.6
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.2.6
125
+ - !ruby/object:Gem::Dependency
126
+ name: sassc
43
127
  requirement: !ruby/object:Gem::Requirement
44
128
  requirements:
45
- - - ~>
129
+ - - "~>"
46
130
  - !ruby/object:Gem::Version
47
- version: '0'
131
+ version: '2.0'
48
132
  type: :runtime
49
133
  prerelease: false
50
134
  version_requirements: !ruby/object:Gem::Requirement
51
135
  requirements:
52
- - - ~>
136
+ - - "~>"
53
137
  - !ruby/object:Gem::Version
54
- version: '0'
138
+ version: '2.0'
55
139
  - !ruby/object:Gem::Dependency
56
- name: sass
140
+ name: source_map
57
141
  requirement: !ruby/object:Gem::Requirement
58
142
  requirements:
59
- - - ~>
143
+ - - "~>"
60
144
  - !ruby/object:Gem::Version
61
- version: '3.4'
145
+ version: '3.0'
62
146
  type: :runtime
63
147
  prerelease: false
64
148
  version_requirements: !ruby/object:Gem::Requirement
65
149
  requirements:
66
- - - ~>
150
+ - - "~>"
67
151
  - !ruby/object:Gem::Version
68
- version: '3.4'
152
+ version: '3.0'
69
153
  - !ruby/object:Gem::Dependency
70
- name: yui-compressor
154
+ name: uglifier
71
155
  requirement: !ruby/object:Gem::Requirement
72
156
  requirements:
73
- - - ~>
157
+ - - "~>"
74
158
  - !ruby/object:Gem::Version
75
- version: '0.12'
159
+ version: '4.1'
76
160
  type: :runtime
77
161
  prerelease: false
78
162
  version_requirements: !ruby/object:Gem::Requirement
79
163
  requirements:
80
- - - ~>
164
+ - - "~>"
81
165
  - !ruby/object:Gem::Version
82
- version: '0.12'
83
- description: Asset Handling for Pakyow
166
+ version: '4.1'
167
+ description: Asset pipeline for Pakyow
84
168
  email: bryan@metabahn.com
85
169
  executables: []
86
170
  extensions: []
87
171
  extra_rdoc_files: []
88
172
  files:
89
- - CHANGELOG.md
90
173
  - LICENSE
91
- - README.md
92
- - lib/assets.rb
93
- - lib/config.rb
94
- - lib/middleware.rb
95
- - lib/pakyow-assets.rb
96
- - lib/preprocessors/css-preprocessor.rb
97
- - lib/preprocessors/image-preprocessor.rb
98
- - lib/preprocessors/javascript-preprocessor.rb
99
- - lib/preprocessors/sass-preprocessor.rb
100
- - lib/version.rb
101
- - pakyow-assets.gemspec
102
- homepage: http://pakyow.org
174
+ - lib/pakyow/assets.rb
175
+ - lib/pakyow/assets/actions/process.rb
176
+ - lib/pakyow/assets/actions/public.rb
177
+ - lib/pakyow/assets/asset.rb
178
+ - lib/pakyow/assets/babel.rb
179
+ - lib/pakyow/assets/behavior/assets.rb
180
+ - lib/pakyow/assets/behavior/config.rb
181
+ - lib/pakyow/assets/behavior/externals.rb
182
+ - lib/pakyow/assets/behavior/packs.rb
183
+ - lib/pakyow/assets/behavior/prelaunching.rb
184
+ - lib/pakyow/assets/behavior/processing.rb
185
+ - lib/pakyow/assets/behavior/rendering/install_assets.rb
186
+ - lib/pakyow/assets/behavior/silencing.rb
187
+ - lib/pakyow/assets/behavior/watching.rb
188
+ - lib/pakyow/assets/errors.rb
189
+ - lib/pakyow/assets/external.rb
190
+ - lib/pakyow/assets/framework.rb
191
+ - lib/pakyow/assets/pack.rb
192
+ - lib/pakyow/assets/precompiler.rb
193
+ - lib/pakyow/assets/source_map.rb
194
+ - lib/pakyow/assets/tasks/precompile.rake
195
+ - lib/pakyow/assets/tasks/update.rake
196
+ - lib/pakyow/assets/types/css.rb
197
+ - lib/pakyow/assets/types/js.rb
198
+ - lib/pakyow/assets/types/sass.rb
199
+ - lib/pakyow/assets/types/scss.rb
200
+ - src/@babel/standalone@7.3.1/babel.min.js
201
+ - src/@babel/standalone@7.4.5/babel.min.js
202
+ homepage: https://pakyow.org
103
203
  licenses:
104
- - MIT
204
+ - LGPL-3.0
105
205
  metadata: {}
106
206
  post_install_message:
107
207
  rdoc_options: []
@@ -109,17 +209,17 @@ require_paths:
109
209
  - lib
110
210
  required_ruby_version: !ruby/object:Gem::Requirement
111
211
  requirements:
112
- - - '>='
212
+ - - ">="
113
213
  - !ruby/object:Gem::Version
114
- version: '0'
214
+ version: 2.5.0
115
215
  required_rubygems_version: !ruby/object:Gem::Requirement
116
216
  requirements:
117
- - - '>='
217
+ - - ">"
118
218
  - !ruby/object:Gem::Version
119
- version: '0'
219
+ version: 1.3.1
120
220
  requirements: []
121
221
  rubyforge_project:
122
- rubygems_version: 2.0.14
222
+ rubygems_version: 2.7.6
123
223
  signing_key:
124
224
  specification_version: 4
125
225
  summary: Pakyow Assets
data/CHANGELOG.md DELETED
@@ -1,18 +0,0 @@
1
- # 0.1.2 / 2015-11-30
2
-
3
- * Fix bug causing html processor being registered too late, thus not mixing in
4
- the fingerprinted asset names into the html
5
- * Fingerprint contents after all assets are fingerprinted, not before
6
- * Add option to not fingerprint assets
7
- * Add Vary and Last-Modified cache headers
8
- * Handle unknown asset types by copying them over during compilation
9
-
10
- # 0.1.1 / 2015-11-29
11
-
12
- * Take dependent assets into account when building the hash
13
- * Use sass gem rather than sassc; choosing reliability over speed
14
- * Make sure assets middleware executes first
15
-
16
- # 0.1.0 / 2015-11-26
17
-
18
- * Initial gem release
data/README.md DELETED
@@ -1,58 +0,0 @@
1
- # pakyow-assets
2
-
3
- Asset handling for [Pakyow](http://pakyow.com). It's intended to be lightweight
4
- and fast in development while providing powerful fingerprinting and caching
5
- support for production environments.
6
-
7
- In development, assets are compiled on demand rather than up-front. They'll only
8
- be recompiled again when the source changes.
9
-
10
- When starting up in production, Pakyow will compile, minify, and fingerprint
11
- every asset file. Fingerprinted filenames are automatically handled.
12
-
13
- Bundled preprocessors include: js, css, png, gif, jpg, favicon, and sass.
14
-
15
- # Installation
16
-
17
- Place inside your Gemfile
18
-
19
- gem 'pakyow-assets'
20
-
21
- Run `bundle install` and restart your app server.
22
-
23
- # Usage
24
-
25
- Place all assets in a `app/assets` directory. When compiled, assets will mimic
26
- the directory structure. During development, all assets will be compiled to a
27
- `.assets` directory by default. Pakyow will serve requests to all assets when
28
- running in a development environment. The idea in production is for all assets
29
- to be in a non-minified state, making debugging easy.
30
-
31
- *Note that all compiled assets should be excluded from version control as they
32
- will be compiled and fingerprinted when deployed to a production environment.*
33
-
34
- In production, assets will automatically be minified and fingerprinted. As a
35
- developer you don't have to worry about caching or fingerprints; Pakyow takes
36
- care of all of that for you.
37
-
38
- ## Configuration
39
-
40
- There are many configuration options available. Take a look at `lib/config.rb`
41
- for all the available options.
42
-
43
- ## Custom Preprocessor
44
-
45
- Pakyow Assets can easily be extended. Take a look at the existing preprocessors
46
- in `lib/preprocessors` for examples.
47
-
48
- ## External Asset Store
49
-
50
- Any number of asset stores can be registered:
51
-
52
- ```ruby
53
- Pakyow::Config.assets.stores[:store_name] = 'absolute_path_to_store'
54
- ```
55
-
56
- # License
57
-
58
- pakyow-assets is released under the [MIT License](http://opensource.org/licenses/MIT).
data/lib/assets.rb DELETED
@@ -1,221 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Pakyow
4
- module Assets
5
- def self.register_path_with_name(path, name)
6
- stores[name] = {
7
- path: path,
8
- assets: assets_at_path(path)
9
- }
10
- end
11
-
12
- def self.assets_at_path(path)
13
- Dir.glob(File.join(path, '**/[!_]*.[a-z]*')).map { |asset|
14
- String.normalize_path(asset[path.length..-1])
15
- }
16
- end
17
-
18
- def self.stores
19
- @stores ||= {}
20
- end
21
-
22
- def self.preprocessors
23
- @preprocessors ||= {}
24
- end
25
-
26
- def self.dependents
27
- @dependents ||= {}
28
- end
29
-
30
- def self.compiled_asset_path_for_request_path(path)
31
- path = String.normalize_path(path)
32
- ext = File.extname(path)
33
-
34
- return unless path =~ /\.(.*)$/
35
- return unless preprocessor?(ext)
36
-
37
- path_regex = /#{path.gsub(ext, '')}\.(#{alias_exts(ext).map(&:to_s).join('|')})/
38
-
39
- @stores.each_pair do |name, info|
40
- if asset = info[:assets].find { |asset| asset =~ path_regex }
41
- return compile_asset_at_path(asset, info[:path])
42
- end
43
- end
44
-
45
- nil
46
- end
47
-
48
- def self.normalize_ext(ext)
49
- ext.gsub(/[^a-z]/, '').to_sym
50
- end
51
-
52
- def self.alias_exts(ext)
53
- preprocessors.select { |_, info|
54
- info[:output_ext] == normalize_ext(ext)
55
- }.keys
56
- end
57
-
58
- def self.output_ext(ext)
59
- ".#{preprocessor_for_ext(ext)[:output_ext]}"
60
- end
61
-
62
- def self.preprocessor?(ext)
63
- preprocessors.values.map { |info| info[:output_ext] }.flatten.include?(normalize_ext(ext))
64
- end
65
-
66
- def self.preprocessor_for_ext(ext)
67
- ext = normalize_ext(ext)
68
-
69
- preprocessors[ext] || {
70
- block: nil,
71
- output_ext: ext,
72
- fingerprint_contents: false,
73
- finterprint: false
74
- }
75
- end
76
-
77
- def self.compile_asset_at_path(asset, path)
78
- absolute_path = File.join(path, asset)
79
-
80
- asset_dir = File.dirname(asset)
81
- asset_ext = output_ext(File.extname(asset))
82
- asset_file = File.basename(asset, '.*')
83
-
84
- if fingerprinted?(asset_ext)
85
- compiled_asset = "#{asset_file + '-' + asset_hash(absolute_path) + asset_ext}"
86
- else
87
- compiled_asset = "#{asset_file + asset_ext}"
88
- end
89
-
90
- compiled_path = File.join(
91
- Pakyow::Config.app.root,
92
- Pakyow::Config.assets.compiled_asset_path,
93
- asset_dir,
94
- compiled_asset
95
- )
96
-
97
- unless File.exists?(compiled_path)
98
- FileUtils.mkdir_p(File.dirname(compiled_path))
99
-
100
- if fingerprinted?(asset_ext)
101
- glob_path = File.join(Pakyow::Config.app.root, Pakyow::Config.assets.compiled_asset_path, asset_dir, "#{asset_file}-*#{asset_ext}")
102
- else
103
- glob_path = File.join(Pakyow::Config.app.root, Pakyow::Config.assets.compiled_asset_path, asset_dir, asset_file + asset_ext)
104
- end
105
-
106
- FileUtils.rm(Dir.glob(glob_path))
107
- File.open(compiled_path, 'wb+') { |fp| fp.write(preprocess(absolute_path)) }
108
- end
109
-
110
- compiled_path
111
- end
112
-
113
- def self.preprocessor(*exts, output: nil, fingerprint: false, fingerprint_contents: false, &block)
114
- exts.each do |ext|
115
- preprocessors[ext] = {
116
- block: block,
117
- output_ext: output || ext,
118
- fingerprint_contents: fingerprint_contents,
119
- fingerprint: fingerprint
120
- }
121
- end
122
- end
123
-
124
- def self.dependencies(*exts, &block)
125
- exts.each do |ext|
126
- dependents[ext] = block
127
- end
128
- end
129
-
130
- def self.preprocess(path)
131
- preprocessor = preprocessor_for_ext(File.extname(path))
132
- block = preprocessor[:block]
133
-
134
- block.nil? ? File.read(path) : block.call(path)
135
- end
136
-
137
- def self.precompile
138
- if File.exists?(Pakyow::Config.assets.compiled_asset_path)
139
- FileUtils.rm_r(Pakyow::Config.assets.compiled_asset_path)
140
- end
141
-
142
- stores.each do |_, info|
143
- info[:assets].each do |asset|
144
- compile_asset_at_path(asset, info[:path])
145
- absolute_path = File.join(info[:path], asset)
146
-
147
- fingerprint = asset_hash(absolute_path)
148
-
149
- if fingerprinted?(File.extname(asset))
150
- fingerprinted_asset = File.join(
151
- File.dirname(asset),
152
- "#{File.basename(asset, '.*')}-#{fingerprint + output_ext(File.extname(asset))}",
153
- )
154
- else
155
- fingerprinted_asset = File.join(
156
- File.dirname(asset),
157
- File.basename(asset, '.*') + output_ext(File.extname(asset)),
158
- )
159
- end
160
-
161
- replaceable_asset = File.join(
162
- File.dirname(asset),
163
- File.basename(asset, '.*') + output_ext(File.extname(asset)),
164
- )
165
-
166
- manifest[replaceable_asset] = {
167
- original_ext: File.extname(asset),
168
- fingerprinted_asset: fingerprinted_asset
169
- }
170
- end
171
- end
172
-
173
- base = File.join(Pakyow::Config.app.root, Pakyow::Config.assets.compiled_asset_path)
174
-
175
- manifest.each do |replaceable_asset, info|
176
- next unless fingerprint_contents?(info[:original_ext])
177
-
178
- path = File.join(base, info[:fingerprinted_asset])
179
-
180
- content = File.read(path)
181
- File.open(path, 'wb') { |file|
182
- file.write(mixin_fingerprints(content))
183
- }
184
- end
185
- end
186
-
187
- def self.manifest
188
- @manifest ||= {}
189
- end
190
-
191
- def self.mixin_fingerprints(content)
192
- return content if content.nil? || content.empty?
193
-
194
- manifest.each do |asset, info|
195
- content = content.gsub(asset, info[:fingerprinted_asset])
196
- end
197
-
198
- content
199
- end
200
-
201
- def self.asset_hash(absolute_path)
202
- Digest::MD5.hexdigest(dependencies_for(absolute_path).concat([absolute_path]).map { |filename|
203
- Digest::MD5.file(filename).hexdigest
204
- }.flatten.join)
205
- end
206
-
207
- def self.dependencies_for(absolute_path)
208
- block = dependents[normalize_ext(File.extname(absolute_path))]
209
- return [] if block.nil?
210
- block.call(absolute_path)
211
- end
212
-
213
- def self.fingerprinted?(ext)
214
- preprocessor_for_ext(ext)[:fingerprint]
215
- end
216
-
217
- def self.fingerprint_contents?(ext)
218
- preprocessor_for_ext(ext)[:fingerprint_contents]
219
- end
220
- end
221
- end