tonka 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/tonka +5 -0
- data/lib/tonka.rb +112 -0
- metadata +48 -0
data/bin/tonka
ADDED
data/lib/tonka.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
# make index page.
|
2
|
+
class Tonka
|
3
|
+
|
4
|
+
attr_accessor :options, :site_name, :action
|
5
|
+
|
6
|
+
def initialize(options=[])
|
7
|
+
@options = options || ARGV
|
8
|
+
if !@options[0].nil?
|
9
|
+
|
10
|
+
parse_options(@options)
|
11
|
+
|
12
|
+
else
|
13
|
+
display_usage
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def make_directories(site_name)
|
18
|
+
if !Dir.exist? site_name
|
19
|
+
Dir.mkdir site_name
|
20
|
+
Dir.mkdir "#{site_name}/stylesheets"
|
21
|
+
Dir.mkdir "#{site_name}/javascripts"
|
22
|
+
|
23
|
+
puts "#{site_name} was successfully created!"
|
24
|
+
else
|
25
|
+
puts "a '#{site_name}' directory already exists!"
|
26
|
+
display_usage
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def make_files(site_name)
|
31
|
+
Tonka::HTML.new(site_name,@options)
|
32
|
+
Tonka::CSS.new(site_name,@options)
|
33
|
+
Tonka::JS.new(site_name,@options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def parse_options(options=[])
|
37
|
+
|
38
|
+
@action = @options[0]
|
39
|
+
|
40
|
+
case @action
|
41
|
+
|
42
|
+
when "build"
|
43
|
+
#handles the 'build' command
|
44
|
+
|
45
|
+
@site_name = @options[1] || 'sites'
|
46
|
+
|
47
|
+
jquery = true if @options[2] == '-jquery'
|
48
|
+
css_reset = true if @options[2] == '-jquery'
|
49
|
+
|
50
|
+
make_directories(@site_name)
|
51
|
+
make_files(@site_name)
|
52
|
+
|
53
|
+
when "destroy"
|
54
|
+
#handles the 'build' command
|
55
|
+
|
56
|
+
@site_name = @options[1] || 'sites'
|
57
|
+
|
58
|
+
system("rm -rf #{@site_name}")
|
59
|
+
|
60
|
+
when "add"
|
61
|
+
#handles the 'build' command
|
62
|
+
|
63
|
+
else
|
64
|
+
puts "Oops! I don't know that one."
|
65
|
+
display_usage
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def display_usage
|
70
|
+
puts "usage: tonka <action> SITE_NAME [-options] BODY_TEXT\n\nThe most common actions:\n\nbuild\s\t\t\tbuilds a basic static site with the name passed in as SITE_NAME\n\nThe most common options:\n\n-jquery \t\tadds jquery to index.html file.\n-css_reset \t\tadds css resetters to style.css file."
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
class Tonka::HTML
|
76
|
+
#CSS processing module
|
77
|
+
attr_accessor :layout
|
78
|
+
|
79
|
+
def initialize(site_name,options=[])
|
80
|
+
site_name = site_name
|
81
|
+
body = options[3] || ""
|
82
|
+
jquery = true if options[2] == "-jquery"
|
83
|
+
index_html = File.new("#{site_name}/index.html","w")
|
84
|
+
@layout = "<!DOCTYPE html>\n<html>\n<head>\n<title>#{site_name}</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheets/style.css\" />\n<script type=\"text/javascripts\" src=\"/javascripts/scripts.js\"></script>#{ "\n<script type=\"text/javascripts\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\"></script>" if jquery == true }\n</head>\n<body>\n#{ body+"\n" }\</body>\n</html>"
|
85
|
+
index_html.puts @layout
|
86
|
+
index_html.close
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Tonka::CSS
|
91
|
+
#CSS processing module
|
92
|
+
attr_accessor :layout
|
93
|
+
|
94
|
+
def initialize(site_name,options=[])
|
95
|
+
style_css = File.new("#{site_name}/stylesheets/style.css","w")
|
96
|
+
style_css_content = "/* html5doctor.com Reset v1.6.1 - http://cssreset.com */\nhtml,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}nav ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}a{margin:0;padding:0;font-size:100%;vertical-align:baseline;background:transparent}ins{background-color:#ff9;color:#000;text-decoration:none}mark{background-color:#ff9;color:#000;font-style:italic;font-weight:bold}del{text-decoration:line-through}abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}table{border-collapse:collapse;border-spacing:0}hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}input,select{vertical-align:middle}"
|
97
|
+
style_css.puts style_css_content
|
98
|
+
style_css.close
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class Tonka::JS
|
103
|
+
#CSS processing module
|
104
|
+
attr_accessor :layout
|
105
|
+
|
106
|
+
def initialize(site_name,options=[])
|
107
|
+
scripts_js = File.new("#{site_name}/javascripts/scripts.js","w")
|
108
|
+
scripts_js_content = "console.log('feed me javascripts')"
|
109
|
+
scripts_js.puts scripts_js_content
|
110
|
+
scripts_js.close
|
111
|
+
end
|
112
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tonka
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Omar Delarosa
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-07 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A static site builder.
|
15
|
+
email: thedelarosa@gmail.com
|
16
|
+
executables:
|
17
|
+
- tonka
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/tonka.rb
|
22
|
+
- bin/tonka
|
23
|
+
homepage: http://rubygems.org/gems/tonka
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 1.8.25
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: Tonka!
|
48
|
+
test_files: []
|