jquery_tag 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +42 -0
- data/README.markdown +16 -0
- data/Rakefile +12 -0
- data/jquery_tag.gemspec +21 -0
- data/lib/jquery_tag/version.rb +5 -0
- data/lib/jquery_tag/view_helpers.rb +17 -0
- data/lib/jquery_tag.rb +3 -0
- data/test/jquery_tag_test.rb +31 -0
- data/test/support.rb +25 -0
- data/test/test_helper.rb +10 -0
- metadata +110 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jquery_tag (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
abstract (1.0.0)
|
10
|
+
actionpack (3.0.0)
|
11
|
+
activemodel (= 3.0.0)
|
12
|
+
activesupport (= 3.0.0)
|
13
|
+
builder (~> 2.1.2)
|
14
|
+
erubis (~> 2.6.6)
|
15
|
+
i18n (~> 0.4.1)
|
16
|
+
rack (~> 1.2.1)
|
17
|
+
rack-mount (~> 0.6.12)
|
18
|
+
rack-test (~> 0.5.4)
|
19
|
+
tzinfo (~> 0.3.23)
|
20
|
+
activemodel (3.0.0)
|
21
|
+
activesupport (= 3.0.0)
|
22
|
+
builder (~> 2.1.2)
|
23
|
+
i18n (~> 0.4.1)
|
24
|
+
activesupport (3.0.0)
|
25
|
+
builder (2.1.2)
|
26
|
+
erubis (2.6.6)
|
27
|
+
abstract (>= 1.0.0)
|
28
|
+
i18n (0.4.1)
|
29
|
+
rack (1.2.1)
|
30
|
+
rack-mount (0.6.13)
|
31
|
+
rack (>= 1.0.0)
|
32
|
+
rack-test (0.5.6)
|
33
|
+
rack (>= 1.0)
|
34
|
+
tzinfo (0.3.23)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
actionpack
|
41
|
+
bundler (>= 1.0.0)
|
42
|
+
jquery_tag!
|
data/README.markdown
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Jquery_tag
|
2
|
+
a Rails Helper for togglin' between a local jquery.js file `located in /public/javascripts/jquery.js` or the hosted script on Google's CDN.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
`gem jquery_tag` + `bundle install`
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
Inside your views
|
9
|
+
|
10
|
+
<%= jquery_tag %>
|
11
|
+
|
12
|
+
Accepted options:
|
13
|
+
|
14
|
+
:version # Overrides the script version on the CDN URL. Defaults do '1.4.2'
|
15
|
+
:file # Path for the local script. Defaults do 'jquery.js'
|
16
|
+
:args # Any other arguments that will be passed to the javascript_include_tag helper
|
data/Rakefile
ADDED
data/jquery_tag.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/jquery_tag/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "jquery_tag"
|
6
|
+
s.version = Jquery::Tag::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Lucas Mazza"]
|
9
|
+
s.email = ["luc4smazza@gmail.com"]
|
10
|
+
s.homepage = "http://rubygems.org/gems/jquery_tag"
|
11
|
+
s.summary = "jQuery script tag helper for Rails"
|
12
|
+
s.description = "Helper gem that toggles between local jquery script and Google CDN version based on your app environment"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
16
|
+
s.add_development_dependency "actionpack"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
20
|
+
s.require_path = 'lib'
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Jquery
|
2
|
+
module Tag
|
3
|
+
module ViewHelpers
|
4
|
+
|
5
|
+
def jquery_tag(options = {})
|
6
|
+
arguments = options.delete(:args) || []
|
7
|
+
path = options.delete(:file) || "jquery.js"
|
8
|
+
version = options.delete(:version) || "1.4.2"
|
9
|
+
|
10
|
+
path = "http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js" if Rails.env.production?
|
11
|
+
|
12
|
+
arguments.unshift(path)
|
13
|
+
javascript_include_tag arguments
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/jquery_tag.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class HelperTest < ActionView::TestCase
|
3
|
+
tests Jquery::Tag::ViewHelpers
|
4
|
+
|
5
|
+
test "should render a script tag for a local jquery.js file" do
|
6
|
+
environment :development do
|
7
|
+
assert_match /\/javascripts\/jquery.js/, jquery_tag
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
test "should accept a different path for the local script file" do
|
12
|
+
environment :development do
|
13
|
+
assert_match /\/javascripts\/frameworks\/jquery.min.js/, jquery_tag(:file => "frameworks/jquery.min.js")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should use the Google CDN url when in production environment" do
|
18
|
+
environment :production do
|
19
|
+
assert_match /ajax.googleapis.com\/\S*\/1.4.2\/jquery.min.js/, jquery_tag
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
test "should accept another jquery version for the Google CDN" do
|
24
|
+
environment :production do
|
25
|
+
assert_match /ajax.googleapis.com\/\S*\/1.4.1\/jquery.min.js/, jquery_tag(:version => "1.4.1")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
data/test/support.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Jquery::Routes = ActionDispatch::Routing::RouteSet.new
|
2
|
+
Jquery::Routes.draw do
|
3
|
+
match ':controller(/:action(/:id(.:format)))'
|
4
|
+
end
|
5
|
+
|
6
|
+
class ApplicationController < ActionController::Base; end
|
7
|
+
ActionController::Base.send :include, Jquery::Routes.url_helpers
|
8
|
+
|
9
|
+
# Here we have some lame workarounds for testing.
|
10
|
+
ENV["RAILS_ASSET_ID"] = ""
|
11
|
+
|
12
|
+
module Rails
|
13
|
+
def self.env
|
14
|
+
@_env ||= ActiveSupport::StringInquirer.new("development")
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.env=(env)
|
18
|
+
@_env = env
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def environment(env)
|
23
|
+
Rails.env = ActiveSupport::StringInquirer.new(env.to_s)
|
24
|
+
yield
|
25
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery_tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Lucas Mazza
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-30 00:00:00 -03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bundler
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 1.0.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: actionpack
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
description: Helper gem that toggles between local jquery script and Google CDN version based on your app environment
|
52
|
+
email:
|
53
|
+
- luc4smazza@gmail.com
|
54
|
+
executables: []
|
55
|
+
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files: []
|
59
|
+
|
60
|
+
files:
|
61
|
+
- .gitignore
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.lock
|
64
|
+
- README.markdown
|
65
|
+
- Rakefile
|
66
|
+
- jquery_tag.gemspec
|
67
|
+
- lib/jquery_tag.rb
|
68
|
+
- lib/jquery_tag/version.rb
|
69
|
+
- lib/jquery_tag/view_helpers.rb
|
70
|
+
- test/jquery_tag_test.rb
|
71
|
+
- test/support.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://rubygems.org/gems/jquery_tag
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 23
|
97
|
+
segments:
|
98
|
+
- 1
|
99
|
+
- 3
|
100
|
+
- 6
|
101
|
+
version: 1.3.6
|
102
|
+
requirements: []
|
103
|
+
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.3.7
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: jQuery script tag helper for Rails
|
109
|
+
test_files: []
|
110
|
+
|