headjs-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +82 -0
- data/LICENSE.txt +20 -0
- data/README.md +47 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/headjs-rails.gemspec +73 -0
- data/lib/generators/headjs/install/install_generator.rb +32 -0
- data/lib/headjs-rails.rb +3 -0
- data/lib/headjs-rails/tag_helper.rb +21 -0
- data/test/helper.rb +19 -0
- data/test/public/javascripts/jquery.js +0 -0
- data/test/public/javascripts/rails.js +0 -0
- data/test/test_generator.rb +31 -0
- data/test/test_tag_helper.rb +72 -0
- metadata +160 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.3)
|
6
|
+
actionpack (= 3.0.3)
|
7
|
+
mail (~> 2.2.9)
|
8
|
+
actionpack (3.0.3)
|
9
|
+
activemodel (= 3.0.3)
|
10
|
+
activesupport (= 3.0.3)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.6)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.3)
|
19
|
+
activesupport (= 3.0.3)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.3)
|
23
|
+
activemodel (= 3.0.3)
|
24
|
+
activesupport (= 3.0.3)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.3)
|
28
|
+
activemodel (= 3.0.3)
|
29
|
+
activesupport (= 3.0.3)
|
30
|
+
activesupport (3.0.3)
|
31
|
+
arel (2.0.6)
|
32
|
+
builder (2.1.2)
|
33
|
+
erubis (2.6.6)
|
34
|
+
abstract (>= 1.0.0)
|
35
|
+
git (1.2.5)
|
36
|
+
i18n (0.5.0)
|
37
|
+
jeweler (1.5.1)
|
38
|
+
bundler (~> 1.0.0)
|
39
|
+
git (>= 1.2.5)
|
40
|
+
rake
|
41
|
+
mail (2.2.11)
|
42
|
+
activesupport (>= 2.3.6)
|
43
|
+
i18n (~> 0.5.0)
|
44
|
+
mime-types (~> 1.16)
|
45
|
+
treetop (~> 1.4.8)
|
46
|
+
mime-types (1.16)
|
47
|
+
polyglot (0.3.1)
|
48
|
+
rack (1.2.1)
|
49
|
+
rack-mount (0.6.13)
|
50
|
+
rack (>= 1.0.0)
|
51
|
+
rack-test (0.5.6)
|
52
|
+
rack (>= 1.0)
|
53
|
+
rails (3.0.3)
|
54
|
+
actionmailer (= 3.0.3)
|
55
|
+
actionpack (= 3.0.3)
|
56
|
+
activerecord (= 3.0.3)
|
57
|
+
activeresource (= 3.0.3)
|
58
|
+
activesupport (= 3.0.3)
|
59
|
+
bundler (~> 1.0)
|
60
|
+
railties (= 3.0.3)
|
61
|
+
railties (3.0.3)
|
62
|
+
actionpack (= 3.0.3)
|
63
|
+
activesupport (= 3.0.3)
|
64
|
+
rake (>= 0.8.7)
|
65
|
+
thor (~> 0.14.4)
|
66
|
+
rake (0.8.7)
|
67
|
+
rcov (0.9.9)
|
68
|
+
shoulda (2.11.3)
|
69
|
+
thor (0.14.6)
|
70
|
+
treetop (1.4.9)
|
71
|
+
polyglot (>= 0.3.1)
|
72
|
+
tzinfo (0.3.23)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
bundler (~> 1.0.0)
|
79
|
+
jeweler (~> 1.5.1)
|
80
|
+
rails (>= 3.0.0)
|
81
|
+
rcov
|
82
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 David Bittencourt
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# headjs-rails
|
2
|
+
|
3
|
+
This gem adds a helper and a generator to facilitate the use of [Head JS](http://headjs.com) in your Rails 3 projects, the same way you would normally add javascript tags using Rails `javascript_include_tag` helper.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
In your Gemfile, add this line:
|
8
|
+
|
9
|
+
gem "headjs-rails"
|
10
|
+
|
11
|
+
Then, run `bundle install`. To invoke the generator and install the latest Head JS files in your `public/javascripts` folder, run:
|
12
|
+
|
13
|
+
rails generate headjs:install
|
14
|
+
|
15
|
+
Now just add headjs to your head, using default rails `javascript_include_tag('head.min')` for example, and put the rest of your scripts at the bottom of your layout with the `headjs_include_tag` method the gem provides. This method is a wrapper of `javascript_include_tag` and accepts the exact same methods, so it should work fine with any other gem/plugin that works with it.
|
16
|
+
|
17
|
+
headjs_include_tag(:defaults)
|
18
|
+
headjs_include_tag(:all)
|
19
|
+
headjs_include_tag('http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js')
|
20
|
+
headjs_include_tag('jquery', 'jquery.ui', 'jquery.plugin', 'rails')
|
21
|
+
headjs_include_tag(:defaults, :cache => true)
|
22
|
+
headjs_include_tag(:defaults, 'jquery.ui', :cache => 'bundle')
|
23
|
+
|
24
|
+
The sources will have labels automatically assigned based on the filename (removing .js, .min.js and any other parameter).
|
25
|
+
|
26
|
+
headjs_include_tag('jquery', 'rails')
|
27
|
+
# <script type="text/javascript">head.js( { 'jquery': '/javascripts/jquery.js?23495342' }, { 'rails': '/javascripts/rails.js?458292234' } );</script>
|
28
|
+
|
29
|
+
headjs_include_tag(:defaults, :cache => 'bundle')
|
30
|
+
# <script type="text/javascript">head.js( { 'bundle': '/javascripts/bundle.js' } );</script>
|
31
|
+
|
32
|
+
Don't forget to use `head.ready()` in any code that runs inside your views. More information in [Head JS API](http://headjs.com/#api).
|
33
|
+
|
34
|
+
I also suggest you take a look at the [smurf gem](https://github.com/thumblemonks/smurf), a drop-in gem that automatically minifies Javascript (and CSS) when you use caching and rails default include tag helpers. It works fine with `headjs_include_tag` as well as it's just a wrapper of `javascript_include_tag`.
|
35
|
+
|
36
|
+
## Testing
|
37
|
+
|
38
|
+
Clone the repo, run `bundle install` and `rake test`.
|
39
|
+
|
40
|
+
## Contributing to headjs-rails
|
41
|
+
|
42
|
+
Fork the project and send pull requests.
|
43
|
+
|
44
|
+
## Copyright
|
45
|
+
|
46
|
+
Author: David Bittencourt. See LICENSE.txt for further details.
|
47
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "headjs-rails"
|
16
|
+
gem.homepage = "http://github.com/muitocomplicado/headjs-rails"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Provides Rails 3 helper and generator for adding Head JS support.}
|
19
|
+
gem.description = %Q{This gem adds a helper and generator to facilitate the use of Head JS in your Rails 3 projects the same way you would normally add javascript tags using Rails default helpers.}
|
20
|
+
gem.email = "muitocomplicado@gmail.com"
|
21
|
+
gem.authors = ["David Bittencourt"]
|
22
|
+
end
|
23
|
+
Jeweler::RubygemsDotOrgTasks.new
|
24
|
+
|
25
|
+
require 'rake/testtask'
|
26
|
+
Rake::TestTask.new(:test) do |test|
|
27
|
+
test.libs << 'lib' << 'test'
|
28
|
+
test.pattern = 'test/**/test_*.rb'
|
29
|
+
test.verbose = true
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'rcov/rcovtask'
|
33
|
+
Rcov::RcovTask.new do |test|
|
34
|
+
test.libs << 'test'
|
35
|
+
test.pattern = 'test/**/test_*.rb'
|
36
|
+
test.verbose = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :test
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "headjs-rails #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{headjs-rails}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["David Bittencourt"]
|
12
|
+
s.date = %q{2010-12-02}
|
13
|
+
s.description = %q{This gem adds a helper and generator to facilitate the use of Head JS in your Rails 3 projects the same way you would normally add javascript tags using Rails default helpers.}
|
14
|
+
s.email = %q{muitocomplicado@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"headjs-rails.gemspec",
|
28
|
+
"lib/generators/headjs/install/install_generator.rb",
|
29
|
+
"lib/headjs-rails.rb",
|
30
|
+
"lib/headjs-rails/tag_helper.rb",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/public/javascripts/jquery.js",
|
33
|
+
"test/public/javascripts/rails.js",
|
34
|
+
"test/test_generator.rb",
|
35
|
+
"test/test_tag_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/muitocomplicado/headjs-rails}
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
41
|
+
s.summary = %q{Provides Rails 3 helper and generator for adding Head JS support.}
|
42
|
+
s.test_files = [
|
43
|
+
"test/helper.rb",
|
44
|
+
"test/test_generator.rb",
|
45
|
+
"test/test_tag_helper.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
|
54
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
57
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
60
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
61
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
63
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
64
|
+
end
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
67
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
68
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
69
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
70
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Headjs
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < ::Rails::Generators::Base
|
4
|
+
desc "This generator downloads and installs Head JS"
|
5
|
+
class_option :version, :type => :string, :default => "master", :desc => "Which version of Head JS to fetch"
|
6
|
+
@@default_version = "master"
|
7
|
+
|
8
|
+
def remove_headjs
|
9
|
+
%w(head.js head.min.js).each do |js|
|
10
|
+
remove_file "public/javascripts/#{js}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def download_headjs
|
15
|
+
say_status("fetching", "Head JS (#{options.version})", :green)
|
16
|
+
get_headjs(options.version)
|
17
|
+
rescue OpenURI::HTTPError
|
18
|
+
say_status("warning", "could not find Head JS (#{options.version})", :yellow)
|
19
|
+
say_status("fetching", "Head JS (#{@@default_version})", :green)
|
20
|
+
get_headjs(@@default_version)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def get_headjs(version)
|
26
|
+
get "https://github.com/headjs/headjs/raw/#{version}/head.js", "public/javascripts/head.js"
|
27
|
+
get "https://github.com/headjs/headjs/raw/#{version}/head.min.js", "public/javascripts/head.min.js"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/headjs-rails.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Headjs
|
2
|
+
|
3
|
+
module TagHelper
|
4
|
+
|
5
|
+
def headjs_include_tag(*sources)
|
6
|
+
keys = []
|
7
|
+
content_tag :script, :type => Mime::JS do
|
8
|
+
"head.js( #{javascript_include_tag(*sources).scan(/src="([^"]+)"/).flatten.map { |src|
|
9
|
+
key = URI.parse(src).path[%r{[^/]+\z}].gsub(/\.js$/,'').gsub(/\.min$/,'')
|
10
|
+
while keys.include?(key) do
|
11
|
+
key += '_' + key
|
12
|
+
end
|
13
|
+
keys << key
|
14
|
+
"{ '#{key}': '#{src}' }"
|
15
|
+
}.join(', ')} );"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
|
11
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
|
14
|
+
require 'rails/all'
|
15
|
+
require 'shoulda'
|
16
|
+
require 'rails/test_help'
|
17
|
+
require 'rails/generators'
|
18
|
+
require 'headjs-rails'
|
19
|
+
|
File without changes
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'generators/headjs/install/install_generator'
|
3
|
+
|
4
|
+
class Headjs::Generators::InstallGeneratorTest < Rails::Generators::TestCase
|
5
|
+
tests Headjs::Generators::InstallGenerator
|
6
|
+
destination File.join(File.dirname(__FILE__), 'tmp')
|
7
|
+
teardown :cleanup_destination_root
|
8
|
+
|
9
|
+
context 'the Head JS install generator' do
|
10
|
+
|
11
|
+
should 'download the default master Head JS files' do
|
12
|
+
run_generator %w(headjs:install)
|
13
|
+
assert_file 'public/javascripts/head.js'
|
14
|
+
assert_file 'public/javascripts/head.min.js'
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'download the versioned Head JS files' do
|
18
|
+
run_generator %w(headjs:install --version master)
|
19
|
+
assert_file 'public/javascripts/head.js'
|
20
|
+
assert_file 'public/javascripts/head.min.js'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def cleanup_destination_root
|
28
|
+
FileUtils.rm_r(destination_root)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Headjs
|
4
|
+
|
5
|
+
class TagHelperTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
|
9
|
+
ENV["RAILS_ASSET_ID"] = ''
|
10
|
+
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :defaults => %w(jquery rails)
|
11
|
+
|
12
|
+
public_dir = File.join(File.dirname(__FILE__), 'public')
|
13
|
+
@helpers = ActionController::Base.helpers
|
14
|
+
@helpers.config.perform_caching = false
|
15
|
+
@helpers.config.assets_dir = public_dir
|
16
|
+
@helpers.config.javascripts_dir = "#{public_dir}/javascripts"
|
17
|
+
|
18
|
+
%w(all.js bundle.js).each do |js|
|
19
|
+
begin
|
20
|
+
File.delete(File.join(public_dir, 'javascripts', js))
|
21
|
+
rescue
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def jquery
|
28
|
+
'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'
|
29
|
+
end
|
30
|
+
|
31
|
+
context "The Head JS helper include tag" do
|
32
|
+
|
33
|
+
should "return a valid script tag" do
|
34
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'jquery': '#{jquery}' } );</script>", @helpers.headjs_include_tag(jquery)
|
35
|
+
end
|
36
|
+
|
37
|
+
should "concatenate labels to avoid overwriting" do
|
38
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'jquery': '#{jquery}' }, { 'jquery_jquery': '#{jquery}' } );</script>", @helpers.headjs_include_tag(jquery, jquery)
|
39
|
+
end
|
40
|
+
|
41
|
+
should "accept strings for local paths" do
|
42
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'jquery': '/javascripts/jquery.js' }, { 'rails': '/javascripts/other/rails.js' } );</script>", @helpers.headjs_include_tag('jquery', 'other/rails')
|
43
|
+
end
|
44
|
+
|
45
|
+
should "accept :defaults registered expansions" do
|
46
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'jquery': '/javascripts/jquery.js' }, { 'rails': '/javascripts/rails.js' } );</script>", @helpers.headjs_include_tag(:defaults)
|
47
|
+
end
|
48
|
+
|
49
|
+
should "accept :all expansion" do
|
50
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'jquery': '/javascripts/jquery.js' }, { 'rails': '/javascripts/rails.js' }, { 'application': '/javascripts/application.js' } );</script>", @helpers.headjs_include_tag(:all)
|
51
|
+
end
|
52
|
+
|
53
|
+
should "accept a :cache => true parameter" do
|
54
|
+
@helpers.config.perform_caching = true
|
55
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'all': '/javascripts/all.js' } );</script>", @helpers.headjs_include_tag(:defaults, :cache => true)
|
56
|
+
end
|
57
|
+
|
58
|
+
should "accept a :cache => bundle parameter" do
|
59
|
+
@helpers.config.perform_caching = true
|
60
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'bundle': '/javascripts/bundle.js' } );</script>", @helpers.headjs_include_tag(:defaults, :cache => 'bundle')
|
61
|
+
end
|
62
|
+
|
63
|
+
should "work with random rails asset ids" do
|
64
|
+
ENV["RAILS_ASSET_ID"] = '123456789'
|
65
|
+
assert_equal "<script type=\"text/javascript\">head.js( { 'jquery': '/javascripts/jquery.js?#{ENV["RAILS_ASSET_ID"]}' }, { 'rails': '/javascripts/rails.js?#{ENV["RAILS_ASSET_ID"]}' } );</script>", @helpers.headjs_include_tag(:defaults)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: headjs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- David Bittencourt
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-02 00:00:00 -02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 7
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 3.0.0
|
33
|
+
type: :runtime
|
34
|
+
name: rails
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
name: shoulda
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 23
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 0
|
61
|
+
- 0
|
62
|
+
version: 1.0.0
|
63
|
+
type: :development
|
64
|
+
name: bundler
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 1
|
74
|
+
segments:
|
75
|
+
- 1
|
76
|
+
- 5
|
77
|
+
- 1
|
78
|
+
version: 1.5.1
|
79
|
+
type: :development
|
80
|
+
name: jeweler
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
type: :development
|
94
|
+
name: rcov
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: *id005
|
97
|
+
description: This gem adds a helper and generator to facilitate the use of Head JS in your Rails 3 projects the same way you would normally add javascript tags using Rails default helpers.
|
98
|
+
email: muitocomplicado@gmail.com
|
99
|
+
executables: []
|
100
|
+
|
101
|
+
extensions: []
|
102
|
+
|
103
|
+
extra_rdoc_files:
|
104
|
+
- LICENSE.txt
|
105
|
+
- README.md
|
106
|
+
files:
|
107
|
+
- .document
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- VERSION
|
114
|
+
- headjs-rails.gemspec
|
115
|
+
- lib/generators/headjs/install/install_generator.rb
|
116
|
+
- lib/headjs-rails.rb
|
117
|
+
- lib/headjs-rails/tag_helper.rb
|
118
|
+
- test/helper.rb
|
119
|
+
- test/public/javascripts/jquery.js
|
120
|
+
- test/public/javascripts/rails.js
|
121
|
+
- test/test_generator.rb
|
122
|
+
- test/test_tag_helper.rb
|
123
|
+
has_rdoc: true
|
124
|
+
homepage: http://github.com/muitocomplicado/headjs-rails
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
hash: 3
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
version: "0"
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
requirements: []
|
151
|
+
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 1.3.7
|
154
|
+
signing_key:
|
155
|
+
specification_version: 3
|
156
|
+
summary: Provides Rails 3 helper and generator for adding Head JS support.
|
157
|
+
test_files:
|
158
|
+
- test/helper.rb
|
159
|
+
- test/test_generator.rb
|
160
|
+
- test/test_tag_helper.rb
|