rails_responsive_images 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +1 -0
- data/app/controllers/rails_responsive_images/assets_controller.rb +46 -0
- data/config/routes.rb +3 -0
- data/lib/assets/javascripts/jquery-picture.js +279 -0
- data/lib/rails_responsive_images.rb +52 -0
- data/lib/rails_responsive_images/configuration.rb +23 -0
- data/lib/rails_responsive_images/engine.rb +3 -0
- data/lib/rails_responsive_images/version.rb +3 -0
- data/rails_responsive_images.gemspec +26 -0
- data/spec/spec_helper.rb +91 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 533708a79d576f39b8d794bc49edd323b38f400d
|
4
|
+
data.tar.gz: f197d41ae752d62b983e1f92dbb1866d02a1aa69
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 390c812e13f4ef90f387a499d72e4d30ac9eafce3f9f8cc7d6ce225e1ed9f4c1aa55f7469eac279d75b881b7d953064ba9799fac3ebdd0902f5c8f19b416ee6f
|
7
|
+
data.tar.gz: ec61eb527efd3b44f9121bb185472c43a7471d61f45ce9682a058e4694df59fe8b9057b522216ab1cd78cfe8c6d19e79b51e051d36ab374c0b8f9452d5f757a1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Christoph Chilian
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# RailsResponsiveImages
|
2
|
+
|
3
|
+
A Rails image_tag() extension to generate HTML5 <picture> tag markup from the W3C HTML Responsive Images Extension Proposal.
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
<picture>
|
7
|
+
<source media="(max-width: 766px)" srcset="/assets/responsive_images_766/picture.jpg">
|
8
|
+
<source media="(max-width: 990px)" srcset="/assets/responsive_images_990/picture.jpg">
|
9
|
+
<source media="(max-width: 200px)" srcset="/assets/responsive_images_200/picture.jpg">
|
10
|
+
<img width="2568" height="878" alt="awesome" src="/assets/picture.jpg">
|
11
|
+
</picture>
|
12
|
+
```
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'rails_responsive_images'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install rails_responsive_images
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
Configure the size steps you want to create:
|
33
|
+
```ruby
|
34
|
+
RailsResponsiveImages.configure do |c|
|
35
|
+
c.image_sizes = [767, 991, 1999]
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
Require jquery-picture for cross browser support
|
40
|
+
```javascript
|
41
|
+
//= require jquery-picture
|
42
|
+
```
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
= image_tag 'awesome/picture.jpeg', alt: 'awesome', responsive: true
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it ( https://github.com/chilian/rails_responsive_images/fork )
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create a new Pull Request
|
55
|
+
|
56
|
+
## Copyright
|
57
|
+
Copyright © 2015 Christoph Chilian. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module RailsResponsiveImages
|
2
|
+
require 'RMagick'
|
3
|
+
require 'fileutils'
|
4
|
+
class AssetsController < ActionController::Base
|
5
|
+
def responsive_image
|
6
|
+
filepath = params[:filepath]
|
7
|
+
filename = params[:filename]
|
8
|
+
format = params[:format]
|
9
|
+
image_filename = "#{filename}.#{format}"
|
10
|
+
|
11
|
+
# TODO cleanup
|
12
|
+
requested_image_size = filepath.match(/(responsive_images_)\d+/).to_s.split('_').last
|
13
|
+
|
14
|
+
original_filepath = "#{filepath}".sub(/(responsive_images_)\d+/, '/')
|
15
|
+
.sub(/\/\//, '') # remove duplicated slashes
|
16
|
+
.sub(/\A\//, '') # remove leading slash
|
17
|
+
|
18
|
+
full_original_filepath = Rails.root.join('app', 'assets', 'images', original_filepath, image_filename)
|
19
|
+
full_responsive_filepath = Rails.root.join('app', 'assets', 'images', filepath, image_filename)
|
20
|
+
|
21
|
+
create_responsive_folder!(full_responsive_filepath)
|
22
|
+
|
23
|
+
fail ActionController::RoutingError.new('Not found') unless File.exist?(full_original_filepath)
|
24
|
+
|
25
|
+
generate_responsive_image!(full_original_filepath, requested_image_size, full_responsive_filepath)
|
26
|
+
|
27
|
+
mime_type = MIME::Types.type_for("#{full_responsive_filepath}").first.content_type
|
28
|
+
send_file full_responsive_filepath, type: mime_type, disposition: :inline
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def create_responsive_folder!(path)
|
34
|
+
dirname = File.dirname(path)
|
35
|
+
unless File.directory?(dirname)
|
36
|
+
FileUtils.mkdir_p(dirname)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_responsive_image!(original_image, size, output_path)
|
41
|
+
img = ::Magick::Image.read(original_image).first
|
42
|
+
img = img.resize_to_fit(size, size)
|
43
|
+
img.write(output_path)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,279 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Picture
|
3
|
+
* http://jquerypicture.com
|
4
|
+
* http://github.com/Abban/jQuery-Picture
|
5
|
+
*
|
6
|
+
* May 2012
|
7
|
+
*
|
8
|
+
* @version 0.9
|
9
|
+
* @author Abban Dunne http://abandon.ie
|
10
|
+
* @license MIT
|
11
|
+
*
|
12
|
+
* jQuery Picture is a plugin to add support for responsive images to your layouts.
|
13
|
+
* It supports both figure elements with some custom data attributes and the new
|
14
|
+
* proposed picture format. This plugin will be made redundant when the format is
|
15
|
+
* approved and implemented by browsers. Lets hope that happens soon. In the meantime
|
16
|
+
* this plugin will be kept up to date with latest developments.
|
17
|
+
*
|
18
|
+
*/
|
19
|
+
(function($){
|
20
|
+
|
21
|
+
$.fn.picture = function(args){
|
22
|
+
|
23
|
+
var defaults = {
|
24
|
+
|
25
|
+
container : null,
|
26
|
+
ignorePixelRatio: false,
|
27
|
+
useLarger: false,
|
28
|
+
insertElement: '>a',
|
29
|
+
inlineDimensions: false
|
30
|
+
|
31
|
+
};
|
32
|
+
|
33
|
+
var settings = $.extend({}, defaults, args);
|
34
|
+
|
35
|
+
this.each(function(){
|
36
|
+
|
37
|
+
var breakpoints = new Array();
|
38
|
+
|
39
|
+
var windowWidth, currentMedia, element, timeoutOffset;
|
40
|
+
|
41
|
+
// Check the device pixel ratio
|
42
|
+
var PixelRatio = 1;
|
43
|
+
if(!settings.ignorePixelRatio && window.devicePixelRatio !== undefined) PixelRatio = window.devicePixelRatio;
|
44
|
+
|
45
|
+
// Save off the element so it can be easily used inside a function
|
46
|
+
element = $(this);
|
47
|
+
|
48
|
+
//Delete the noscript we don't need it now anyway
|
49
|
+
element.find('noscript').remove();
|
50
|
+
|
51
|
+
// Initialise the images
|
52
|
+
getCurrentMedia(true);
|
53
|
+
|
54
|
+
// Only call the image resize function 200ms after window stops being resized
|
55
|
+
timeoutOffset = false;
|
56
|
+
|
57
|
+
$(window).resize(function(){
|
58
|
+
|
59
|
+
if(timeoutOffset !== false)
|
60
|
+
clearTimeout(timeoutOffset);
|
61
|
+
|
62
|
+
timeoutOffset = setTimeout(getCurrentMedia, 200);
|
63
|
+
|
64
|
+
});
|
65
|
+
|
66
|
+
|
67
|
+
/**
|
68
|
+
* getCurrentMedia
|
69
|
+
*
|
70
|
+
* Checks the window width off the media query types and selects the current one.
|
71
|
+
* Calls the setPicture or setFigure function to set the image.
|
72
|
+
*
|
73
|
+
*/
|
74
|
+
function getCurrentMedia(init){
|
75
|
+
|
76
|
+
if(init){
|
77
|
+
|
78
|
+
if(element.get(0).tagName.toLowerCase() == 'figure'){
|
79
|
+
|
80
|
+
var mediaObj = element.data();
|
81
|
+
|
82
|
+
$.each(mediaObj, function(media){
|
83
|
+
|
84
|
+
var num;
|
85
|
+
|
86
|
+
num = media.replace(/[^\d.]/g, '');
|
87
|
+
|
88
|
+
if(num)
|
89
|
+
breakpoints.push(parseInt(num));
|
90
|
+
|
91
|
+
});
|
92
|
+
|
93
|
+
}else{
|
94
|
+
|
95
|
+
element.find('source').each(function(){
|
96
|
+
|
97
|
+
var media, num;
|
98
|
+
|
99
|
+
media = $(this).attr('media');
|
100
|
+
|
101
|
+
if(media){
|
102
|
+
|
103
|
+
num = media.replace(/[^\d.]/g, '');
|
104
|
+
|
105
|
+
breakpoints.push(parseInt(num));
|
106
|
+
}
|
107
|
+
|
108
|
+
});
|
109
|
+
|
110
|
+
}
|
111
|
+
breakpoints.sort(function(a,b){return a - b}); //make sure the largest breakpoint is the last
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
var c = 0;
|
116
|
+
|
117
|
+
// Check if user defined container, otherwise take window
|
118
|
+
if (settings.container == null){
|
119
|
+
|
120
|
+
windowWidth = ($(window).width()) * PixelRatio;
|
121
|
+
|
122
|
+
}else{
|
123
|
+
|
124
|
+
windowWidth = ($(settings.container).width()) * PixelRatio;
|
125
|
+
|
126
|
+
}
|
127
|
+
|
128
|
+
// Set the c variable to the current media width
|
129
|
+
$.each(breakpoints, function(i,v){
|
130
|
+
|
131
|
+
if(parseInt(windowWidth) >= parseInt(v) && parseInt(c) <= parseInt(v))
|
132
|
+
c = v;
|
133
|
+
|
134
|
+
});
|
135
|
+
|
136
|
+
if (settings.useLarger ){
|
137
|
+
idx = breakpoints.indexOf(c);
|
138
|
+
if (idx < breakpoints.length-1) //make sure we're not already using the largest breakpoint
|
139
|
+
c = breakpoints[ idx + 1];
|
140
|
+
}
|
141
|
+
|
142
|
+
if(currentMedia !== c){
|
143
|
+
currentMedia = c;
|
144
|
+
|
145
|
+
if(element.get(0).tagName.toLowerCase() == 'figure')
|
146
|
+
setFigure();
|
147
|
+
else
|
148
|
+
setPicture();
|
149
|
+
}
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
/**
|
155
|
+
* setPicture
|
156
|
+
*
|
157
|
+
* Pulls the image src and media attributes from the source tags and sets
|
158
|
+
* the src of the enclosed img tag to the appropriate one.
|
159
|
+
*
|
160
|
+
*/
|
161
|
+
function setPicture(){
|
162
|
+
|
163
|
+
var sizes = new Object();
|
164
|
+
|
165
|
+
element.find('source').each(function(){
|
166
|
+
|
167
|
+
var media, path, num;
|
168
|
+
media = $(this).attr('media');
|
169
|
+
path = $(this).attr('src');
|
170
|
+
|
171
|
+
if(media)
|
172
|
+
num = media.replace(/[^\d.]/g, '');
|
173
|
+
else
|
174
|
+
num = 0;
|
175
|
+
|
176
|
+
sizes[num] = path;
|
177
|
+
|
178
|
+
});
|
179
|
+
|
180
|
+
if(element.find('img').length == 0){
|
181
|
+
|
182
|
+
var prep = '<img src="' + sizes[currentMedia] + '"'
|
183
|
+
if(element.attr('style')) prep += ' style="' + element.attr('style') + '"';
|
184
|
+
if(element.attr('alt')) prep += ' alt="' + element.attr('alt') + '"';
|
185
|
+
prep += '>';
|
186
|
+
|
187
|
+
if($(settings.insertElement, element).length == 0){
|
188
|
+
|
189
|
+
element.append(prep);
|
190
|
+
|
191
|
+
}else{
|
192
|
+
|
193
|
+
$(settings.insertElement, element).append(prep);
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
}else{
|
198
|
+
|
199
|
+
element.find('img').attr('src', sizes[currentMedia]);
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
if(settings.inlineDimensions){
|
204
|
+
|
205
|
+
$("<img/>").attr("src", $('img', element).attr("src")).load(function(){
|
206
|
+
$('img', element).attr('height', this.height);
|
207
|
+
$('img', element).attr('width', this.width);
|
208
|
+
});
|
209
|
+
|
210
|
+
}
|
211
|
+
|
212
|
+
}
|
213
|
+
|
214
|
+
|
215
|
+
/**
|
216
|
+
* setFigure
|
217
|
+
*
|
218
|
+
* Pulls the image src and and media values from the data attributes
|
219
|
+
* and sets the src of the enclosed img tag to the appropriate one.
|
220
|
+
*
|
221
|
+
*/
|
222
|
+
function setFigure(){
|
223
|
+
|
224
|
+
var sizes = new Object();
|
225
|
+
|
226
|
+
var mediaObj = element.data();
|
227
|
+
|
228
|
+
$.each(mediaObj, function(media, path){
|
229
|
+
|
230
|
+
var num;
|
231
|
+
|
232
|
+
num = media.replace(/[^\d.]/g, '');
|
233
|
+
|
234
|
+
if(!num)
|
235
|
+
num = 0;
|
236
|
+
|
237
|
+
sizes[num] = path;
|
238
|
+
|
239
|
+
});
|
240
|
+
|
241
|
+
if(element.find('img').length == 0){
|
242
|
+
|
243
|
+
var prep = '<img src="' + sizes[currentMedia] + '"';
|
244
|
+
if(element.attr('style')) prep += ' style="' + element.attr('style') + '"';
|
245
|
+
if(element.attr('title')) prep += ' alt="' + element.attr('title') + '"';
|
246
|
+
prep += '>';
|
247
|
+
|
248
|
+
if($(settings.insertElement, element).length == 0){
|
249
|
+
|
250
|
+
element.append(prep);
|
251
|
+
|
252
|
+
}else{
|
253
|
+
|
254
|
+
$(settings.insertElement, element).append(prep);
|
255
|
+
|
256
|
+
}
|
257
|
+
|
258
|
+
}else{
|
259
|
+
|
260
|
+
$('img', element).attr('src', sizes[currentMedia]);
|
261
|
+
|
262
|
+
}
|
263
|
+
|
264
|
+
if(settings.inlineDimensions){
|
265
|
+
|
266
|
+
$("<img/>").attr("src", $('img', element).attr("src")).load(function(){
|
267
|
+
$('img', element).attr('height', this.height);
|
268
|
+
$('img', element).attr('width', this.width);
|
269
|
+
});
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
});
|
276
|
+
|
277
|
+
};
|
278
|
+
|
279
|
+
})(jQuery);
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
require 'rails_responsive_images/version'
|
3
|
+
require 'rails_responsive_images/configuration'
|
4
|
+
require 'rails_responsive_images/engine'
|
5
|
+
|
6
|
+
module RailsResponsiveImages
|
7
|
+
def self.configuration
|
8
|
+
@configuration ||= RailsResponsiveImages::Configuration.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configuration=(new_configuration)
|
12
|
+
@configuration = new_configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
# Yields the global configuration to a block.
|
16
|
+
#
|
17
|
+
# Example:
|
18
|
+
# RailsResponsiveImages::Rails.configure do |config|
|
19
|
+
# config.sizes = [767, 991, 1999]
|
20
|
+
# end
|
21
|
+
def self.configure
|
22
|
+
yield configuration if block_given?
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.reset
|
26
|
+
@configuration = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
ActionView::Helpers::AssetTagHelper.module_eval do
|
32
|
+
|
33
|
+
def image_tag_with_responsiveness(path, options = {})
|
34
|
+
options = options.dup
|
35
|
+
responsive = options.delete(:responsive) { false }
|
36
|
+
if responsive
|
37
|
+
content_tag :picture do
|
38
|
+
original_filepath = path.sub(/\A\/assets/, '')
|
39
|
+
::RailsResponsiveImages.configuration.image_sizes.each do |size|
|
40
|
+
# TODO use image_path helper
|
41
|
+
responsive_file_name = "/assets/responsive_images_#{size}/#{original_filepath}"
|
42
|
+
concat content_tag(:source, '', media: "(max-width: #{size}px)", srcset: responsive_file_name)
|
43
|
+
end
|
44
|
+
concat image_tag_without_responsiveness(path, options)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
image_tag_without_responsiveness(path, options)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
alias_method_chain :image_tag, :responsiveness
|
52
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RailsResponsiveImages
|
2
|
+
# Stores runtime configuration information.
|
3
|
+
#
|
4
|
+
# Example settings
|
5
|
+
# RailsResponsiveImages.configure do |c|
|
6
|
+
# c.image_sizes = [767, 991, 1999]
|
7
|
+
# end
|
8
|
+
class Configuration
|
9
|
+
|
10
|
+
# The image_sizes to put into the picture source src attribute
|
11
|
+
def image_sizes
|
12
|
+
@image_sizes
|
13
|
+
end
|
14
|
+
def image_sizes=(new_sizes)
|
15
|
+
@image_sizes = new_sizes
|
16
|
+
end
|
17
|
+
|
18
|
+
# Set default settings
|
19
|
+
def initialize
|
20
|
+
@image_sizes = [767, 991, 1999]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails_responsive_images/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'rails_responsive_images'
|
8
|
+
spec.version = RailsResponsiveImages::VERSION
|
9
|
+
spec.authors = ['Christoph Chilian']
|
10
|
+
spec.email = ['christoph@chilian.de']
|
11
|
+
spec.summary = %q{A Rails image_tag() extension to generate HTML5 <picture> tag markup from the W3C HTML Responsive Images Extension Proposal.}
|
12
|
+
spec.description = %q{A Rails image_tag() extension to generate HTML5 <picture> tag markup from the W3C HTML Responsive Images Extension Proposal.}
|
13
|
+
spec.homepage = "https://chilian.de"
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_runtime_dependency 'rmagick', '~> 2.13'
|
25
|
+
spec.add_runtime_dependency 'rails', '>= 4.0'
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rails_responsive_images'
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
6
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
7
|
+
#
|
8
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
9
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
10
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
11
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
12
|
+
# a separate helper file that requires the additional dependencies and performs
|
13
|
+
# the additional setup, and require it from the spec files that actually need it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
=begin
|
46
|
+
# These two settings work together to allow you to limit a spec run
|
47
|
+
# to individual examples or groups you care about by tagging them with
|
48
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
+
# get run.
|
50
|
+
config.filter_run :focus
|
51
|
+
config.run_all_when_everything_filtered = true
|
52
|
+
|
53
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
54
|
+
# For more details, see:
|
55
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
56
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
57
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
58
|
+
config.disable_monkey_patching!
|
59
|
+
|
60
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
61
|
+
# be too noisy due to issues in dependencies.
|
62
|
+
config.warnings = true
|
63
|
+
|
64
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
65
|
+
# file, and it's useful to allow more verbose output when running an
|
66
|
+
# individual spec file.
|
67
|
+
if config.files_to_run.one?
|
68
|
+
# Use the documentation formatter for detailed output,
|
69
|
+
# unless a formatter has already been configured
|
70
|
+
# (e.g. via a command-line flag).
|
71
|
+
config.default_formatter = 'doc'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Print the 10 slowest examples and example groups at the
|
75
|
+
# end of the spec run, to help surface which specs are running
|
76
|
+
# particularly slow.
|
77
|
+
config.profile_examples = 10
|
78
|
+
|
79
|
+
# Run specs in random order to surface order dependencies. If you find an
|
80
|
+
# order dependency and want to debug it, you can fix the order by providing
|
81
|
+
# the seed, which is printed after each run.
|
82
|
+
# --seed 1234
|
83
|
+
config.order = :random
|
84
|
+
|
85
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
86
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
87
|
+
# test failures related to randomization by passing the same `--seed` value
|
88
|
+
# as the one that triggered the failure.
|
89
|
+
Kernel.srand config.seed
|
90
|
+
=end
|
91
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_responsive_images
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christoph Chilian
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rmagick
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.13'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.13'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
83
|
+
description: A Rails image_tag() extension to generate HTML5 <picture> tag markup
|
84
|
+
from the W3C HTML Responsive Images Extension Proposal.
|
85
|
+
email:
|
86
|
+
- christoph@chilian.de
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- app/controllers/rails_responsive_images/assets_controller.rb
|
98
|
+
- config/routes.rb
|
99
|
+
- lib/assets/javascripts/jquery-picture.js
|
100
|
+
- lib/rails_responsive_images.rb
|
101
|
+
- lib/rails_responsive_images/configuration.rb
|
102
|
+
- lib/rails_responsive_images/engine.rb
|
103
|
+
- lib/rails_responsive_images/version.rb
|
104
|
+
- rails_responsive_images.gemspec
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: https://chilian.de
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.4.3
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: A Rails image_tag() extension to generate HTML5 <picture> tag markup from
|
130
|
+
the W3C HTML Responsive Images Extension Proposal.
|
131
|
+
test_files:
|
132
|
+
- spec/spec_helper.rb
|