rails-sass-images 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -6
- data/ChangeLog.md +4 -0
- data/Gemfile +2 -2
- data/lib/rails-sass-images.rb +2 -2
- data/lib/rails-sass-images/sass.rb +12 -2
- data/lib/rails-sass-images/sass/inline.rb +1 -1
- data/lib/rails-sass-images/sass/size.rb +2 -2
- data/lib/rails-sass-images/version.rb +1 -1
- data/rails-sass-images.gemspec +1 -1
- data/spec/app/app/assets/config/manifest.js +0 -0
- data/spec/app/app/controllers/css_controller.rb +1 -1
- data/spec/rails_spec.rb +13 -13
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5597370435dfd1e26fcccced419bc5436abb93b3b31525c403bdcf2fc548dca9
|
4
|
+
data.tar.gz: b67958a1549ac23dc5ad9ce6ab55119f9a45246be27b2d5eb271115ef3a8e3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc2e83ac37d70006121281900e9d1314ba785e766952437cc797126fcd43c5387e212b910650ec0cbf57821bc351c625eeafa2f4c40951944923c8fd75973abe
|
7
|
+
data.tar.gz: 0ee00729e16d86f9dbc5e920681e862df5b4526d8f530ff29382d80dac0b0e0779d2d7595015b06277066effef922b7624e015ae02d482fb35462526f4faca3d
|
data/.travis.yml
CHANGED
data/ChangeLog.md
CHANGED
data/Gemfile
CHANGED
data/lib/rails-sass-images.rb
CHANGED
@@ -13,7 +13,7 @@ module RailsSassImages
|
|
13
13
|
elsif sprockets? @load_from
|
14
14
|
asset = @load_from[path]
|
15
15
|
raise "Can't find asset #{path}" unless asset
|
16
|
-
asset = asset.
|
16
|
+
asset = Pathname.new(asset.filename)
|
17
17
|
else
|
18
18
|
raise "Unknown type of RailsSassImages.load_from"
|
19
19
|
end
|
@@ -43,7 +43,7 @@ private
|
|
43
43
|
# Safe detect is `var` is a Sprockets environment
|
44
44
|
def self.sprockets?(var)
|
45
45
|
return false unless defined? Sprockets
|
46
|
-
var.is_a? Sprockets::Environment or var.is_a? Sprockets::
|
46
|
+
var.is_a? Sprockets::Environment or var.is_a? Sprockets::CachedEnvironment
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -1,8 +1,18 @@
|
|
1
|
-
require '
|
1
|
+
require 'sassc'
|
2
2
|
|
3
3
|
dir = Pathname(__FILE__).dirname.join('sass')
|
4
4
|
Dir.glob(dir.join('*.rb').to_s) { |ext| require ext }
|
5
5
|
|
6
|
-
module
|
6
|
+
module SassC::Script::Functions
|
7
7
|
include RailsSassImages::Sass
|
8
8
|
end
|
9
|
+
|
10
|
+
if defined? Sprockets
|
11
|
+
module Sprockets
|
12
|
+
class SasscProcessor
|
13
|
+
module Functions
|
14
|
+
include RailsSassImages::Sass
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -4,12 +4,12 @@ module RailsSassImages::Sass
|
|
4
4
|
# Get image width
|
5
5
|
def image_width(path)
|
6
6
|
asset = RailsSassImages.asset(path)
|
7
|
-
|
7
|
+
SassC::Script::Value::Number.new(Dimensions.width(asset), ["px"])
|
8
8
|
end
|
9
9
|
|
10
10
|
# Get image height
|
11
11
|
def image_height(path)
|
12
12
|
asset = RailsSassImages.asset(path)
|
13
|
-
|
13
|
+
SassC::Script::Value::Number.new(Dimensions.height(asset), ["px"])
|
14
14
|
end
|
15
15
|
end
|
data/rails-sass-images.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.homepage = 'https://github.com/ai/rails-sass-images'
|
19
19
|
s.license = 'MIT'
|
20
20
|
|
21
|
-
s.add_dependency '
|
21
|
+
s.add_dependency 'sassc', ['> 0']
|
22
22
|
s.add_dependency 'dimensions', ['> 0']
|
23
23
|
s.add_dependency 'mime-types', ['> 0']
|
24
24
|
end
|
File without changes
|
data/spec/rails_spec.rb
CHANGED
@@ -7,40 +7,40 @@ describe CssController, type: :controller do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "inlines assets" do
|
10
|
-
get :test, file: 'inline'
|
11
|
-
expect(response).to
|
10
|
+
get :test, params: { file: 'inline' }
|
11
|
+
expect(response).to be_successful
|
12
12
|
expect(response.body).to eq ".icon{background:#{INLINE}}\n"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "raises error on unknown file" do
|
16
16
|
expect {
|
17
|
-
get :test, file: 'wrong-inline'
|
17
|
+
get :test, params: { file: 'wrong-inline' }
|
18
18
|
}.to raise_error(/Can't find asset no\.png/)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "gets image size" do
|
22
|
-
get :test, file: 'size'
|
23
|
-
expect(response).to
|
22
|
+
get :test, params: { file: 'size' }
|
23
|
+
expect(response).to be_successful
|
24
24
|
expect(response.body).to eq ".icon{width:4px;height:6px}\n"
|
25
25
|
end
|
26
26
|
|
27
27
|
it "gets image size by mixin" do
|
28
|
-
get :test, file: 'image-size'
|
29
|
-
expect(response).to
|
28
|
+
get :test, params: { file: 'image-size' }
|
29
|
+
expect(response).to be_successful
|
30
30
|
expect(response.body).to eq ".icon{width:4px;height:6px}\n"
|
31
31
|
end
|
32
32
|
|
33
33
|
it "has hidpi-background mixin" do
|
34
|
-
get :test, file: 'hidpi-background'
|
35
|
-
expect(response).to
|
34
|
+
get :test, params: { file: 'hidpi-background' }
|
35
|
+
expect(response).to be_successful
|
36
36
|
expect(response.body).to include ".icon{" +
|
37
37
|
"background-image:url(/assets/monolith"
|
38
38
|
expect(response.body).to include "background-size:2px 3px}"
|
39
39
|
end
|
40
40
|
|
41
41
|
it "has hidpi-image mixin" do
|
42
|
-
get :test, file: 'hidpi-image'
|
43
|
-
expect(response).to
|
42
|
+
get :test, params: { file: 'hidpi-image' }
|
43
|
+
expect(response).to be_successful
|
44
44
|
expect(response.body).to include ".icon{" +
|
45
45
|
"width:2px;height:3px;" +
|
46
46
|
"background-image:url(/assets/monolith"
|
@@ -49,8 +49,8 @@ describe CssController, type: :controller do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "has hidpi-inline mixin" do
|
52
|
-
get :test, file: 'hidpi-inline'
|
53
|
-
expect(response).to
|
52
|
+
get :test, params: { file: 'hidpi-inline' }
|
53
|
+
expect(response).to be_successful
|
54
54
|
expect(response.body).to eq ".icon{" +
|
55
55
|
"width:2px;height:3px;" +
|
56
56
|
"background:#{INLINE} no-repeat;" +
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-sass-images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey "A.I." Sitnik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: sassc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">"
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/rails-sass-images/version.rb
|
83
83
|
- rails-sass-images.gemspec
|
84
84
|
- spec/app/.gitignore
|
85
|
+
- spec/app/app/assets/config/manifest.js
|
85
86
|
- spec/app/app/assets/images/monolith.png
|
86
87
|
- spec/app/app/assets/images/square.svg
|
87
88
|
- spec/app/app/assets/stylesheets/hidpi-background.sass
|
@@ -123,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.5.1
|
127
|
+
rubygems_version: 3.0.3
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Sass functions and mixins to inline images and get images size
|