darkroom 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 518b5ff3d82631d41125029a7292c2bfdd8942990a7e92e2be08f99217fe8d02
4
- data.tar.gz: 388cf8db580df8de6d85a9d196786ef7400a97a096dfbbb316de4b0dbca8e295
3
+ metadata.gz: 1a77051a57dc9a5b32fe1ea1e96c831884183729058f1336139e15142d55a43f
4
+ data.tar.gz: 11ee7f486da94bf7c5dadf9af8e14fd9c1ab41a9620cc72c604885d9474d9150
5
5
  SHA512:
6
- metadata.gz: 439b783c5d7afcb20c6a5bde715f686e42236bd70251af909938784f3c4e855f3e22b8fa779b1de19478e64e17462dc4fe37d28f043c0a62f95d13cc8e40829a
7
- data.tar.gz: 3bb350472717b4a656e71ef3c7c1b8c200b88c7414c3f7feecfee46b19327e7d7bb5bb061878474d584c65afa84777cdf784fe76fd0cada86cecfbb20485fd13
6
+ metadata.gz: c4a4bb0e7cb9845154951aa703197be875b7777bba1f824d0bbba6ccfed609cebc9460a3c32db60ca846e819a0ac4b4a9c4024ba2b882a498108ef83230757d8
7
+ data.tar.gz: 83a14e41099925ae3ea44c23a18a044c1db1b1ca8fc10c15dabecf725270c32ec559165ef6e596852f5c7b22f2354ab92a0cdfadd654c1c8d22a6d9d2f5ae9f1
data/README.md CHANGED
@@ -6,6 +6,23 @@ performed for upload to a CDN or proxy server in production environments); this
6
6
  simple and performant in development. Darkroom also supports asset bundling for CSS and JavaScript using
7
7
  each language's native import statement syntax.
8
8
 
9
+ The following file types are supported out of the box, though support for others can be added (see the
10
+ [Extending](#extending) section):
11
+
12
+ | Name | Content Type | Exension(s) |
13
+ | ---------- |----------------------- |-------------|
14
+ | CSS | text/css | .css |
15
+ | JavaScript | application/javascript | .js |
16
+ | HTML | text/html | .htm, .html |
17
+ | HTX | application/javascript | .htx |
18
+ | ICO | image/x-icon | .ico |
19
+ | JPEG | image/jpeg | .jpg, .jpeg |
20
+ | PNG | image/png | .png |
21
+ | SVG | image/svg+xml | .svg |
22
+ | Text | text/plain | .txt |
23
+ | WOFF | font/woff | .woff |
24
+ | WOFF2 | font/woff2 | .woff2 |
25
+
9
26
  ## Installation
10
27
 
11
28
  Add this line to your Gemfile:
@@ -36,7 +53,7 @@ darkroom = Darkroom.new('app/assets', 'vendor/assets', '...',
36
53
  min_process_interval: 1, # Minimum time that must elapse between process calls
37
54
  )
38
55
 
39
- # Refreshe any assets that have been modified (in development, this should be called at the
56
+ # Refresh any assets that have been modified (in development, this should be called at the
40
57
  # beginning of each web request).
41
58
  darkroom.process
42
59
 
@@ -48,7 +65,7 @@ darkroom.dump('output/dir',
48
65
  ) # /favicon.ico or /robots.txt should be left out)
49
66
  ```
50
67
 
51
- Note that assets paths across all load path directories must be globally unique (e.g. the existance of both
68
+ Note that assets paths across all load path directories must be globally unique (e.g. the existence of both
52
69
  `app/assets/app.js` and `vendor/assets/app.js` will result in an error).
53
70
 
54
71
  To work with assets:
@@ -129,6 +146,23 @@ Imports can even be cyclical. If `asset-a.css` imports `asset-b.css` and vice-ve
129
146
  contain the content of both of those assets (though order will be different as an asset's own content always
130
147
  comes after any imported assets' contents).
131
148
 
149
+ ## Extending
150
+
151
+ Darkroom is extensible. Support for arbitrary file types can be added as follows (all named parameters are
152
+ optional):
153
+
154
+ ```ruby
155
+ Darkroom::Asset.add_spec('.extension1', 'extension2', '...', 'content/type',
156
+ dependency_regex: /import (?<path>.*)/, # Regex for identifying dependencies for bundling;
157
+ # must include `path` named capture group
158
+ compile_lib: 'some-compile-lib', # Name of library required for compilation
159
+ compile: -> (path, content) { '...' }, # Proc that returns compiled content
160
+ minify_lib: 'some-minify-lib', # Name of library required for minification
161
+ minify: -> (content) { '...' }, # Proc that returns minified content
162
+ )
163
+
164
+ ```
165
+
132
166
  ## Contributing
133
167
 
134
168
  Bug reports and pull requests are welcome on GitHub at https://github.com/npickens/darkroom.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/darkroom.rb CHANGED
@@ -11,13 +11,13 @@ require('darkroom/errors/processing_error')
11
11
  require('darkroom/errors/spec_not_defined_error')
12
12
 
13
13
  Darkroom::Asset.add_spec('.css', 'text/css',
14
- dependency_regex: /^ *@import +(?<quote>['"]) *(?<path>.*) *\g<quote> *; *$/,
15
- minify: -> (content) { CSSminify.compress(content) },
16
- minify_lib: 'cssminify',
14
+ dependency_regex: /^ *@import +#{Darkroom::Asset::IMPORT_PATH_REGEX} *; *$/,
15
+ minify: -> (content) { SassC::Engine.new(content, style: :compressed).render },
16
+ minify_lib: 'sassc',
17
17
  )
18
18
 
19
19
  Darkroom::Asset.add_spec('.js', 'application/javascript',
20
- dependency_regex: /^ *import +(?<quote>['"])(?<path>.*)\g<quote> *;? *$/,
20
+ dependency_regex: /^ *import +#{Darkroom::Asset::IMPORT_PATH_REGEX} *;? *$/,
21
21
  minify: -> (content) { Uglifier.compile(content, harmony: true) },
22
22
  minify_lib: 'uglifier',
23
23
  )
@@ -29,7 +29,7 @@ Darkroom::Asset.add_spec('.htx', 'application/javascript',
29
29
  minify_lib: Darkroom::Asset.spec('.js').minify_lib,
30
30
  )
31
31
 
32
- Darkroom::Asset.add_spec('.html', '.html', 'text/html')
32
+ Darkroom::Asset.add_spec('.htm', '.html', 'text/html')
33
33
  Darkroom::Asset.add_spec('.ico', 'image/x-icon')
34
34
  Darkroom::Asset.add_spec('.jpg', '.jpeg', 'image/jpeg')
35
35
  Darkroom::Asset.add_spec('.png', 'image/png')
@@ -11,6 +11,13 @@ class Darkroom
11
11
  DEPENDENCY_JOINER = "\n"
12
12
  EXTENSION_REGEX = /(?=\.\w+)/.freeze
13
13
 
14
+ OPEN_QUOTE = '(?<quote>[\'"])'
15
+ BODY = '((?!\k<quote>).|(?<!\\\\)\\\\(\\\\\\\\)*\k<quote>)*'
16
+ BODY_END = '(?<!\\\\)(\\\\\\\\)*'
17
+ CLOSE_QUOTE = '\k<quote>'
18
+
19
+ IMPORT_PATH_REGEX = /#{OPEN_QUOTE}(?<path>#{BODY}#{BODY_END})#{CLOSE_QUOTE}/.freeze
20
+
14
21
  @@specs = {}
15
22
 
16
23
  attr_reader(:content, :error, :errors, :path, :path_unversioned, :path_versioned)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Darkroom
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Pickens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,8 +44,10 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 6.0.0
47
- description: Darkroom provides simple web asset management complete with dependency
48
- bundling based on import statements, compilation, and minification.
47
+ description: Darkroom provides web asset compilation, bundling, and minification without
48
+ any external tools, manifest files, or special comment syntax. CSS and JavaScript
49
+ bundles are automatically generated based on import statements native to each language.
50
+ Darkroom is also extensible, allowing support to be added for arbitrary file types.
49
51
  email:
50
52
  executables: []
51
53
  extensions: []