tonka 0.0.3 → 0.0.4
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 +7 -0
- data/lib/tonka.rb +112 -42
- metadata +6 -8
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03da4a022809e7159288945d16e7c2dfcdd4ad09
|
4
|
+
data.tar.gz: cae7de061ed44daa11720a6b2c597f8966a34b8a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d182869c5e2079eb8c72076b4cf8cf2d660c653455f6b72e919cf3394e1d949a6a554bb557847d686adad43089096ff0c17812f1db862ed03fed37dbd59b429b
|
7
|
+
data.tar.gz: 69a14b5ade385298a2ee9c095f2857fab977868ff19f7b47003597141e544189257c98f3f058138fcf0f1f229f3e8d99ee53217536bb1e1f83ef1f51ffec2814
|
data/lib/tonka.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
1
3
|
class Tonka
|
2
4
|
|
3
5
|
attr_accessor :options, :site_name, :action, :messages
|
@@ -6,7 +8,7 @@ class Tonka
|
|
6
8
|
|
7
9
|
def initialize(options=[])
|
8
10
|
|
9
|
-
@version = "0.0.
|
11
|
+
@version = "0.0.3";
|
10
12
|
|
11
13
|
@options = options || ARGV
|
12
14
|
if !@options[0].nil?
|
@@ -18,24 +20,23 @@ class Tonka
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
def make_directories
|
22
|
-
if !Dir.exist?
|
23
|
-
Dir.mkdir
|
24
|
-
Dir.mkdir "#{
|
25
|
-
puts "\t\tbuilt ".green+"#{
|
23
|
+
def make_directories
|
24
|
+
if !Dir.exist? $SITE_NAME
|
25
|
+
Dir.mkdir $SITE_NAME
|
26
|
+
Dir.mkdir "#{$SITE_NAME}/stylesheets"
|
27
|
+
puts "\t\tbuilt ".green+"#{$SITE_NAME}/stylesheets/"
|
26
28
|
|
27
|
-
Dir.mkdir "#{
|
28
|
-
puts "\t\tbuilt ".green+"#{
|
29
|
+
Dir.mkdir "#{$SITE_NAME}/javascripts"
|
30
|
+
puts "\t\tbuilt ".green+"#{$SITE_NAME}/javascripts/"
|
29
31
|
else
|
30
|
-
puts "a '#{
|
32
|
+
puts "a '#{$SITE_NAME}' directory already exists!"
|
31
33
|
display_usage
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
def make_files
|
36
|
-
Tonka::HTML.new(
|
37
|
-
Tonka::CSS.new(
|
38
|
-
Tonka::JS.new(site_name,@options)
|
37
|
+
def make_files
|
38
|
+
Tonka::HTML.new(@options).render(@options)
|
39
|
+
Tonka::CSS.new(@options)
|
39
40
|
end
|
40
41
|
|
41
42
|
def parse_options(options=[])
|
@@ -51,25 +52,25 @@ class Tonka
|
|
51
52
|
when "build"
|
52
53
|
#handles the 'build' command
|
53
54
|
|
54
|
-
|
55
|
+
$SITE_NAME = @options[1] || 'sites'
|
55
56
|
|
56
57
|
jquery = true if @options[2] == '-jquery'
|
57
58
|
css_reset = true if @options[2] == '-jquery'
|
58
59
|
|
59
|
-
make_directories
|
60
|
-
make_files
|
60
|
+
make_directories
|
61
|
+
make_files
|
61
62
|
|
62
|
-
puts "\n\t\tthe construction of "+"#{
|
63
|
+
puts "\n\t\tthe construction of "+"#{$SITE_NAME}".green+" is now complete!"
|
63
64
|
|
64
65
|
when "destroy"
|
65
66
|
#handles the 'destroy' command
|
66
67
|
|
67
|
-
|
68
|
-
if Dir.exist?
|
69
|
-
system("rm -rf #{
|
70
|
-
puts "\t\tdemolished ".red+"#{
|
68
|
+
$SITE_NAME = @options[1] || 'sites'
|
69
|
+
if Dir.exist? $SITE_NAME
|
70
|
+
system("rm -rf #{$SITE_NAME}")
|
71
|
+
puts "\t\tdemolished ".red+"#{$SITE_NAME}"
|
71
72
|
else
|
72
|
-
"Oops! There is no directory called #{
|
73
|
+
"Oops! There is no directory called #{$SITE_NAME}!"
|
73
74
|
end
|
74
75
|
|
75
76
|
when "add"
|
@@ -82,7 +83,7 @@ class Tonka
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def display_usage
|
85
|
-
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-
|
86
|
+
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-underscore \t\tadds underscore.js to the javascripts folder and the index.html file.\n-backbone \t\tadds backbone.js to the javascripts folder and the index.html file."
|
86
87
|
end
|
87
88
|
|
88
89
|
end
|
@@ -91,42 +92,111 @@ class Tonka::HTML
|
|
91
92
|
#CSS processing module
|
92
93
|
attr_accessor :layout
|
93
94
|
|
94
|
-
def initialize(
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
95
|
+
def initialize(options=[])
|
96
|
+
@layout_arrays = []
|
97
|
+
@layout_array_1 = ["<!DOCTYPE html>\n",
|
98
|
+
"<html>\n",
|
99
|
+
"<head>\n",
|
100
|
+
"\t<title>#{$SITE_NAME}</title>\n",
|
101
|
+
"\t<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheets/style.css\" />\n"]
|
102
|
+
@script_array = add_js_files(options)
|
103
|
+
@layout_array_2 = [
|
104
|
+
"</head>\n",
|
105
|
+
"<body>\n",
|
106
|
+
"\</body>\n",
|
107
|
+
"</html>"]
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
def render(options)
|
115
|
+
@index_html = File.new("#{$SITE_NAME}/index.html","w")
|
116
|
+
@layout = @layout_array_1.join("") + @script_array.join("") + @layout_array_2.join("")
|
117
|
+
@index_html.puts @layout
|
118
|
+
@index_html.close
|
119
|
+
puts "\t\tbuilt ".green+"#{$SITE_NAME}/index.html"
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
def add_js_files(options)
|
124
|
+
tags = []
|
125
|
+
options.each do |option|
|
126
|
+
library_name = option.gsub("-","")
|
127
|
+
if library_name == "backbone" && !options.include?("jquery")
|
128
|
+
jquery = Tonka::JS.new("jquery")
|
129
|
+
tags << jquery.script_tag
|
130
|
+
end
|
131
|
+
if library_name == "backbone" && !options.include?("underscore")
|
132
|
+
underscore = Tonka::JS.new("underscore")
|
133
|
+
tags << underscore.script_tag
|
134
|
+
end
|
135
|
+
Tonka::JS.libraries.each do |library|
|
136
|
+
if library[library_name]
|
137
|
+
js = Tonka::JS.new(library_name)
|
138
|
+
tags << js.script_tag
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
tags << Tonka::JS.new("app").script_tag
|
144
|
+
return tags
|
103
145
|
end
|
146
|
+
|
147
|
+
|
104
148
|
end
|
105
149
|
|
106
150
|
class Tonka::CSS
|
107
151
|
#CSS processing module
|
108
152
|
attr_accessor :layout
|
109
153
|
|
110
|
-
def initialize(
|
111
|
-
style_css = File.new("#{
|
154
|
+
def initialize(options=[])
|
155
|
+
style_css = File.new("#{$SITE_NAME}/stylesheets/style.css","w")
|
112
156
|
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}"
|
113
157
|
style_css.puts style_css_content
|
114
158
|
style_css.close
|
115
|
-
puts "\t\tbuilt ".green+"#{
|
159
|
+
puts "\t\tbuilt ".green+"#{$SITE_NAME}/stylesheets/style.css"
|
116
160
|
end
|
117
161
|
end
|
118
162
|
|
119
163
|
class Tonka::JS
|
120
164
|
#CSS processing module
|
121
|
-
attr_accessor :layout
|
165
|
+
attr_accessor :layout, :script_tag, :libraries
|
166
|
+
|
167
|
+
def self.libraries
|
168
|
+
[
|
169
|
+
{"jquery" => "http://code.jquery.com/jquery-1.10.2.min.js"},
|
170
|
+
{"underscore" => "https://raw.github.com/jashkenas/underscore/master/underscore.js"},
|
171
|
+
{"backbone" => "https://raw.github.com/jashkenas/backbone/master/backbone.js"}
|
172
|
+
]
|
173
|
+
end
|
122
174
|
|
123
|
-
def initialize(
|
124
|
-
|
125
|
-
scripts_js_content = "console.log('feed me javascripts')"
|
126
|
-
scripts_js.puts scripts_js_content
|
127
|
-
scripts_js.close
|
128
|
-
puts "\t\tbuilt ".green+"#{site_name}/javascripts/scripts.js"
|
175
|
+
def initialize(file_name,options=[])
|
176
|
+
@script_tag = generate_file(file_name)
|
129
177
|
end
|
178
|
+
|
179
|
+
def generate_file(file_name)
|
180
|
+
|
181
|
+
js_file = File.new("#{$SITE_NAME}/javascripts/#{file_name}.js","w")
|
182
|
+
if file_name == "app"
|
183
|
+
js_file_content = "console.log('feed me javascripts')"
|
184
|
+
else
|
185
|
+
uri = ''
|
186
|
+
Tonka::JS.libraries.each do |library|
|
187
|
+
uri = library[file_name] if library[file_name]
|
188
|
+
end
|
189
|
+
js_file_content = Net::HTTP.get(URI(uri))
|
190
|
+
end
|
191
|
+
js_file.puts js_file_content
|
192
|
+
js_file.close
|
193
|
+
script_tag = "\t<script src='/javascripts/#{file_name}.js'></script>\n"
|
194
|
+
puts "\t\tbuilt ".green+"#{$SITE_NAME}/javascripts/#{file_name}.js"
|
195
|
+
return script_tag
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
|
130
200
|
end
|
131
201
|
|
132
202
|
class String
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tonka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Omar Delarosa
|
@@ -23,26 +22,25 @@ files:
|
|
23
22
|
homepage: http://rubygems.org/gems/tonka
|
24
23
|
licenses:
|
25
24
|
- MIT
|
25
|
+
metadata: {}
|
26
26
|
post_install_message:
|
27
27
|
rdoc_options: []
|
28
28
|
require_paths:
|
29
29
|
- lib
|
30
30
|
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
-
none: false
|
32
31
|
requirements:
|
33
|
-
- -
|
32
|
+
- - '>='
|
34
33
|
- !ruby/object:Gem::Version
|
35
34
|
version: '0'
|
36
35
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
36
|
requirements:
|
39
|
-
- -
|
37
|
+
- - '>='
|
40
38
|
- !ruby/object:Gem::Version
|
41
39
|
version: '0'
|
42
40
|
requirements: []
|
43
41
|
rubyforge_project:
|
44
|
-
rubygems_version: 1.
|
42
|
+
rubygems_version: 2.1.11
|
45
43
|
signing_key:
|
46
|
-
specification_version:
|
44
|
+
specification_version: 4
|
47
45
|
summary: Tonka!
|
48
46
|
test_files: []
|