ajaxlibs 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -53,6 +53,14 @@ will produce :
53
53
 
54
54
  <script src="/javascripts/ajaxlibs/prototype/1.6.0.3/prototype.js?1267013480" type="text/javascript"></script>
55
55
 
56
+ === https support
57
+
58
+ <%= ajaxlibs_include :jquery, :secure => true %>
59
+
60
+ used in production, will produce :
61
+
62
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
63
+
56
64
  === automatic dependencies
57
65
 
58
66
  <%= ajaxlibs_include :scriptaculous %>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -9,7 +9,7 @@ class Ajaxlibs::Library
9
9
  Versions = []
10
10
  Requirements = {}
11
11
 
12
- attr_reader :version, :source
12
+ attr_reader :version, :source, :secure
13
13
 
14
14
  @@subclasses = {}
15
15
 
@@ -23,6 +23,7 @@ class Ajaxlibs::Library
23
23
  end
24
24
 
25
25
  # Search a specific library by its name (could be either a string or a symbol) and initialized it with given version and source.
26
+ # See initialize method for available <tt>options</tt>.
26
27
  def self.by_name(name, options = {})
27
28
  @@subclasses[name.to_sym].new options
28
29
  rescue NoMethodError
@@ -34,9 +35,15 @@ class Ajaxlibs::Library
34
35
  name.match(/::(\w+)$/)[1].downcase
35
36
  end
36
37
 
38
+ # Initialize a new instance of a specific library.
39
+ # <tt>options</tt> can take the following arguments :
40
+ # * <tt>:version</tt> : specify a version (ex: "1.8.1").
41
+ # * <tt>:source</tt> : force the source to use, default to <tt>:local</tt>.
42
+ # * <tt>:secure</tt> : specify if the generated link should be secured (https) or not. Default is <tt>false</tt>.
37
43
  def initialize(options = {})
38
44
  @version = check_version_or_latest_version(options[:version])
39
45
  @source = options[:source] || :local
46
+ @secure = options[:secure] || false
40
47
  end
41
48
 
42
49
  # Returns requirements for a library (for example, prototype for scriptaculous)
@@ -66,7 +73,8 @@ class Ajaxlibs::Library
66
73
 
67
74
  # Include path using google CDN
68
75
  def google_cdn_include_path
69
- "http://ajax.googleapis.com/ajax/libs/#{library_name}/#{version}/#{file_name}.js"
76
+ scheme = secure ? "https" : "http"
77
+ "#{scheme}://ajax.googleapis.com/ajax/libs/#{library_name}/#{version}/#{file_name}.js"
70
78
  end
71
79
 
72
80
  # Javascript include path regarding source (call either local_path or google_cdn_include_path)
data/spec/library_spec.rb CHANGED
@@ -88,6 +88,16 @@ describe "Ajaxlibs::Library" do
88
88
  end
89
89
  end
90
90
 
91
+ it "will return a secured (https) link if asked for secure" do
92
+ @library = Ajaxlibs::Library::Basic.new(:secure => true)
93
+ @library.google_cdn_include_path.should == "https://ajax.googleapis.com/ajax/libs/basic/2.0.1.3/basic.js"
94
+ end
95
+
96
+ it "will return a secured (https) link if asked for secure" do
97
+ @library = Ajaxlibs::Library::Basic.new(:secure => false)
98
+ @library.google_cdn_include_path.should == "http://ajax.googleapis.com/ajax/libs/basic/2.0.1.3/basic.js"
99
+ end
100
+
91
101
  it "will return a local path if library is local only" do
92
102
  @library = Ajaxlibs::Library::Jrails.new
93
103
  @library.include_path.should == @library.local_path
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Fabien Jakimowicz
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-02 00:00:00 +02:00
17
+ date: 2010-04-07 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency