assetsio-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README.md +3 -0
- data/Rakefile +18 -0
- data/assetsio-rails.gemspec +25 -0
- data/lib/assetsio-rails.rb +2 -0
- data/lib/assetsio-rails/helpers.rb +25 -0
- data/lib/assetsio-rails/railtie.rb +9 -0
- data/lib/assetsio-rails/sprockets.rb +32 -0
- data/lib/assetsio-rails/version.rb +5 -0
- data/rails/init.rb +2 -0
- metadata +116 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create ruby-1.9.2-p180@assetsio-rails
|
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
require 'rdoc/task'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
desc 'Generate documentation'
|
11
|
+
RDoc::Task.new do |rdoc|
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = 'Assets.io Rails 3.1 Helper'
|
14
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
15
|
+
rdoc.rdoc_files.include('README.md')
|
16
|
+
rdoc.rdoc_files.include('lib/assetsio-rails.rb')
|
17
|
+
rdoc.rdoc_files.include('lib/assetsio-rails/**/*.rb')
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'assetsio-rails/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'assetsio-rails'
|
7
|
+
s.summary = 'Assets.io helper for Rails 3.1'
|
8
|
+
s.email = 'martin.rehfeld@assets.io'
|
9
|
+
s.homepage = 'https://github.com/assets-io/assetsio-rails'
|
10
|
+
s.description = 'Use Assets.io to deliver your Javascript and CSS assets from the Amazon Cloudfront CDN.'
|
11
|
+
s.authors = ['Martin Rehfeld']
|
12
|
+
s.version = AssetsIO::VERSION
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
|
15
|
+
s.add_dependency 'addressable'
|
16
|
+
|
17
|
+
s.add_development_dependency 'rdoc', '>=2.4.2'
|
18
|
+
s.add_development_dependency 'rspec', '>=2.0'
|
19
|
+
s.add_development_dependency 'rake'
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ['lib']
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'addressable/uri'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module AssetsIO
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :account, :origin
|
8
|
+
|
9
|
+
def asset_url(request, source, type)
|
10
|
+
source_url = Addressable::URI.parse(request.url) + source
|
11
|
+
asset_spec = {
|
12
|
+
:a => account,
|
13
|
+
:r => 'b6',
|
14
|
+
:h => 'localhost', # TODO: remove once whitelisting refers to sources
|
15
|
+
:s => [ source_url.to_s ],
|
16
|
+
:v => 0,
|
17
|
+
:w => 0
|
18
|
+
}
|
19
|
+
|
20
|
+
origin_server = origin || "//#{account}.cloudfront.net"
|
21
|
+
"#{origin_server}/#{Base64.urlsafe_encode64(asset_spec.to_json)}.#{type}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
if ActionView::Helpers.const_defined?(:SprocketsHelper)
|
3
|
+
|
4
|
+
module ::ActionView::Helpers::SprocketsHelper
|
5
|
+
|
6
|
+
def sprockets_javascript_include_tag_with_assetsio(source, options = {})
|
7
|
+
if Rails.env.production?
|
8
|
+
sprockets_javascript_include_tag_without_assetsio(AssetsIO.asset_url(sprockets_asset_paths.controller.request, asset_path(source, 'js'), 'js'), options)
|
9
|
+
else
|
10
|
+
sprockets_javascript_include_tag_without_assetsio(source, options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
alias_method_chain :sprockets_javascript_include_tag, :assetsio
|
14
|
+
|
15
|
+
def sprockets_stylesheet_link_tag_with_assetsio(source, options = {})
|
16
|
+
if Rails.env.production?
|
17
|
+
sprockets_stylesheet_link_tag_without_assetsio(AssetsIO.asset_url(sprockets_asset_paths.controller.request, asset_path(source, 'css'), 'css'), options)
|
18
|
+
else
|
19
|
+
sprockets_stylesheet_link_tag_without_assetsio(source, options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
alias_method_chain :sprockets_stylesheet_link_tag, :assetsio
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
else
|
27
|
+
raise NameError
|
28
|
+
end
|
29
|
+
|
30
|
+
rescue NameError
|
31
|
+
raise "assetsio-rails initialization failed: ActionView::Helpers::SprocketsHelper is not defined!"
|
32
|
+
end
|
data/rails/init.rb
ADDED
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: assetsio-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Martin Rehfeld
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-06 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: addressable
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.4.2
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "2.0"
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rake
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
description: Use Assets.io to deliver your Javascript and CSS assets from the Amazon Cloudfront CDN.
|
61
|
+
email: martin.rehfeld@assets.io
|
62
|
+
executables: []
|
63
|
+
|
64
|
+
extensions: []
|
65
|
+
|
66
|
+
extra_rdoc_files: []
|
67
|
+
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rvmrc
|
71
|
+
- Gemfile
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- assetsio-rails.gemspec
|
75
|
+
- lib/assetsio-rails.rb
|
76
|
+
- lib/assetsio-rails/helpers.rb
|
77
|
+
- lib/assetsio-rails/railtie.rb
|
78
|
+
- lib/assetsio-rails/sprockets.rb
|
79
|
+
- lib/assetsio-rails/version.rb
|
80
|
+
- rails/init.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: https://github.com/assets-io/assetsio-rails
|
83
|
+
licenses: []
|
84
|
+
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: -4394763084675672952
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: -4394763084675672952
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.6.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Assets.io helper for Rails 3.1
|
115
|
+
test_files: []
|
116
|
+
|