Module: Serve::JavaScripts
- Included in:
- Project
- Defined in:
- lib/serve/javascripts.rb
Constant Summary collapse
- GOOGLE_AJAX_APIS =
JavaScript Versions
'http://ajax.googleapis.com/ajax/libs'- JQUERY_VERSION =
the latest stable version of 1.x.x
'1'- JQUERY_UI_VERSION =
'1'- PROTOTYPE_VERSION =
'1'- SCRIPTACULOUS_VERSION =
'1'- MOOTOOLS_VERSION =
'1'- JAVASCRIPT_FRAMEWORKS =
%w(jquery jquery-ui mootools prototype scriptaculous)
Instance Method Summary collapse
- #fetch_javascript(framework, download_path) ⇒ Object
- #javascript_filename(framework, path) ⇒ Object
- #javascript_framework_url(framework) ⇒ Object
- #jquery_ui_url ⇒ Object
- #jquery_url ⇒ Object
- #mootools_url ⇒ Object
- #prototype_url ⇒ Object
- #scriptaculous_url ⇒ Object
- #supported_javascript_frameworks ⇒ Object
- #valid_javascript_framework?(framework) ⇒ Boolean
Instance Method Details
#fetch_javascript(framework, download_path) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/serve/javascripts.rb', line 17 def fetch_javascript(framework, download_path) filename = javascript_filename(framework, download_path) framework_url = javascript_framework_url(framework) lines = open(framework_url) { |io| io.read } open(filename, "w+") { |io| io.write(lines) } end |
#javascript_filename(framework, path) ⇒ Object
33 34 35 |
# File 'lib/serve/javascripts.rb', line 33 def javascript_filename(framework, path) File.join(path, "#{framework}.js") end |
#javascript_framework_url(framework) ⇒ Object
37 38 39 |
# File 'lib/serve/javascripts.rb', line 37 def javascript_framework_url(framework) self.send(framework.tr('-', '_') + "_url") end |
#jquery_ui_url ⇒ Object
45 46 47 |
# File 'lib/serve/javascripts.rb', line 45 def jquery_ui_url "#{GOOGLE_AJAX_APIS}/jqueryui/#{JQUERY_UI_VERSION}/jquery-ui.min.js" end |
#jquery_url ⇒ Object
41 42 43 |
# File 'lib/serve/javascripts.rb', line 41 def jquery_url "#{GOOGLE_AJAX_APIS}/jquery/#{JQUERY_VERSION}/jquery.min.js" end |
#mootools_url ⇒ Object
49 50 51 |
# File 'lib/serve/javascripts.rb', line 49 def mootools_url "#{GOOGLE_AJAX_APIS}/mootools/#{MOOTOOLS_VERSION}/mootools-yui-compressed.js" end |
#prototype_url ⇒ Object
53 54 55 |
# File 'lib/serve/javascripts.rb', line 53 def prototype_url "#{GOOGLE_AJAX_APIS}/prototype/#{PROTOTYPE_VERSION}/prototype.js" end |
#scriptaculous_url ⇒ Object
57 58 59 |
# File 'lib/serve/javascripts.rb', line 57 def scriptaculous_url "#{GOOGLE_AJAX_APIS}/scriptaculous/#{SCRIPTACULOUS_VERSION}/scriptaculous.js" end |
#supported_javascript_frameworks ⇒ Object
24 25 26 |
# File 'lib/serve/javascripts.rb', line 24 def supported_javascript_frameworks JAVASCRIPT_FRAMEWORKS end |
#valid_javascript_framework?(framework) ⇒ Boolean
28 29 30 31 |
# File 'lib/serve/javascripts.rb', line 28 def valid_javascript_framework?(framework) framework = framework.downcase JAVASCRIPT_FRAMEWORKS.include?(framework) end |