ajaxlibs 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -109,11 +109,14 @@ Finally, include some javascript libraries to your views or layouts :
109
109
 
110
110
  <%= ajaxlibs_include :scriptaculous %>
111
111
 
112
+ === Migration
113
+ ==== from 0.1.9 and below
114
+
115
+ Ajaxlibs prior to version 0.1.10 was copying all javascript libraries in all available version to the public javascript directory. Version 0.1.10 provide an automatic copy of needed libraries in their local version (copy is not performed if you are using google CDN, in production environment by default). You can now safely remove <tt>public/javascripts/ajaxlibs</tt> and ignore it in your SCM.
116
+
112
117
  == TODO
113
118
 
114
119
  * support more javascript libraries : available though Google CDN (mootools, ...), not available through Google CDN (jrails, ...), available only from google (google maps, ...).
115
- * provide a rake task to copy only required javascript libraries.
116
- * automatic support for jrails.
117
120
 
118
121
  == Note on Patches/Pull Requests
119
122
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.10
@@ -69,7 +69,9 @@ class Ajaxlibs::Library
69
69
  end
70
70
 
71
71
  # Local path for a particular version, or the latest if given version is nil.
72
+ # Search for the file in rails public path and copy it if needed.
72
73
  def local_path
74
+ check_and_copy_local_file_to_rails_public
73
75
  File.join('ajaxlibs', library_name, version, file_name)
74
76
  end
75
77
 
@@ -101,4 +103,20 @@ class Ajaxlibs::Library
101
103
  raise Ajaxlibs::Exception::VersionNotFound unless self.class::Versions.include?(version)
102
104
  version
103
105
  end
106
+
107
+ def check_and_copy_local_file_to_rails_public
108
+ if Object.const_defined?(:Rails) and File.directory?(File.join(Rails.root, 'public'))
109
+
110
+ ajaxlibs_js_path = File.join(Rails.root, 'public', 'javascripts', 'ajaxlibs')
111
+ source_path = File.join(File.dirname(__FILE__), '../../public', library_name, version)
112
+ source = File.join(source_path, '*.*')
113
+ destination = File.join(ajaxlibs_js_path, library_name, version)
114
+
115
+ if not File.exists?(destination) or Dir.entries(source_path) != Dir.entries(destination)
116
+ FileUtils.mkdir_p(destination)
117
+ FileUtils.cp(Dir.glob(source), destination)
118
+ end
119
+
120
+ end
121
+ end
104
122
  end
data/lib/ajaxlibs.rb CHANGED
@@ -12,27 +12,4 @@ require 'ajaxlibs/libraries/prototype'
12
12
  require 'ajaxlibs/libraries/scriptaculous'
13
13
  require 'ajaxlibs/includes_helper'
14
14
 
15
- if Object.const_defined?(:ActionView)
16
- # Make Ajaxlibs helpers available in views
17
- ActionView::Base.send(:include, Ajaxlibs::IncludesHelper)
18
-
19
- # Copy all available js libraries to rails public folder
20
- if Object.const_defined?(:Rails) and File.directory?(File.join(Rails.root, 'public'))
21
- ajaxlibs_js_path = File.join(Rails.root, 'public', 'javascripts', 'ajaxlibs')
22
-
23
- # We do not have already copied local javascript files, copying them right away
24
- # OPTIMIZE : we should copy only necessary libraries
25
- unless File.directory?(ajaxlibs_js_path)
26
- FileUtils.mkdir_p(ajaxlibs_js_path)
27
- Ajaxlibs::Library.all.each do |library|
28
- library::Versions.each do |version|
29
- source = File.join(File.dirname(__FILE__), '..', 'public', library.library_name, version, '*.*')
30
- destination = File.join(ajaxlibs_js_path, library.library_name, version)
31
- FileUtils.mkdir_p(destination)
32
- FileUtils.cp(Dir.glob(source), destination)
33
- end
34
- end
35
- end
36
- end
37
-
38
- end
15
+ ActionView::Base.send(:include, Ajaxlibs::IncludesHelper) if Object.const_defined?(:ActionView)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 9
9
- version: 0.1.9
8
+ - 10
9
+ version: 0.1.10
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-05-03 00:00:00 +02:00
17
+ date: 2010-05-04 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency