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 +5 -5
- data/README.md +17 -1
- data/lib/jquery-rails-cdn.rb +5 -3
- data/lib/jquery-rails-cdn/version.rb +1 -1
- data/test/test_cdn.rb +18 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 827c0cab735c1e1d66cb48e767ad7c7adc48690268a885d8bffacf02f6a487a6
|
4
|
+
data.tar.gz: 98c8e3059c1b7ae1f95ade87a7788d9efdc205a5d5ee5f380aa84f2b4428c12d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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).
|
data/lib/jquery-rails-cdn.rb
CHANGED
@@ -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
|
data/test/test_cdn.rb
CHANGED
@@ -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.
|
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:
|
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.
|
76
|
+
rubygems_version: 2.7.7
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Add CDN support to jquery-rails
|