data_uri_revived 0.1.1.beta1 → 0.1.1.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{README.rdoc → README.md} +30 -41
- data/Rakefile +0 -6
- data/lib/data_uri/uri.rb +3 -3
- metadata +33 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3f6487f4179dd2ebd1b1edf4ce32c2a0383e94ecd6547e3da10f5ce18fe4cf1
|
4
|
+
data.tar.gz: 73647509bd48cdbce11936e8feff14c1c3c5b5be6739127f56166dcb3a8e59f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e41cc6d37fdf6e593ffcf28f16b8847784563a698d224c23cd28a9166b7313862ddb99e91befc040518b23a80e1359754e322433b949bef795e1a20c35cc3fb2
|
7
|
+
data.tar.gz: d791d28ce5319db0224849b12b2d25132bdb4b7e67bc4e5821a80b4dd75869334079f41dc92460520992fcd8ea8507682cd7bb6449774f83f8e748f628934b37
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,8 +1,18 @@
|
|
1
|
-
|
1
|
+
# Data URI Revived
|
2
2
|
|
3
3
|
Fork of unmaintained original `data_uri` (No commit for 11 years)
|
4
4
|
|
5
|
-
|
5
|
+
## Status
|
6
|
+
|
7
|
+
[![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/data-uri-ruby/data_uri/tests.yaml?branch=master&style=flat-square)](https://github.com/data-uri-ruby/data_uri/actions/workflows/tests.yaml)
|
8
|
+
|
9
|
+
[![Gem Version](http://img.shields.io/gem/v/data_uri_revived.svg?style=flat-square)](http://badge.fury.io/rb/data_uri_revived)
|
10
|
+
[![License](https://img.shields.io/github/license/data-uri-ruby/data_uri.svg?style=flat-square)](http://badge.fury.io/rb/data_uri_revived)
|
11
|
+
|
12
|
+
[![Coverage Status](http://img.shields.io/coveralls/data-uri-ruby/data_uri.svg?style=flat-square)](https://coveralls.io/r/data-uri-ruby/data_uri)
|
13
|
+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/data-uri-ruby/data_uri.svg?style=flat-square)](https://codeclimate.com/github/data-uri-ruby/data_uri)
|
14
|
+
|
15
|
+
## Introduction
|
6
16
|
|
7
17
|
Data URIs allow resources to be embedded inside a URI. The URI::Data class
|
8
18
|
provides support for parsing these URIs using the normal URI.parse method.
|
@@ -11,27 +21,32 @@ I wrote it to support embedding binary data inside JSON messages in a
|
|
11
21
|
relatively reasonable way. If you find some other use for it, please drop me
|
12
22
|
a line.
|
13
23
|
|
14
|
-
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# Replacement of `data_uri`, do not mix with it
|
28
|
+
gem 'data_uri_revived'
|
29
|
+
```
|
15
30
|
|
16
|
-
|
17
|
-
gem 'data_uri_revived'
|
31
|
+
## Usage
|
18
32
|
|
19
|
-
|
33
|
+
```ruby
|
34
|
+
require 'data_uri_revived'
|
35
|
+
# Or the old one in case you have old require statements
|
36
|
+
require 'data_uri'
|
20
37
|
|
21
|
-
|
22
|
-
#
|
23
|
-
|
38
|
+
uri = URI::Data.new('data:image/gif;base64,...')
|
39
|
+
uri.content_type # image/gif
|
40
|
+
uri.data # Base64 decoded data
|
24
41
|
|
25
|
-
|
26
|
-
|
27
|
-
uri.data # Base64 decoded data
|
42
|
+
# Same as `URI::Data.new`
|
43
|
+
uri = URI.parse('data:image/gif;base64,...')
|
28
44
|
|
29
|
-
|
30
|
-
uri = URI.parse('data:image/gif;base64,...')
|
45
|
+
```
|
31
46
|
|
32
47
|
Data URIs CANNOT play nicely with open-uri (was mentioned to be working in original `data_uri` gem
|
33
48
|
|
34
|
-
|
49
|
+
## Features & Limitations
|
35
50
|
|
36
51
|
URI.parse knows about URI::Data, but unfortunately, its regexp for splitting
|
37
52
|
URIs into components maxes out at 92 characters for an opaque URI, which is
|
@@ -64,29 +79,3 @@ formats of the URIs it will try to open, and it's ambiguous to me at least if
|
|
64
79
|
data URIs can necessarily be distinguished from filesystem paths on all
|
65
80
|
platforms. Again, if this causes undue pain and suffering, we can commit
|
66
81
|
minor violence to open-uri to convince it to see reason.
|
67
|
-
|
68
|
-
== License:
|
69
|
-
|
70
|
-
(The MIT License)
|
71
|
-
|
72
|
-
Copyright (c) 2010 Donald Ball <donald.ball@gmail.com>
|
73
|
-
Copyright (c) 2025 PikachuEXE <git@pikachuexe.net>
|
74
|
-
|
75
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
76
|
-
a copy of this software and associated documentation files (the
|
77
|
-
'Software'), to deal in the Software without restriction, including
|
78
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
79
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
80
|
-
permit persons to whom the Software is furnished to do so, subject to
|
81
|
-
the following conditions:
|
82
|
-
|
83
|
-
The above copyright notice and this permission notice shall be
|
84
|
-
included in all copies or substantial portions of the Software.
|
85
|
-
|
86
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
87
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
88
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
89
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
90
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
91
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
92
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
data/lib/data_uri/uri.rb
CHANGED
@@ -16,7 +16,7 @@ module URI
|
|
16
16
|
def initialize(*args)
|
17
17
|
if args.length == 1
|
18
18
|
uri = args.first.to_s
|
19
|
-
unless uri.match(/^data:/)
|
19
|
+
unless uri.match?(/^data:/)
|
20
20
|
raise URI::InvalidURIError.new('Invalid Data URI: ' + args.first.inspect)
|
21
21
|
end
|
22
22
|
@scheme = 'data'
|
@@ -35,10 +35,10 @@ module URI
|
|
35
35
|
@mime_params[md[1]] = md[2]
|
36
36
|
@data = @data[md[0].length .. -1]
|
37
37
|
end
|
38
|
-
if (base64 = /^;base64/.match(@data))
|
38
|
+
if (base64 = /^;base64/.match?(@data))
|
39
39
|
@data = @data[7 .. -1]
|
40
40
|
end
|
41
|
-
unless /^,/.match(@data)
|
41
|
+
unless /^,/.match?(@data)
|
42
42
|
raise URI::InvalidURIError.new('Invalid data URI')
|
43
43
|
end
|
44
44
|
@data = @data[1 .. -1]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_uri_revived
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.
|
4
|
+
version: 0.1.1.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Donald Ball
|
@@ -52,22 +52,50 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov-lcov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
description: URI class for parsing data URIs
|
56
84
|
email:
|
57
85
|
- donald.ball@gmail.com
|
58
86
|
- git@pikachuexe.net
|
59
87
|
executables: []
|
60
88
|
extensions: []
|
61
|
-
extra_rdoc_files:
|
62
|
-
- README.rdoc
|
89
|
+
extra_rdoc_files: []
|
63
90
|
files:
|
64
|
-
- README.
|
91
|
+
- README.md
|
65
92
|
- Rakefile
|
66
93
|
- lib/data_uri.rb
|
67
94
|
- lib/data_uri/uri.rb
|
68
95
|
- lib/data_uri_revived.rb
|
69
96
|
homepage: https://github.com/data-uri-ruby/data_uri
|
70
|
-
licenses:
|
97
|
+
licenses:
|
98
|
+
- MIT
|
71
99
|
metadata: {}
|
72
100
|
rdoc_options: []
|
73
101
|
require_paths:
|