nyx 1.2.0 → 1.3.0
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/nyx.rb +70 -20
- metadata +1 -1
    
        data/lib/nyx.rb
    CHANGED
    
    | @@ -12,10 +12,10 @@ require 'fssm' | |
| 12 12 |  | 
| 13 13 | 
             
            class Nyx
         | 
| 14 14 |  | 
| 15 | 
            -
            	VERSION = '1. | 
| 15 | 
            +
            	VERSION = '1.3.0'
         | 
| 16 16 |  | 
| 17 17 | 
             
            	def compile_scripts(args = nil)
         | 
| 18 | 
            -
             | 
| 18 | 
            +
             | 
| 19 19 | 
             
            		# @todo CLEANUP properly read "silent" parameter
         | 
| 20 20 |  | 
| 21 21 | 
             
            		if args != nil
         | 
| @@ -44,7 +44,7 @@ class Nyx | |
| 44 44 |  | 
| 45 45 | 
             
            		self.ensure_closure_compiler(dirpath)
         | 
| 46 46 |  | 
| 47 | 
            -
            		puts | 
| 47 | 
            +
            		puts
         | 
| 48 48 | 
             
            		puts " Recompiling..."
         | 
| 49 49 | 
             
            		puts " ----------------------------------------------------------------------- "
         | 
| 50 50 | 
             
            		conf = self.read_script_configuration(dirpath);
         | 
| @@ -59,8 +59,8 @@ class Nyx | |
| 59 59 | 
             
            		if conf['targeted-common'] == nil
         | 
| 60 60 | 
             
            			conf['targeted-common'] = [];
         | 
| 61 61 | 
             
            		else # not nil
         | 
| 62 | 
            -
            			conf['targeted-common'] = conf['targeted-common'].find_all do |item| | 
| 63 | 
            -
            				item !~ /(^[a-z]+:\/\/|^\/\/).*$/ | 
| 62 | 
            +
            			conf['targeted-common'] = conf['targeted-common'].find_all do |item|
         | 
| 63 | 
            +
            				item !~ /(^[a-z]+:\/\/|^\/\/).*$/
         | 
| 64 64 | 
             
            			end#find_all
         | 
| 65 65 | 
             
            		end#def
         | 
| 66 66 |  | 
| @@ -73,8 +73,8 @@ class Nyx | |
| 73 73 |  | 
| 74 74 | 
             
            		# include common files
         | 
| 75 75 | 
             
            		conf['targeted-mapping'].each do |key, files|
         | 
| 76 | 
            -
            			files = files.find_all do |item| | 
| 77 | 
            -
            				item !~ /(^[a-z]+:\/\/|^\/\/).*$/ | 
| 76 | 
            +
            			files = files.find_all do |item|
         | 
| 77 | 
            +
            				item !~ /(^[a-z]+:\/\/|^\/\/).*$/
         | 
| 78 78 | 
             
            			end#find_all
         | 
| 79 79 | 
             
            			conf['targeted-mapping'][key] = conf['targeted-common'].clone;
         | 
| 80 80 | 
             
            			files.each do |file|
         | 
| @@ -86,22 +86,22 @@ class Nyx | |
| 86 86 |  | 
| 87 87 | 
             
            		# convert to paths
         | 
| 88 88 | 
             
            		conf['targeted-mapping'].each do |key, files|
         | 
| 89 | 
            -
            			files = files.find_all do |item| | 
| 90 | 
            -
            				item !~ /(^[a-z]+:\/\/|^\/\/).*$/ | 
| 89 | 
            +
            			files = files.find_all do |item|
         | 
| 90 | 
            +
            				item !~ /(^[a-z]+:\/\/|^\/\/).*$/
         | 
| 91 91 | 
             
            			end#find_all
         | 
| 92 | 
            -
            			files.collect! do |file| | 
| 93 | 
            -
            				'src/'+file+'.js'; | 
| 92 | 
            +
            			files.collect! do |file|
         | 
| 93 | 
            +
            				'src/'+file+'.js';
         | 
| 94 94 | 
             
            			end#collect
         | 
| 95 95 | 
             
            			conf['targeted-mapping'][key] = files
         | 
| 96 96 | 
             
            		end#each
         | 
| 97 97 |  | 
| 98 98 | 
             
            		# convert to paths
         | 
| 99 99 | 
             
            		files = conf['complete-mapping']
         | 
| 100 | 
            -
            		files = files.find_all do |item| | 
| 101 | 
            -
            			item !~ /(^[a-z]+:\/\/|^\/\/).*$/ | 
| 100 | 
            +
            		files = files.find_all do |item|
         | 
| 101 | 
            +
            			item !~ /(^[a-z]+:\/\/|^\/\/).*$/
         | 
| 102 102 | 
             
            		end#find_all
         | 
| 103 | 
            -
            		files.collect! do |file| | 
| 104 | 
            -
            			'src/'+file+'.js'; | 
| 103 | 
            +
            		files.collect! do |file|
         | 
| 104 | 
            +
            			'src/'+file+'.js';
         | 
| 105 105 | 
             
            		end#collect
         | 
| 106 106 | 
             
            		conf['complete-mapping'] = files
         | 
| 107 107 |  | 
| @@ -213,13 +213,13 @@ class Nyx | |
| 213 213 | 
             
            			filecount = Dir["#{srcpath}/**/*"].length
         | 
| 214 214 | 
             
            			fileidx = 0
         | 
| 215 215 | 
             
            			removed = 0
         | 
| 216 | 
            -
            			print "   - keep: #{fileidx} files processed (#{removed}  | 
| 216 | 
            +
            			print "   - keep: #{fileidx} files processed (#{removed} deleted)"
         | 
| 217 217 | 
             
            			Dir.glob("#{srcpath}/**/*", File::FNM_DOTMATCH) do |file|
         | 
| 218 218 | 
             
            				basename = File.basename(file)
         | 
| 219 219 | 
             
            				next if basename == '.' or basename == '..'
         | 
| 220 220 | 
             
            				fileidx += 1
         | 
| 221 | 
            -
            				print (' ' *  | 
| 222 | 
            -
            				print "   - keep: #{fileidx} files processed (#{removed}  | 
| 221 | 
            +
            				print (' ' * 256) + "\r"
         | 
| 222 | 
            +
            				print "   - keep: #{fileidx} files processed (#{removed} deleted)"
         | 
| 223 223 | 
             
            				filepath = File.expand_path(file)
         | 
| 224 224 | 
             
            				filesubpath = filepath.sub(srcpath, '').gsub(/^\//, '')
         | 
| 225 225 |  | 
| @@ -238,6 +238,56 @@ class Nyx | |
| 238 238 | 
             
            			end#glob
         | 
| 239 239 | 
             
            			puts
         | 
| 240 240 | 
             
            		end#if
         | 
| 241 | 
            +
             | 
| 242 | 
            +
            		# process "ensure" rules
         | 
| 243 | 
            +
            		if conf.has_key? 'ensure'
         | 
| 244 | 
            +
            			srcpath = File.expand_path(corepath) + '/'
         | 
| 245 | 
            +
            			ensure_rules = conf['ensure']
         | 
| 246 | 
            +
            			print "   - ensuring files"
         | 
| 247 | 
            +
            			ensure_rules.each do |depfiles, srcfiles|
         | 
| 248 | 
            +
            				depfilespath = srcpath + depfiles.sub(/\/$/, '') + '/'
         | 
| 249 | 
            +
            				srcfilespath = srcfiles.sub(/\/$/, '')
         | 
| 250 | 
            +
            				Dir.glob("#{depfilespath}**/*", File::FNM_DOTMATCH) do |file|
         | 
| 251 | 
            +
            					# skip parent and self symbols
         | 
| 252 | 
            +
            					basename = File.basename(file)
         | 
| 253 | 
            +
            					next if basename == '.' or basename == '..'
         | 
| 254 | 
            +
            					# compute file paths
         | 
| 255 | 
            +
            					filepath = File.expand_path(file)
         | 
| 256 | 
            +
            					filesubpath = filepath.sub(depfilespath, '')
         | 
| 257 | 
            +
            					srcfile = srcfilespath + '/' + filesubpath
         | 
| 258 | 
            +
            					# skip directories
         | 
| 259 | 
            +
            					next if File.directory?(filepath)
         | 
| 260 | 
            +
            					# progress info
         | 
| 261 | 
            +
            					print (' ' * 256) + "\r"
         | 
| 262 | 
            +
            					prettysubpath = filepath.sub(srcpath, '')
         | 
| 263 | 
            +
            					print "   - ensure: #{prettysubpath}"
         | 
| 264 | 
            +
            					# write missing file
         | 
| 265 | 
            +
            					if ! File.exist?(srcfile)
         | 
| 266 | 
            +
            						text = File.read filepath
         | 
| 267 | 
            +
            						FileUtils.mkpath File.dirname(srcfile)
         | 
| 268 | 
            +
            						File.write srcfile, text
         | 
| 269 | 
            +
            					end#if
         | 
| 270 | 
            +
            				end#glob
         | 
| 271 | 
            +
            			end#each
         | 
| 272 | 
            +
            			print (' ' * 256) + "\r"
         | 
| 273 | 
            +
            			puts "   - ensure: all dependencies resolved"
         | 
| 274 | 
            +
            		end#if
         | 
| 275 | 
            +
             | 
| 276 | 
            +
            		# process "remove" rules
         | 
| 277 | 
            +
            		if conf.has_key? 'remove'
         | 
| 278 | 
            +
            			removed = 0
         | 
| 279 | 
            +
            			srcpath = File.expand_path(corepath) + '/'
         | 
| 280 | 
            +
            			conf['remove'].each do |file|
         | 
| 281 | 
            +
            				filepath = srcpath + file
         | 
| 282 | 
            +
            				if File.exist? filepath
         | 
| 283 | 
            +
            					removed += 1
         | 
| 284 | 
            +
            					FileUtils.rm_rf filepath
         | 
| 285 | 
            +
            				end#if
         | 
| 286 | 
            +
            			end#each
         | 
| 287 | 
            +
            			files_tr = removed != 1 ? 'files' : 'file';
         | 
| 288 | 
            +
            			puts "   - remove: #{removed} #{files_tr} deleted"
         | 
| 289 | 
            +
            		end#if
         | 
| 290 | 
            +
             | 
| 241 291 | 
             
            	end#def
         | 
| 242 292 |  | 
| 243 293 | 
             
            	def do_cleanup_scripts(dirpath, conf, silent)
         | 
| @@ -398,7 +448,7 @@ class Nyx | |
| 398 448 | 
             
            		end
         | 
| 399 449 |  | 
| 400 450 | 
             
            		if conf['mode'] == 'complete'
         | 
| 401 | 
            -
             | 
| 451 | 
            +
             | 
| 402 452 | 
             
            			conf['complete-mapping'].each do |file|
         | 
| 403 453 | 
             
            				if file.eql? r
         | 
| 404 454 | 
             
            					puts " >>> recompiling [complete-script]"
         | 
| @@ -420,7 +470,7 @@ class Nyx | |
| 420 470 | 
             
            					end#if
         | 
| 421 471 | 
             
            				end#each
         | 
| 422 472 | 
             
            			end#each
         | 
| 423 | 
            -
             | 
| 473 | 
            +
             | 
| 424 474 | 
             
            		end#if
         | 
| 425 475 |  | 
| 426 476 | 
             
            	end#def
         |