ajaxlibs 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +28 -8
- data/VERSION +1 -1
- data/lib/ajaxlibs.rb +1 -0
- data/lib/ajaxlibs/includes_helper.rb +12 -6
- data/lib/ajaxlibs/libraries/dojo.rb +1 -1
- data/lib/ajaxlibs/libraries/ext_core.rb +1 -1
- data/lib/ajaxlibs/libraries/jquery.rb +4 -0
- data/lib/ajaxlibs/libraries/jqueryui.rb +1 -1
- data/lib/ajaxlibs/libraries/jrails.rb +9 -0
- data/lib/ajaxlibs/libraries/mootools.rb +4 -0
- data/lib/ajaxlibs/library.rb +2 -0
- data/spec/includes_helper_spec.rb +47 -0
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -17,6 +17,17 @@ In development environment, it provides local javascript files for the developme
|
|
17
17
|
|
18
18
|
You can specify a specific version of each library to use, or the latest available.
|
19
19
|
|
20
|
+
== Supported Libraries
|
21
|
+
|
22
|
+
* dojo
|
23
|
+
* ext-core (use <tt>:extcore</tt> to load it)
|
24
|
+
* jquery
|
25
|
+
* jquery-ui
|
26
|
+
* jrails
|
27
|
+
* mootools
|
28
|
+
* prototype
|
29
|
+
* scriptaculous
|
30
|
+
|
20
31
|
== Examples
|
21
32
|
|
22
33
|
=== simple library load, under the development environment
|
@@ -25,11 +36,11 @@ You can specify a specific version of each library to use, or the latest availab
|
|
25
36
|
|
26
37
|
will produce, under the development environment :
|
27
38
|
|
28
|
-
<script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.js?1267013480" type="text/javascript"></script>
|
39
|
+
<script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.min.js?1267013480" type="text/javascript"></script>
|
29
40
|
|
30
41
|
and in production :
|
31
42
|
|
32
|
-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
|
43
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery,min.js" type="text/javascript"></script>
|
33
44
|
|
34
45
|
=== multiple libraries load
|
35
46
|
|
@@ -37,13 +48,13 @@ and in production :
|
|
37
48
|
|
38
49
|
in development environment :
|
39
50
|
|
40
|
-
<script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.js?1267013480" type="text/javascript"></script>
|
41
|
-
<script src="/javascripts/ajaxlibs/jqueryui/1.7.2/jqueryui.js?1267013480" type="text/javascript"></script>
|
51
|
+
<script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.min.js?1267013480" type="text/javascript"></script>
|
52
|
+
<script src="/javascripts/ajaxlibs/jqueryui/1.7.2/jqueryui.min.js?1267013480" type="text/javascript"></script>
|
42
53
|
|
43
54
|
this time in production :
|
44
55
|
|
45
|
-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
|
46
|
-
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js" type="text/javascript"></script>
|
56
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
57
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
|
47
58
|
|
48
59
|
=== forcing a version
|
49
60
|
|
@@ -59,7 +70,17 @@ will produce :
|
|
59
70
|
|
60
71
|
used in production, will produce :
|
61
72
|
|
62
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
|
73
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
74
|
+
|
75
|
+
=== minified / non-minified
|
76
|
+
|
77
|
+
By default, each javascript are the minified version. But you can ask for a plain version :
|
78
|
+
|
79
|
+
<%= ajaxlibs_include :jquery, :minified => false %>
|
80
|
+
|
81
|
+
will produce
|
82
|
+
|
83
|
+
<script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.js?1267013480" type="text/javascript"></script>
|
63
84
|
|
64
85
|
=== automatic dependencies
|
65
86
|
|
@@ -91,7 +112,6 @@ Finally, include some javascript libraries to your views or layouts :
|
|
91
112
|
== TODO
|
92
113
|
|
93
114
|
* support more javascript libraries : available though Google CDN (mootools, ...), not available through Google CDN (jrails, ...), available only from google (google maps, ...).
|
94
|
-
* support plain/minified versions.
|
95
115
|
* provide a rake task to copy only required javascript libraries.
|
96
116
|
* automatic support for jrails.
|
97
117
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/lib/ajaxlibs.rb
CHANGED
@@ -3,6 +3,7 @@ require 'ajaxlibs/exceptions'
|
|
3
3
|
require 'ajaxlibs/versions_tools'
|
4
4
|
require 'ajaxlibs/library'
|
5
5
|
require 'ajaxlibs/libraries/dojo'
|
6
|
+
require 'ajaxlibs/libraries/ext_core'
|
6
7
|
require 'ajaxlibs/libraries/jquery'
|
7
8
|
require 'ajaxlibs/libraries/jqueryui'
|
8
9
|
require 'ajaxlibs/libraries/jrails'
|
@@ -6,6 +6,8 @@ module Ajaxlibs::IncludesHelper
|
|
6
6
|
# == Options
|
7
7
|
# * <tt>version</tt> : specify the version to use for each library
|
8
8
|
# * <tt>local</tt> : if true, always serve file locally, if false, use Google CDN
|
9
|
+
# * <tt>:secure</tt> : specify if the generated link should be secured (https) or not. Default is <tt>false</tt>.
|
10
|
+
# * <tt>:minified</tt> : <tt>true</tt> if you want a minified version of the javascript library, <tt>false</tt> otherwise. Default is <tt>true</tt>.
|
9
11
|
#
|
10
12
|
# == Exceptions
|
11
13
|
# * <tt>Ajaxlibs::Exception::LibraryNotFound</tt> : raised if one or more of the given library is not available
|
@@ -14,24 +16,28 @@ module Ajaxlibs::IncludesHelper
|
|
14
16
|
# == Examples
|
15
17
|
# * Simple library load, under the development environment
|
16
18
|
# ajaxlibs_include :jquery
|
17
|
-
# <script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.js?1267013480" type="text/javascript"></script>
|
19
|
+
# <script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.min.js?1267013480" type="text/javascript"></script>
|
18
20
|
#
|
19
21
|
# ajaxlibs_include :jquery, :jqueryui
|
20
|
-
# <script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.js?1267013480" type="text/javascript"></script>
|
21
|
-
# <script src="/javascripts/ajaxlibs/jqueryui/1.7.2/
|
22
|
+
# <script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.min.js?1267013480" type="text/javascript"></script>
|
23
|
+
# <script src="/javascripts/ajaxlibs/jqueryui/1.7.2/jquery-ui.min.js?1267013480" type="text/javascript"></script>
|
22
24
|
#
|
23
25
|
# * Same examples as above, this time in production
|
24
26
|
# ajaxlibs_include :jquery
|
25
|
-
# <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
|
27
|
+
# <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
26
28
|
#
|
27
29
|
# ajaxlibs_include :jquery, :jqueryui
|
28
|
-
# <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>
|
29
|
-
# <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js" type="text/javascript"></script>
|
30
|
+
# <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
31
|
+
# <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
|
30
32
|
#
|
31
33
|
# * Specifying version
|
32
34
|
# ajaxlibs_include :prototype, :version => '1.6.0.3'
|
33
35
|
# <script src="/javascripts/ajaxlibs/prototype/1.6.0.3/prototype.js?1267013480" type="text/javascript"></script>
|
34
36
|
#
|
37
|
+
# * Ask for a non-minified version
|
38
|
+
# ajaxlibs_include :jquery, :minified => false
|
39
|
+
# <script src="/javascripts/ajaxlibs/jquery/1.4.2/jquery.js?1267013480" type="text/javascript"></script>
|
40
|
+
#
|
35
41
|
# * Automatic dependencies
|
36
42
|
# ajaxlibs_include :scriptaculous
|
37
43
|
# <script src="/javascripts/ajaxlibs/prototype/1.6.1.0/prototype.js?1267013480" type="text/javascript"></script>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# JRails library, local support only.
|
2
2
|
# This is only the javascript support of JRails, you must install JRails plugin to have a full support.
|
3
|
+
# TODO : require jrails gem (or fail) if included
|
3
4
|
class Ajaxlibs::Library::Jrails < Ajaxlibs::Library
|
4
5
|
Versions = ['0.5.0']
|
5
6
|
|
@@ -8,4 +9,12 @@ class Ajaxlibs::Library::Jrails < Ajaxlibs::Library
|
|
8
9
|
def local_only?
|
9
10
|
true
|
10
11
|
end
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
require 'rubygems'
|
15
|
+
require 'jrails' # Check if we have jrails support before trying to load it
|
16
|
+
super
|
17
|
+
rescue LoadError
|
18
|
+
raise "jrails gem is missing, you must install it."
|
19
|
+
end
|
11
20
|
end
|
data/lib/ajaxlibs/library.rb
CHANGED
@@ -40,9 +40,11 @@ class Ajaxlibs::Library
|
|
40
40
|
# * <tt>:version</tt> : specify a version (ex: "1.8.1").
|
41
41
|
# * <tt>:source</tt> : force the source to use, default to <tt>:local</tt>.
|
42
42
|
# * <tt>:secure</tt> : specify if the generated link should be secured (https) or not. Default is <tt>false</tt>.
|
43
|
+
# * <tt>:minified</tt> : <tt>true</tt> if you want a minified version of the javascript library, <tt>false</tt> otherwise. Default is <tt>true</tt>.
|
43
44
|
def initialize(options = {})
|
44
45
|
@version = check_version_or_latest_version(options[:version])
|
45
46
|
@source = options[:source] || :local
|
47
|
+
@minified = options[:minified].nil? ? true : options[:minified]
|
46
48
|
@secure = options[:secure] || false
|
47
49
|
end
|
48
50
|
|
@@ -17,6 +17,15 @@ describe "Ajaxlibs::IncludesHelper" do
|
|
17
17
|
Object.send(:remove_const, 'RAILS_ENV') if Object.const_defined?('RAILS_ENV')
|
18
18
|
RAILS_ENV = 'development'
|
19
19
|
end
|
20
|
+
|
21
|
+
it "should follow options to Ajaxlibs::Library class" do
|
22
|
+
Ajaxlibs::Library.should_receive(:by_name).
|
23
|
+
with(:prototype, hash_including(:minified => false, :secure => true)).
|
24
|
+
once.
|
25
|
+
and_return(Ajaxlibs::Library::Prototype.new)
|
26
|
+
|
27
|
+
@fake_action_view.ajaxlibs_include :prototype, :minified => false, :secure => true
|
28
|
+
end
|
20
29
|
|
21
30
|
context "should call javascript_include_tag to include local javascript library file" do
|
22
31
|
example "once if only one library was specified" do
|
@@ -68,6 +77,25 @@ describe "Ajaxlibs::IncludesHelper" do
|
|
68
77
|
@fake_action_view.ajaxlibs_include :prototype, :version => '1.6.0.3'
|
69
78
|
end
|
70
79
|
end # end of context "while specifying a specific version number"
|
80
|
+
|
81
|
+
context "while asking for a uncompressed version" do
|
82
|
+
example "with a filename to the uncompressed version" do
|
83
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
84
|
+
with(Ajaxlibs::Library.by_name(:jquery, :minified => false).local_path).
|
85
|
+
once
|
86
|
+
|
87
|
+
@fake_action_view.ajaxlibs_include :jquery, :minified => false
|
88
|
+
end
|
89
|
+
end # end of context "while asking for a uncompressed version"
|
90
|
+
|
91
|
+
example "with a minified version by default" do
|
92
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
93
|
+
with(Ajaxlibs::Library.by_name(:jquery, :minified => true).local_path).
|
94
|
+
once
|
95
|
+
|
96
|
+
@fake_action_view.ajaxlibs_include :jquery
|
97
|
+
end
|
98
|
+
|
71
99
|
end # end of context "should call javascript_include_tag to include local javascript library file"
|
72
100
|
|
73
101
|
example "should call javascript_include_tag with google cdn include path if specified source is remote" do
|
@@ -147,6 +175,25 @@ describe "Ajaxlibs::IncludesHelper" do
|
|
147
175
|
@fake_action_view.ajaxlibs_include :prototype, :version => '1.6.0.3'
|
148
176
|
end
|
149
177
|
end # end of context "while specifying a specific version number"
|
178
|
+
|
179
|
+
context "while asking for a uncompressed version" do
|
180
|
+
example "with a filename to the uncompressed version" do
|
181
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
182
|
+
with(Ajaxlibs::Library.by_name(:jquery, :minified => false).google_cdn_include_path).
|
183
|
+
once
|
184
|
+
|
185
|
+
@fake_action_view.ajaxlibs_include :jquery, :minified => false
|
186
|
+
end
|
187
|
+
end # end of context "while asking for a uncompressed version"
|
188
|
+
|
189
|
+
example "with a minified version by default" do
|
190
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
191
|
+
with(Ajaxlibs::Library.by_name(:jquery, :minified => true).google_cdn_include_path).
|
192
|
+
once
|
193
|
+
|
194
|
+
@fake_action_view.ajaxlibs_include :jquery
|
195
|
+
end
|
196
|
+
|
150
197
|
end # end of context "should call javascript_include_tag with google cdn include path"
|
151
198
|
end # end of context "in production environment"
|
152
199
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 8
|
9
|
+
version: 0.1.8
|
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-
|
17
|
+
date: 2010-05-03 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|