ajaxlibs 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -14
- data/VERSION +1 -1
- data/lib/ajaxlibs/includes_helper.rb +17 -36
- data/lib/ajaxlibs/libraries/dojo.rb +14 -0
- data/lib/ajaxlibs/libraries/jqueryui.rb +3 -5
- data/lib/ajaxlibs/libraries/mootools.rb +8 -0
- data/lib/ajaxlibs/libraries/scriptaculous.rb +2 -4
- data/lib/ajaxlibs/library.rb +30 -9
- data/lib/ajaxlibs.rb +2 -0
- data/public/dojo/1.1.1/dojo.xd.js.uncompressed.js +8986 -0
- data/public/dojo/1.2.0/dojo.xd.js.uncompressed.js +9350 -0
- data/public/dojo/1.2.3/dojo.xd.js.uncompressed.js +9337 -0
- data/public/dojo/1.3.0/dojo.xd.js.uncompressed.js +10322 -0
- data/public/dojo/1.3.1/dojo.xd.js.uncompressed.js +10329 -0
- data/public/dojo/1.3.2/dojo.xd.js.uncompressed.js +10331 -0
- data/public/dojo/1.4.0/dojo.xd.js.uncompressed.js +12129 -0
- data/public/dojo/1.4.1/dojo.xd.js.uncompressed.js +12129 -0
- data/spec/includes_helper_spec.rb +25 -40
- data/spec/library_spec.rb +92 -10
- metadata +13 -3
@@ -7,17 +7,17 @@ describe "Ajaxlibs::IncludesHelper" do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
before :each do
|
11
|
+
@fake_action_view = FakeActionView.new
|
12
|
+
@fake_action_view.stub! :javascript_include_tag
|
13
|
+
end
|
14
|
+
|
10
15
|
context "in development environment" do
|
11
16
|
before :all do
|
12
17
|
Object.send(:remove_const, 'RAILS_ENV') if Object.const_defined?('RAILS_ENV')
|
13
18
|
RAILS_ENV = 'development'
|
14
19
|
end
|
15
20
|
|
16
|
-
before :each do
|
17
|
-
@fake_action_view = FakeActionView.new
|
18
|
-
@fake_action_view.stub! :javascript_include_tag
|
19
|
-
end
|
20
|
-
|
21
21
|
context "should call javascript_include_tag to include local javascript library file" do
|
22
22
|
example "once if only one library was specified" do
|
23
23
|
@fake_action_view.should_receive(:javascript_include_tag).
|
@@ -54,7 +54,7 @@ describe "Ajaxlibs::IncludesHelper" do
|
|
54
54
|
example "once for specified library, avoiding multiple includes" do
|
55
55
|
@fake_action_view.should_receive(:javascript_include_tag).
|
56
56
|
with(Ajaxlibs::Library.by_name(:prototype).local_path).
|
57
|
-
once
|
57
|
+
once
|
58
58
|
|
59
59
|
@fake_action_view.ajaxlibs_include :prototype, :prototype
|
60
60
|
end
|
@@ -62,7 +62,7 @@ describe "Ajaxlibs::IncludesHelper" do
|
|
62
62
|
context "while specifying a specific version number" do
|
63
63
|
example "once if one library was specified" do
|
64
64
|
@fake_action_view.should_receive(:javascript_include_tag).
|
65
|
-
with(Ajaxlibs::Library.by_name(:prototype
|
65
|
+
with(Ajaxlibs::Library.by_name(:prototype, :version => '1.6.0.3').local_path).
|
66
66
|
once
|
67
67
|
|
68
68
|
@fake_action_view.ajaxlibs_include :prototype, :version => '1.6.0.3'
|
@@ -77,63 +77,48 @@ describe "Ajaxlibs::IncludesHelper" do
|
|
77
77
|
RAILS_ENV = 'production'
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
@fake_action_view = FakeActionView.new
|
82
|
-
@fake_action_view.stub! :javascript_tag
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should include google jsapi script" do
|
86
|
-
@fake_action_view.ajaxlibs_include(:prototype).should include("<script type=\"text/javascript\" src=\"#{Ajaxlibs::GoogleJSAPI}\"></script>")
|
87
|
-
end
|
88
|
-
|
89
|
-
context "should call javascript_tag with google jsapi load code" do
|
80
|
+
context "should call javascript_include_tag with google cdn include path" do
|
90
81
|
example "once if only one library was specified" do
|
91
|
-
@fake_action_view.should_receive(:
|
92
|
-
with(Ajaxlibs::Library.by_name(:prototype).
|
82
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
83
|
+
with(Ajaxlibs::Library.by_name(:prototype).google_cdn_include_path).
|
93
84
|
once
|
94
85
|
|
95
86
|
@fake_action_view.ajaxlibs_include :prototype
|
96
87
|
end
|
97
88
|
|
98
89
|
example "once for each specified library" do
|
99
|
-
@fake_action_view.should_receive(:
|
100
|
-
with(
|
101
|
-
|
102
|
-
|
103
|
-
].join("\n")).
|
104
|
-
once
|
105
|
-
|
90
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
91
|
+
with(Ajaxlibs::Library.by_name(:prototype).google_cdn_include_path).once
|
92
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
93
|
+
with(Ajaxlibs::Library.by_name(:scriptaculous).google_cdn_include_path).once
|
106
94
|
@fake_action_view.ajaxlibs_include :prototype, :scriptaculous
|
107
95
|
end
|
108
96
|
|
109
97
|
example "once for each specified library and dependendencies" do
|
110
|
-
@fake_action_view.should_receive(:
|
111
|
-
with(
|
112
|
-
|
113
|
-
|
114
|
-
].join("\n")).
|
115
|
-
once
|
116
|
-
|
98
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
99
|
+
with(Ajaxlibs::Library.by_name(:prototype).google_cdn_include_path).once
|
100
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
101
|
+
with(Ajaxlibs::Library.by_name(:scriptaculous).google_cdn_include_path).once
|
117
102
|
@fake_action_view.ajaxlibs_include :scriptaculous
|
118
103
|
end
|
119
104
|
|
120
105
|
example "once for specified library, avoiding multiple includes" do
|
121
|
-
@fake_action_view.should_receive(:
|
122
|
-
with(Ajaxlibs::Library.by_name(:prototype).
|
123
|
-
once
|
106
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
107
|
+
with(Ajaxlibs::Library.by_name(:prototype).google_cdn_include_path).
|
108
|
+
once
|
124
109
|
|
125
110
|
@fake_action_view.ajaxlibs_include :prototype, :prototype
|
126
111
|
end
|
127
112
|
|
128
113
|
context "while specifying a specific version number" do
|
129
114
|
example "once if one library was specified" do
|
130
|
-
@fake_action_view.should_receive(:
|
131
|
-
with(Ajaxlibs::Library.by_name(:prototype
|
132
|
-
once
|
115
|
+
@fake_action_view.should_receive(:javascript_include_tag).
|
116
|
+
with(Ajaxlibs::Library.by_name(:prototype, :version => '1.6.0.3').google_cdn_include_path).
|
117
|
+
once
|
133
118
|
|
134
119
|
@fake_action_view.ajaxlibs_include :prototype, :version => '1.6.0.3'
|
135
120
|
end
|
136
121
|
end # end of context "while specifying a specific version number"
|
137
|
-
end # end of context "should call
|
122
|
+
end # end of context "should call javascript_include_tag with google cdn include path"
|
138
123
|
end # end of context "in production environment"
|
139
124
|
end
|
data/spec/library_spec.rb
CHANGED
@@ -6,6 +6,8 @@ class Ajaxlibs::Library::Basic < Ajaxlibs::Library
|
|
6
6
|
'1.5',
|
7
7
|
'1.8.1',
|
8
8
|
'2.0.1.3']
|
9
|
+
|
10
|
+
Requirements = {'1.5' => {:prototype => nil}, :all => {:scriptaculous => nil}}
|
9
11
|
end
|
10
12
|
|
11
13
|
describe "Ajaxlibs::Library" do
|
@@ -24,6 +26,14 @@ describe "Ajaxlibs::Library" do
|
|
24
26
|
@library.latest_version.should == '2.0.1.3'
|
25
27
|
end
|
26
28
|
|
29
|
+
it "should use the latest version if non provided" do
|
30
|
+
@library.version.should == @library.latest_version
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should use a local source if non provided" do
|
34
|
+
@library.source.should == :local
|
35
|
+
end
|
36
|
+
|
27
37
|
it "should determine library_name by its own class name" do
|
28
38
|
@library.library_name.should == 'basic'
|
29
39
|
end
|
@@ -32,48 +42,120 @@ describe "Ajaxlibs::Library" do
|
|
32
42
|
@library.library_name.should == @library.file_name
|
33
43
|
end
|
34
44
|
|
45
|
+
it "should search through requirements using key :all if requirements for specific version is not found" do
|
46
|
+
@library.requires.should == {:scriptaculous => nil}
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be equal to another library instance if class, version and source are equals" do
|
50
|
+
another_library = Ajaxlibs::Library::Basic.new(:version => @library.version, :source => @library.source)
|
51
|
+
@library.should == another_library
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not be equal to another library instance if source differs" do
|
55
|
+
another_library = Ajaxlibs::Library::Basic.new(:version => @library.version, :source => :remote)
|
56
|
+
@library.should_not == another_library
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not be equal to another library instance if version differs" do
|
60
|
+
another_library = Ajaxlibs::Library::Basic.new(:version => '1.5', :source => @library.source)
|
61
|
+
@library.should_not == another_library
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should not be equal to another library instance if class differs" do
|
65
|
+
class Ajaxlibs::Library::AnotherBasic < Ajaxlibs::Library::Basic
|
66
|
+
end
|
67
|
+
|
68
|
+
another_library = Ajaxlibs::Library::AnotherBasic.new(:version => @library.version, :source => @library.source)
|
69
|
+
@library.should_not == another_library
|
70
|
+
end
|
71
|
+
|
72
|
+
example "should raise an error if provided version is wrong" do
|
73
|
+
lambda { Ajaxlibs::Library::Basic.new(:version => '42') }.should raise_error(Ajaxlibs::Exception::VersionNotFound)
|
74
|
+
end
|
75
|
+
|
35
76
|
context "will return a local path composed of library_name, version and file_name" do
|
36
77
|
example "using provided version if specified" do
|
37
|
-
@library.
|
78
|
+
@library = Ajaxlibs::Library::Basic.new(:version => '1.8.1')
|
79
|
+
@library.local_path.should == "ajaxlibs/basic/1.8.1/basic"
|
38
80
|
end
|
39
81
|
|
40
82
|
example "using latest version if none was specified" do
|
41
83
|
@library.local_path.should == "ajaxlibs/basic/2.0.1.3/basic"
|
42
84
|
end
|
43
85
|
|
44
|
-
example "
|
45
|
-
|
86
|
+
example "while calling include_path" do
|
87
|
+
@library.include_path.should == @library.local_path
|
46
88
|
end
|
89
|
+
|
47
90
|
end
|
48
91
|
|
49
92
|
context "will return a javascript code to load from google cdn with library_name and version" do
|
50
93
|
example "using provided version if specified" do
|
51
|
-
@library
|
94
|
+
@library = Ajaxlibs::Library::Basic.new(:version => '1.8.1')
|
95
|
+
@library.google_cdn_include_path.should == "http://ajax.googleapis.com/ajax/libs/basic/1.8.1/basic.js"
|
52
96
|
end
|
53
97
|
|
54
98
|
example "using latest version if none was specified" do
|
55
|
-
@library.
|
56
|
-
end
|
57
|
-
|
58
|
-
example "
|
59
|
-
|
60
|
-
|
99
|
+
@library.google_cdn_include_path.should == "http://ajax.googleapis.com/ajax/libs/basic/2.0.1.3/basic.js"
|
100
|
+
end
|
101
|
+
|
102
|
+
example "while calling include_path" do
|
103
|
+
@library = Ajaxlibs::Library::Basic.new(:source => :remote)
|
104
|
+
@library.include_path.should == @library.google_cdn_include_path
|
105
|
+
end
|
61
106
|
end
|
62
107
|
end
|
63
108
|
|
109
|
+
context "instance with version provided" do
|
110
|
+
before :each do
|
111
|
+
@library = Ajaxlibs::Library::Basic.new(:version => '1.5')
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should returns provided version" do
|
115
|
+
@library.version.should == '1.5'
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should search through requirements using provided version" do
|
119
|
+
@library.requires.should == {:prototype => nil}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "instance with source provided" do
|
124
|
+
before :each do
|
125
|
+
@library = Ajaxlibs::Library::Basic.new(:source => :remote)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should returns provided source" do
|
129
|
+
@library.source.should == :remote
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
64
133
|
context "base class" do
|
65
134
|
example "will return the right instance while searching by name" do
|
66
135
|
Ajaxlibs::Library.by_name(:jquery).should be_kind_of(Ajaxlibs::Library::Jquery)
|
67
136
|
end
|
137
|
+
|
138
|
+
example "will use given version" do
|
139
|
+
Ajaxlibs::Library.by_name(:jquery, :version => '1.3.2').version.should == '1.3.2'
|
140
|
+
end
|
141
|
+
|
142
|
+
example "will use given source" do
|
143
|
+
Ajaxlibs::Library.by_name(:jquery, :source => :remote).source.should == :remote
|
144
|
+
end
|
68
145
|
|
69
146
|
example "will raise an exception if library is not found" do
|
70
147
|
lambda { Ajaxlibs::Library.by_name(:foo) }.should raise_error(Ajaxlibs::Exception::LibraryNotFound)
|
71
148
|
end
|
149
|
+
|
150
|
+
example "will raise an exception if version is not found" do
|
151
|
+
lambda { Ajaxlibs::Library.by_name(:jquery, :version => '42') }.should raise_error(Ajaxlibs::Exception::VersionNotFound)
|
152
|
+
end
|
72
153
|
|
73
154
|
example "will register class by name when inherited" do
|
74
155
|
Ajaxlibs::Library.should_not have_registered_child_class(:foo)
|
75
156
|
lambda { Ajaxlibs::Library.by_name(:foo) }.should raise_error(Ajaxlibs::Exception::LibraryNotFound)
|
76
157
|
class Ajaxlibs::Library::Foo < Ajaxlibs::Library
|
158
|
+
Versions = %w{0}
|
77
159
|
end
|
78
160
|
Ajaxlibs::Library.should have_registered_child_class(:foo)
|
79
161
|
Ajaxlibs::Library.all.should include(Ajaxlibs::Library::Foo)
|
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
|
+
- 1
|
9
|
+
version: 0.1.1
|
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-03-
|
17
|
+
date: 2010-03-11 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -51,12 +51,22 @@ files:
|
|
51
51
|
- lib/ajaxlibs/constants.rb
|
52
52
|
- lib/ajaxlibs/exceptions.rb
|
53
53
|
- lib/ajaxlibs/includes_helper.rb
|
54
|
+
- lib/ajaxlibs/libraries/dojo.rb
|
54
55
|
- lib/ajaxlibs/libraries/jquery.rb
|
55
56
|
- lib/ajaxlibs/libraries/jqueryui.rb
|
57
|
+
- lib/ajaxlibs/libraries/mootools.rb
|
56
58
|
- lib/ajaxlibs/libraries/prototype.rb
|
57
59
|
- lib/ajaxlibs/libraries/scriptaculous.rb
|
58
60
|
- lib/ajaxlibs/library.rb
|
59
61
|
- lib/ajaxlibs/versions_tools.rb
|
62
|
+
- public/dojo/1.1.1/dojo.xd.js.uncompressed.js
|
63
|
+
- public/dojo/1.2.0/dojo.xd.js.uncompressed.js
|
64
|
+
- public/dojo/1.2.3/dojo.xd.js.uncompressed.js
|
65
|
+
- public/dojo/1.3.0/dojo.xd.js.uncompressed.js
|
66
|
+
- public/dojo/1.3.1/dojo.xd.js.uncompressed.js
|
67
|
+
- public/dojo/1.3.2/dojo.xd.js.uncompressed.js
|
68
|
+
- public/dojo/1.4.0/dojo.xd.js.uncompressed.js
|
69
|
+
- public/dojo/1.4.1/dojo.xd.js.uncompressed.js
|
60
70
|
- public/jquery/1.2.3/jquery.js
|
61
71
|
- public/jquery/1.2.6/jquery.js
|
62
72
|
- public/jquery/1.3.0/jquery.js
|