himg 0.0.1 → 0.0.3

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.
@@ -0,0 +1,329 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ himg (0.0.2)
5
+ rb_sys (~> 0.9)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (8.0.2)
11
+ actionpack (= 8.0.2)
12
+ activesupport (= 8.0.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ zeitwerk (~> 2.6)
16
+ actionmailbox (8.0.2)
17
+ actionpack (= 8.0.2)
18
+ activejob (= 8.0.2)
19
+ activerecord (= 8.0.2)
20
+ activestorage (= 8.0.2)
21
+ activesupport (= 8.0.2)
22
+ mail (>= 2.8.0)
23
+ actionmailer (8.0.2)
24
+ actionpack (= 8.0.2)
25
+ actionview (= 8.0.2)
26
+ activejob (= 8.0.2)
27
+ activesupport (= 8.0.2)
28
+ mail (>= 2.8.0)
29
+ rails-dom-testing (~> 2.2)
30
+ actionpack (8.0.2)
31
+ actionview (= 8.0.2)
32
+ activesupport (= 8.0.2)
33
+ nokogiri (>= 1.8.5)
34
+ rack (>= 2.2.4)
35
+ rack-session (>= 1.0.1)
36
+ rack-test (>= 0.6.3)
37
+ rails-dom-testing (~> 2.2)
38
+ rails-html-sanitizer (~> 1.6)
39
+ useragent (~> 0.16)
40
+ actiontext (8.0.2)
41
+ actionpack (= 8.0.2)
42
+ activerecord (= 8.0.2)
43
+ activestorage (= 8.0.2)
44
+ activesupport (= 8.0.2)
45
+ globalid (>= 0.6.0)
46
+ nokogiri (>= 1.8.5)
47
+ actionview (8.0.2)
48
+ activesupport (= 8.0.2)
49
+ builder (~> 3.1)
50
+ erubi (~> 1.11)
51
+ rails-dom-testing (~> 2.2)
52
+ rails-html-sanitizer (~> 1.6)
53
+ activejob (8.0.2)
54
+ activesupport (= 8.0.2)
55
+ globalid (>= 0.3.6)
56
+ activemodel (8.0.2)
57
+ activesupport (= 8.0.2)
58
+ activerecord (8.0.2)
59
+ activemodel (= 8.0.2)
60
+ activesupport (= 8.0.2)
61
+ timeout (>= 0.4.0)
62
+ activestorage (8.0.2)
63
+ actionpack (= 8.0.2)
64
+ activejob (= 8.0.2)
65
+ activerecord (= 8.0.2)
66
+ activesupport (= 8.0.2)
67
+ marcel (~> 1.0)
68
+ activesupport (8.0.2)
69
+ base64
70
+ benchmark (>= 0.3)
71
+ bigdecimal
72
+ concurrent-ruby (~> 1.0, >= 1.3.1)
73
+ connection_pool (>= 2.2.5)
74
+ drb
75
+ i18n (>= 1.6, < 2)
76
+ logger (>= 1.4.2)
77
+ minitest (>= 5.1)
78
+ securerandom (>= 0.3)
79
+ tzinfo (~> 2.0, >= 2.0.5)
80
+ uri (>= 0.13.1)
81
+ appraisal (2.5.0)
82
+ bundler
83
+ rake
84
+ thor (>= 0.14.0)
85
+ ast (2.4.3)
86
+ base64 (0.2.0)
87
+ benchmark (0.4.0)
88
+ bigdecimal (3.1.9)
89
+ builder (3.3.0)
90
+ bump (0.10.0)
91
+ concurrent-ruby (1.3.5)
92
+ connection_pool (2.5.1)
93
+ crass (1.0.6)
94
+ csv (3.3.4)
95
+ date (3.4.1)
96
+ debug (1.10.0)
97
+ irb (~> 1.10)
98
+ reline (>= 0.3.8)
99
+ diff-lcs (1.6.1)
100
+ drb (2.2.1)
101
+ erubi (1.13.1)
102
+ ffi (1.17.2-aarch64-linux-gnu)
103
+ ffi (1.17.2-aarch64-linux-musl)
104
+ ffi (1.17.2-arm-linux-gnu)
105
+ ffi (1.17.2-arm-linux-musl)
106
+ ffi (1.17.2-arm64-darwin)
107
+ ffi (1.17.2-x86_64-darwin)
108
+ ffi (1.17.2-x86_64-linux-gnu)
109
+ ffi (1.17.2-x86_64-linux-musl)
110
+ fileutils (1.7.3)
111
+ globalid (1.2.1)
112
+ activesupport (>= 6.1)
113
+ i18n (1.14.7)
114
+ concurrent-ruby (~> 1.0)
115
+ io-console (0.8.0)
116
+ irb (1.15.2)
117
+ pp (>= 0.6.0)
118
+ rdoc (>= 4.0.0)
119
+ reline (>= 0.4.2)
120
+ json (2.10.2)
121
+ language_server-protocol (3.17.0.4)
122
+ lint_roller (1.1.0)
123
+ listen (3.9.0)
124
+ rb-fsevent (~> 0.10, >= 0.10.3)
125
+ rb-inotify (~> 0.9, >= 0.9.10)
126
+ logger (1.7.0)
127
+ loofah (2.24.0)
128
+ crass (~> 1.0.2)
129
+ nokogiri (>= 1.12.0)
130
+ mail (2.8.1)
131
+ mini_mime (>= 0.1.1)
132
+ net-imap
133
+ net-pop
134
+ net-smtp
135
+ marcel (1.0.4)
136
+ mini_mime (1.1.5)
137
+ minitest (5.25.5)
138
+ mutex_m (0.3.0)
139
+ net-imap (0.5.6)
140
+ date
141
+ net-protocol
142
+ net-pop (0.1.2)
143
+ net-protocol
144
+ net-protocol (0.2.2)
145
+ timeout
146
+ net-smtp (0.5.1)
147
+ net-protocol
148
+ nio4r (2.7.4)
149
+ nokogiri (1.18.8-aarch64-linux-gnu)
150
+ racc (~> 1.4)
151
+ nokogiri (1.18.8-aarch64-linux-musl)
152
+ racc (~> 1.4)
153
+ nokogiri (1.18.8-arm-linux-gnu)
154
+ racc (~> 1.4)
155
+ nokogiri (1.18.8-arm-linux-musl)
156
+ racc (~> 1.4)
157
+ nokogiri (1.18.8-arm64-darwin)
158
+ racc (~> 1.4)
159
+ nokogiri (1.18.8-x86_64-darwin)
160
+ racc (~> 1.4)
161
+ nokogiri (1.18.8-x86_64-linux-gnu)
162
+ racc (~> 1.4)
163
+ nokogiri (1.18.8-x86_64-linux-musl)
164
+ racc (~> 1.4)
165
+ parallel (1.27.0)
166
+ parser (3.3.8.0)
167
+ ast (~> 2.4.1)
168
+ racc
169
+ pp (0.6.2)
170
+ prettyprint
171
+ prettyprint (0.2.0)
172
+ prism (1.4.0)
173
+ psych (5.2.3)
174
+ date
175
+ stringio
176
+ racc (1.8.1)
177
+ rack (3.1.13)
178
+ rack-session (2.1.0)
179
+ base64 (>= 0.1.0)
180
+ rack (>= 3.0.0)
181
+ rack-test (2.2.0)
182
+ rack (>= 1.3)
183
+ rackup (2.2.1)
184
+ rack (>= 3)
185
+ rails (8.0.2)
186
+ actioncable (= 8.0.2)
187
+ actionmailbox (= 8.0.2)
188
+ actionmailer (= 8.0.2)
189
+ actionpack (= 8.0.2)
190
+ actiontext (= 8.0.2)
191
+ actionview (= 8.0.2)
192
+ activejob (= 8.0.2)
193
+ activemodel (= 8.0.2)
194
+ activerecord (= 8.0.2)
195
+ activestorage (= 8.0.2)
196
+ activesupport (= 8.0.2)
197
+ bundler (>= 1.15.0)
198
+ railties (= 8.0.2)
199
+ rails-dom-testing (2.2.0)
200
+ activesupport (>= 5.0.0)
201
+ minitest
202
+ nokogiri (>= 1.6)
203
+ rails-html-sanitizer (1.6.2)
204
+ loofah (~> 2.21)
205
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
206
+ railties (8.0.2)
207
+ actionpack (= 8.0.2)
208
+ activesupport (= 8.0.2)
209
+ irb (~> 1.13)
210
+ rackup (>= 1.0.0)
211
+ rake (>= 12.2)
212
+ thor (~> 1.0, >= 1.2.2)
213
+ zeitwerk (~> 2.6)
214
+ rainbow (3.1.1)
215
+ rake (13.2.1)
216
+ rake-compiler (1.3.0)
217
+ rake
218
+ rake-compiler-dock (1.9.1)
219
+ rb-fsevent (0.11.2)
220
+ rb-inotify (0.11.1)
221
+ ffi (~> 1.0)
222
+ rb_sys (0.9.111)
223
+ rake-compiler-dock (= 1.9.1)
224
+ rbs (3.9.2)
225
+ logger
226
+ rdoc (6.13.1)
227
+ psych (>= 4.0.0)
228
+ regexp_parser (2.10.0)
229
+ reline (0.6.1)
230
+ io-console (~> 0.5)
231
+ rspec (3.13.0)
232
+ rspec-core (~> 3.13.0)
233
+ rspec-expectations (~> 3.13.0)
234
+ rspec-mocks (~> 3.13.0)
235
+ rspec-core (3.13.3)
236
+ rspec-support (~> 3.13.0)
237
+ rspec-expectations (3.13.3)
238
+ diff-lcs (>= 1.2.0, < 2.0)
239
+ rspec-support (~> 3.13.0)
240
+ rspec-mocks (3.13.2)
241
+ diff-lcs (>= 1.2.0, < 2.0)
242
+ rspec-support (~> 3.13.0)
243
+ rspec-rails (7.1.1)
244
+ actionpack (>= 7.0)
245
+ activesupport (>= 7.0)
246
+ railties (>= 7.0)
247
+ rspec-core (~> 3.13)
248
+ rspec-expectations (~> 3.13)
249
+ rspec-mocks (~> 3.13)
250
+ rspec-support (~> 3.13)
251
+ rspec-support (3.13.2)
252
+ rubocop (1.75.2)
253
+ json (~> 2.3)
254
+ language_server-protocol (~> 3.17.0.2)
255
+ lint_roller (~> 1.1.0)
256
+ parallel (~> 1.10)
257
+ parser (>= 3.3.0.2)
258
+ rainbow (>= 2.2.2, < 4.0)
259
+ regexp_parser (>= 2.9.3, < 3.0)
260
+ rubocop-ast (>= 1.44.0, < 2.0)
261
+ ruby-progressbar (~> 1.7)
262
+ unicode-display_width (>= 2.4.0, < 4.0)
263
+ rubocop-ast (1.44.1)
264
+ parser (>= 3.3.7.2)
265
+ prism (~> 1.4)
266
+ ruby-progressbar (1.13.0)
267
+ securerandom (0.4.1)
268
+ steep (1.10.0)
269
+ activesupport (>= 5.1)
270
+ concurrent-ruby (>= 1.1.10)
271
+ csv (>= 3.0.9)
272
+ fileutils (>= 1.1.0)
273
+ json (>= 2.1.0)
274
+ language_server-protocol (>= 3.17.0.4, < 4.0)
275
+ listen (~> 3.0)
276
+ logger (>= 1.3.0)
277
+ mutex_m (>= 0.3.0)
278
+ parser (>= 3.1)
279
+ rainbow (>= 2.2.2, < 4.0)
280
+ rbs (~> 3.9)
281
+ securerandom (>= 0.1)
282
+ strscan (>= 1.0.0)
283
+ terminal-table (>= 2, < 5)
284
+ uri (>= 0.12.0)
285
+ stringio (3.1.7)
286
+ strscan (3.1.3)
287
+ terminal-table (4.0.0)
288
+ unicode-display_width (>= 1.1.1, < 4)
289
+ thor (1.3.2)
290
+ timeout (0.4.3)
291
+ tzinfo (2.0.6)
292
+ concurrent-ruby (~> 1.0)
293
+ unicode-display_width (3.1.4)
294
+ unicode-emoji (~> 4.0, >= 4.0.4)
295
+ unicode-emoji (4.0.4)
296
+ uri (1.0.3)
297
+ useragent (0.16.11)
298
+ websocket-driver (0.7.7)
299
+ base64
300
+ websocket-extensions (>= 0.1.0)
301
+ websocket-extensions (0.1.5)
302
+ zeitwerk (2.7.2)
303
+
304
+ PLATFORMS
305
+ aarch64-linux-gnu
306
+ aarch64-linux-musl
307
+ arm-linux-gnu
308
+ arm-linux-musl
309
+ arm64-darwin
310
+ x86_64-darwin
311
+ x86_64-linux-gnu
312
+ x86_64-linux-musl
313
+
314
+ DEPENDENCIES
315
+ appraisal
316
+ bump
317
+ debug
318
+ himg!
319
+ irb
320
+ rails (~> 8.0)
321
+ rake
322
+ rake-compiler
323
+ rspec
324
+ rspec-rails (~> 7.0)
325
+ rubocop
326
+ steep
327
+
328
+ BUNDLED WITH
329
+ 2.6.7
@@ -0,0 +1,32 @@
1
+ module Himg
2
+ class Railtie
3
+ # Handles .himg templates by calling through to Himg.render
4
+ class TemplateHandler
5
+ def self.call(_template, source)
6
+ <<-CODE
7
+ Himg.render(#{source.inspect})
8
+ CODE
9
+ end
10
+ end
11
+
12
+ # Handles .himg.erb templates by pre-processing with Erb, possibly appending
13
+ # to @output_buffer or calling .safe_append, and then passing the result to
14
+ # Himg.render
15
+ class ErbTemplateHandler
16
+ def self.call(template, source)
17
+ erb_handler = ActionView::Template.registered_template_handler(:erb)
18
+ preprocessed_view_code = erb_handler.call(template, source)
19
+
20
+ <<-CODE
21
+ output = begin
22
+ #{preprocessed_view_code}
23
+ end
24
+ Himg.render(output)
25
+ CODE
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ ActionView::Template.register_template_handler :himg, Himg::Railtie::TemplateHandler
32
+ ActionView::Template.register_template_handler "himg.erb", Himg::Railtie::ErbTemplateHandler
@@ -0,0 +1,38 @@
1
+ module Himg
2
+ # Himg::Railtie
3
+ #
4
+ # Allows you to render Png images directly from rails using HTML based templates.
5
+ #
6
+ # View templates can be registered with `.himg` and will be converted from
7
+ # HTML to an image, or with `.himg.erb` to insert dynamic content. A renderer
8
+ # also allows direct rendering of HTML without going through a template.
9
+ #
10
+ # Example usage:
11
+ # - `show.himg.erb` renders an image based on controller data.
12
+ # - `render himg: '<div>My Data</div>'` generates an image from HTML.
13
+ #
14
+ # This works by registering a template handler, which will be called by Rails'
15
+ # default_render method when a view template exists matching the current action
16
+ # in a request where the format extension is .himg or a png is requested.
17
+ #
18
+ # The direct render works similarly, but instead of checking the request format
19
+ # it looks for the :himg key passed into a Rails render function.
20
+ class Railtie < Rails::Railtie
21
+ initializer "himg.configure_rails_initialization" do
22
+ ActiveSupport.on_load(:action_view) do
23
+ require "himg/railtie/template_handler"
24
+ end
25
+ end
26
+
27
+ initializer "himg.mime_types" do
28
+ Mime::Type.register "image/png", :himg
29
+ end
30
+
31
+ initializer "himg.controller_renderer" do
32
+ ActionController::Renderers.add :himg do |obj, _options|
33
+ png_data = Himg.render(obj)
34
+ send_data png_data, type: "image/png", disposition: "inline"
35
+ end
36
+ end
37
+ end
38
+ end
data/lib/himg/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Himg
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.3"
5
5
  end
data/lib/himg.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "himg/version"
4
+ require "himg/railtie" if defined?(Rails::Railtie)
4
5
 
5
6
  # Attempt to load a versioned extension based on the Ruby version.
6
7
  # Fall back to loading the non-versioned extension if version-specific loading fails.
@@ -15,5 +16,5 @@ end
15
16
  #
16
17
  # Converts HTML to an Image for a minimal subset of HTML and CSS
17
18
  module Himg
18
- #class Error < StandardError; end
19
+ class Error < StandardError; end
19
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: himg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Edwards-Jones
@@ -23,7 +23,133 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0.9'
26
- description: Generates images from a minimal subset of HTML and CSS
26
+ - !ruby/object:Gem::Dependency
27
+ name: appraisal
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: bump
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: debug
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: irb
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rake-compiler
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: rubocop
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ - !ruby/object:Gem::Dependency
139
+ name: steep
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ description: You give it HTML and it renders an Image!
27
153
  email:
28
154
  - git@jamedjo.co.uk
29
155
  executables: []
@@ -32,8 +158,9 @@ extensions:
32
158
  extra_rdoc_files: []
33
159
  files:
34
160
  - ".rspec"
161
+ - ".rubocop.yml"
35
162
  - ".ruby-version"
36
- - ".standard.yml"
163
+ - Appraisals
37
164
  - CHANGELOG.md
38
165
  - Cargo.lock
39
166
  - Cargo.toml
@@ -54,10 +181,23 @@ files:
54
181
  - ext/himg/src/logger.rs
55
182
  - ext/himg/src/options.rs
56
183
  - ext/himg/src/writer.rs
184
+ - gemfiles/plain_ruby.gemfile
185
+ - gemfiles/plain_ruby.gemfile.lock
186
+ - gemfiles/rails_6.gemfile
187
+ - gemfiles/rails_6.gemfile.lock
188
+ - gemfiles/rails_7_0.gemfile
189
+ - gemfiles/rails_7_0.gemfile.lock
190
+ - gemfiles/rails_7_1.gemfile
191
+ - gemfiles/rails_7_1.gemfile.lock
192
+ - gemfiles/rails_7_2.gemfile
193
+ - gemfiles/rails_7_2.gemfile.lock
194
+ - gemfiles/rails_8.gemfile
195
+ - gemfiles/rails_8.gemfile.lock
57
196
  - lib/himg.rb
197
+ - lib/himg/railtie.rb
198
+ - lib/himg/railtie/template_handler.rb
58
199
  - lib/himg/version.rb
59
200
  - sig/himg.rbs
60
- - test.html.rbd
61
201
  homepage: https://github.com/Jamedjo/Himg
62
202
  licenses:
63
203
  - MIT
data/.standard.yml DELETED
@@ -1,3 +0,0 @@
1
- # For available configuration options, see:
2
- # https://github.com/standardrb/standard
3
- ruby_version: 3.1
data/test.html.rbd DELETED
@@ -1,5 +0,0 @@
1
- <div style="background-color: red; width: '100%'; height: '100%'>
2
-
3
- <h1>Hello World</h1>
4
- __From_Rust_Ruby__
5
- </div>