rack-jquery 1.2.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # CH CH CH CHANGES #
2
2
 
3
+ ## v1.3.2 ##
4
+
5
+ Thursday the 23rd of May 2013
6
+
7
+ * Made the Microsoft CDN link protocol relative.
8
+
9
+ ----
10
+
11
+
12
+ ## v1.3.1 ##
13
+
14
+ Thursday the 23rd of May 2013
15
+
16
+ * Added an easier way to run the examples.
17
+ * Added links to make it easier to move around the app.
18
+
19
+ ----
20
+
21
+
22
+ ## v1.3.0 ##
23
+
24
+ Thursday the 23rd of May 2013
25
+
26
+ * Added the Cloudflare CDN.
27
+
28
+ ____
29
+
30
+
3
31
  ## v1.2.0 ##
4
32
 
5
33
  Thursday the 23rd of May 2013
data/README.md CHANGED
@@ -25,7 +25,7 @@ Have a look in the examples directory, but here's a snippet.
25
25
  = Rack::JQuery.cdn
26
26
  </code></pre>
27
27
 
28
- Now you have the script tags to Google's CDN in the head (you can also use Media Temple or Microsoft, see the docs).
28
+ Now you have the script tags to Google's CDN in the head (you can also use Media Temple or Microsoft, or Cloudflare, see the docs).
29
29
 
30
30
  It also adds in a bit of javascript that will load in a locally kept version of jQuery, just incase the CDN is unreachable. The script will use the "/js/jquery-1.9.1.min.js" path (or, instead of 1.9.1, whatever is in {Rack::JQuery::VERSION}). You can change the "/js" bit if you like (see the docs).
31
31
 
data/Rakefile CHANGED
@@ -37,3 +37,12 @@ namespace :spec do
37
37
  end
38
38
 
39
39
  end
40
+
41
+ namespace :examples do
42
+
43
+ desc "Run the examples."
44
+ task :run do
45
+ exec "bundle exec rackup examples/config.ru"
46
+ end
47
+
48
+ end
data/examples/config.rb CHANGED
@@ -8,7 +8,22 @@ class App < Sinatra::Base
8
8
  use Rack::JQuery
9
9
 
10
10
  get "/" do
11
- "RUNNING"
11
+ output = <<STR
12
+ !!!
13
+ %body
14
+ %ul
15
+ %li
16
+ %a{ href: "/google-cdn"} google-cdn
17
+ %li
18
+ %a{ href: "/media-temple-cdn"} media-temple-cdn
19
+ %li
20
+ %a{ href: "/microsoft-cdn"} microsoft-cdn
21
+ %li
22
+ %a{ href: "/cloudflare-cdn"} cloudflare-cdn
23
+ %li
24
+ %a{ href: "/unspecified-cdn"} unspecified-cdn
25
+ STR
26
+ haml output
12
27
  end
13
28
 
14
29
  get "/google-cdn" do
@@ -23,6 +38,10 @@ class App < Sinatra::Base
23
38
  haml :index, :layout => :microsoft
24
39
  end
25
40
 
41
+ get "/cloudflare-cdn" do
42
+ haml :index, :layout => :cloudflare
43
+ end
44
+
26
45
  get "/unspecified-cdn" do
27
46
  haml :index, :layout => :unspecified
28
47
  end
@@ -48,6 +67,12 @@ __END__
48
67
  = Rack::JQuery.cdn( :media_temple )
49
68
  = yield
50
69
 
70
+ @@cloudflare
71
+ %html
72
+ %head
73
+ = Rack::JQuery.cdn( :cloudflare )
74
+ = yield
75
+
51
76
  @@unspecified
52
77
  %html
53
78
  %head
data/lib/rack/jquery.rb CHANGED
@@ -16,7 +16,10 @@ module Rack
16
16
  GOOGLE = "<script src='//ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js'></script>"
17
17
 
18
18
  # Script tags for the Microsoft CDN
19
- MICROSOFT = "<script src='http://ajax.aspnetcdn.com/ajax/jQuery/#{JQUERY_FILE_NAME}'></script>"
19
+ MICROSOFT = "<script src='//ajax.aspnetcdn.com/ajax/jQuery/#{JQUERY_FILE_NAME}'></script>"
20
+
21
+ # Script tags for the Cloudflare CDN
22
+ CLOUDFLARE = "<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js'></script>"
20
23
 
21
24
  # This javascript checks if the jQuery object has loaded. If not, that most likely means the CDN is unreachable, so it uses the local minified jQuery.
22
25
  FALLBACK = <<STR
@@ -35,6 +38,8 @@ STR
35
38
  MEDIA_TEMPLE
36
39
  when :microsoft
37
40
  MICROSOFT
41
+ when :cloudflare
42
+ CLOUDFLARE
38
43
  else
39
44
  GOOGLE
40
45
  end
@@ -1,6 +1,6 @@
1
1
  module Rack
2
2
  class JQuery
3
- VERSION = "1.2.0" # the version of this library
3
+ VERSION = "1.3.2" # the version of this library
4
4
  JQUERY_VERSION = "2.0.0" # the version of jQuery it supports.
5
5
 
6
6
  # This is the release date of the jQuery file, it makes an easy "Last-Modified" date for setting the headers around caching.
@@ -22,6 +22,10 @@ describe "The class methods" do
22
22
  let(:organisation) { :media_temple }
23
23
  it { should == "#{Rack::JQuery::MEDIA_TEMPLE}\n#{Rack::JQuery::FALLBACK}" }
24
24
  end
25
+ context "of :media_temple" do
26
+ let(:organisation) { :cloudflare }
27
+ it { should == "#{Rack::JQuery::CLOUDFLARE}\n#{Rack::JQuery::FALLBACK}" }
28
+ end
25
29
  end
26
30
  end
27
31
 
@@ -69,6 +73,15 @@ describe "Inserting the CDN" do
69
73
  let(:expected) { Rack::JQuery::GOOGLE }
70
74
  it { should include expected }
71
75
  end
76
+ context "Cloudflare CDN" do
77
+ before do
78
+ get "/cloudflare-cdn"
79
+ end
80
+ it_should_behave_like "Any route"
81
+ subject { last_response.body }
82
+ let(:expected) { Rack::JQuery::CLOUDFLARE }
83
+ it { should include expected }
84
+ end
72
85
  end
73
86
 
74
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: