scms 2.0.9 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b39434ffa4c1bbd9419277ac9d1df1147a93e2f7
4
- data.tar.gz: ae6d56f657f22d9154be02cbdfaaa90fb185fb85
3
+ metadata.gz: b943e5110913001c531f5db7d229d77e32ea5f4c
4
+ data.tar.gz: a2eceff57906100fde18df5daa2e4d4e84100dd1
5
5
  SHA512:
6
- metadata.gz: 9667ba1ff13349a6b2ae9121338adb126cb81252176fd1d0479416bd1f42e2f37910f87d1a759650b8ff2be957a94f8a4afa9ce382b7d5d910c7214c90df06ce
7
- data.tar.gz: a79d5a45f8834fd1bf2ffe287eea2fba48ef34e7cd080fd5503fae2700c1d5fc6d2b96c7703f0a0976129690af9414b6999a9e84d0590bc4112c3b793aea250c
6
+ metadata.gz: 0ab284712cbccc96170b35a232529fb8f60f7237a3837822c1e69354112a2c06ced296c647e53ba0b4710e3d3b217c30101b8690ae43b6ed5417ce9cfaf66f57
7
+ data.tar.gz: 5249468af79e85557d93fdf821bce440a9e75369ace10b32d4212395225540783a8ef59336e1a697dc97064a1b6a4a7dc3536efcc0f99e8a8ba7d39afae60c2c
data/bin/scms CHANGED
@@ -90,11 +90,11 @@ else
90
90
  FileUtils.rm(monkeyhook) if File.exist?(monkeyhook)
91
91
  end
92
92
 
93
- #puts "System root folder = #{Folders[:root]}"
94
- #puts "Website folder = #{Folders[:website]}"
95
- #puts "Pub dir = #{Folders[:pub]}"
96
- #puts "Config dir = #{Folders[:config]}"
97
- #puts "Mode = #{options[:mode]}"
93
+ #ScmsUtils.log "System root folder = #{Folders[:root]}"
94
+ #ScmsUtils.log "Website folder = #{Folders[:website]}"
95
+ #ScmsUtils.log "Pub dir = #{Folders[:pub]}"
96
+ #ScmsUtils.log "Config dir = #{Folders[:config]}"
97
+ #ScmsUtils.log "Mode = #{options[:mode]}"
98
98
 
99
99
  raise "No website in folder #{Folders[:website]}" if !File::directory?(Folders[:website])
100
100
  Scms.upgrade(Folders[:website])
data/lib/scms.rb CHANGED
@@ -18,7 +18,7 @@ module Scms
18
18
  @mode = mode
19
19
  #ScmsUtils.log("Mode: #{mode}")
20
20
 
21
- ScmsUtils.log("Website #{@website}")
21
+ ScmsUtils.boldlog("Compiling #{@website}")
22
22
  Scms.sassall(File.join(@website))
23
23
 
24
24
  yamlpath=File.join(config, "_config.yml")
@@ -33,7 +33,7 @@ module Scms
33
33
  require_relative bootstrap
34
34
  rescue Exception=>e
35
35
  ScmsUtils.errLog(e.message)
36
- ScmsUtils.log(e.backtrace.inspect )
36
+ ScmsUtils.log(e.backtrace.inspect)
37
37
  end
38
38
  else
39
39
  ScmsUtils.errLog("Bootstrap does not exist #{@settings["bootstrap"]}")
@@ -48,7 +48,7 @@ module Scms
48
48
  ScmsUtils.errLog("Config is empty")
49
49
  end
50
50
 
51
- ScmsUtils.log("Built website:")
51
+ ScmsUtils.boldlog("Built website:")
52
52
  ScmsUtils.log(ScmsUtils.uriEncode("file:///#{@website}"))
53
53
  end
54
54
 
@@ -93,8 +93,12 @@ module Scms
93
93
  resourcepath = File.join(@website, pageconfig["resource"])
94
94
  if File.exists?(resourcepath)
95
95
  #ScmsUtils.log( "_Resource found: #{pageconfig["resource"]}_" )
96
- #todo: error handeling
97
- resource = YAML.load_file(resourcepath)
96
+ begin
97
+ resource = YAML.load_file(resourcepath)
98
+ rescue Exception=>e
99
+ ScmsUtils.errLog(e.message)
100
+ ScmsUtils.log(e.backtrace.inspect)
101
+ end
98
102
  else
99
103
  ScmsUtils.errLog("Resource not found: #{pageconfig["resource"]}")
100
104
  ScmsUtils.writelog("::Resource not found #{pageconfig["resource"]}", @website)
@@ -127,8 +131,12 @@ module Scms
127
131
  views[view[0]] = ""
128
132
  viewpath = File.join(@website, view[1])
129
133
  if File.exists?(viewpath)
130
- #todo: error handeling
131
- htmlsnipet = File.read(viewpath)
134
+ begin
135
+ htmlsnipet = File.read(viewpath)
136
+ rescue Exception=>e
137
+ ScmsUtils.errLog(e.message)
138
+ ScmsUtils.log(e.backtrace.inspect)
139
+ end
132
140
  if !htmlsnipet.empty?
133
141
  viewmodel = Hash.new
134
142
  viewmodel = {
@@ -142,8 +150,13 @@ module Scms
142
150
 
143
151
  if hasHandler
144
152
  ScmsUtils.log("Rendering with handler")
145
- #todo: error handeling
146
- viewSnippet = Handler.render(viewpath)
153
+ begin
154
+ viewSnippet = Handler.render(viewpath)
155
+ rescue Exception=>e
156
+ ScmsUtils.errLog(e.message)
157
+ ScmsUtils.log(e.backtrace.inspect)
158
+ end
159
+
147
160
  else
148
161
  #todo: why not use htmlsnipet
149
162
  snnipetCode = File.read(viewpath)
@@ -154,8 +167,8 @@ module Scms
154
167
  viewSnippet = doc.to_html
155
168
  rescue Exception => e
156
169
  viewSnippet = snnipetCode
157
- puts e.message
158
- puts e.backtrace.inspect
170
+ ScmsUtils.errLog(e.message)
171
+ ScmsUtils.log(e.backtrace.inspect)
159
172
  #todo: use scmslog
160
173
  end
161
174
  else
@@ -222,8 +235,12 @@ module Scms
222
235
  websiteroot = @settings["url"] unless @settings["rooturl"] == nil
223
236
 
224
237
  html = html.gsub('~/', websiteroot)
225
- #todo: error handeling
226
- File.open(out, 'w') {|f| f.write(html) }
238
+ begin
239
+ File.open(out, 'w') {|f| f.write(html) }
240
+ rescue Exception=>e
241
+ ScmsUtils.errLog(e.message)
242
+ ScmsUtils.log(e.backtrace.inspect)
243
+ end
227
244
  else
228
245
  ScmsUtils.errLog("Template doesn't exist: #{skin}")
229
246
  ScmsUtils.writelog("::Template doesn't exist #{skin}", @website)
@@ -243,9 +260,8 @@ module Scms
243
260
  begin
244
261
  result = ERB.new(template).result(page.instance_eval { binding })
245
262
  rescue Exception => e
246
- ScmsUtils.errLog("Critical Error: Could not parse template")
247
- ScmsUtils.errLog( e.message )
248
- #todo: log error to build.log
263
+ ScmsUtils.errLog("Critical Error: Could not parse template")
264
+ ScmsUtils.errLog(e.message)
249
265
  end
250
266
 
251
267
  return result
@@ -254,41 +270,52 @@ module Scms
254
270
  def Scms.bundle(bundleConfig)
255
271
  bundles = Hash.new
256
272
  if bundleConfig != nil
257
- ScmsUtils.log("Bundeling:")
273
+
258
274
  bundleConfig.each do |bundle|
259
275
  #ScmsUtils.log( "bundle (#{bundle.class}) = #{bundle}" )
260
276
  bundle.each do |option|
261
277
  name = option[0]
262
278
  bundleName = File.join(option[1]["generate"])
263
279
  bundles[name] = bundleName
264
- ScmsUtils.successLog("#{bundleName}")
280
+ ScmsUtils.boldlog("Bundeling:")
265
281
 
266
282
  content = ""
267
283
  assetList = ""
268
284
  files = option[1]["files"]
269
285
  if files != nil
270
286
  files.each do |asset|
271
- assetList += "\t#{asset}\n"
287
+ assetList += " - #{asset}\n"
272
288
  assetdir = File.join(@website, asset)
273
289
  if File::exists?(assetdir)
274
290
  #try catch for permisions
275
- #todo: error handeling
276
- content = content + "\n" + File.read(assetdir)
291
+ begin
292
+ content = content + "\n" + File.read(assetdir)
293
+ rescue Exception=>e
294
+ ScmsUtils.errLog(e.message)
295
+ ScmsUtils.log(e.backtrace.inspect)
296
+ end
277
297
  else
278
- ScmsUtils.errLog( "Asset file doesn't exists: #{asset}" )
298
+ ScmsUtils.errLog("Asset file doesn't exists: #{asset}")
279
299
  ScmsUtils.writelog("::Asset file doesn't exists: #{asset}", @website)
280
300
  ScmsUtils.writelog("type NUL > #{assetdir}", @website)
281
301
  end
282
302
  end
283
303
  ScmsUtils.log("#{assetList}")
284
304
 
285
- bundleDir = File.dirname(bundleName)
286
- #todo: error handeling
287
- Dir.mkdir(bundleDir, 755) unless File::directory?(bundleDir)
288
- File.open(bundleName, 'w') {|f| f.write(content) }
305
+ bundleFullPath = File.join(@website, bundleName)
306
+ bundleDir = File.dirname(File.join(@website, bundleName))
307
+ begin
308
+ Dir.mkdir(bundleDir, 755) unless File::directory?(bundleDir)
309
+ File.open(bundleFullPath, 'w') {|f| f.write(content) }
310
+ ScmsUtils.successLog("Created: #{bundleName}")
311
+ rescue Exception=>e
312
+ ScmsUtils.errLog("Error creating bundle: #{bundleName}")
313
+ ScmsUtils.errLog(e.message)
314
+ ScmsUtils.log(e.backtrace.inspect)
315
+ end
289
316
  if File.extname(bundleName) == ".js"
290
317
  puts "Minifing: #{bundleName}"
291
- Scms.packr(bundleName) unless /(-min)|(\.min)/.match(bundleName)
318
+ Scms.packr(bundleFullPath) unless /(-min)|(\.min)/.match(bundleName)
292
319
  end
293
320
  else
294
321
  ScmsUtils.errLog("No files in bundle");
@@ -320,10 +347,10 @@ module Scms
320
347
  output = sass_engine.to_css
321
348
  css_file = "#{File.dirname(asset)}/#{File.basename(asset,'.*')}.css"
322
349
  File.open(css_file, 'w') { |file| file.write(output) }
323
- ScmsUtils.log( "_Sassed: #{css_file}_" )
350
+ ScmsUtils.log( "CSS minified (sassed): #{css_file}" )
324
351
  rescue Exception => e
325
- ScmsUtils.errLog( "Error processing: #{asset}" )
326
- ScmsUtils.errLog( e.message )
352
+ ScmsUtils.errLog("Error processing: #{asset}")
353
+ ScmsUtils.errLog(e.message)
327
354
  end
328
355
  else
329
356
  ScmsUtils.errLog("Sass file doesn't exists: #{asset}")
@@ -338,15 +365,13 @@ module Scms
338
365
  code = File.read(asset)
339
366
  compressed = Packr.pack(code)
340
367
  File.open(asset, 'w') { |f| f.write(compressed) }
341
- ScmsUtils.log( "Minified #{File.basename(asset)}" )
368
+ ScmsUtils.log("Minified #{File.basename(asset)}")
342
369
  rescue Exception => e
343
- ScmsUtils.errLog( "Error processing: #{asset}" )
344
- ScmsUtils.errLog( e.message )
370
+ ScmsUtils.errLog("Error processing: #{asset}")
371
+ ScmsUtils.errLog(e.message)
345
372
  end
346
373
  else
347
- ScmsUtils.errLog("Asset file doesn't exist: #{asset}")
348
- ScmsUtils.writelog("::Asset file doesn't exist #{asset}", @website)
349
- ScmsUtils.writelog("type NUL > #{asset}", @website)
374
+ ScmsUtils.errLog("Can't minify asset because file doesn't exist: #{asset}")
350
375
  end
351
376
  end
352
377
 
data/lib/scms/s3deploy.rb CHANGED
@@ -14,7 +14,7 @@ module S3Deploy
14
14
  s3yamlpath=File.join(config, "_s3config.yml")
15
15
  settings = YAML.load_file(s3yamlpath)
16
16
  throw "No bucket defined in _s3config.yml settings file" if settings['bucket'] == nil
17
- ScmsUtils.log( "Syncing with Amazon S3: #{settings['bucket']}" )
17
+ ScmsUtils.boldlog( "Syncing with Amazon S3: #{settings['bucket']}" )
18
18
 
19
19
  exclude = "(\\.svn$)|(^_)"
20
20
  if settings['ignore'] != nil
@@ -27,7 +27,7 @@ module S3Deploy
27
27
  #First deploy private directories
28
28
  Dir.glob("#{pub}/_*/").each do |f|
29
29
  privatedir = File.basename(f)
30
- ScmsUtils.log( "Backing up #{privatedir} (private)" )
30
+ ScmsUtils.log( "Backing up: #{privatedir} (private)" )
31
31
  privateparams = "#{params} \"#{pub}/#{privatedir}/\" #{settings['bucket']}:#{privatedir}/"
32
32
  ScmsUtils.run(cmd, privateparams)
33
33
  end
@@ -35,13 +35,13 @@ module S3Deploy
35
35
  #Them deploy publid dir with caching
36
36
  if settings['cache'] != nil
37
37
  settings['cache'].each do |folder|
38
- ScmsUtils.log( "Syncing #{folder}(public: caching: 1 year)" )
38
+ ScmsUtils.log("Publishing: #{folder}(public: caching: 1 year)")
39
39
  cacheparams = "#{params} --public-read --cache-control='max-age=31449600' \"#{pub}/#{folder}/\" #{settings['bucket']}:#{folder}/"
40
40
  ScmsUtils.run(cmd, cacheparams)
41
41
  end
42
42
  end
43
43
 
44
- ScmsUtils.log( "Syncing root (public)" )
44
+ ScmsUtils.log("Publishing root (public)")
45
45
  removeold = ""
46
46
  removeold = "--delete" if settings['clean'].to_s == "true"
47
47
  roorparams = "#{removeold} #{params} --public-read \"#{pub}/\" #{settings['bucket']}:/"
@@ -7,6 +7,7 @@ module ScmsUtils
7
7
  ScmsUtils.log("Loading Config: #{ScmsUtils.uriEncode("file:///#{yamlpath}")}")
8
8
  config = nil
9
9
 
10
+ ##http://snk.tuxfamily.org/log/yaml-json-validation-kwalify-ruby19.html
10
11
  #'kwalify'
11
12
  #schema = Kwalify::Yaml.load_file('some_complex_schema.yaml')
12
13
  #validator = Kwalify::Validator.new(schema)
@@ -63,6 +64,16 @@ module ScmsUtils
63
64
  end
64
65
  end
65
66
 
67
+ def ScmsUtils.boldlog(msg)
68
+ if !msg.nil?
69
+ if ENV["SCMS_HTML_OUT"] == "true"
70
+ puts "<strong>#{ScmsUtils.txt_2_html(msg)}</strong>"
71
+ else
72
+ puts msg
73
+ end
74
+ end
75
+ end
76
+
66
77
  def ScmsUtils.log(msg)
67
78
  if !msg.nil?
68
79
  if ENV["SCMS_HTML_OUT"] == "true"
@@ -75,7 +86,7 @@ module ScmsUtils
75
86
 
76
87
  def ScmsUtils.writelog(log, pub)
77
88
  if !pub.nil? && !log.nil?
78
- open(File.join(pub, "build.log"), 'a') { |f|
89
+ open(File.join(pub, "_build.log"), 'a') { |f|
79
90
  f.puts log
80
91
  }
81
92
  end
data/lib/scms/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scms
2
- VERSION = "2.0.9"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.9
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Courtenay Probert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-02 00:00:00.000000000 Z
11
+ date: 2013-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cprobert-s3sync