roda-sprockets 1.0.2 → 1.1.0.rc1

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: 64c7457f4f6cca73af4aede33d7fbbe2922aac43a05a399af1658a2fa54250ec
4
- data.tar.gz: d14d895b6704ae71b20958df0e3d0fa054054b25862b529d6b94b15a6acbbb3d
3
+ metadata.gz: a4a70ad21f0db49bb53cea400c3e90c27e2cae1c1d791f5c6dd471ee89b27621
4
+ data.tar.gz: 4bb46d275d252145e7406463d9a6fd1e6171eacc1bc59ff45d10e977de3b030e
5
5
  SHA512:
6
- metadata.gz: 4e2fa406bc9c3d22c508e683bbe65e5424361b3cf73c6c10e09f470c2fe43bd288789a6c11df8d5c3deea7d3f28ece35cfc609f6942cbe2046309384aae05535
7
- data.tar.gz: 565f7f00f965f808cde41a95c9c1309cbfea91068f4f9090760b0d47e58bef41966855836c32f8981db72322f899aee32d109de046d3327d47a378330b330b92
6
+ metadata.gz: 26eee21ed69f840bc04a1b024bf7d4ce7347a12d917cbfcd3eada64a7b9a76288748e99889a40fe273a150c92702c2a7048c369b1445fc078d888300055458f2
7
+ data.tar.gz: 839696f0f772909e113c14776eccf09a961723ca2dd2c33aa6edf252b3d3fb3ddd078a5021889ffd292bd3f92d41c0510ec710afbad1af4af2ce9a2034c0a037
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ v1.1.0
2
+
3
+ - Fix the Rack::Lint issue (#1)
4
+ - :public_path argument to receive a default value (#7)
5
+ - Roda::RodaPlugins::Sprockets::Task to superclass SprocketsTask (#6)
6
+ - The debug logic now depends on :debug argument, not environment (#4)
7
+
8
+ v1.0.2
9
+
10
+ - :root argument to select a default argument more robustly (#2)
11
+
12
+ v1.0.1
13
+
14
+ - New :cache argument to plugin configuration
15
+
16
+ v1.0.0
17
+
18
+ - Sprockets 4.0 support
19
+
20
+ v0.0.11
21
+
22
+ - Support polyinstantiation, improve Opal support
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2015 cj
2
- Copyright (c) 2020 hmdne
2
+ Copyright (c) 2020-2021 hmdne and opal-sprockets contributors
3
3
 
4
4
  MIT License
5
5
 
data/README.md CHANGED
@@ -22,7 +22,7 @@ And then execute:
22
22
  ```ruby
23
23
  class App < Roda
24
24
  plugin :sprockets, precompile: %w(site.js site.css),
25
- public_path: 'public/',
25
+ public_path: 'public/assets/',
26
26
  opal: true,
27
27
  debug: true
28
28
  plugin :public
@@ -41,8 +41,9 @@ end
41
41
  but also supports absolute paths) - an array of directories where your
42
42
  assets are located, by default: `%w(assets vendor/assets)`.
43
43
  * `root` - a filesystem root directory of your app. By default, `app.opts[:root]`.
44
- * `public_path` - filesystem path to your `public` directory, for all your
45
- precompilation needs. (REQUIRED)
44
+ * `public_path` - filesystem path to a place, where precompiled assets will be
45
+ stored, by default: `public/assets` (it should be a directory from which `:public`
46
+ plugin takes files + `path_prefix`)
46
47
  * `path_prefix` - a Roda prefix of your assets directory. By default: `/assets`
47
48
  * `protocol` - either :http (default) or :https.
48
49
  * `css_compressor`, `js_compressor` - pick a compressor of your choice.
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "roda-sprockets", path: "../.."
4
+ gem "opal-sprockets"
5
+ gem "puma"
6
+ gem "rake"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ roda-sprockets (1.0.2)
5
+ roda (~> 3)
6
+ sprockets (>= 2.2)
7
+ sprockets-helpers (>= 1.4.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ concurrent-ruby (1.1.9)
14
+ nio4r (2.5.7)
15
+ opal (1.2.0)
16
+ ast (>= 2.3.0)
17
+ parser (~> 3.0)
18
+ opal-sprockets (1.0.1)
19
+ opal (>= 1.0, < 2.0)
20
+ sprockets (~> 4.0)
21
+ tilt (>= 1.4)
22
+ parser (3.0.2.0)
23
+ ast (~> 2.4.1)
24
+ puma (5.4.0)
25
+ nio4r (~> 2.0)
26
+ rack (2.2.3)
27
+ rake (13.0.6)
28
+ roda (3.46.0)
29
+ rack
30
+ sprockets (4.0.2)
31
+ concurrent-ruby (~> 1.0)
32
+ rack (> 1, < 3)
33
+ sprockets-helpers (1.4.0)
34
+ sprockets (>= 2.2)
35
+ tilt (2.0.10)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ opal-sprockets
42
+ puma
43
+ rake
44
+ roda-sprockets!
45
+
46
+ BUNDLED WITH
47
+ 2.1.4
@@ -0,0 +1,4 @@
1
+ This is an example found in `opal` repository in `docs/roda-sprockets.md`.
2
+
3
+ It describes how to create the simplest application with roda, roda-sprockets
4
+ and opal.
@@ -0,0 +1,6 @@
1
+ require "bundler/setup"
2
+ require "roda/plugins/sprockets_task"
3
+
4
+ require_relative "app"
5
+
6
+ Roda::RodaPlugins::Sprockets::Task.define!(App)
@@ -0,0 +1,26 @@
1
+ require 'roda'
2
+
3
+ class App < Roda
4
+ plugin :sprockets, precompile: %w(application.js),
5
+ prefix: %w(app/),
6
+ opal: true,
7
+ debug: ENV['RACK_ENV'] != 'production'
8
+ plugin :public
9
+
10
+ route do |r|
11
+ r.public
12
+ r.sprockets
13
+
14
+ r.root do
15
+ <<~END
16
+ <!doctype html>
17
+ <html>
18
+ <head>
19
+ #{ javascript_tag 'application' }
20
+ #{ opal_require 'application' }
21
+ </head>
22
+ </html>
23
+ END
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ require 'opal'
2
+
3
+ puts "wow, running ruby!"
@@ -0,0 +1,3 @@
1
+ require_relative "app"
2
+
3
+ run App.app
@@ -10,7 +10,7 @@ class Roda
10
10
  precompile: %w(app.js app.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2),
11
11
  prefix: %w(assets vendor/assets),
12
12
  root: false,
13
- public_path: false,
13
+ public_path: "public/assets/",
14
14
  path_prefix: "/assets",
15
15
  protocol: :http,
16
16
  css_compressor: nil,
@@ -22,10 +22,6 @@ class Roda
22
22
  cache: nil,
23
23
  }.freeze
24
24
 
25
- def self.load_dependencies(app, _opts = nil)
26
- app.plugin :environments
27
- end
28
-
29
25
  def self.configure(app, plugin_options = {})
30
26
  if app.opts[:sprockets]
31
27
  app.opts[:sprockets].merge!(plugin_options)
@@ -39,8 +35,6 @@ class Roda
39
35
  options[:root] = app.opts[:root] || Dir.pwd
40
36
  end
41
37
 
42
- %i(root public_path).each { |type| raise "#{type} needs to be set." unless options[type] }
43
-
44
38
  # opal-sprockets registers engines when required, but if we create Sprockets::Environment before
45
39
  # requiring that, they don't get registered
46
40
  require 'opal/sprockets' if options[:opal]
@@ -85,7 +79,7 @@ class Roda
85
79
  options[:sprockets_helpers].prefix = options[:path_prefix] unless options[:path_prefix].nil?
86
80
  options[:sprockets_helpers].debug = options[:debug]
87
81
 
88
- app.configure :staging, :production do
82
+ unless options[:debug]
89
83
  options[:sprockets].css_compressor = options[:css_compressor] unless options[:css_compressor].nil?
90
84
  options[:sprockets].js_compressor = options[:js_compressor] unless options[:js_compressor].nil?
91
85
 
@@ -138,15 +132,20 @@ class Roda
138
132
 
139
133
  status, headers, response = options[:sprockets].call env_sprockets
140
134
 
141
- # Appease Rack::Lint
142
- if (300..399).include? status
143
- headers.delete("Content-type")
144
- end
145
-
146
135
  scope.response.status = status
147
136
  scope.response.headers.merge! headers
148
137
 
149
- response.is_a?(Array) ? response.join('\n') : response.to_s
138
+ case response
139
+ when nil, []
140
+ # Empty response happens for example when 304 Not Modified happens.
141
+ # We want to return nil in this case.
142
+ # (See: https://github.com/hmdne/roda-sprockets/issues/1)
143
+ nil
144
+ when Array
145
+ response.join("\n")
146
+ else
147
+ response.to_s
148
+ end
150
149
  end
151
150
  end
152
151
  end
@@ -5,20 +5,40 @@ require 'rake/sprocketstask'
5
5
  class Roda
6
6
  module RodaPlugins
7
7
  module Sprockets
8
- class Task < Rake::TaskLib
8
+ class Task < Rake::SprocketsTask
9
9
  def initialize(app_klass)
10
+ @app_klass = app_klass
11
+ super() { update_values }
12
+ end
13
+
14
+ def update_values
15
+ @environment = sprockets_options[:sprockets]
16
+ @output = sprockets_options[:public_path]
17
+ @assets = sprockets_options[:precompile]
18
+ end
19
+
20
+ def sprockets_options
21
+ @opts ||= begin
22
+ opts = @app_klass.sprockets_options.dup
23
+ opts[:debug] = false
24
+ opts
25
+ end
26
+ end
27
+
28
+ def define
10
29
  namespace :assets do
11
30
  desc "Precompile assets"
12
31
  task :precompile do
13
- options = app_klass.sprockets_options
14
- environment = options[:sprockets]
15
- manifest = ::Sprockets::Manifest.new(environment.index, options[:public_path])
16
- manifest.compile(options[:precompile])
32
+ with_logger do
33
+ manifest.compile(assets)
34
+ end
17
35
  end
18
36
 
19
37
  desc "Clean assets"
20
38
  task :clean do
21
- FileUtils.rm_rf(app_klass.sprockets_options[:public_path])
39
+ with_logger do
40
+ manifest.clobber
41
+ end
22
42
  end
23
43
  end
24
44
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "roda-sprockets"
7
- spec.version = '1.0.2'
7
+ spec.version = '1.1.0.rc1'
8
8
  spec.authors = ["cj", "hmdne"]
9
9
  spec.email = ["cjlazell@gmail.com"]
10
10
  spec.summary = %q{Use sprockets to serve assets in roda.}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-08-13 00:00:00.000000000 Z
12
+ date: 2021-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: roda
@@ -89,10 +89,18 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
+ - CHANGELOG.md
92
93
  - Gemfile
93
94
  - LICENSE.txt
94
95
  - README.md
95
96
  - Rakefile
97
+ - examples/opal-doc/Gemfile
98
+ - examples/opal-doc/Gemfile.lock
99
+ - examples/opal-doc/README.md
100
+ - examples/opal-doc/Rakefile
101
+ - examples/opal-doc/app.rb
102
+ - examples/opal-doc/app/application.rb
103
+ - examples/opal-doc/config.ru
96
104
  - lib/roda/plugins/sprockets.rb
97
105
  - lib/roda/plugins/sprockets_task.rb
98
106
  - lib/roda/sprockets.rb
@@ -112,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
120
  version: '0'
113
121
  required_rubygems_version: !ruby/object:Gem::Requirement
114
122
  requirements:
115
- - - ">="
123
+ - - ">"
116
124
  - !ruby/object:Gem::Version
117
- version: '0'
125
+ version: 1.3.1
118
126
  requirements: []
119
127
  rubygems_version: 3.2.22
120
128
  signing_key: