appmake 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.
- data/lib/appmake.rb +40 -2
- metadata +1 -1
data/lib/appmake.rb
CHANGED
@@ -1,13 +1,51 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "listen"
|
3
|
+
|
1
4
|
class Appmake
|
2
5
|
def self.main(option)
|
3
|
-
if option == "
|
6
|
+
if option == "init"
|
7
|
+
self.init()
|
8
|
+
elsif option == "watch"
|
4
9
|
self.watch()
|
5
10
|
else
|
6
11
|
abort "error: invalid option passed"
|
7
12
|
end
|
8
13
|
end
|
9
14
|
|
15
|
+
def self.init
|
16
|
+
FileUtils.mkdir "css"
|
17
|
+
FileUtils.touch "css/main.scss"
|
18
|
+
FileUtils.mkdir "js"
|
19
|
+
FileUtils.touch "js/main.js"
|
20
|
+
FileUtils.mkdir "tpl"
|
21
|
+
end
|
22
|
+
|
10
23
|
def self.watch
|
11
|
-
|
24
|
+
tpl_callback = Proc.new do |modified, added, removed|
|
25
|
+
puts "=> rebuilding TPL"
|
26
|
+
system("node bin/compile_templates.js")
|
27
|
+
end
|
28
|
+
|
29
|
+
tpl_listener = Listen.to "tpl", :filter => /\.html$/
|
30
|
+
tpl_listener.change(&tpl_callback)
|
31
|
+
tpl_listener.start(false)
|
32
|
+
|
33
|
+
css_callback = Proc.new do |modified, added, removed|
|
34
|
+
puts "=> rebuilding CSS"
|
35
|
+
system("bundle exec sass css/app.scss css/app.css")
|
36
|
+
end
|
37
|
+
|
38
|
+
css_listener = Listen.to "css", :filter => /\.scss$/
|
39
|
+
css_listener.change(&css_callback)
|
40
|
+
css_listener.start(false)
|
41
|
+
|
42
|
+
js_callback = Proc.new do |modified, added, removed|
|
43
|
+
puts "=> rebuilding JS"
|
44
|
+
system("webmake js/app_tpl.js js/app.js")
|
45
|
+
end
|
46
|
+
|
47
|
+
js_listener = Listen.to "js", :filter => /\.js$/
|
48
|
+
js_listener.change(&js_callback)
|
49
|
+
js_listener.start
|
12
50
|
end
|
13
51
|
end
|