darkroom 0.0.8 → 0.0.10

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.
@@ -1,30 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Darkroom
4
- ##
5
- # Error class used when an asset exists under multiple load paths.
6
- #
4
+ # Error class used when the same asset path exists under multiple load paths.
7
5
  class DuplicateAssetError < StandardError
8
6
  attr_reader(:path, :first_load_path, :second_load_path)
9
7
 
10
- ##
11
- # Creates a new instance.
12
- #
13
- # [path] Path of the asset that exists under multiple load paths.
14
- # [first_load_path] Load path where the asset was first found.
15
- # [second_load_path] Load path where the asset was subsequently found.
8
+ # Public: Create a new instance.
16
9
  #
10
+ # path - String path of the asset that exists under multiple load paths.
11
+ # first_load_path - String load path where the asset was first found.
12
+ # second_load_path - String load path where the asset was subsequently found.
17
13
  def initialize(path, first_load_path, second_load_path)
14
+ super("Asset file exists in both #{first_load_path} and #{second_load_path}: #{path}")
15
+
18
16
  @path = path
19
17
  @first_load_path = first_load_path
20
18
  @second_load_path = second_load_path
21
19
  end
22
-
23
- ##
24
- # Returns a string representation of the error.
25
- #
26
- def to_s
27
- "Asset file exists in both #{@first_load_path} and #{@second_load_path}: #{@path}"
28
- end
29
20
  end
30
21
  end
@@ -3,28 +3,19 @@
3
3
  require_relative('../asset')
4
4
 
5
5
  class Darkroom
6
- ##
7
6
  # Error class used when an asset's path contains one or more invalid characters.
8
- #
9
7
  class InvalidPathError < StandardError
10
8
  attr_reader(:path, :index)
11
9
 
12
- ##
13
- # Creates a new instance.
14
- #
15
- # [path] Path of the asset with the invalid character(s).
16
- # [index] Position of the first bad character in the path.
10
+ # Public: Create a new instance.
17
11
  #
12
+ # path - Path of the asset with the invalid character(s).
13
+ # index - Position of the first bad character in the path.
18
14
  def initialize(path, index)
15
+ super("Asset path contains one or more invalid characters (#{Asset::DISALLOWED_PATH_CHARS}): #{path}")
16
+
19
17
  @path = path
20
18
  @index = index
21
19
  end
22
-
23
- ##
24
- # Returns a string representation of the error.
25
- #
26
- def to_s
27
- "Asset path contains one or more invalid characters (#{Asset::DISALLOWED_PATH_CHARS}): #{@path}"
28
- end
29
20
  end
30
21
  end
@@ -1,31 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Darkroom
4
- ##
5
4
  # Error class used when a needed library cannot be loaded. See Asset#require_libs.
6
- #
7
5
  class MissingLibraryError < StandardError
8
6
  attr_reader(:library, :need, :extension)
9
7
 
10
- ##
11
- # Creates a new instance.
12
- #
13
- # [library] Name of the library that's missing.
14
- # [need] Reason the library is needed ('pre-process', 'post-process', or 'minify').
15
- # [extension] Extension of the type of asset that needs the library.
8
+ # Public: Create a new instance.
16
9
  #
10
+ # library - String name of the library that's missing.
11
+ # need - Symbol or String reason the library is needed (:compile, :finalize, or :minify).
12
+ # extension - String extension of the type of asset that needs the library.
17
13
  def initialize(library, need, extension)
14
+ super("Cannot #{need} #{extension} files: '#{library}' library not available [hint: try adding " \
15
+ "gem('#{library}') to your Gemfile]")
16
+
18
17
  @library = library
19
18
  @need = need
20
19
  @extension = extension
21
20
  end
22
-
23
- ##
24
- # Returns a string representation of the error.
25
- #
26
- def to_s
27
- "Cannot #{@need} #{@extension} file(s): #{@library} library not available [hint: try adding "\
28
- "gem('#{@library}') to your Gemfile]"
29
- end
30
21
  end
31
22
  end
@@ -1,35 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Darkroom
4
- ##
5
4
  # Error class used to wrap all accumulated errors encountered during asset processing.
6
- #
7
5
  class ProcessingError < StandardError
8
- ##
9
- # Creates a new instance.
10
- #
11
- # [errors] Error or array of errors.
6
+ include(Enumerable)
7
+
8
+ # Public: Create a new instance.
12
9
  #
10
+ # errors - Error or Array of errors.
13
11
  def initialize(errors)
14
12
  @errors = Array(errors)
15
- end
16
13
 
17
- ##
18
- # Returns a string representation of the error.
19
- #
20
- def to_s
21
- lines = @errors.map do |error|
22
- error.kind_of?(AssetError) ? error.to_s : "#{error.inspect} at #{error.backtrace[0]}"
23
- end
24
-
25
- "Errors were encountered while processing assets:\n #{lines.join("\n ")}"
14
+ super("Errors were encountered while processing assets:\n #{@errors.map(&:to_s).join("\n ")}")
26
15
  end
27
16
 
28
- ##
29
- # Passes any missing method call on to the @errors array.
17
+ # Public: Iterate over each error.
18
+ #
19
+ # block - Block to call and pass each error to.
20
+ #
21
+ # Yields each error to the provided block.
30
22
  #
31
- def method_missing(m, *args, &block)
32
- @errors.send(m, *args, &block)
23
+ # Returns Enumerator object.
24
+ def each(&block)
25
+ @errors.each(&block)
33
26
  end
34
27
  end
35
28
  end
@@ -3,17 +3,13 @@
3
3
  require_relative('asset_error')
4
4
 
5
5
  class Darkroom
6
- ##
7
6
  # Error class used when a reference is made to a file with an unrecognized extension.
8
- #
9
7
  class UnrecognizedExtensionError < AssetError
10
- ##
11
- # Creates a new instance.
12
- #
13
- # [file] File with the unrecognized extension.
14
- # [source_path] Path of the asset that contains the error.
15
- # [source_line_num] Line number in the asset where the error is located.
8
+ # Public: Create a new instance.
16
9
  #
10
+ # file - String file path with the unrecognized extension.
11
+ # source_path - String path of the asset that contains the error.
12
+ # source_line_num - Integer line number in the asset file where the error is located.
17
13
  def initialize(file, source_path = nil, source_line_num = nil)
18
14
  super('File extension not recognized', file, source_path, source_line_num)
19
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Darkroom
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.10'
5
5
  end
data/lib/darkroom.rb CHANGED
@@ -1,16 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require('darkroom/asset')
4
3
  require('darkroom/darkroom')
5
- require('darkroom/delegate')
6
4
  require('darkroom/version')
7
5
 
8
- require('darkroom/delegates/css')
9
- require('darkroom/delegates/html')
10
- require('darkroom/delegates/htx')
11
- require('darkroom/delegates/javascript')
6
+ require('darkroom/delegates/css_delegate')
7
+ require('darkroom/delegates/html_delegate')
8
+ require('darkroom/delegates/htx_delegate')
9
+ require('darkroom/delegates/javascript_delegate')
12
10
 
11
+ Darkroom.register('.apng', 'image/apng')
12
+ Darkroom.register('.avif', 'image/avif')
13
13
  Darkroom.register('.css', Darkroom::CSSDelegate)
14
+ Darkroom.register('.gif', 'image/gif')
14
15
  Darkroom.register('.htm', '.html', Darkroom::HTMLDelegate)
15
16
  Darkroom.register('.htx', Darkroom::HTXDelegate)
16
17
  Darkroom.register('.ico', 'image/x-icon')
@@ -20,5 +21,6 @@ Darkroom.register('.json', 'application/json')
20
21
  Darkroom.register('.png', 'image/png')
21
22
  Darkroom.register('.svg', 'image/svg+xml')
22
23
  Darkroom.register('.txt', 'text/plain')
24
+ Darkroom.register('.webp', 'image/webp')
23
25
  Darkroom.register('.woff', 'font/woff')
24
26
  Darkroom.register('.woff2', 'font/woff2')
metadata CHANGED
@@ -1,58 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darkroom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Pickens
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-07-16 00:00:00.000000000 Z
10
+ date: 2025-02-19 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
13
+ name: base64
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
18
+ version: '0.2'
19
+ type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '2.0'
25
+ version: '0.2'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: minitest
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 5.11.2
34
- - - "<"
30
+ - - "~>"
35
31
  - !ruby/object:Gem::Version
36
- version: 6.0.0
32
+ version: '5.24'
37
33
  type: :development
38
34
  prerelease: false
39
35
  version_requirements: !ruby/object:Gem::Requirement
40
36
  requirements:
41
- - - ">="
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '5.24'
40
+ - !ruby/object:Gem::Dependency
41
+ name: minitest-reporters
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
42
45
  - !ruby/object:Gem::Version
43
- version: 5.11.2
44
- - - "<"
46
+ version: '1.7'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
45
52
  - !ruby/object:Gem::Version
46
- version: 6.0.0
53
+ version: '1.7'
47
54
  description: Darkroom provides web asset compilation, bundling, and minification without
48
55
  any external tools, manifest files, or special comment syntax. CSS and JavaScript
49
56
  bundles are automatically generated based on import statements native to each language.
50
57
  Darkroom is also extensible, allowing support to be added for arbitrary file types.
51
- email:
52
58
  executables: []
53
59
  extensions: []
54
60
  extra_rdoc_files: []
55
61
  files:
62
+ - CHANGELOG.md
56
63
  - LICENSE
57
64
  - README.md
58
65
  - VERSION
@@ -60,10 +67,10 @@ files:
60
67
  - lib/darkroom/asset.rb
61
68
  - lib/darkroom/darkroom.rb
62
69
  - lib/darkroom/delegate.rb
63
- - lib/darkroom/delegates/css.rb
64
- - lib/darkroom/delegates/html.rb
65
- - lib/darkroom/delegates/htx.rb
66
- - lib/darkroom/delegates/javascript.rb
70
+ - lib/darkroom/delegates/css_delegate.rb
71
+ - lib/darkroom/delegates/html_delegate.rb
72
+ - lib/darkroom/delegates/htx_delegate.rb
73
+ - lib/darkroom/delegates/javascript_delegate.rb
67
74
  - lib/darkroom/errors/asset_error.rb
68
75
  - lib/darkroom/errors/asset_not_found_error.rb
69
76
  - lib/darkroom/errors/circular_reference_error.rb
@@ -77,10 +84,10 @@ homepage: https://github.com/npickens/darkroom
77
84
  licenses:
78
85
  - MIT
79
86
  metadata:
80
- allowed_push_host: https://rubygems.org
81
- homepage_uri: https://github.com/npickens/darkroom
82
- source_code_uri: https://github.com/npickens/darkroom
83
- post_install_message:
87
+ bug_tracker_uri: https://github.com/npickens/darkroom/issues
88
+ changelog_uri: https://github.com/npickens/darkroom/blob/master/CHANGELOG.md
89
+ documentation_uri: https://github.com/npickens/darkroom/blob/0.0.10/README.md
90
+ source_code_uri: https://github.com/npickens/darkroom/tree/0.0.10
84
91
  rdoc_options: []
85
92
  require_paths:
86
93
  - lib
@@ -88,15 +95,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
95
  requirements:
89
96
  - - ">="
90
97
  - !ruby/object:Gem::Version
91
- version: 2.5.8
98
+ version: 3.0.0
92
99
  required_rubygems_version: !ruby/object:Gem::Requirement
93
100
  requirements:
94
101
  - - ">="
95
102
  - !ruby/object:Gem::Version
96
- version: '0'
103
+ version: 2.0.0
97
104
  requirements: []
98
- rubygems_version: 3.4.15
99
- signing_key:
105
+ rubygems_version: 3.6.3
100
106
  specification_version: 4
101
- summary: A fast, lightweight, and straightforward web asset management library.
107
+ summary: A simple and straightforward web asset management library.
102
108
  test_files: []