jquery-rails-cdn 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 905b1466bf0e3a89be9184259fd904dc9ae7913a
4
- data.tar.gz: 4bcb09cbf00ab56e6f9483f056b850d86010565e
2
+ SHA256:
3
+ metadata.gz: 827c0cab735c1e1d66cb48e767ad7c7adc48690268a885d8bffacf02f6a487a6
4
+ data.tar.gz: 98c8e3059c1b7ae1f95ade87a7788d9efdc205a5d5ee5f380aa84f2b4428c12d
5
5
  SHA512:
6
- metadata.gz: d7f503a50bceb0e971ade140cd97663ddab3f0777e678ad53493484ecc8787adde8e002fa9533b6f0532449fad3b2adaaf6cc9dabcdf3cbd4617311c86b7eab2
7
- data.tar.gz: 68b98770e1a3d30f74eaf29a246d2637e06d2416af41ace9fdb119098b650b28e4a9205c9c44f8f6c1f77562d3652bbeb3bd1abe0cc9b828ecf7317a37e3d42a
6
+ metadata.gz: f9a636c1c061e060de4ec63a15565743e2562b4002880633f12225d5baf6c3fa265c21fcbcca435b9acb8ce3777d3644c3b7f5749ad5a2ea1d5e720d5d2fb9fe
7
+ data.tar.gz: 9bceb0b76cf374896c82b2f27ba509534154421bf7d27c43701c61c30101bdb42cee2833d89d909acc53cb9c27bd9b94d0eeb9fb684421ecfb0393a4372e6857
data/README.md CHANGED
@@ -27,6 +27,7 @@ On top of that, if you're using asset pipeline, you may have noticed that the ma
27
27
 
28
28
  Changelog:
29
29
 
30
+ * v1.2.0: Support jQuery3. (Thanks to @CUnknown)
30
31
  * v1.1.0: Support jQuery2. (Thanks to @timurkhafizov)
31
32
  * v1.0.0: Options like `defer: true` or `data-turbolinks-eval: false` are allowed to be passed. (Thanks to @mkitt)
32
33
  * v0.4.0: Added Cloudflare. (Thanks to @damonmorgan)
@@ -89,7 +90,7 @@ If you want to check the production URL, you can pass `force: true` as an option
89
90
  jquery_include_tag :google, force: true
90
91
  ```
91
92
 
92
- ## jQuery 2
93
+ ## jQuery 2 / jQuery 3
93
94
 
94
95
  If you want to use jQuery 2, drop the following line in `config/initializers/jquery_cdn.rb`:
95
96
 
@@ -97,8 +98,23 @@ If you want to use jQuery 2, drop the following line in `config/initializers/jqu
97
98
  Jquery::Rails::Cdn.major_version = 2
98
99
  ```
99
100
 
101
+ or for jQuery 3:
102
+
103
+ ```ruby
104
+ Jquery::Rails::Cdn.major_version = 3
105
+ ```
106
+
100
107
  and then in `config/application.rb`:
101
108
 
102
109
  ```ruby
103
110
  config.assets.precompile += ['jquery2.js']
104
111
  ```
112
+
113
+ or for jQuery 3:
114
+
115
+ ```ruby
116
+ config.assets.precompile += ['jquery3.js']
117
+ ```
118
+
119
+ ## jQuery UI
120
+ To get the same CDN benefits with jQuery UI, we recommend [jquery-ui-rails-cdn](https://github.com/styx/jquery-ui-rails-cdn).
@@ -16,23 +16,25 @@ module Jquery::Rails
16
16
 
17
17
  def jquery_url(name)
18
18
  @@jquery_urls ||= begin
19
- constant = jquery_version_chooser('JQUERY_VERSION', 'JQUERY_2_VERSION')
19
+ constant = jquery_version_chooser('JQUERY_VERSION', 'JQUERY_2_VERSION', 'JQUERY_3_VERSION')
20
20
  version = "Jquery::Rails::#{constant}".constantize
21
21
  Hash[URL.map{|k,v| [k, v.sub(/\{JQUERY_VERSION\}/, version)] }]
22
22
  end
23
23
  if name == :local
24
- jquery_version_chooser(:jquery, :jquery2)
24
+ jquery_version_chooser(:jquery, :jquery2, :jquery3)
25
25
  else
26
26
  @@jquery_urls[name]
27
27
  end
28
28
  end
29
29
 
30
- def jquery_version_chooser(one, two)
30
+ def jquery_version_chooser(one, two, three)
31
31
  case Jquery::Rails::Cdn.major_version
32
32
  when 1, NilClass
33
33
  one
34
34
  when 2
35
35
  two
36
+ when 3
37
+ three
36
38
  else
37
39
  raise 'invalid :major_version option'
38
40
  end
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Rails
3
3
  module Cdn
4
- VERSION = '1.1.2'
4
+ VERSION = '1.2.0'
5
5
  end
6
6
  end
7
7
  end
@@ -46,4 +46,22 @@ class TestCdn < Minitest::Test
46
46
  assert_match regex, @view.jquery_include_tag(:google, force: true)
47
47
  end
48
48
  end
49
+
50
+ class Three < Minitest::Test
51
+ def setup
52
+ Jquery::Rails::Cdn.major_version = 3
53
+ Jquery::Rails::Cdn.class_variable_set(:@@jquery_urls, nil)
54
+ @view = ActionView::Base.new
55
+ end
56
+
57
+ def test_local
58
+ Jquery::Rails::Cdn.major_version = 3
59
+ assert_equal '<script src="/javascripts/jquery3.js"></script>', @view.jquery_include_tag(:google)
60
+ end
61
+
62
+ def test_remote
63
+ regex = Regexp.new 'ajax.googleapis.com/ajax/libs/jquery/3.\d+.\d+/jquery.min.js'
64
+ assert_match regex, @view.jquery_include_tag(:google, force: true)
65
+ end
66
+ end
49
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-rails-cdn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenn Ejima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-10 00:00:00.000000000 Z
11
+ date: 2019-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.4.8
76
+ rubygems_version: 2.7.7
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Add CDN support to jquery-rails