class TerraspaceBundler::Syncer
Public Class Methods
new(options={})
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 5 def initialize(options={}) @options = options @mod_name = @options[:mod] end
Public Instance Methods
create()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 28 def create sync_mods end
lockfile()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 66 def lockfile Lockfile.instance end
run()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 10 def run validate! FileUtils.rm_f(TB.config.lockfile) if update_all? logger.info "Bundling with #{TB.config.terrafile}..." if File.exist?(TB.config.lockfile) sync else create end TB::Lockfile.write end
subtract(mods1, mods2)
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 57 def subtract(mods1, mods2) mod2_names = mods2.map(&:name) mods1.select {|mod1| !mod2_names.include?(mod1.name) } end
sync()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 22 def sync sync_mods removed_mods = subtract(lockfile.mods, terrafile.mods) lockfile.prune(removed_mods) end
sync?(mod)
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 41 def sync?(mod) names = @options[:mods] names.blank? or names.include?(mod.name) end
sync_mods()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 32 def sync_mods # VersionComparer is used in lockfile.sync and does heavy lifting to check if mod should be updated and replaced terrafile.mods.each do |mod| next unless sync?(mod) logger.debug "Syncing #{mod.name}" lockfile.sync(mod) # update (if version mismatch) or create (if missing) end end
terrafile()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 62 def terrafile Terrafile.instance end
update_all?()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 53 def update_all? TB.update_mode? && @options[:mods].empty? end
validate!()
click to toggle source
# File lib/terraspace_bundler/syncer.rb, line 46 def validate! return unless terrafile.missing_org? logger.error "ERROR: org must be set in the #{TB.config.terrafile}.".color(:red) logger.error "Please set org in the Terrafile" exit 1 end