jquery_tag 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/lib/jquery_tag/helper.rb +4 -4
- data/lib/jquery_tag/helpers/rails_helper.rb +1 -1
- data/lib/jquery_tag/helpers/sinatra_helper.rb +1 -1
- data/lib/jquery_tag/version.rb +1 -1
- data/lib/jquery_tag.rb +2 -2
- data/spec/rails_helper_spec.rb +2 -2
- data/spec/sinatra_helper_spec.rb +3 -3
- metadata +5 -5
data/README.markdown
CHANGED
@@ -16,7 +16,7 @@ Inside your views, you can just call the `jquery_tag` method.
|
|
16
16
|
|
17
17
|
It accepts a some configuration options by using the following symbols:
|
18
18
|
|
19
|
-
:version # Overrides the script version on the CDN URL. Defaults do '1.5.
|
19
|
+
:version # Overrides the script version on the CDN URL. Defaults do '1.5.1'
|
20
20
|
:file # Path for the local script. Defaults do 'jquery.js'
|
21
21
|
:ui # Loads jQuery UI. Accepts a true value for loading a 'jquery-ui.js' file or a String for the local path.
|
22
22
|
|
data/lib/jquery_tag/helper.rb
CHANGED
@@ -12,14 +12,14 @@ module JqueryTag # :nodoc:
|
|
12
12
|
## <script type="text/javascript" src="/javascripts/jquery.js"></script>
|
13
13
|
## Your application will be using a local version of jQuery, avoiding any network usage. Once you
|
14
14
|
## shift to production mode, the ouput will be:
|
15
|
-
## <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.
|
15
|
+
## <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
|
16
16
|
## Reducing your server bandwidth load and sharing the same cached file from many other sites.
|
17
17
|
##
|
18
18
|
## == Dependencies
|
19
19
|
## +jQueryTag::Helper+ relies on two other methods that should be implemented:
|
20
20
|
##
|
21
21
|
## * +production?+ - it should return +true+ if the application is on production mode. Otherwise, false.
|
22
|
-
## * +
|
22
|
+
## * +create_javascript_tags(paths, options)+ - responsible for building the tags for the given paths array. Any other option should be passed on the second argument, a options hash.
|
23
23
|
module Helper
|
24
24
|
|
25
25
|
## Builds the proper script tags for a suitable url or path for both jQuery or jQuery UI scripts.
|
@@ -27,7 +27,7 @@ module JqueryTag # :nodoc:
|
|
27
27
|
## @option :file [String] an alternative path for the local jquery.js file. Defaults to `jquery.js`
|
28
28
|
## @option :version [String] tells the helper to target a different version of jQuery hosted on Google's CDN. Defaults to JqueryTag.version
|
29
29
|
## @option :ui [String, TrueClass] loads the jQuery UI File. Can be a [TrueClass] or a [String], overriding the local path for the script.
|
30
|
-
## Any other argument will be delivered to the +
|
30
|
+
## Any other argument will be delivered to the +create_javascript_tags+ method.
|
31
31
|
##
|
32
32
|
## @return [String] the html tags to include scripts
|
33
33
|
def jquery_tag(*arguments)
|
@@ -36,7 +36,7 @@ module JqueryTag # :nodoc:
|
|
36
36
|
paths << jquery_file(options[:file], options[:version])
|
37
37
|
paths << jquery_ui_file(options[:ui]) if options[:ui]
|
38
38
|
|
39
|
-
|
39
|
+
create_javascript_tags(paths, arguments)
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
@@ -14,7 +14,7 @@ module JqueryTag # :nodoc:
|
|
14
14
|
## @param [Array] paths_or_urls The paths for the local files or the CDN urls.
|
15
15
|
## @param [Hash] options any other option that should be delivered to +javascript_include_tag+.
|
16
16
|
## @return [String] the concatenated html tags
|
17
|
-
def
|
17
|
+
def create_javascript_tags(paths_or_urls, options = {})
|
18
18
|
arguments = paths_or_urls + [options].flatten
|
19
19
|
javascript_include_tag(arguments)
|
20
20
|
end
|
@@ -19,7 +19,7 @@ module JqueryTag # :nodoc:
|
|
19
19
|
## @param [Array] paths_or_urls The paths for the local files or the CDN urls.
|
20
20
|
## @param [Hash] options the current implementation doesn't use the options hash.
|
21
21
|
## @return [String] the concatenated html tags
|
22
|
-
def
|
22
|
+
def create_javascript_tags(paths_or_urls, options = {})
|
23
23
|
paths_or_urls.map { |path| build_tag(path) }.join
|
24
24
|
end
|
25
25
|
|
data/lib/jquery_tag/version.rb
CHANGED
data/lib/jquery_tag.rb
CHANGED
@@ -4,9 +4,9 @@ require 'jquery_tag/helpers/sinatra_helper'
|
|
4
4
|
|
5
5
|
module JqueryTag # :nodoc:
|
6
6
|
## @return [String] the current (mostly latest) version of jQuery.
|
7
|
-
def self.version; '1.5.
|
7
|
+
def self.version; '1.5.1'; end
|
8
8
|
## @return [String] the current (mostly latest) version of jQuery UI.
|
9
|
-
def self.ui_version; '1.8.
|
9
|
+
def self.ui_version; '1.8.10'; end
|
10
10
|
end
|
11
11
|
|
12
12
|
ActionView::Base.send(:include, JqueryTag::RailsHelper) if defined? Rails
|
data/spec/rails_helper_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe JqueryTag::RailsHelper do
|
|
41
41
|
before { production! }
|
42
42
|
|
43
43
|
it "uses the google CDN path" do
|
44
|
-
expects_include_with ['//ajax.googleapis.com/ajax/libs/jquery/1.5.
|
44
|
+
expects_include_with ['//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js']
|
45
45
|
jquery_tag
|
46
46
|
end
|
47
47
|
|
@@ -51,7 +51,7 @@ describe JqueryTag::RailsHelper do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "uses the google CDN path for the jquery ui script" do
|
54
|
-
expects_include_with ['//ajax.googleapis.com/ajax/libs/jquery/1.5.
|
54
|
+
expects_include_with ['//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js']
|
55
55
|
jquery_tag :ui => true
|
56
56
|
end
|
57
57
|
end
|
data/spec/sinatra_helper_spec.rb
CHANGED
@@ -33,7 +33,7 @@ describe JqueryTag::SinatraHelper do
|
|
33
33
|
before { production! }
|
34
34
|
|
35
35
|
it "uses the google CDN path" do
|
36
|
-
expected = %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.
|
36
|
+
expected = %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>}
|
37
37
|
jquery_tag.should == expected
|
38
38
|
end
|
39
39
|
|
@@ -43,8 +43,8 @@ describe JqueryTag::SinatraHelper do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "uses the google CDN path for the jquery ui script" do
|
46
|
-
expected = %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.
|
47
|
-
expected << %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.
|
46
|
+
expected = %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>}
|
47
|
+
expected << %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>}
|
48
48
|
jquery_tag(:ui => true).should == expected
|
49
49
|
end
|
50
50
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
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: 2011-
|
18
|
+
date: 2011-03-14 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements: []
|
106
106
|
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 1.6.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 3
|
111
111
|
summary: jQuery script tag helper for Rails and Sinatra
|