roda-opal_assets 0.3.1 → 0.3.2

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
- SHA1:
3
- metadata.gz: 78483143ca6323ed106c3df87544fb46f338b51b
4
- data.tar.gz: cf89f87cfe8f943ed21e1f87ca2b49714f1001b4
2
+ SHA256:
3
+ metadata.gz: ad04aa05c883c414533c871375b6f517f31a11edb1758e3e83c23a57e4ba5946
4
+ data.tar.gz: 43a137e08f7b490ba2bc8dd03e9c613521bfc3d4dab261b37e4935a7db495558
5
5
  SHA512:
6
- metadata.gz: 5ba01491457fcc2e0def724ffa949316de65fa06b2b83274ec233f736577f7763e7b9a11a43a917b2f140090df0db84f9189b4434fd675c2ee8ca73365151763
7
- data.tar.gz: 16308e2aea93de44a00e4e025b46aaa6033c19ff475bca246672c590a85be92e67d7d7b383e9c054ab6279abefcae2365af20f806f89f19b5711ff920b8d82af
6
+ metadata.gz: cc94fa13d04889372e6c4579c69bc00abb28bf2f7f51e2a34959e93a4a5d64579733edc707fe950e446e96da3424f3ed4eeda419331eb7ca2724ec4893fd5cc7
7
+ data.tar.gz: f5dff7c431360408886d3ecec922ddb0954f1d21462ea9065b60ba152b4d150fa405fb527f33e230e824c5fba1623b6abce4b4dc870e155c4d99ecf62dfd23c2
@@ -29,6 +29,12 @@ class Roda
29
29
  r.on 'assets/css' do
30
30
  r.run sprockets
31
31
  end
32
+ r.on 'assets/images' do
33
+ r.run sprockets
34
+ end
35
+ r.on 'assets' do
36
+ r.run sprockets
37
+ end
32
38
  end
33
39
  end
34
40
 
@@ -68,6 +74,27 @@ class Roda
68
74
 
69
75
  %{<link href="#{path}" media="#{media}" rel="stylesheet" />}
70
76
  end
77
+ alias css stylesheet
78
+
79
+ def image file, **attrs
80
+ path = if production?
81
+ "/assets/#{manifest[file]}"
82
+ else
83
+ asset = sprockets[file]
84
+
85
+ if asset.nil?
86
+ raise "File not found: #{file}"
87
+ end
88
+
89
+ "/assets/images/#{asset.digest_path}"
90
+ end
91
+
92
+ attrs = attrs.each_with_object('') do |(key, value), string|
93
+ string << " #{key}=#{value}"
94
+ end
95
+
96
+ %{<img src="#{path}"#{attrs}/>}
97
+ end
71
98
 
72
99
  def << asset
73
100
  @assets << asset
@@ -80,7 +107,9 @@ class Roda
80
107
  print "Compiling #{file}..."
81
108
  asset = sprockets[file]
82
109
  hash[file] = asset.digest_path
83
- compile_file file, "public/assets/#{asset.digest_path}"
110
+ filename = "public/assets/#{asset.digest_path}"
111
+ FileUtils.mkdir_p File.dirname(filename)
112
+ compile_file file, filename
84
113
  puts ' done'
85
114
  end
86
115
 
@@ -107,6 +136,8 @@ class Roda
107
136
  end
108
137
  sprockets.append_path 'assets/js'
109
138
  sprockets.append_path 'assets/css'
139
+ sprockets.append_path 'assets/images'
140
+ sprockets.append_path 'assets'
110
141
 
111
142
  sprockets.js_compressor = :uglifier if @minify
112
143
 
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class OpalAssets
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-opal_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Gaskins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-24 00:00:00.000000000 Z
11
+ date: 2018-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.5.1
169
+ rubygems_version: 2.7.6
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Compile Opal assets trivially on Roda