fastimage_inline 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -3
- data/VERSION.yml +1 -1
- data/lib/fastimage_inline.rb +5 -2
- data/test/config/boot.rb +4 -108
- data/test/config/environment.rb +4 -38
- data/test/config/routes.rb +57 -2
- data/test/test.rb +6 -6
- metadata +42 -40
data/README.textile
CHANGED
@@ -52,7 +52,7 @@ h4. As a Rails plugin
|
|
52
52
|
h4. As a Gem
|
53
53
|
|
54
54
|
<pre>
|
55
|
-
sudo gem install
|
55
|
+
sudo gem install fastimage_inline
|
56
56
|
</pre>
|
57
57
|
|
58
58
|
Install the gem as above, and configure it in your environment.rb file as below:
|
@@ -61,7 +61,7 @@ Install the gem as above, and configure it in your environment.rb file as below:
|
|
61
61
|
...
|
62
62
|
Rails::Initializer.run do |config|
|
63
63
|
...
|
64
|
-
config.gem "
|
64
|
+
config.gem "fastimage_inline", :lib=>"fastimage_inline"
|
65
65
|
...
|
66
66
|
end
|
67
67
|
...
|
@@ -72,7 +72,7 @@ h2. Requirements
|
|
72
72
|
* "FastImage":http://github.com/sdsykes/fastimage
|
73
73
|
|
74
74
|
<pre>
|
75
|
-
sudo gem install
|
75
|
+
sudo gem install fastimage
|
76
76
|
</pre>
|
77
77
|
|
78
78
|
h2. Documentation
|
data/VERSION.yml
CHANGED
data/lib/fastimage_inline.rb
CHANGED
@@ -60,11 +60,14 @@ module FastImageInline
|
|
60
60
|
# in a data uri rather than just the path to the image
|
61
61
|
#
|
62
62
|
def inline_image_path(source)
|
63
|
+
public_path = respond_to?(:compute_public_path) ? compute_public_path(source, 'images') : asset_paths.compute_public_path(source, 'images')
|
64
|
+
|
63
65
|
has_request = respond_to?(:request)
|
66
|
+
|
64
67
|
if has_request && inline_capable_browser?
|
65
|
-
inline_image_data(
|
68
|
+
inline_image_data(public_path)
|
66
69
|
else
|
67
|
-
|
70
|
+
public_path
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
data/test/config/boot.rb
CHANGED
@@ -1,110 +1,6 @@
|
|
1
|
-
|
2
|
-
# Configure your app in config/environment.rb and config/environments/*.rb
|
1
|
+
require 'rubygems'
|
3
2
|
|
4
|
-
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
5
5
|
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def boot!
|
9
|
-
unless booted?
|
10
|
-
preinitialize
|
11
|
-
pick_boot.run
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def booted?
|
16
|
-
defined? Rails::Initializer
|
17
|
-
end
|
18
|
-
|
19
|
-
def pick_boot
|
20
|
-
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
-
end
|
22
|
-
|
23
|
-
def vendor_rails?
|
24
|
-
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
-
end
|
26
|
-
|
27
|
-
def preinitialize
|
28
|
-
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
-
end
|
30
|
-
|
31
|
-
def preinitializer_path
|
32
|
-
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Boot
|
37
|
-
def run
|
38
|
-
load_initializer
|
39
|
-
Rails::Initializer.run(:set_load_path)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class VendorBoot < Boot
|
44
|
-
def load_initializer
|
45
|
-
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
-
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
-
Rails::GemDependency.add_frozen_gem_path
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class GemBoot < Boot
|
52
|
-
def load_initializer
|
53
|
-
self.class.load_rubygems
|
54
|
-
load_rails_gem
|
55
|
-
require 'initializer'
|
56
|
-
end
|
57
|
-
|
58
|
-
def load_rails_gem
|
59
|
-
if version = self.class.gem_version
|
60
|
-
gem 'rails', version
|
61
|
-
else
|
62
|
-
gem 'rails'
|
63
|
-
end
|
64
|
-
rescue Gem::LoadError => load_error
|
65
|
-
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
66
|
-
exit 1
|
67
|
-
end
|
68
|
-
|
69
|
-
class << self
|
70
|
-
def rubygems_version
|
71
|
-
Gem::RubyGemsVersion rescue nil
|
72
|
-
end
|
73
|
-
|
74
|
-
def gem_version
|
75
|
-
if defined? RAILS_GEM_VERSION
|
76
|
-
RAILS_GEM_VERSION
|
77
|
-
elsif ENV.include?('RAILS_GEM_VERSION')
|
78
|
-
ENV['RAILS_GEM_VERSION']
|
79
|
-
else
|
80
|
-
parse_gem_version(read_environment_rb)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def load_rubygems
|
85
|
-
min_version = '1.3.2'
|
86
|
-
require 'rubygems'
|
87
|
-
unless rubygems_version >= min_version
|
88
|
-
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
89
|
-
exit 1
|
90
|
-
end
|
91
|
-
|
92
|
-
rescue LoadError
|
93
|
-
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
94
|
-
exit 1
|
95
|
-
end
|
96
|
-
|
97
|
-
def parse_gem_version(text)
|
98
|
-
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
def read_environment_rb
|
103
|
-
File.read("#{RAILS_ROOT}/config/environment.rb")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# All that for this:
|
110
|
-
Rails.boot!
|
6
|
+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
data/test/config/environment.rb
CHANGED
@@ -1,39 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# Load the rails application
|
2
|
+
require File.expand_path('../application', __FILE__)
|
2
3
|
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
Rails::Initializer.run do |config|
|
7
|
-
# Settings in config/environments/* take precedence over those specified here.
|
8
|
-
# Application configuration should go into files in config/initializers
|
9
|
-
# -- all .rb files in that directory are automatically loaded.
|
10
|
-
|
11
|
-
# Add additional load paths for your own custom dirs
|
12
|
-
# config.load_paths += %W( #{RAILS_ROOT}/extras )
|
13
|
-
|
14
|
-
# Specify gems that this application depends on and have them installed with rake gems:install
|
15
|
-
# config.gem "bj"
|
16
|
-
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
17
|
-
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
18
|
-
# config.gem "aws-s3", :lib => "aws/s3"
|
19
|
-
|
20
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
21
|
-
# :all can be used as a placeholder for all plugins not explicitly named
|
22
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
23
|
-
|
24
|
-
# Skip frameworks you're not going to use. To use Rails without a database,
|
25
|
-
# you must remove the Active Record framework.
|
26
|
-
config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
27
|
-
|
28
|
-
# Activate observers that should always be running
|
29
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
30
|
-
|
31
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
32
|
-
# Run "rake -D time" for a list of tasks for finding time zone names.
|
33
|
-
config.time_zone = 'UTC'
|
34
|
-
|
35
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
36
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
37
|
-
# config.i18n.default_locale = :de
|
38
|
-
config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase blah blah blah blah" }
|
39
|
-
end
|
4
|
+
# Initialize the rails application
|
5
|
+
Test::Application.initialize!
|
data/test/config/routes.rb
CHANGED
@@ -1,3 +1,58 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Test::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get 'short'
|
20
|
+
# post 'toggle'
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get 'sold'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get 'recent', :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => 'welcome#index'
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
match ':controller(/:action(/:id))(.:format)'
|
3
58
|
end
|
data/test/test.rb
CHANGED
@@ -17,7 +17,7 @@ require File.join(PathHere, 'config', 'environment')
|
|
17
17
|
|
18
18
|
require File.join(PathHere, "..", "lib", 'fastimage_inline')
|
19
19
|
|
20
|
-
require 'test_help'
|
20
|
+
require 'rails/test_help'
|
21
21
|
|
22
22
|
class InlineTests < ActionController::TestCase
|
23
23
|
def setup
|
@@ -35,20 +35,20 @@ class InlineTests < ActionController::TestCase
|
|
35
35
|
@request.env['HTTP_USER_AGENT'] = "msie 7"
|
36
36
|
get "index"
|
37
37
|
assert_response :success
|
38
|
-
assert_select "img#i1[src=?]", %r{/
|
38
|
+
assert_select "img#i1[src=?]", %r{/assets/bg.png}
|
39
39
|
@request.env['HTTP_USER_AGENT'] = "msie 8"
|
40
40
|
get "index"
|
41
41
|
assert_response :success
|
42
|
-
assert_select "img#i1[src=?]", %r{/
|
42
|
+
assert_select "img#i1[src=?]", %r{/assets/bg.png}
|
43
43
|
end
|
44
44
|
|
45
45
|
test "inline image tags are rendered as normal tags if browser is not recognised" do
|
46
46
|
@request.env['HTTP_USER_AGENT'] = "rails test"
|
47
47
|
get "index"
|
48
48
|
assert_response :success
|
49
|
-
assert_select "img#i2[src=?]", %r{/images/bg.png
|
50
|
-
assert_select "img#i3[src=?]", %r{/images/bullet.gif
|
51
|
-
assert_select "img#i4[src=?]", %r{/images/flag.jpg
|
49
|
+
assert_select "img#i2[src=?]", %r{/images/bg.png}
|
50
|
+
assert_select "img#i3[src=?]", %r{/images/bullet.gif}
|
51
|
+
assert_select "img#i4[src=?]", %r{/images/flag.jpg}
|
52
52
|
end
|
53
53
|
|
54
54
|
test "inline images are rendered inline for ie 8" do
|
metadata
CHANGED
@@ -1,37 +1,41 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastimage_inline
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Stephen Sykes
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: fastimage
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.2
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
23
29
|
version: 1.1.2
|
24
|
-
|
25
|
-
|
30
|
+
description: FastImage Inline places small images inline in you HTML IMG tags code
|
31
|
+
using a 'data' url.
|
26
32
|
email: sdsykes@gmail.com
|
27
33
|
executables: []
|
28
|
-
|
29
34
|
extensions: []
|
30
|
-
|
31
|
-
extra_rdoc_files:
|
35
|
+
extra_rdoc_files:
|
32
36
|
- README
|
33
37
|
- README.textile
|
34
|
-
files:
|
38
|
+
files:
|
35
39
|
- README
|
36
40
|
- README.textile
|
37
41
|
- Rakefile
|
@@ -47,35 +51,33 @@ files:
|
|
47
51
|
- test/public/images/bullet.gif
|
48
52
|
- test/public/images/flag.jpg
|
49
53
|
- test/test.rb
|
50
|
-
has_rdoc: true
|
51
54
|
homepage: http://github.com/sdsykes/fastimage_inline
|
52
55
|
licenses: []
|
53
|
-
|
54
56
|
post_install_message:
|
55
|
-
rdoc_options:
|
57
|
+
rdoc_options:
|
56
58
|
- --charset=UTF-8
|
57
|
-
require_paths:
|
59
|
+
require_paths:
|
58
60
|
- lib
|
59
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
71
73
|
requirements: []
|
72
|
-
|
73
74
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.
|
75
|
+
rubygems_version: 1.8.23
|
75
76
|
signing_key:
|
76
77
|
specification_version: 3
|
77
|
-
summary: FastImage Inline - Speeds up your webpages with inline images in HTML using
|
78
|
-
|
78
|
+
summary: FastImage Inline - Speeds up your webpages with inline images in HTML using
|
79
|
+
a data url
|
80
|
+
test_files:
|
79
81
|
- test/app/controllers/main_controller.rb
|
80
82
|
- test/config/boot.rb
|
81
83
|
- test/config/environment.rb
|