appmake 0.0.22 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in appmake.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sebastian Sito
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Appmake
2
+
3
+ Appmake allows you to easily develop single-page apps in HTML5
4
+
5
+ ## Requirements
6
+
7
+ Appmake require `node.js` along with `webmake` module installed.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'appmake'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install appmake
22
+
23
+ ## Usage
24
+
25
+ To create your app use `bundle exec appmake init <app name>`. `cd` to created folder and issue `appmake watch` and you're done.
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/appmake.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'appmake/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "appmake"
8
+ gem.version = Appmake::VERSION
9
+ gem.authors = ["Sebastian Sito"]
10
+ gem.email = ["sebastian@hypenode.com"]
11
+ gem.description = %q{Appmake allows you to easily develop single-page apps in HTML5}
12
+ gem.summary = %q{Appmake app bootstrapper}
13
+ gem.homepage = "https://github.com/sebastiansito/appmake"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "thor"
21
+ gem.add_dependency "listen"
22
+ gem.add_dependency "rb-fsevent"
23
+ gem.add_dependency "sass"
24
+ end
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "appmake"
4
4
 
5
- Appmake.main(ARGV[0])
5
+ Appmake.start
@@ -0,0 +1,3 @@
1
+ class Appmake
2
+ VERSION = "0.0.24"
3
+ end
data/lib/appmake.rb CHANGED
@@ -1,355 +1,37 @@
1
- require "fileutils"
2
- require "listen"
1
+ require "thor"
2
+ require "appmake/version"
3
+ require "appmake/listeners/js"
3
4
 
4
- class Appmake
5
- def self.main(option)
6
- if option == "init"
7
- self.init()
8
- elsif option == "watch"
9
- self.watch()
10
- else
11
- abort "error: invalid option passed"
12
- end
13
- end
14
-
15
- def self.init
16
- unless Dir.exists? "css"
17
- puts "=> mkdir /css"
18
- FileUtils.mkdir "css"
19
- end
20
-
21
- puts "=> create /css/app.scss"
22
- f = File.new("css/app.scss", "w+")
23
- f.puts(APP_SCSS)
24
- f.close
25
-
26
- puts "=> create /css/body.scss"
27
- f = File.new("css/body.scss", "w+")
28
- f.puts(BODY_SCSS)
29
- f.close
30
-
31
- unless Dir.exists? "js"
32
- puts "=> mkdir /js"
33
- FileUtils.mkdir "js"
34
- end
35
-
36
- unless Dir.exists? "js/lib"
37
- puts "=> mkdir /js/lib"
38
- FileUtils.mkdir "js/lib"
39
- end
40
-
41
- puts "=> create /js/app_tpl.js"
42
- f = File.new("js/app_tpl.js", "w+")
43
- f.puts(APP_TPL_JS)
44
- f.close
45
- FileUtils.touch "js/app_tpl.js"
46
-
47
- puts "=> create /js/compile_templates.js"
48
- f = File.new("js/compile_templates.js", "w+")
49
- f.puts(COMPILE_TEMPLATES_JS)
50
- f.close
51
-
52
- puts "=> create /js/lib/doT.js"
53
- f = File.new("js/lib/doT.js", "w+")
54
- f.puts(DOTJS_JS)
55
- f.close
56
-
57
- unless Dir.exists? "tpl"
58
- puts "=> mkdir /tpl"
59
- FileUtils.mkdir "tpl"
60
- end
61
-
62
- puts "=> create /index.html"
63
- f = File.new("index.html", "w+")
64
- f.puts(INDEX_HTML)
65
- f.close
66
-
67
- puts "=> create /tpl/welcome.html"
68
- f = File.new("tpl/welcome.html", "w+")
69
- f.puts(WELCOME_HTML)
70
- f.close
71
-
72
- puts "=> rebuilding TPL"
73
- system("node js/compile_templates.js")
74
-
75
- puts "=> rebuilding CSS"
76
- system("bundle exec sass css/app.scss css/app.css")
5
+ class Appmake < Thor
6
+ include Thor::Actions
77
7
 
78
- puts "=> rebuilding JS"
79
- system("webmake js/app_tpl.js js/app.js")
8
+ def self.source_root
9
+ File.dirname(File.dirname(__FILE__))
80
10
  end
81
11
 
82
- def self.watch
83
- tpl_callback = Proc.new do |modified, added, removed|
84
- puts "=> rebuilding TPL"
85
- system("node js/compile_templates.js")
86
- end
12
+ desc "init", "initialize new application"
13
+ def init
14
+ empty_directory "bin"
15
+ template"templates/bin/compile_templates.js.tt", "bin/compile_templates.js"
87
16
 
88
- tpl_listener = Listen.to "tpl", :filter => /\.html$/
89
- tpl_listener.change(&tpl_callback)
90
- tpl_listener.start(false)
17
+ empty_directory "css"
18
+ template"templates/css/app.scss.tt", "css/app.scss"
19
+ template"templates/css/body.scss.tt", "css/body.scss"
91
20
 
92
- css_callback = Proc.new do |modified, added, removed|
93
- puts "=> rebuilding CSS"
94
- system("bundle exec sass css/app.scss css/app.css")
95
- end
21
+ empty_directory "js"
22
+ template"templates/js/lib/doT.js.tt", "js/lib/doT.js"
23
+ template"templates/js/app.js.tt", "js/app.js"
96
24
 
97
- css_listener = Listen.to "css", :filter => /\.scss$/
98
- css_listener.change(&css_callback)
99
- css_listener.start(false)
25
+ empty_directory "tpl"
26
+ template "templates/tpl/welcome.html.tt", "tpl/welcome.html"
100
27
 
101
- js_callback = Proc.new do |modified, added, removed|
102
- puts "=> rebuilding JS"
103
- system("webmake js/app_tpl.js js/app.js")
104
- end
28
+ empty_directory "public"
29
+ template "templates/public/index.html.tt", "public/index.html"
30
+ end
105
31
 
106
- js_listener = Listen.to "js", :filter => /\.js$/
107
- js_listener.change(&js_callback)
32
+ desc "watch", "watch for files to compile"
33
+ def watch
34
+ js_listener = Listeners::Js.new
108
35
  js_listener.start
109
36
  end
110
- end
111
-
112
- COMPILE_TEMPLATES_JS = <<'EOS'
113
- var app_dir = __dirname + '/../',
114
- tpl_dir = app_dir + 'tpl/',
115
- js_dir = app_dir + 'js/',
116
-
117
- fs = require('fs'),
118
- dot = require('../js/lib/doT.js'),
119
-
120
- templates = {};
121
-
122
- walk();
123
- fs.writeFile(js_dir + 'templates.js', buildModule(templates));
124
-
125
-
126
- function walk(subdir) {
127
- var dir = tpl_dir,
128
- files;
129
-
130
- if (subdir)
131
- dir += subdir;
132
-
133
- files = fs.readdirSync(dir);
134
- files.forEach(function (filename) {
135
- var stats = fs.statSync(dir + filename);
136
-
137
- if (stats.isDirectory()) {
138
- if (subdir) filename = subdir + filename;
139
- filename += '/';
140
-
141
- walk(filename);
142
- }
143
-
144
- if (!isHTML(filename))
145
- return;
146
-
147
- readFile(filename, subdir, fs.readFileSync(dir + filename));
148
- });
149
- }
150
-
151
- function readFile (filename, dir, data) {
152
- var name = filename.split('.').slice(0, -1).join('.'),
153
- compiled = dot.template(data).toString().replace(/^function anonymous/, 'function ');
154
-
155
- if (dir)
156
- name = dir + name;
157
-
158
- templates[name] = compiled;
159
- }
160
-
161
- function isHTML(name) {
162
- if (!~name.indexOf('.'))
163
- return false;
164
-
165
- return name.split('.').slice(-1)[0].toLowerCase() === 'html';
166
- }
167
-
168
- function buildModule() {
169
- var content = [],
170
- n;
171
-
172
- for (n in templates)
173
- content.push('"' + n + '": ' + templates[n]);
174
-
175
- return ['module.exports = {', content.join(','), '};'].join('').replace(/(\n|\r|\r\n)/, '');
176
- }
177
- EOS
178
-
179
- DOTJS_JS = <<'EOS'
180
- // doT.js
181
- // 2011, Laura Doktorova, https://github.com/olado/doT
182
- // Licensed under the MIT license.
183
-
184
- (function() {
185
- "use strict";
186
-
187
- var doT = {
188
- version: '1.0.0',
189
- templateSettings: {
190
- evaluate: /\{\{([\s\S]+?\}?)\}\}/g,
191
- interpolate: /\{\{=([\s\S]+?)\}\}/g,
192
- encode: /\{\{!([\s\S]+?)\}\}/g,
193
- use: /\{\{#([\s\S]+?)\}\}/g,
194
- useParams: /(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,
195
- define: /\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,
196
- defineParams:/^\s*([\w$]+):([\s\S]+)/,
197
- conditional: /\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,
198
- iterate: /\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,
199
- varname: 'it',
200
- strip: true,
201
- append: true,
202
- selfcontained: false
203
- },
204
- template: undefined, //fn, compile template
205
- compile: undefined //fn, for express
206
- };
207
-
208
- if (typeof module !== 'undefined' && module.exports) {
209
- module.exports = doT;
210
- } else if (typeof define === 'function' && define.amd) {
211
- define(function(){return doT;});
212
- } else {
213
- (function(){ return this || (0,eval)('this'); }()).doT = doT;
214
- }
215
-
216
- function encodeHTMLSource() {
217
- var encodeHTMLRules = { "&": "&#38;", "<": "&#60;", ">": "&#62;", '"': '&#34;', "'": '&#39;', "/": '&#47;' },
218
- matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g;
219
- return function() {
220
- return this ? this.replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : this;
221
- };
222
- }
223
- String.prototype.encodeHTML = encodeHTMLSource();
224
-
225
- var startend = {
226
- append: { start: "'+(", end: ")+'", endencode: "||'').toString().encodeHTML()+'" },
227
- split: { start: "';out+=(", end: ");out+='", endencode: "||'').toString().encodeHTML();out+='"}
228
- }, skip = /$^/;
229
-
230
- function resolveDefs(c, block, def) {
231
- return ((typeof block === 'string') ? block : block.toString())
232
- .replace(c.define || skip, function(m, code, assign, value) {
233
- if (code.indexOf('def.') === 0) {
234
- code = code.substring(4);
235
- }
236
- if (!(code in def)) {
237
- if (assign === ':') {
238
- if (c.defineParams) value.replace(c.defineParams, function(m, param, v) {
239
- def[code] = {arg: param, text: v};
240
- });
241
- if (!(code in def)) def[code]= value;
242
- } else {
243
- new Function("def", "def['"+code+"']=" + value)(def);
244
- }
245
- }
246
- return '';
247
- })
248
- .replace(c.use || skip, function(m, code) {
249
- if (c.useParams) code = code.replace(c.useParams, function(m, s, d, param) {
250
- if (def[d] && def[d].arg && param) {
251
- var rw = (d+":"+param).replace(/'|\\/g, '_');
252
- def.__exp = def.__exp || {};
253
- def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2");
254
- return s + "def.__exp['"+rw+"']";
255
- }
256
- });
257
- var v = new Function("def", "return " + code)(def);
258
- return v ? resolveDefs(c, v, def) : v;
259
- });
260
- }
261
-
262
- function unescape(code) {
263
- return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, ' ');
264
- }
265
-
266
- doT.template = function(tmpl, c, def) {
267
- c = c || doT.templateSettings;
268
- var cse = c.append ? startend.append : startend.split, needhtmlencode, sid = 0, indv,
269
- str = (c.use || c.define) ? resolveDefs(c, tmpl, def || {}) : tmpl;
270
-
271
- str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g,' ')
272
- .replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,''): str)
273
- .replace(/'|\\/g, '\\$&')
274
- .replace(c.interpolate || skip, function(m, code) {
275
- return cse.start + unescape(code) + cse.end;
276
- })
277
- .replace(c.encode || skip, function(m, code) {
278
- needhtmlencode = true;
279
- return cse.start + unescape(code) + cse.endencode;
280
- })
281
- .replace(c.conditional || skip, function(m, elsecase, code) {
282
- return elsecase ?
283
- (code ? "';}else if(" + unescape(code) + "){out+='" : "';}else{out+='") :
284
- (code ? "';if(" + unescape(code) + "){out+='" : "';}out+='");
285
- })
286
- .replace(c.iterate || skip, function(m, iterate, vname, iname) {
287
- if (!iterate) return "';} } out+='";
288
- sid+=1; indv=iname || "i"+sid; iterate=unescape(iterate);
289
- return "';var arr"+sid+"="+iterate+";if(arr"+sid+"){var "+vname+","+indv+"=-1,l"+sid+"=arr"+sid+".length-1;while("+indv+"<l"+sid+"){"
290
- +vname+"=arr"+sid+"["+indv+"+=1];out+='";
291
- })
292
- .replace(c.evaluate || skip, function(m, code) {
293
- return "';" + unescape(code) + "out+='";
294
- })
295
- + "';return out;")
296
- .replace(/\n/g, '\\n').replace(/\t/g, '\\t').replace(/\r/g, '\\r')
297
- .replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, '')
298
- .replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+=');
299
-
300
- if (needhtmlencode && c.selfcontained) {
301
- str = "String.prototype.encodeHTML=(" + encodeHTMLSource.toString() + "());" + str;
302
- }
303
- try {
304
- return new Function(c.varname, str);
305
- } catch (e) {
306
- if (typeof console !== 'undefined') console.log("Could not create a template function: " + str);
307
- throw e;
308
- }
309
- };
310
-
311
- doT.compile = function(tmpl, def) {
312
- return doT.template(tmpl, null, def);
313
- };
314
- }());
315
- EOS
316
-
317
- INDEX_HTML = <<'EOS'
318
- <!doctype>
319
- <html>
320
- <head>
321
- <title></title>
322
- <meta http=equiv="Content-Type" content="text/html; charset=UTF-8">
323
- <link rel="stylesheet" type="text/css" href="css/app.css">
324
- </head>
325
- <body>
326
- <script type="text/javascript" src="js/app.js"></script>
327
- </body>
328
- </html>
329
- EOS
330
-
331
- APP_TPL_JS = <<'EOS'
332
- (function() {
333
- var templates = require("./templates");
334
- document.write(templates.welcome({title: "Appmake", description: "Welcome in Appmake example app"}));
335
- }())
336
- EOS
337
-
338
- WELCOME_HTML = <<'EOS'
339
- <h1>{{= it.title }}</h1>
340
- <p>{{= it.description }}</p>
341
- EOS
342
-
343
- APP_SCSS = <<'EOS'
344
- @import "body";
345
-
346
- body {
347
- color: $bodyColor;
348
- background-color: $bodyBackgroundColor;
349
- }
350
- EOS
351
-
352
- BODY_SCSS = <<'EOS'
353
- $bodyColor: #A47;
354
- $bodyBackgroundColor: #BCF;
355
- EOS
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.24
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-12 00:00:00.000000000 Z
12
+ date: 2013-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: listen
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,16 +75,24 @@ dependencies:
59
75
  - - ! '>='
60
76
  - !ruby/object:Gem::Version
61
77
  version: '0'
62
- description: ''
63
- email: sebastian@hypenode.com
78
+ description: Appmake allows you to easily develop single-page apps in HTML5
79
+ email:
80
+ - sebastian@hypenode.com
64
81
  executables:
65
- - appmake
82
+ - appmake.rb
66
83
  extensions: []
67
84
  extra_rdoc_files: []
68
85
  files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - appmake.gemspec
92
+ - bin/appmake.rb
69
93
  - lib/appmake.rb
70
- - bin/appmake
71
- homepage: ''
94
+ - lib/appmake/version.rb
95
+ homepage: https://github.com/sebastiansito/appmake
72
96
  licenses: []
73
97
  post_install_message:
74
98
  rdoc_options: []
@@ -91,5 +115,5 @@ rubyforge_project:
91
115
  rubygems_version: 1.8.23
92
116
  signing_key:
93
117
  specification_version: 3
94
- summary: ''
118
+ summary: Appmake app bootstrapper
95
119
  test_files: []