darkroom 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c212cd979a1c11e4eb93a920a0b88bb20aae573fc8a0d290431203b77528eb3
4
- data.tar.gz: a20ba0476f0508f574924e5d3d848a29f4adb550b4b5a1dd9e1ae16812c67a4e
3
+ metadata.gz: bfceb46e778a627cdd5fb64a51224ce2fdbfabb27dc4020e625d470fd80050a5
4
+ data.tar.gz: 38478af8de2fb0c42f46857e204b05ba76fa5f18415e0ae7d66baaefb04a5d8f
5
5
  SHA512:
6
- metadata.gz: b8b038fe72b9e644eb323d3b2d8afecd3d525e7796687827cc621d556c1e593ffb1b95529e4336070819f837031b8b1ad45d1241465365336ec59f51d494367e
7
- data.tar.gz: fc3407836eb5a01317fb20177dc52ac1ea1e8a114cf955c136e46de2cf8d800ed344219e558f2baa5bb3ef1d3bce960d0b34d38f0574d00288de1fbef0fcd7f0
6
+ metadata.gz: 513abc20887e655aa9ecbcdfb706ae9c75d0e97907de7cd72e42aec6544839c4e96596f576b551b3e06dbc8d0fcd1edacbb212a662a017c6edbf0ed6c3111b58
7
+ data.tar.gz: e93f811868982d3ede4e64c848f9479a8564959845d0a1dea3a1bce980961d9fb8278513f969bfef45ac258fc39bce486c1915129ed69c914ffdce75ad0060ed
data/README.md CHANGED
@@ -44,9 +44,9 @@ project includes HTX templates or you wish to minify CSS and/or JavaScript asset
44
44
  to be added to your Gemfile:
45
45
 
46
46
  ```ruby
47
- gem('htx') # HTX compilation
48
- gem('sassc') # CSS minification
49
- gem('uglifier') # JavaScript and HTX minification
47
+ gem('htx') # HTX compilation
48
+ gem('sassc') # CSS minification
49
+ gem('terser') # JavaScript and HTX minification
50
50
  ```
51
51
 
52
52
  ## Usage
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -5,6 +5,12 @@ require('digest')
5
5
  require('set')
6
6
 
7
7
  require_relative('darkroom')
8
+ require_relative('errors/asset_error')
9
+ require_relative('errors/asset_not_found_error')
10
+ require_relative('errors/circular_reference_error')
11
+ require_relative('errors/missing_library_error')
12
+ require_relative('errors/processing_error')
13
+ require_relative('errors/unrecognized_extension_error')
8
14
 
9
15
  class Darkroom
10
16
  ##
@@ -241,8 +247,13 @@ class Darkroom
241
247
  # * +ignore+ - Assets already accounted for as dependency tree is walked (to prevent infinite loops when
242
248
  # circular chains are encountered).
243
249
  #
244
- def dependencies(ignore = Set.new)
245
- @dependencies ||= accumulate(:dependencies, ignore)
250
+ def dependencies(ignore = nil)
251
+ return @dependencies if @dependencies
252
+
253
+ dependencies = accumulate(:dependencies, ignore)
254
+ @dependencies = dependencies unless ignore
255
+
256
+ dependencies
246
257
  end
247
258
 
248
259
  ##
@@ -251,8 +262,13 @@ class Darkroom
251
262
  # * +ignore+ - Assets already accounted for as import tree is walked (to prevent infinite loops when
252
263
  # circular chains are encountered).
253
264
  #
254
- def imports(ignore = Set.new)
255
- @imports ||= accumulate(:imports, ignore)
265
+ def imports(ignore = nil)
266
+ return @imports if @imports
267
+
268
+ imports = accumulate(:imports, ignore)
269
+ @imports = imports unless ignore
270
+
271
+ imports
256
272
  end
257
273
 
258
274
  ##
@@ -419,7 +435,7 @@ class Darkroom
419
435
  # Darkroom does not explicitly depend on any libraries necessary for asset compilation or minification,
420
436
  # since not every app will use every kind of asset or use minification. It is instead up to each app
421
437
  # using Darkroom to specify any needed compilation and minification libraries as direct dependencies
422
- # (e.g. specify +gem('uglifier')+ in the app's Gemfile if JavaScript minification is desired).
438
+ # (e.g. specify +gem('terser')+ in the app's Gemfile if JavaScript minification is desired).
423
439
  #
424
440
  def require_libs
425
441
  begin
@@ -446,7 +462,9 @@ class Darkroom
446
462
  # circular references are encountered).
447
463
  #
448
464
  def accumulate(name, ignore)
465
+ ignore ||= Set.new
449
466
  ignore << self
467
+
450
468
  process
451
469
 
452
470
  instance_variable_get(:"@own_#{name}").each_with_object([]) do |asset, assets|
@@ -2,6 +2,12 @@
2
2
 
3
3
  require('set')
4
4
 
5
+ require_relative('asset')
6
+ require_relative('errors/asset_not_found_error')
7
+ require_relative('errors/duplicate_asset_error')
8
+ require_relative('errors/invalid_path_error')
9
+ require_relative('errors/processing_error')
10
+
5
11
  ##
6
12
  # Main class providing fast, lightweight, and straightforward web asset management.
7
13
  #
@@ -7,10 +7,8 @@ class Darkroom
7
7
  JavaScriptDelegate = Delegate.new(
8
8
  content_type: 'text/javascript',
9
9
  import_regex: /^ *import +#{QUOTED_PATH.source} *;? *(\n|$)/.freeze,
10
- minify_lib: 'uglifier',
11
- minify: ->(content) do
12
- Uglifier.compile(content, harmony: true)
13
- end,
10
+ minify_lib: 'terser',
11
+ minify: ->(content) { Terser.compile(content) },
14
12
  )
15
13
  end
16
14
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Darkroom
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.6'
5
5
  end
data/lib/darkroom.rb CHANGED
@@ -9,15 +9,6 @@ require('darkroom/delegates/html')
9
9
  require('darkroom/delegates/htx')
10
10
  require('darkroom/delegates/javascript')
11
11
 
12
- require('darkroom/errors/asset_error')
13
- require('darkroom/errors/asset_not_found_error')
14
- require('darkroom/errors/circular_reference_error')
15
- require('darkroom/errors/duplicate_asset_error')
16
- require('darkroom/errors/invalid_path_error')
17
- require('darkroom/errors/missing_library_error')
18
- require('darkroom/errors/processing_error')
19
- require('darkroom/errors/unrecognized_extension_error')
20
-
21
12
  Darkroom.register('.css', Darkroom::Asset::CSSDelegate)
22
13
  Darkroom.register('.htm', '.html', Darkroom::Asset::HTMLDelegate)
23
14
  Darkroom.register('.htx', Darkroom::Asset::HTXDelegate)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darkroom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Pickens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-31 00:00:00.000000000 Z
11
+ date: 2022-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler