lib/modulesync.rb in modulesync-0.5.0 vs lib/modulesync.rb in modulesync-0.6.0

- old
+ new

@@ -11,12 +11,12 @@ def self.local_file(config_path, file) "#{config_path}/#{MODULE_FILES_DIR}/#{file}" end - def self.module_file(puppet_module, file) - "#{PROJ_ROOT}/#{puppet_module}/#{file}" + def self.module_file(project_root, puppet_module, file) + "#{project_root}/#{puppet_module}/#{file}" end def self.local_files(path) if File.exists?(path) local_files = Find.find(path).collect { |file| file if !File.directory?(file) }.compact @@ -54,13 +54,15 @@ managed_modules = self.managed_modules("#{options[:configs]}/managed_modules.yml", options[:filter]) # managed_modules is either an array or a hash managed_modules.each do |puppet_module, opts| puts "Syncing #{puppet_module}" - git_base = "#{options[:git_base]}#{options[:namespace]}" - Git.pull(git_base, puppet_module, options[:branch], opts || {}) - module_configs = Util.parse_config("#{PROJ_ROOT}/#{puppet_module}/#{MODULE_CONF_FILE}") + unless options[:offline] + git_base = "#{options[:git_base]}#{options[:namespace]}" + Git.pull(git_base, puppet_module, options[:branch], options[:project_root], opts || {}) + end + module_configs = Util.parse_config("#{options[:project_root]}/#{puppet_module}/#{MODULE_CONF_FILE}") global_defaults = defaults[GLOBAL_DEFAULTS_KEY] || {} module_defaults = module_configs[GLOBAL_DEFAULTS_KEY] || {} files_to_manage = (module_files | defaults.keys | module_configs.keys) - [GLOBAL_DEFAULTS_KEY] files_to_delete = [] files_to_manage.each do |file| @@ -68,20 +70,20 @@ file_configs[:puppet_module] = puppet_module if file_configs['unmanaged'] puts "Not managing #{file} in #{puppet_module}" files_to_delete << file elsif file_configs['delete'] - Renderer.remove(module_file(puppet_module, file)) + Renderer.remove(module_file(options['project_root'], puppet_module, file)) else erb = Renderer.build(local_file(options[:configs], file)) template = Renderer.render(erb, file_configs) - Renderer.sync(template, "#{PROJ_ROOT}/#{puppet_module}/#{file}") + Renderer.sync(template, "#{options[:project_root]}/#{puppet_module}/#{file}") end end files_to_manage -= files_to_delete if options[:noop] Git.update_noop(puppet_module, options) - else + elsif not options[:offline] Git.update(puppet_module, files_to_manage, options) end end elsif options[:command] == 'hook' Hook.hook(args[1], options)