rails-sass-images 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,10 +1,7 @@
1
1
  language: ruby
2
2
  bundler_args: --without development
3
3
  rvm:
4
- - 1.8.7
5
4
  - 1.9.3
6
5
  - 2.0.0
7
- - jruby-18mode
8
6
  - jruby-19mode
9
- - rbx-18mode
10
7
  - rbx-19mode
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.3 (Michelangelo di Lodovico Buonarroti Simoni)
2
+ * Allow to use with Sprockets in plain Ruby application.
3
+ * Clean up code by removing Ruby 1.8 support.
4
+
1
5
  == 0.2 (Raffaello Sanzio da Urbino)
2
6
  * Rename retina-image and retina-inline mixins to hidpi-image and hidpi-inline.
3
7
 
data/Gemfile CHANGED
@@ -3,3 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
  gem 'rake'
5
5
  gem 'rspec-rails'
6
+
7
+ gem 'rails', '>= 4.0.0.rc1'
8
+ gem 'sass-rails', '>= 4.0.0.rc1'
9
+ gem 'sprockets-rails', '>= 2.0.0.rc4'
data/Gemfile.lock CHANGED
@@ -1,82 +1,72 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-sass-images (0.2)
4
+ rails-sass-images (0.3)
5
5
  dimensions (> 0)
6
- rails (>= 3.1)
7
- sass-rails (> 0)
6
+ mime-types (> 0)
7
+ sass (> 0)
8
+ sprockets (> 0)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- actionmailer (3.2.13)
13
- actionpack (= 3.2.13)
13
+ actionmailer (4.0.0.rc1)
14
+ actionpack (= 4.0.0.rc1)
14
15
  mail (~> 2.5.3)
15
- actionpack (3.2.13)
16
- activemodel (= 3.2.13)
17
- activesupport (= 3.2.13)
18
- builder (~> 3.0.0)
16
+ actionpack (4.0.0.rc1)
17
+ activesupport (= 4.0.0.rc1)
18
+ builder (~> 3.1.0)
19
19
  erubis (~> 2.7.0)
20
- journey (~> 1.0.4)
21
- rack (~> 1.4.5)
22
- rack-cache (~> 1.2)
23
- rack-test (~> 0.6.1)
24
- sprockets (~> 2.2.1)
25
- activemodel (3.2.13)
26
- activesupport (= 3.2.13)
27
- builder (~> 3.0.0)
28
- activerecord (3.2.13)
29
- activemodel (= 3.2.13)
30
- activesupport (= 3.2.13)
31
- arel (~> 3.0.2)
32
- tzinfo (~> 0.3.29)
33
- activeresource (3.2.13)
34
- activemodel (= 3.2.13)
35
- activesupport (= 3.2.13)
36
- activesupport (3.2.13)
37
- i18n (= 0.6.1)
38
- multi_json (~> 1.0)
39
- arel (3.0.2)
40
- builder (3.0.4)
20
+ rack (~> 1.5.2)
21
+ rack-test (~> 0.6.2)
22
+ activemodel (4.0.0.rc1)
23
+ activesupport (= 4.0.0.rc1)
24
+ builder (~> 3.1.0)
25
+ activerecord (4.0.0.rc1)
26
+ activemodel (= 4.0.0.rc1)
27
+ activerecord-deprecated_finders (~> 1.0.2)
28
+ activesupport (= 4.0.0.rc1)
29
+ arel (~> 4.0.0)
30
+ activerecord-deprecated_finders (1.0.2)
31
+ activesupport (4.0.0.rc1)
32
+ i18n (~> 0.6, >= 0.6.4)
33
+ minitest (~> 4.2)
34
+ multi_json (~> 1.3)
35
+ thread_safe (~> 0.1)
36
+ tzinfo (~> 0.3.37)
37
+ arel (4.0.0)
38
+ atomic (1.1.9)
39
+ builder (3.1.4)
41
40
  diff-lcs (1.2.4)
42
41
  dimensions (1.2.0)
43
42
  erubis (2.7.0)
44
43
  hike (1.2.2)
45
- i18n (0.6.1)
46
- journey (1.0.4)
47
- json (1.7.7)
44
+ i18n (0.6.4)
48
45
  mail (2.5.3)
49
46
  i18n (>= 0.4.0)
50
47
  mime-types (~> 1.16)
51
48
  treetop (~> 1.4.8)
52
49
  mime-types (1.23)
53
- multi_json (1.7.2)
50
+ minitest (4.7.4)
51
+ multi_json (1.7.3)
54
52
  polyglot (0.3.3)
55
- rack (1.4.5)
56
- rack-cache (1.2)
57
- rack (>= 0.4)
58
- rack-ssl (1.3.3)
59
- rack
53
+ rack (1.5.2)
60
54
  rack-test (0.6.2)
61
55
  rack (>= 1.0)
62
- rails (3.2.13)
63
- actionmailer (= 3.2.13)
64
- actionpack (= 3.2.13)
65
- activerecord (= 3.2.13)
66
- activeresource (= 3.2.13)
67
- activesupport (= 3.2.13)
68
- bundler (~> 1.0)
69
- railties (= 3.2.13)
70
- railties (3.2.13)
71
- actionpack (= 3.2.13)
72
- activesupport (= 3.2.13)
73
- rack-ssl (~> 1.3.2)
56
+ rails (4.0.0.rc1)
57
+ actionmailer (= 4.0.0.rc1)
58
+ actionpack (= 4.0.0.rc1)
59
+ activerecord (= 4.0.0.rc1)
60
+ activesupport (= 4.0.0.rc1)
61
+ bundler (>= 1.3.0, < 2.0)
62
+ railties (= 4.0.0.rc1)
63
+ sprockets-rails (~> 2.0.0.rc4)
64
+ railties (4.0.0.rc1)
65
+ actionpack (= 4.0.0.rc1)
66
+ activesupport (= 4.0.0.rc1)
74
67
  rake (>= 0.8.7)
75
- rdoc (~> 3.4)
76
- thor (>= 0.14.6, < 2.0)
68
+ thor (>= 0.18.1, < 2.0)
77
69
  rake (10.0.4)
78
- rdoc (3.12.2)
79
- json (~> 1.4)
80
70
  rspec-core (2.13.1)
81
71
  rspec-expectations (2.13.0)
82
72
  diff-lcs (>= 1.1.3, < 2.0)
@@ -89,17 +79,24 @@ GEM
89
79
  rspec-expectations (~> 2.13.0)
90
80
  rspec-mocks (~> 2.13.0)
91
81
  sass (3.2.8)
92
- sass-rails (3.2.6)
93
- railties (~> 3.2.0)
82
+ sass-rails (4.0.0.rc1)
83
+ railties (>= 4.0.0.beta, < 5.0)
94
84
  sass (>= 3.1.10)
85
+ sprockets-rails (~> 2.0.0.rc0)
95
86
  tilt (~> 1.3)
96
- sprockets (2.2.2)
87
+ sprockets (2.9.3)
97
88
  hike (~> 1.2)
98
89
  multi_json (~> 1.0)
99
90
  rack (~> 1.0)
100
91
  tilt (~> 1.1, != 1.3.0)
92
+ sprockets-rails (2.0.0.rc4)
93
+ actionpack (>= 3.0)
94
+ activesupport (>= 3.0)
95
+ sprockets (~> 2.8)
101
96
  thor (0.18.1)
102
- tilt (1.3.7)
97
+ thread_safe (0.1.0)
98
+ atomic
99
+ tilt (1.4.0)
103
100
  treetop (1.4.12)
104
101
  polyglot
105
102
  polyglot (>= 0.3.1)
@@ -109,6 +106,9 @@ PLATFORMS
109
106
  ruby
110
107
 
111
108
  DEPENDENCIES
109
+ rails (>= 4.0.0.rc1)
112
110
  rails-sass-images!
113
111
  rake
114
112
  rspec-rails
113
+ sass-rails (>= 4.0.0.rc1)
114
+ sprockets-rails (>= 2.0.0.rc4)
data/README.md CHANGED
@@ -47,6 +47,8 @@ see [Autoprefixer](https://github.com/ai/autoprefixer).
47
47
 
48
48
  ## Usage
49
49
 
50
+ ### Ruby on Rails
51
+
50
52
  Add gem to your Rails `Gemfile`:
51
53
 
52
54
  ```ruby
@@ -58,3 +60,20 @@ and import mixins in your `application.sass`:
58
60
  ```sass
59
61
  @import "rails-sass-images"
60
62
  ```
63
+
64
+ # Other
65
+
66
+ You can use Rails Sass Images with plain Ruby application with Sprockets.
67
+ Just install in to Sprockets environment:
68
+
69
+ ```ruby
70
+ require 'rails-sass-images'
71
+
72
+ RailsSassImages.install(sprockets_env)
73
+ ```
74
+
75
+ and import mixins in your Sass files:
76
+
77
+ ```sass
78
+ @import "rails-sass-images"
79
+ ```
@@ -17,21 +17,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  =end
18
18
 
19
19
  require 'pathname'
20
- dir = Pathname(__FILE__).dirname.join('rails-sass-images')
21
20
 
22
21
  module RailsSassImages
23
- # Enable `lib/assets/`
24
- class Engine < ::Rails::Engine
25
- end
26
-
27
22
  # Return asset by file `path` from Sass parser
28
23
  def self.asset(path)
29
24
  path = path.value
30
- asset = Rails.application.assets[path]
25
+ asset = self.assets[path]
31
26
  raise "Can't find asset #{path}" unless asset
32
27
  asset
33
28
  end
29
+
30
+ # Set Sprockets environment and add Rails Sass Images styles paths
31
+ def self.install(sprockets)
32
+ sprockets.append_path(Pathname(__FILE__).dirname.join('assets/stylesheets'))
33
+ self.assets = sprockets
34
+ end
35
+
36
+ # Set Sprockets environment
37
+ def self.assets=(env = nil)
38
+ @assets = env
39
+ end
40
+
41
+ # Get Sprockets environment
42
+ def self.assets
43
+ @assets
44
+ end
34
45
  end
35
46
 
47
+ dir = Pathname(__FILE__).dirname.join('rails-sass-images')
36
48
  require dir.join('version')
37
49
  require dir.join('sass')
50
+ require dir.join('railtie') if defined?(Rails)
@@ -0,0 +1,30 @@
1
+ =begin
2
+ Copyright 2013 Andrey “A.I.” Sitnik <andrey@sitnik.ru>,
3
+ sponsored by Evil Martians.
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ =end
18
+
19
+ module RailsSassImages
20
+ # Enable `lib/assets/`
21
+ class Engine < ::Rails::Engine
22
+ end
23
+
24
+ # Rails integration
25
+ class Railtie < Rails::Railtie
26
+ initializer 'rails-sass-images' do
27
+ RailsSassImages.assets = Rails.application.assets
28
+ end
29
+ end
30
+ end
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Lesser General Public License
16
16
  along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  =end
18
18
 
19
- require 'sass-rails'
19
+ require 'sass'
20
20
 
21
21
  dir = Pathname(__FILE__).dirname.join('sass')
22
22
  Dir.glob(dir.join('*.rb').to_s) { |ext| require ext }
@@ -1,3 +1,3 @@
1
1
  module RailsSassImages
2
- VERSION = '0.2'.freeze unless defined? RailsSassImages::VERSION
2
+ VERSION = '0.3'.freeze unless defined? RailsSassImages::VERSION
3
3
  end
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.email = 'andrey@sitnik.ru'
18
18
  s.homepage = 'https://github.com/ai/rails-sass-images'
19
19
 
20
- s.add_dependency 'sass-rails', ['> 0']
20
+ s.add_dependency 'sass', ['> 0']
21
+ s.add_dependency 'sprockets', ['> 0']
21
22
  s.add_dependency 'dimensions', ['> 0']
22
- s.add_dependency 'rails', ['>= 3.1']
23
+ s.add_dependency 'mime-types', ['> 0']
23
24
  end
@@ -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 text: Rails.application.assets[file]
5
5
  end
6
6
  end
@@ -4,7 +4,7 @@ require "action_controller/railtie"
4
4
  require "sprockets/railtie"
5
5
 
6
6
  if defined?(Bundler)
7
- Bundler.require(*Rails.groups(:assets => %w(development test)))
7
+ Bundler.require(*Rails.groups(assets: %w(development test)))
8
8
  end
9
9
 
10
10
  module App
@@ -13,6 +13,6 @@ module App
13
13
  config.assets.enabled = true
14
14
  config.assets.version = '1.0'
15
15
 
16
- config.sass.style = :compressed
16
+ config.secret_key_base = 'foo'
17
17
  end
18
18
  end
@@ -1,11 +1,13 @@
1
1
  App::Application.configure do
2
- config.cache_classes = true
3
- config.serve_static_assets = true
4
- config.static_cache_control = "public, max-age=3600"
5
- config.whiny_nils = true
6
- config.consider_all_requests_local = true
7
- config.action_controller.perform_caching = false
8
- config.action_dispatch.show_exceptions = false
2
+ config.eager_load = false
3
+ config.cache_classes = true
4
+ config.serve_static_assets = true
5
+ config.static_cache_control = "public, max-age=3600"
6
+ config.active_support.deprecation = :stderr
7
+ config.consider_all_requests_local = true
8
+ config.action_dispatch.show_exceptions = false
9
+ config.action_controller.perform_caching = false
9
10
  config.action_controller.allow_forgery_protection = false
10
- config.active_support.deprecation = :stderr
11
+
12
+ config.assets.css_compressor = :sass
11
13
  end
@@ -1,3 +1,3 @@
1
1
  App::Application.routes.draw do
2
- root :to => 'css#test'
2
+ root to: 'css#test'
3
3
  end
@@ -0,0 +1,56 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ require 'sprockets'
4
+
5
+ describe RailsSassImages do
6
+ before(:all) do
7
+ @original = RailsSassImages.assets
8
+
9
+ @assets = Sprockets::Environment.new
10
+ @assets.append_path(DIR.join('app/app/assets/images'))
11
+ @assets.append_path(DIR.join('app/app/assets/stylesheets'))
12
+ @assets.css_compressor = :sass
13
+
14
+ @assets.context_class.class_eval do
15
+ def asset_path(path, options = {})
16
+ "/assets/#{path}"
17
+ end
18
+ end
19
+
20
+ RailsSassImages.install(@assets)
21
+ end
22
+
23
+ after(:all) do
24
+ RailsSassImages.assets = @original
25
+ end
26
+
27
+ it "should inline assets" do
28
+ @assets['inline.css'].to_s.should == ".icon{background:#{INLINE}}\n"
29
+ end
30
+
31
+ it "should raise error on unknown file" do
32
+ proc {
33
+ @assets['wrong-inline.css']
34
+ }.should raise_error(/Can't find asset no\.png/)
35
+ end
36
+
37
+ it "should get image size" do
38
+ @assets['size.css'].to_s.should == ".icon{width:4px;height:6px}\n"
39
+ end
40
+
41
+ it "should get image size by mixin" do
42
+ @assets['image-size.css'].to_s.should == ".icon{width:4px;height:6px}\n"
43
+ end
44
+
45
+ it "should has hidpi-image mixin" do
46
+ @assets['hidpi-image.css'].to_s == ".icon{width:2px;height:3px;" +
47
+ "background:url(/assets/monolith.png) no-repeat;" +
48
+ "background-size:2px 3px}\n"
49
+ end
50
+
51
+ it "should has hidpi-inline mixin" do
52
+ @assets['hidpi-inline.css'].to_s.should == ".icon{width:2px;height:3px;" +
53
+ "background:#{INLINE} no-repeat;" +
54
+ "background-size:2px 3px}\n"
55
+ end
56
+ end
@@ -1,37 +1,37 @@
1
1
  require File.expand_path('../spec_helper', __FILE__)
2
2
 
3
- describe CssController, :type => :controller do
3
+ describe CssController, type: :controller do
4
4
  after :all do
5
5
  Rails.root.join('tmp').rmtree
6
6
  Rails.root.join('log').rmtree
7
7
  end
8
8
 
9
9
  it "should inline assets" do
10
- get :test, :file => 'inline'
10
+ get :test, file: 'inline'
11
11
  response.should be_success
12
12
  response.body.should == ".icon{background:#{INLINE}}\n"
13
13
  end
14
14
 
15
15
  it "should raise error on unknown file" do
16
16
  proc {
17
- get :test, :file => 'wrong-inline'
17
+ get :test, file: 'wrong-inline'
18
18
  }.should raise_error(/Can't find asset no\.png/)
19
19
  end
20
20
 
21
21
  it "should get image size" do
22
- get :test, :file => 'size'
22
+ get :test, file: 'size'
23
23
  response.should be_success
24
24
  response.body.should == ".icon{width:4px;height:6px}\n"
25
25
  end
26
26
 
27
27
  it "should get image size by mixin" do
28
- get :test, :file => 'image-size'
28
+ get :test, file: 'image-size'
29
29
  response.should be_success
30
30
  response.body.should == ".icon{width:4px;height:6px}\n"
31
31
  end
32
32
 
33
33
  it "should has hidpi-image mixin" do
34
- get :test, :file => 'hidpi-image'
34
+ get :test, file: 'hidpi-image'
35
35
  response.should be_success
36
36
  response.body.should == ".icon{width:2px;height:3px;" +
37
37
  "background:url(/assets/monolith.png) no-repeat;" +
@@ -39,7 +39,7 @@ describe CssController, :type => :controller do
39
39
  end
40
40
 
41
41
  it "should has hidpi-inline mixin" do
42
- get :test, :file => 'hidpi-inline'
42
+ get :test, file: 'hidpi-inline'
43
43
  response.should be_success
44
44
  response.body.should == ".icon{width:2px;height:3px;" +
45
45
  "background:#{INLINE} no-repeat;" +
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,10 @@
1
- # encoding: utf-8
2
1
  ENV['RAILS_ENV'] ||= 'test'
3
2
 
4
3
  DIR = Pathname(__FILE__).dirname
5
4
  require DIR.join('app/config/environment').to_s
6
5
  require DIR.join('../lib/rails-sass-images').to_s
7
6
 
8
- require 'pp'
9
7
  require 'rspec/rails'
10
8
 
11
- INLINE = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAGCAAAAADB" +
12
- "UmCpAAAAC0lEQVQI12NgwAcAAB4AAW6FRzIAAAAASUVORK5CYII=')"
9
+ INLINE = 'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAGCAAAAADB' +
10
+ 'UmCpAAAAC0lEQVQI12NgwAcAAB4AAW6FRzIAAAAASUVORK5CYII=")'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-sass-images
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,26 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-29 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: sass-rails
15
+ name: sass
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>'
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>'
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sprockets
16
32
  requirement: !ruby/object:Gem::Requirement
17
33
  none: false
18
34
  requirements:
@@ -44,21 +60,21 @@ dependencies:
44
60
  - !ruby/object:Gem::Version
45
61
  version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
- name: rails
63
+ name: mime-types
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
51
- - - ! '>='
67
+ - - ! '>'
52
68
  - !ruby/object:Gem::Version
53
- version: '3.1'
69
+ version: '0'
54
70
  type: :runtime
55
71
  prerelease: false
56
72
  version_requirements: !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
- - - ! '>='
75
+ - - ! '>'
60
76
  - !ruby/object:Gem::Version
61
- version: '3.1'
77
+ version: '0'
62
78
  description:
63
79
  email: andrey@sitnik.ru
64
80
  executables: []
@@ -83,6 +99,7 @@ files:
83
99
  - lib/assets/stylesheets/rails-sass-images/hidpi-inline.sass
84
100
  - lib/assets/stylesheets/rails-sass-images/image-size.sass
85
101
  - lib/rails-sass-images.rb
102
+ - lib/rails-sass-images/railtie.rb
86
103
  - lib/rails-sass-images/sass.rb
87
104
  - lib/rails-sass-images/sass/inline.rb
88
105
  - lib/rails-sass-images/sass/size.rb
@@ -104,7 +121,8 @@ files:
104
121
  - spec/app/config/environment.rb
105
122
  - spec/app/config/environments/test.rb
106
123
  - spec/app/config/routes.rb
107
- - spec/sass_spec.rb
124
+ - spec/plain_spec.rb
125
+ - spec/rails_spec.rb
108
126
  - spec/spec_helper.rb
109
127
  homepage: https://github.com/ai/rails-sass-images
110
128
  licenses: []
@@ -120,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
138
  version: '0'
121
139
  segments:
122
140
  - 0
123
- hash: -2995797738750552235
141
+ hash: 3926307620625692974
124
142
  required_rubygems_version: !ruby/object:Gem::Requirement
125
143
  none: false
126
144
  requirements:
@@ -129,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
147
  version: '0'
130
148
  segments:
131
149
  - 0
132
- hash: -2995797738750552235
150
+ hash: 3926307620625692974
133
151
  requirements: []
134
152
  rubyforge_project:
135
153
  rubygems_version: 1.8.23