tonka 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tonka.rb +91 -45
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80ab1963929f695dd1a940c4c4e8de68656e5294
|
4
|
+
data.tar.gz: 016397b1485704bb6df981da7832d0f220a057c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec5162b38446de9927b40216b24215dc5f5547da9ba9b750a1a130c6417a0879666ca2fcde2fd9c5a7182522c33debf6d0bf6c9152d5072e16e8cf3bd57c7e9
|
7
|
+
data.tar.gz: 3885e54e2bf74070597b5b3020432b5615a832dffd76f2038fffe2722b5038c954c5911e982c4897be534b144fdd98c6e69e82cb80aa09b27fca12003aa9e029
|
data/lib/tonka.rb
CHANGED
@@ -10,7 +10,7 @@ class Tonka
|
|
10
10
|
|
11
11
|
def initialize(options=[])
|
12
12
|
|
13
|
-
@version = "0.0.
|
13
|
+
@version = "0.0.8";
|
14
14
|
|
15
15
|
@options = options || ARGV
|
16
16
|
if !@options[0].nil?
|
@@ -45,7 +45,6 @@ class Tonka
|
|
45
45
|
|
46
46
|
def make_files
|
47
47
|
Tonka::HTML.new(@options).render(@options)
|
48
|
-
Tonka::CSS.new(@options)
|
49
48
|
end
|
50
49
|
|
51
50
|
def parse_options(options=[])
|
@@ -69,7 +68,7 @@ class Tonka
|
|
69
68
|
make_directories
|
70
69
|
make_files
|
71
70
|
|
72
|
-
puts "\n\t\tthe construction of "+"#{$SITE_NAME}".green+" is now complete!"
|
71
|
+
puts "\n\t\tthe construction of "+"#{$SITE_NAME}".green+" is now complete!"
|
73
72
|
|
74
73
|
when "destroy"
|
75
74
|
#handles the 'destroy' command
|
@@ -93,24 +92,27 @@ class Tonka
|
|
93
92
|
puts "Oops! I don't know that one."
|
94
93
|
display_usage
|
95
94
|
end
|
96
|
-
|
95
|
+
|
97
96
|
end
|
98
97
|
|
99
98
|
def display_usage
|
100
99
|
usage_array = ["usage: tonka <action> SITE_NAME [-options] BODY_TEXT\n\n",
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
101
|
+
"The most common actions:\n\n",
|
102
|
+
"build\s\t\t\tbuilds a basic static site with the name passed in as SITE_NAME\n\n",
|
103
|
+
"destroy\s\t\t\tdestroys a previously built site with the name passed in as SITE_NAME\n\n",
|
104
|
+
"serve\s\t\t\tserves your files using WEBrick on port 2000 (a different port can be passed in as an argument)\n\n",
|
105
|
+
"The most common options:\n\n",
|
106
|
+
"-bootstrap \t adds Bootstrap front-end int your stylesheets, javascripts and index.html\n",
|
107
|
+
"-jquery \t\tadds jquery to index.html file.\n",
|
108
|
+
"-underscore \t\tadds underscore.js to the javascripts folder and the index.html file.\n",
|
109
|
+
"-backbone \t\tadds backbone.js, underscore.js, and jquery.js to the javascripts folder and the index.html file.\n",
|
110
|
+
"-handlebars \t\tadds handlebars.js to the javascripts folder and the index.html file.\n",
|
111
|
+
"-d3 \t\t\tadds d3.js to the javascripts folder and the index.html file.\n",
|
112
|
+
"-raphael \t\tadds raphael.js to the javascripts folder and the index.html file.\n",
|
113
|
+
"-angular \t\tadds angular.js to the javascripts folder and the index.html file. Also adds <html ng-app> at top of the index file.\n"
|
114
|
+
]
|
115
|
+
|
114
116
|
puts usage_array.join("")
|
115
117
|
end
|
116
118
|
|
@@ -122,27 +124,25 @@ class Tonka::HTML
|
|
122
124
|
|
123
125
|
def initialize(options=[])
|
124
126
|
@layout_arrays = []
|
125
|
-
@
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
@layout_array_0 = ["<!DOCTYPE html>\n"]
|
128
|
+
if options.include?("-angular")
|
129
|
+
@layout_array_1 = ["<html ng-app>\n"]
|
130
|
+
else
|
131
|
+
@layout_array_1 = ["<html>\n"]
|
132
|
+
end
|
133
|
+
@layout_array_2 = ["<head>\n","\t<title>#{$SITE_NAME}</title>\n"]
|
134
|
+
@link_array = add_css_files(options)
|
130
135
|
@script_array = add_js_files(options)
|
131
|
-
@
|
132
|
-
"</head>\n",
|
133
|
-
"<body>\n"]
|
136
|
+
@layout_array_3 = ["</head>\n","<body>\n"]
|
134
137
|
@script_array_2 = add_handlebars_template(options)
|
135
|
-
@
|
136
|
-
"</html>"]
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
138
|
+
@layout_array_4 = ["</body>\n","</html>"]
|
141
139
|
end
|
142
140
|
|
143
141
|
def render(options)
|
144
142
|
@index_html = File.new("#{$SITE_NAME}/index.html","w")
|
145
|
-
|
143
|
+
|
144
|
+
@layout = @layout_array_0.join("") + @layout_array_1.join("") + @layout_array_2.join("") + @link_array.join("") + @script_array.join("") + @layout_array_3.join("") + @script_array_2.join("") + @layout_array_4.join("")
|
145
|
+
|
146
146
|
@index_html.puts @layout
|
147
147
|
@index_html.close
|
148
148
|
puts "\t\tbuilt ".green+"#{$SITE_NAME}/index.html"
|
@@ -161,6 +161,10 @@ class Tonka::HTML
|
|
161
161
|
underscore = Tonka::JS.new("underscore")
|
162
162
|
tags << underscore.script_tag
|
163
163
|
end
|
164
|
+
if library_name == "bootstrap" && !options.include?("jquery")
|
165
|
+
jquery = Tonka::JS.new("jquery")
|
166
|
+
tags << jquery.script_tag
|
167
|
+
end
|
164
168
|
Tonka::JS.libraries.each do |library|
|
165
169
|
if library[library_name]
|
166
170
|
js = Tonka::JS.new(library_name)
|
@@ -173,10 +177,26 @@ class Tonka::HTML
|
|
173
177
|
return tags
|
174
178
|
end
|
175
179
|
|
180
|
+
def add_css_files(options)
|
181
|
+
tags = []
|
182
|
+
options.each do |option|
|
183
|
+
library_name = option.gsub("-","")
|
184
|
+
Tonka::CSS.libraries.each do |library|
|
185
|
+
if library[library_name]
|
186
|
+
css = Tonka::CSS.new(library_name)
|
187
|
+
tags << (css.link_tag + "\n")
|
188
|
+
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
tags << (Tonka::CSS.new("style").link_tag + "\n")
|
193
|
+
return tags
|
194
|
+
end
|
195
|
+
|
176
196
|
def add_handlebars_template(options)
|
177
197
|
tag = []
|
178
198
|
handlebars_template = "\t<script id='template' type='text/x-handlebars-template'>\n \t</script>\n"
|
179
|
-
|
199
|
+
|
180
200
|
options.each do |option|
|
181
201
|
library_name = option.gsub("-","")
|
182
202
|
if library_name == "handlebars"
|
@@ -187,19 +207,43 @@ class Tonka::HTML
|
|
187
207
|
return tag
|
188
208
|
end
|
189
209
|
|
210
|
+
|
211
|
+
|
190
212
|
end
|
191
213
|
|
192
214
|
class Tonka::CSS
|
193
215
|
#CSS processing module
|
194
|
-
attr_accessor :layout
|
216
|
+
attr_accessor :layout, :link_tag, :libraries
|
195
217
|
|
196
|
-
def
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
218
|
+
def self.libraries
|
219
|
+
[
|
220
|
+
{"bootstrap" => "http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"}
|
221
|
+
]
|
222
|
+
end
|
223
|
+
|
224
|
+
def initialize(file_name, options=[])
|
225
|
+
@link_tag = generate_file(file_name)
|
202
226
|
end
|
227
|
+
|
228
|
+
def generate_file(file_name)
|
229
|
+
|
230
|
+
css_file = File.new("#{$SITE_NAME}/stylesheets/#{file_name}.css","w")
|
231
|
+
if file_name == "style"
|
232
|
+
css_file_content = "/*INSERT CSS*/"
|
233
|
+
else
|
234
|
+
uri = ''
|
235
|
+
Tonka::CSS.libraries.each do |library|
|
236
|
+
uri = library[file_name] if library[file_name]
|
237
|
+
end
|
238
|
+
css_file_content = Net::HTTP.get(URI(uri))
|
239
|
+
end
|
240
|
+
css_file.puts css_file_content
|
241
|
+
css_file.close
|
242
|
+
link_tag = "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheets/#{file_name}.css\" />"
|
243
|
+
puts "\t\tbuilt ".green+"#{$SITE_NAME}/stylesheets/#{file_name}.css"
|
244
|
+
return link_tag
|
245
|
+
end
|
246
|
+
|
203
247
|
end
|
204
248
|
|
205
249
|
class Tonka::JS
|
@@ -213,20 +257,22 @@ class Tonka::JS
|
|
213
257
|
{"backbone" => "https://raw.github.com/jashkenas/backbone/master/backbone.js"},
|
214
258
|
{"handlebars" => "http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"},
|
215
259
|
{"d3" => "https://raw.github.com/mbostock/d3/master/d3.min.js"},
|
216
|
-
{"raphael" => "https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael-min.js"}
|
260
|
+
{"raphael" => "https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael-min.js"},
|
261
|
+
{"angular" => "https://raw.github.com/angular/angular.js/master/src/Angular.js"},
|
262
|
+
{"bootstrap" => "http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"}
|
217
263
|
]
|
218
264
|
end
|
219
265
|
|
220
|
-
def initialize(file_name,options=[])
|
266
|
+
def initialize(file_name,options=[])
|
221
267
|
@script_tag = generate_file(file_name)
|
222
268
|
end
|
223
269
|
|
224
270
|
def generate_file(file_name)
|
225
|
-
|
271
|
+
|
226
272
|
js_file = File.new("#{$SITE_NAME}/javascripts/#{file_name}.js","w")
|
227
273
|
if file_name == "app"
|
228
274
|
js_file_content = "console.log('feed me javascripts')"
|
229
|
-
else
|
275
|
+
else
|
230
276
|
uri = ''
|
231
277
|
Tonka::JS.libraries.each do |library|
|
232
278
|
uri = library[file_name] if library[file_name]
|
@@ -240,7 +286,7 @@ class Tonka::JS
|
|
240
286
|
return script_tag
|
241
287
|
end
|
242
288
|
|
243
|
-
|
289
|
+
|
244
290
|
|
245
291
|
end
|
246
292
|
|
@@ -265,4 +311,4 @@ class String
|
|
265
311
|
def pink
|
266
312
|
colorize(35)
|
267
313
|
end
|
268
|
-
end
|
314
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tonka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Delarosa
|
8
8
|
- Eric Streske
|
9
|
+
- Brendan Soffientini
|
10
|
+
- Daniel Bushkanets
|
9
11
|
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
14
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
13
15
|
dependencies: []
|
14
16
|
description: A static site builder, destroyer and server.
|
15
17
|
email: thedelarosa@gmail.com
|