inline_image 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -4
- data/lib/inline_image.rb +1 -1
- data/lib/inline_image/version.rb +1 -1
- data/spec/inline_image_spec.rb +4 -0
- metadata +14 -7
data/README.md
CHANGED
@@ -14,6 +14,7 @@ Installation
|
|
14
14
|
Usage and documentation
|
15
15
|
-----------------------
|
16
16
|
Brief usage description
|
17
|
+
|
17
18
|
inline_image help inline
|
18
19
|
|
19
20
|
Replace all image in a css file appearing in `url(img/name.png)` (max size 1024B)
|
@@ -29,10 +30,6 @@ Replace all image in a file with max size 2048B
|
|
29
30
|
inline_image inline /path/to/your_file --size=2048
|
30
31
|
inline_image inline /path/to/your_file -s 2048
|
31
32
|
|
32
|
-
Todo
|
33
|
-
----
|
34
|
-
Add option to specify how small the file must be transformed
|
35
|
-
|
36
33
|
License
|
37
34
|
-------
|
38
35
|
Released under The Unlicense, aka public domain. See the [LICENSE][license] file for further details.
|
data/lib/inline_image.rb
CHANGED
@@ -40,7 +40,7 @@ module InlineImage
|
|
40
40
|
def self.process(base_dir, name_in_file, max_file_size = MAX_FILE_SIZE)
|
41
41
|
image_filename = "#{base_dir}/#{name_in_file}"
|
42
42
|
extension = name_in_file.split('.').last
|
43
|
-
if File.size(image_filename) <= max_file_size then
|
43
|
+
if File.exist?(image_filename) and File.size(image_filename) <= max_file_size then
|
44
44
|
File.open(image_filename) do |img|
|
45
45
|
base64encoded = Base64.encode64(img.read).gsub("\n", "")
|
46
46
|
"data:image/#{extension};base64,#{base64encoded}"
|
data/lib/inline_image/version.rb
CHANGED
data/spec/inline_image_spec.rb
CHANGED
@@ -45,6 +45,10 @@ describe InlineImage do
|
|
45
45
|
InlineImage.process("spec/fixtures", "images/large.png").should eq("images/large.png")
|
46
46
|
end
|
47
47
|
|
48
|
+
it 'does not modify non-existent file' do
|
49
|
+
InlineImage.process('non/existant/path', 'non-existant-file').should eq('non-existant-file')
|
50
|
+
end
|
51
|
+
|
48
52
|
context "when processing css" do
|
49
53
|
it "replace small images in css" do
|
50
54
|
InlineImage.replace_in_css(SMALL_PNG_IN_CSS_BEFORE, "spec/fixtures").should eq(SMALL_PNG_IN_CSS_AFTER)
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Yann Mainier
|
@@ -14,16 +15,17 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-07-
|
18
|
-
default_executable:
|
18
|
+
date: 2011-07-25 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: thor
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
27
29
|
segments:
|
28
30
|
- 0
|
29
31
|
version: "0"
|
@@ -33,9 +35,11 @@ dependencies:
|
|
33
35
|
name: rspec
|
34
36
|
prerelease: false
|
35
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
36
39
|
requirements:
|
37
40
|
- - ">="
|
38
41
|
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
39
43
|
segments:
|
40
44
|
- 0
|
41
45
|
version: "0"
|
@@ -64,7 +68,6 @@ files:
|
|
64
68
|
- spec/fixtures/test.css
|
65
69
|
- spec/fixtures/test.html
|
66
70
|
- spec/inline_image_spec.rb
|
67
|
-
has_rdoc: true
|
68
71
|
homepage: https://github.com/ymainier/inline_image
|
69
72
|
licenses: []
|
70
73
|
|
@@ -74,23 +77,27 @@ rdoc_options: []
|
|
74
77
|
require_paths:
|
75
78
|
- lib
|
76
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
77
81
|
requirements:
|
78
82
|
- - ">="
|
79
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
80
85
|
segments:
|
81
86
|
- 0
|
82
87
|
version: "0"
|
83
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
84
90
|
requirements:
|
85
91
|
- - ">="
|
86
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
87
94
|
segments:
|
88
95
|
- 0
|
89
96
|
version: "0"
|
90
97
|
requirements: []
|
91
98
|
|
92
99
|
rubyforge_project: inline_image
|
93
|
-
rubygems_version: 1.
|
100
|
+
rubygems_version: 1.8.5
|
94
101
|
signing_key:
|
95
102
|
specification_version: 3
|
96
103
|
summary: Inline images within css and html files using data URI
|