jquery_tag 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +10 -12
- data/README.markdown +7 -4
- data/jquery_tag.gemspec +3 -3
- data/lib/jquery_tag/version.rb +2 -4
- data/lib/jquery_tag/view_helpers.rb +21 -23
- data/lib/jquery_tag.rb +1 -1
- data/spec/jquery_tag_spec.rb +12 -12
- metadata +9 -13
data/Gemfile.lock
CHANGED
@@ -7,21 +7,19 @@ GEM
|
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.1.2)
|
10
|
-
rspec (2.
|
11
|
-
rspec-core (
|
12
|
-
rspec-expectations (
|
13
|
-
rspec-mocks (
|
14
|
-
rspec-core (2.
|
15
|
-
rspec-expectations (2.
|
16
|
-
diff-lcs (
|
17
|
-
rspec-mocks (2.
|
18
|
-
rspec-core (= 2.0.0)
|
19
|
-
rspec-expectations (= 2.0.0)
|
10
|
+
rspec (2.1.0)
|
11
|
+
rspec-core (~> 2.1.0)
|
12
|
+
rspec-expectations (~> 2.1.0)
|
13
|
+
rspec-mocks (~> 2.1.0)
|
14
|
+
rspec-core (2.1.0)
|
15
|
+
rspec-expectations (2.1.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.1.0)
|
20
18
|
|
21
19
|
PLATFORMS
|
22
20
|
ruby
|
23
21
|
|
24
22
|
DEPENDENCIES
|
25
|
-
bundler (
|
23
|
+
bundler (~> 1)
|
26
24
|
jquery_tag!
|
27
|
-
rspec (
|
25
|
+
rspec (~> 2)
|
data/README.markdown
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Jquery_tag
|
2
|
-
a Rails Helper for togglin' between a local jquery.js file
|
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
|
+
Also supports the same behaviour for a local jquery-ui.js file or the CDN version.
|
3
4
|
|
4
5
|
## Installation
|
5
|
-
`
|
6
|
+
Just add the `jquery_tag` to your Gemfile and run `bundle install`
|
6
7
|
|
7
8
|
## Usage
|
8
9
|
Inside your views
|
@@ -11,6 +12,8 @@ Inside your views
|
|
11
12
|
|
12
13
|
Accepted options:
|
13
14
|
|
14
|
-
:version # Overrides the script version on the CDN URL. Defaults do '1.4
|
15
|
+
:version # Overrides the script version on the CDN URL. Defaults do '1.4'
|
15
16
|
:file # Path for the local script. Defaults do 'jquery.js'
|
16
|
-
:
|
17
|
+
:ui # Loads the jquery-ui file. Accepts a true value for loading a 'jquery-ui.js' file or a String for the local path.
|
18
|
+
|
19
|
+
Any other arguments will be passed along to the `javascript_include_tag` helper.
|
data/jquery_tag.gemspec
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path("../lib/jquery_tag/version", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "jquery_tag"
|
6
|
-
s.version =
|
6
|
+
s.version = JqueryTag::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Lucas Mazza"]
|
9
9
|
s.email = ["luc4smazza@gmail.com"]
|
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = "Helper gem that toggles between local jquery script and Google CDN version based on your app environment"
|
13
13
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
|
-
s.add_development_dependency "bundler", "
|
16
|
-
s.add_development_dependency "rspec", "
|
15
|
+
s.add_development_dependency "bundler", "~> 1"
|
16
|
+
s.add_development_dependency "rspec", "~> 2"
|
17
17
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
data/lib/jquery_tag/version.rb
CHANGED
@@ -1,27 +1,25 @@
|
|
1
|
-
module
|
2
|
-
module
|
3
|
-
|
4
|
-
def jquery_tag(*args)
|
5
|
-
|
6
|
-
options = args.first.is_a?(Hash) ? args.pop : {}
|
1
|
+
module JqueryTag
|
2
|
+
module ViewHelpers
|
3
|
+
def jquery_tag(*args)
|
7
4
|
|
8
|
-
|
9
|
-
args.unshift(jquery_file(options[:file], options[:version]))
|
5
|
+
options = args.first.is_a?(Hash) ? args.pop : {}
|
10
6
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
7
|
+
args.unshift(jquery_ui_file(options[:ui])) if options[:ui]
|
8
|
+
args.unshift(jquery_file(options[:file], options[:version]))
|
9
|
+
|
10
|
+
javascript_include_tag args
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def jquery_file(path, version)
|
15
|
+
path ||= 'jquery.js'
|
16
|
+
version ||= '1.4'
|
17
|
+
Rails.env.production? ? "http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js" : path
|
18
|
+
end
|
19
|
+
|
20
|
+
def jquery_ui_file(path)
|
21
|
+
path = path.is_a?(String) ? path : "jquery-ui.js"
|
22
|
+
Rails.env.production? ? 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js' : path
|
23
|
+
end
|
26
24
|
end
|
27
25
|
end
|
data/lib/jquery_tag.rb
CHANGED
data/spec/jquery_tag_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
include
|
5
|
-
|
3
|
+
describe JqueryTag::ViewHelpers do
|
4
|
+
include JqueryTag::ViewHelpers
|
5
|
+
|
6
6
|
context "development" do
|
7
7
|
before { development! }
|
8
8
|
|
@@ -10,17 +10,17 @@ describe Jquery::Tag::ViewHelpers do
|
|
10
10
|
expects_include_with ['jquery.js']
|
11
11
|
jquery_tag
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "delegates any other arguments" do
|
15
15
|
expects_include_with ['jquery.js', 'application.js']
|
16
16
|
jquery_tag 'application.js'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "accepts a different path for the local jquery file" do
|
20
20
|
expects_include_with ['frameworks/jquery.min.js']
|
21
21
|
jquery_tag :file => "frameworks/jquery.min.js"
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "renders the jquery-ui.js file" do
|
25
25
|
expects_include_with ['jquery.js', 'jquery-ui.js']
|
26
26
|
jquery_tag :ui => true
|
@@ -31,22 +31,22 @@ describe Jquery::Tag::ViewHelpers do
|
|
31
31
|
jquery_tag :ui => 'frameworks/jquery-ui.js'
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
context "production" do
|
36
36
|
before { production! }
|
37
|
-
|
37
|
+
|
38
38
|
it "uses the google CDN path" do
|
39
|
-
expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.4
|
39
|
+
expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js']
|
40
40
|
jquery_tag
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "accepts a different version for the jquery script" do
|
44
44
|
expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.0.0/jquery.min.js']
|
45
45
|
jquery_tag :version => '1.0.0'
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "uses the google CDN path for the jquery ui script" do
|
49
|
-
expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.4
|
49
|
+
expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js']
|
50
50
|
jquery_tag :ui => true
|
51
51
|
end
|
52
52
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lucas Mazza
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-12 00:00:00 -02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,14 +24,12 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 1
|
30
30
|
segments:
|
31
31
|
- 1
|
32
|
-
|
33
|
-
- 0
|
34
|
-
version: 1.0.0
|
32
|
+
version: "1"
|
35
33
|
type: :development
|
36
34
|
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
@@ -40,14 +38,12 @@ dependencies:
|
|
40
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
|
-
- -
|
41
|
+
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
43
|
+
hash: 7
|
46
44
|
segments:
|
47
45
|
- 2
|
48
|
-
|
49
|
-
- 0
|
50
|
-
version: 2.0.0
|
46
|
+
version: "2"
|
51
47
|
type: :development
|
52
48
|
version_requirements: *id002
|
53
49
|
description: Helper gem that toggles between local jquery script and Google CDN version based on your app environment
|