jquery_tag 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.2'
19
+ :version # Overrides the script version on the CDN URL. Defaults do '1.6.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
 
@@ -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.6.0'; end
7
+ def self.version; '1.6.1'; end
8
8
  ## @return [String] the current (mostly latest) version of jQuery UI.
9
- def self.ui_version; '1.8.12'; end
9
+ def self.ui_version; '1.8.13'; end
10
10
  end
11
11
 
12
12
  ActionView::Base.send(:include, JqueryTag::RailsHelper) if defined? Rails
@@ -15,8 +15,13 @@ module JqueryTag # :nodoc:
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
17
  def create_javascript_tags(paths_or_urls, options = {})
18
- arguments = paths_or_urls + [options].flatten
19
- javascript_include_tag(arguments)
18
+ arguments = [paths_or_urls, options].flatten
19
+ options = arguments.last.is_a?(Hash) ? arguments.pop : nil
20
+
21
+ arguments.map { |path_or_url|
22
+ arguments = [path_or_url, options].compact
23
+ javascript_include_tag(*arguments)
24
+ }.join.html_safe
20
25
  end
21
26
  end
22
27
  end
@@ -1,3 +1,3 @@
1
1
  module JqueryTag #:nodoc:
2
- VERSION = "0.2.3" # :nodoc:
2
+ VERSION = "0.2.4" # :nodoc:
3
3
  end
@@ -7,32 +7,32 @@ describe JqueryTag::RailsHelper do
7
7
  before { development! }
8
8
 
9
9
  it "renders a local jquery.js file" do
10
- expects_include_with ['jquery.js']
10
+ expects_includes_with ['jquery.js']
11
11
  jquery_tag
12
12
  end
13
13
 
14
14
  it "delegates any other arguments and options" do
15
- expects_include_with ['jquery.js', {:cached => true}]
15
+ expects_includes_with ['jquery.js', {:cached => true}]
16
16
  jquery_tag :cached => true
17
17
  end
18
18
 
19
19
  it "delegates any other arguments" do
20
- expects_include_with ['jquery.js', 'other.js', {:cached => true}]
20
+ expects_includes_with ['jquery.js', 'other.js', {:cached => true}]
21
21
  jquery_tag 'other.js', :cached => true
22
22
  end
23
23
 
24
24
  it "accepts a different path for the local jquery file" do
25
- expects_include_with ['frameworks/jquery.min.js']
25
+ expects_includes_with ['frameworks/jquery.min.js']
26
26
  jquery_tag :file => "frameworks/jquery.min.js"
27
27
  end
28
28
 
29
29
  it "renders the jquery-ui.js file" do
30
- expects_include_with ['jquery.js', 'jquery-ui.js']
30
+ expects_includes_with ['jquery.js', 'jquery-ui.js']
31
31
  jquery_tag :ui => true
32
32
  end
33
33
 
34
34
  it "receives a path to the jquery-ui.js file" do
35
- expects_include_with ['jquery.js', 'frameworks/jquery-ui.js']
35
+ expects_includes_with ['jquery.js', 'frameworks/jquery-ui.js']
36
36
  jquery_tag :ui => 'frameworks/jquery-ui.js'
37
37
  end
38
38
  end
@@ -41,17 +41,17 @@ 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.6.0/jquery.min.js']
44
+ expects_includes_with ['//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js']
45
45
  jquery_tag
46
46
  end
47
47
 
48
48
  it "accepts a different version for the jquery script" do
49
- expects_include_with ['//ajax.googleapis.com/ajax/libs/jquery/1.0.0/jquery.min.js']
49
+ expects_includes_with ['//ajax.googleapis.com/ajax/libs/jquery/1.0.0/jquery.min.js']
50
50
  jquery_tag :version => '1.0.0'
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.6.0/jquery.min.js', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js']
54
+ expects_includes_with ['//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js']
55
55
  jquery_tag :ui => true
56
56
  end
57
57
  end
@@ -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.6.0/jquery.min.js"></script>}
36
+ expected = %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.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.6.0/jquery.min.js"></script>}
47
- expected << %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>}
46
+ expected = %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>}
47
+ expected << %Q{<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>}
48
48
  jquery_tag(:ui => true).should == expected
49
49
  end
50
50
  end
@@ -19,11 +19,19 @@ module SpecHelper
19
19
  Rails.stub_chain(:env, :production?) { false }
20
20
  end
21
21
 
22
- def expects_include_with(*args)
23
- should_receive(:javascript_include_tag).with(*args)
22
+ def expects_includes_with(args)
23
+ opts = args.last.is_a?(Hash) ? args.pop : nil
24
+ args.each do |value|
25
+ arguments = [value, opts].compact.flatten
26
+ should_receive(:javascript_include_tag).with(*arguments)
27
+ end
24
28
  end
25
29
  end
26
30
 
31
+ class String
32
+ def html_safe; self; end
33
+ end
34
+
27
35
  RSpec.configure do |config|
28
36
  config.include SpecHelper
29
37
  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: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
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-05-05 00:00:00 -03:00
18
+ date: 2011-05-25 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency