jquery-rails-cdn 1.0.3 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c4e6d51db0f60d5e3a26d12c0a2d7b83d70c8d5
4
- data.tar.gz: 83f2c3427276ef5b1b8ffc72a7dc05ea458fdfa4
3
+ metadata.gz: 74f2fc075f341160c003b22d6ac144273772eed7
4
+ data.tar.gz: e301f983738623f8847385d6dd8d3967960f31ee
5
5
  SHA512:
6
- metadata.gz: f5e028fdb357b141e94ea66f917bc73e1892082fb337666fb50923fe6d410e17bb9adc184b3bbafb129c857303f8c9b192341eb78857bf429cfbaba032d89c03
7
- data.tar.gz: 2261802cf08839060320e21ec4d1820b782c9b8d9b2f0471f3d13f149da7b62dbbace8508ea8a9482cc3433a7d7927b15dba1913bca0a3f605809e73bc8be848
6
+ metadata.gz: 801acf82ee8c3ddee109a8f63da786c9d4dedee74e0371f4e4a32614a46bae4b4871564e95382ec55c2262e8f1425c4306a1ad5cd179f532020b3fd46d6bca92
7
+ data.tar.gz: 6816ed13a68305e82d94651b5635d7f8367eb24ade9878169dd1e639c9a4fcc11665d8d06018ef274c4c2aab8ea9c755a9a6305779f3ddc367c9a29f85cd84ca
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.1.0: Support jQuery2. (Thanks to @timurkhafizov)
30
31
  * v1.0.0: Options like `defer: true` or `data-turbolinks-eval: false` are allowed to be passed. (Thanks to @mkitt)
31
32
  * v0.4.0: Added Cloudflare. (Thanks to @damonmorgan)
32
33
  * v0.3.0: Microsoft and Yandex are now always scheme-less. (Thanks to @atipugin)
@@ -82,8 +83,22 @@ on development:
82
83
  <script src="/assets/jquery.js?body=1" type="text/javascript"></script>
83
84
  ```
84
85
 
85
- If you want to check the production URL, you can pass `:force => true` as an option.
86
+ If you want to check the production URL, you can pass `force: true` as an option.
86
87
 
87
88
  ```ruby
88
- jquery_include_tag :google, :force => true
89
+ jquery_include_tag :google, force: true
90
+ ```
91
+
92
+ ## jQuery 2
93
+
94
+ If you want to use jQuery 2, drop the following line in `config/initializers/jquery_cdn.rb`:
95
+
96
+ ```ruby
97
+ Jquery::Rails::Cdn.major_version = 2
98
+ ```
99
+
100
+ and then in `config/application.rb`:
101
+
102
+ ```ruby
103
+ config.assets.precompile += ['jquery2.js']
89
104
  ```
@@ -2,23 +2,35 @@ require 'jquery-rails'
2
2
  require 'jquery-rails-cdn/version'
3
3
 
4
4
  module Jquery::Rails::Cdn
5
+ mattr_accessor :major_version
6
+
5
7
  module ActionViewExtensions
6
- JQUERY_VERSION = Jquery::Rails::JQUERY_VERSION
7
8
  OFFLINE = (Rails.env.development? or Rails.env.test?)
8
9
  URL = {
9
- :google => "//ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
10
- :microsoft => "//ajax.aspnetcdn.com/ajax/jQuery/jquery-#{JQUERY_VERSION}.min.js",
11
- :jquery => "//code.jquery.com/jquery-#{JQUERY_VERSION}.min.js",
12
- :yandex => "//yandex.st/jquery/#{JQUERY_VERSION}/jquery.min.js",
13
- :cloudflare => "//cdnjs.cloudflare.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js"
10
+ :google => "//ajax.googleapis.com/ajax/libs/jquery/{JQUERY_VERSION}/jquery.min.js",
11
+ :microsoft => "//ajax.aspnetcdn.com/ajax/jQuery/jquery-{JQUERY_VERSION}.min.js",
12
+ :jquery => "//code.jquery.com/jquery-{JQUERY_VERSION}.min.js",
13
+ :yandex => "//yandex.st/jquery/{JQUERY_VERSION}/jquery.min.js",
14
+ :cloudflare => "//cdnjs.cloudflare.com/ajax/libs/jquery/{JQUERY_VERSION}/jquery.min.js"
14
15
  }
15
16
 
16
17
  def jquery_url(name)
17
- URL[name]
18
+ @@jquery_urls ||= begin
19
+ version = case Jquery::Rails::Cdn.major_version
20
+ when 1, NilClass
21
+ Jquery::Rails::JQUERY_VERSION
22
+ when 2
23
+ Jquery::Rails::JQUERY_2_VERSION
24
+ else
25
+ raise 'invalid :major_version option'
26
+ end
27
+ Hash[URL.map{|k,v| [k, v.sub(/\{JQUERY_VERSION\}/, version)] }]
28
+ end
29
+ @@jquery_urls[name]
18
30
  end
19
31
 
20
32
  def jquery_include_tag(name, options = {})
21
- return javascript_include_tag(:jquery, options) if !options.delete(:force) and OFFLINE
33
+ return javascript_include_tag(:jquery, options) if OFFLINE && !options.delete(:force)
22
34
 
23
35
  [ javascript_include_tag(jquery_url(name), options),
24
36
  javascript_tag("window.jQuery || document.write(unescape('#{javascript_include_tag(:jquery, options).gsub('<','%3C')}'))")
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Rails
3
3
  module Cdn
4
- VERSION = '1.0.3'
4
+ VERSION = '1.1.0'
5
5
  end
6
6
  end
7
7
  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.0.3
4
+ version: 1.1.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: 2014-05-25 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  requirements: []
60
60
  rubyforge_project:
61
- rubygems_version: 2.2.2
61
+ rubygems_version: 2.4.8
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Add CDN support to jquery-rails