frontendloader 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fel +22 -4
- data/lib/FrontEndLoader.rb +55 -49
- metadata +10 -6
data/bin/fel
CHANGED
@@ -1,15 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
2
4
|
require 'frontendloader'
|
3
5
|
fel = FrontendLoader.new
|
4
6
|
case ARGV[0]
|
5
7
|
when "init"
|
6
8
|
fel.init_app
|
7
9
|
when "compile"
|
8
|
-
|
10
|
+
if ARGV[1] then
|
11
|
+
fel.compile ARGV[1]
|
12
|
+
else
|
13
|
+
fel.compile
|
14
|
+
end
|
9
15
|
when "listen"
|
10
|
-
|
16
|
+
if ARGV[1] then
|
17
|
+
fel.listen ARGV[1]
|
18
|
+
else
|
19
|
+
fel.listen
|
20
|
+
end
|
11
21
|
when "watch"
|
12
|
-
|
22
|
+
if ARGV[1] then
|
23
|
+
fel.listen ARGV[1]
|
24
|
+
else
|
25
|
+
fel.listen
|
26
|
+
end
|
13
27
|
when "--watch"
|
14
|
-
|
28
|
+
if ARGV[1] then
|
29
|
+
fel.listen ARGV[1]
|
30
|
+
else
|
31
|
+
fel.listen
|
32
|
+
end
|
15
33
|
end
|
data/lib/FrontEndLoader.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'jscat'
|
2
|
-
require 'filestojs'
|
3
1
|
require 'yaml'
|
4
2
|
require 'listen'
|
5
3
|
|
@@ -9,7 +7,7 @@ class FrontendLoader
|
|
9
7
|
attr_accessor :settings
|
10
8
|
|
11
9
|
def initialize
|
12
|
-
version = '0.0.
|
10
|
+
version = '0.0.7'
|
13
11
|
@gem_path = Gem.path[0]+"/gems/frontendloader-"+version
|
14
12
|
@resources_path = Gem.path[0]+"/gems/frontendloader-"+version+"/resources"
|
15
13
|
@processors = {}
|
@@ -29,24 +27,29 @@ class FrontendLoader
|
|
29
27
|
end
|
30
28
|
|
31
29
|
def boilerplate
|
32
|
-
load_settings
|
30
|
+
load_settings
|
33
31
|
end
|
34
32
|
|
35
33
|
def load_settings
|
36
34
|
if ! File.exists? 'FrontendLoader.yml' then
|
37
|
-
|
35
|
+
puts 'FrontendLoader not yet initialized. Please run "fel init" first'
|
36
|
+
return false
|
38
37
|
end
|
39
38
|
begin
|
40
|
-
@settings = YAML.load_file('FrontendLoader.yml')
|
39
|
+
@settings = YAML.load_file('FrontendLoader.yml')
|
41
40
|
return true
|
42
41
|
rescue Exception => e
|
43
42
|
puts "FrontendLoader.yml could not be parsed as valid YAML, please check your syntax"
|
44
43
|
return false
|
45
44
|
end
|
46
45
|
end
|
47
|
-
|
48
|
-
|
49
|
-
def compile
|
46
|
+
|
47
|
+
|
48
|
+
def compile(dir=false)
|
49
|
+
if dir then
|
50
|
+
Dir.chdir(dir)
|
51
|
+
end
|
52
|
+
|
50
53
|
return false unless load_settings
|
51
54
|
|
52
55
|
#CSS
|
@@ -70,7 +73,7 @@ class FrontendLoader
|
|
70
73
|
end
|
71
74
|
puts "Compiled css into css.css"
|
72
75
|
end
|
73
|
-
|
76
|
+
|
74
77
|
#TEMPLATES
|
75
78
|
if @settings['templates']['enabled'] then
|
76
79
|
template_files = Dir.glob("*.#{@settings['templates']['format']}")
|
@@ -82,7 +85,7 @@ class FrontendLoader
|
|
82
85
|
end
|
83
86
|
templates_source = "#{@settings['templates']['varname']} = {};\n"
|
84
87
|
template_files.each {|file|
|
85
|
-
template_markup = File.
|
88
|
+
template_markup = File.open(file, :encoding => "UTF-8").read
|
86
89
|
template_markup.gsub!("\n","")
|
87
90
|
template_markup.gsub!("\"","\\\"")
|
88
91
|
template_markup = template_markup.strip.gsub(/\s{2,}/, ' ')
|
@@ -92,7 +95,7 @@ class FrontendLoader
|
|
92
95
|
else
|
93
96
|
templates_source = ""
|
94
97
|
end
|
95
|
-
|
98
|
+
|
96
99
|
#JS
|
97
100
|
if @settings['javascript']['enabled'] then
|
98
101
|
js_source_files = Dir.glob("*.js")
|
@@ -106,8 +109,8 @@ class FrontendLoader
|
|
106
109
|
js_source_files = clean_ignored_files(js_source_files,(@settings['javascript']['ignore'] << 'js.js'))
|
107
110
|
end
|
108
111
|
js_source = ""
|
109
|
-
js_source_files.each { |file|
|
110
|
-
js_source << File.
|
112
|
+
js_source_files.each { |file|
|
113
|
+
js_source << File.open(file,:encoding => "UTF-8").read+"\n"
|
111
114
|
}
|
112
115
|
js_source << templates_source
|
113
116
|
if @settings['javascript']['jsmin'] then
|
@@ -116,13 +119,13 @@ class FrontendLoader
|
|
116
119
|
rescue Exception => e
|
117
120
|
puts "JSmin not installed"
|
118
121
|
end
|
119
|
-
if jsmin then
|
122
|
+
if jsmin then
|
120
123
|
js_source = JSMin.minify(js_source)
|
121
124
|
end
|
122
125
|
end
|
123
126
|
if @settings['javascript']['yui'] then
|
124
127
|
begin
|
125
|
-
yui = require "yui/compressor"
|
128
|
+
yui = require "yui/compressor"
|
126
129
|
rescue Exception => e
|
127
130
|
puts "YUI compressor gem not installed"
|
128
131
|
end
|
@@ -131,14 +134,14 @@ class FrontendLoader
|
|
131
134
|
js_source = compressor.compress(js_source)
|
132
135
|
end
|
133
136
|
end
|
134
|
-
File.open('js.js','w') { |f|
|
137
|
+
File.open('js.js','w') { |f|
|
135
138
|
f.write(js_source)
|
136
139
|
}
|
137
140
|
puts "Compiled javascript into js.js"
|
138
141
|
end
|
139
|
-
|
142
|
+
|
140
143
|
end
|
141
|
-
|
144
|
+
|
142
145
|
def prioritize_files(files, priority_files=[],path="")
|
143
146
|
if priority_files.class != Array then
|
144
147
|
priority_files = []
|
@@ -153,7 +156,7 @@ class FrontendLoader
|
|
153
156
|
prioritized_files = priority_files + files
|
154
157
|
return prioritized_files
|
155
158
|
end
|
156
|
-
|
159
|
+
|
157
160
|
def clean_ignored_files(files, ignored_files=[],path="")
|
158
161
|
if ignored_files.class != Array then
|
159
162
|
ignored_files = []
|
@@ -166,41 +169,44 @@ class FrontendLoader
|
|
166
169
|
}
|
167
170
|
return files
|
168
171
|
end
|
169
|
-
|
170
172
|
|
171
|
-
|
173
|
+
|
174
|
+
def listen(dir=false)
|
175
|
+
if dir then
|
176
|
+
Dir.chdir(dir)
|
177
|
+
end
|
172
178
|
begin
|
173
179
|
listener = Listen.to("./", :filter => %r{(.*).(js|css|less|scss|mustache|handlebars|html)}, :ignore => [/js.js/,/style.css/]) do
|
174
180
|
compile
|
175
181
|
end
|
176
|
-
listener = listener.ignore(/js.js/,/style.css/)
|
182
|
+
listener = listener.ignore(/js.js/,/style.css/)
|
177
183
|
rescue Exception => e
|
178
|
-
puts "\nListening stopped"
|
184
|
+
puts "\nListening stopped"
|
179
185
|
end
|
180
186
|
end
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
206
212
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frontendloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-07-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: listen
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,12 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
26
31
|
description: Accelerated front end development
|
27
32
|
email: dan@explodingbox.com
|
28
33
|
executables:
|
@@ -56,10 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
61
|
version: '0'
|
57
62
|
requirements: []
|
58
63
|
rubyforge_project:
|
59
|
-
rubygems_version: 1.8.
|
64
|
+
rubygems_version: 1.8.23
|
60
65
|
signing_key:
|
61
66
|
specification_version: 3
|
62
67
|
summary: A command line interface for rapid creation of web app interfaces, compiling
|
63
68
|
less, js and mustache files into two requests
|
64
69
|
test_files: []
|
65
|
-
has_rdoc: true
|