Class: Fas
- Inherits:
-
Object
- Object
- Fas
- Defined in:
- lib/fas.rb
Class Method Summary collapse
Class Method Details
.executeAction(action) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fas.rb', line 34 def self.executeAction(action) actionType = action['type'] actionScript = action['action'] case actionType when 'git' system('git ' + actionScript) when 'rm' File.delete(*Dir.glob(actionScript)) when 'rmdir' FileUtils.rm_rf(Dir.glob(actionScript)) when 'search' puts Dir.glob(actionScript) when 'unzip' Zip::File.open(actionScript) do |zipfile| zipfile.each do |entry| # The 'next if...' code can go here, though I didn't use it unless File.exist?(entry.name) FileUtils::mkdir_p(File.dirname(entry.name)) zipfile.extract(entry, entry.name) end end end else return "puts 'Warning! Non supported type: " + actionType + "'" end end |
.init(lane) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fas.rb', line 2 def self.init(lane) if lane.nil? puts 'You need to define a lane' else # Load fas.json file require 'json' file = File.read('fas.json') data_hash = JSON.parse(file) # Require base libraries require 'fileutils' require 'zip' # First of all, perform all base actions data_hash['actions'].each do |action| executeAction(action) end # Now run lane specific actions data_hash['lanes'].each do |currentLane| if currentLane['name'] == lane currentLane['actions'].each do |action| executeAction(action) end end end # That is it! puts 'Done!' end end |