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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9124601cc9971cbc427489e745f7ed368415eeee
4
- data.tar.gz: f02f28d79c01eec1e9aadb95abe8cfe487274260
2
+ SHA256:
3
+ metadata.gz: 5597370435dfd1e26fcccced419bc5436abb93b3b31525c403bdcf2fc548dca9
4
+ data.tar.gz: b67958a1549ac23dc5ad9ce6ab55119f9a45246be27b2d5eb271115ef3a8e3d7
5
5
  SHA512:
6
- metadata.gz: 16570e6d24c224f76c3da5203a93b842f1fff08e4363f07b6117ea81b1b133c4e476425d15d5acae4a94fc5733f0ae71aa9be3a1ab435e0dee9945c2d53911f2
7
- data.tar.gz: da92c615453e9d0bee84ff2bdc332c934511248d9cdc23879ca252fb589bf312b55dd8eb019c00899ba5d521f4e6ac809204be9a784b969d3e1565bda00f3103
6
+ metadata.gz: bc2e83ac37d70006121281900e9d1314ba785e766952437cc797126fcd43c5387e212b910650ec0cbf57821bc351c625eeafa2f4c40951944923c8fd75973abe
7
+ data.tar.gz: 0ee00729e16d86f9dbc5e920681e862df5b4526d8f530ff29382d80dac0b0e0779d2d7595015b06277066effef922b7624e015ae02d482fb35462526f4faca3d
@@ -1,8 +1,4 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - 2.0
5
- - 2.1
6
- - 2.2
7
- - 2.3.0
8
- - jruby-21mode
3
+ - "2.5"
4
+ - "2.6"
@@ -1,3 +1,7 @@
1
+ ## 2.0.0
2
+ * Add sprockets 4 support ([#9](https://github.com/ai/rails-sass-images/pull/9))
3
+ * Drop sprockets 3 support ([#9](https://github.com/ai/rails-sass-images/pull/9))
4
+
1
5
  ## 1.0.3
2
6
  * Fix Sprockets 3 support.
3
7
  * Better error message for wrong `load_from`.
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ gemspec
4
4
  gem 'rake'
5
5
  gem 'rspec-rails'
6
6
 
7
- gem 'rails', '>= 4'
8
- gem 'sass-rails', '>= 4'
7
+ gem 'rails', '>= 5'
8
+ gem 'sassc-rails'
@@ -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.pathname
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::Index
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 'sass'
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 Sass::Script::Functions
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
@@ -27,6 +27,6 @@ module RailsSassImages::Sass
27
27
  encoding = 'base64'
28
28
  end
29
29
 
30
- Sass::Script::String.new("url('data:#{mime};#{encoding},#{file}')")
30
+ SassC::Script::Value::String.new("url('data:#{mime};#{encoding},#{file}')")
31
31
  end
32
32
  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
- Sass::Script::Number.new(Dimensions.width(asset), ["px"])
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
- Sass::Script::Number.new(Dimensions.height(asset), ["px"])
13
+ SassC::Script::Value::Number.new(Dimensions.height(asset), ["px"])
14
14
  end
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module RailsSassImages
2
- VERSION = '1.0.3'.freeze unless defined? RailsSassImages::VERSION
2
+ VERSION = '2.0.0'.freeze unless defined? RailsSassImages::VERSION
3
3
  end
@@ -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 'sass', ['> 0']
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
@@ -1,6 +1,6 @@
1
1
  class CssController < ApplicationController
2
2
  def test
3
3
  file = params[:file] + '.css'
4
- render text: Rails.application.assets[file]
4
+ render plain: Rails.application.assets[file]
5
5
  end
6
6
  end
@@ -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 be_success
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 be_success
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 be_success
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 be_success
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 be_success
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 be_success
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: 1.0.3
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: 2016-01-26 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sass
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
- rubyforge_project:
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