-
Notifications
You must be signed in to change notification settings - Fork 1
/
sow.rb
88 lines (76 loc) · 2.17 KB
/
sow.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#
# Basic Ruby script to create a new project for basic web development
#
# Author: David Duggins
# Email: [email protected]
#
# Created: 5/4/2010
# License: GPL2
#
require 'fileutils'
require 'net/http'
#OPTIONS
# Here you can define the directory structure that you want on the base level
dir_structure = ['stylesheets','javascript','images','db']
javascript_dir = 'javascript'
#TODO Need to add some code for css and maybe some automatic image stuff
css_dir = 'stylesheets'
# This makes sure that a variable has been passed
if ARGV.length == 0
puts "Please enter the name of your Project"
exit 0
end
# Sets the project name
project = ARGV[0]
FileUtils.mkdir_p project
puts "#{project}:CREATED"
FileUtils.cd project
# Creates a XHTML Strict Doctype Index file
File.open("index.html", 'w') {|file|
file.puts "<!DOCTYPE html>"
file.puts "<html>"
file.puts " <head>"
file.puts " <title></title>"
file.puts " </head>"
file.puts " <body>"
file.puts " "
file.puts " </body>"
file.puts "</html>"}
puts "index.html........done"
# Runs through the array defined in options to create the Directory Structure.
dir_structure.each do |i|
FileUtils.mkdir_p i
puts "#{i}:CREATED"
end
#Here we load the base CSS file
File.open("stylesheets/style.css", 'w'){ |file|
file.puts "# Insert style Here"
}
puts "style.css.....done"
#this is where we load the JavaScript Libraries into the JavaScript folder
FileUtils.cd javascript_dir
Net::HTTP.start("script.aculo.us") { |http|
resp = http.get("/dist/scriptaculous-js-1.8.3.tar.bz2")
open("scriptaculous-js-1.8.3.tar.bz2", "wb") { |file|
file.write(resp.body)
}
}
puts "Prototype.........Downloaded"
puts "Scriptaculous.....Downloaded"
=begin
TODO Need to add some code to extract the prototype/scriptaculous libraries
=end
Net::HTTP.start("code.jquery.com") { |http|
resp = http.get("/jquery-1.4.2.js")
open("jquery-1.4.2.js", "wb") { |file|
file.write(resp.body)
}
}
puts "JQuery............Downloaded"
Net::HTTP.start("mootools.net") { |http|
resp = http.get("/download/get/mootools-1.2.4-core-nc.js")
open("mootools-1.2.4-core-nc.js", "wb") { |file|
file.write(resp.body)
}
}
puts "MooTools..........Downloaded"