lib/core/plugin/project.rb in nucleon-0.1.3 vs lib/core/plugin/project.rb in nucleon-0.1.4

- old
+ new

@@ -34,25 +34,30 @@ end #----------------------------------------------------------------------------- # Project plugin interface - def normalize + def normalize(reload) super - extension(:normalize) - set_directory(Util::Disk.filename(get(:directory, Dir.pwd))) + register + set_url(get(:url)) if get(:url, false) myself.plugin_name = path if myself.plugin_name == plugin_provider + ui.resource = plugin_name + logger = plugin_name + if keys = delete(:keys, nil) set(:private_key, keys[:private_key]) set(:public_key, keys[:public_key]) end + extension(:normalize) + init_project extension(:init) pull if get(:pull, false) end @@ -61,19 +66,24 @@ def init_project init_auth init_parent init_remotes - load_revision + load_revision end #----------------------------------------------------------------------------- # Plugin operations def register super - # TODO: Scan project directory looking for plugins + if directory + lib_path = File.join(directory, 'lib') + if File.directory?(lib_path) + CORL.register(lib_path) + end + end end #----------------------------------------------------------------------------- # Checks @@ -558,11 +568,11 @@ end protected :update_subprojects #--- - def foreach! + def each if can_persist? localize do logger.info("Iterating through all sub projects of project #{name}") subprojects.each do |path, project| @@ -612,18 +622,24 @@ url end #--- - def set_remote(name, url) + def set_remote(name, url, options = {}) + config = Config.ensure(options) + if can_persist? localize do - if ! url.strip.empty? && url = extension_set(:set_remote, url, { :name => name }) - delete_remote(name) + unless url.strip.empty? + if url = extension_set(:set_remote, url, { :name => name }) + delete_remote(name) + + url = translate_edit_url(url) if name == :edit && config.get(:translate, true) - logger.info("Setting project remote #{name} to #{url}") - yield(url) if block_given? + logger.info("Setting project remote #{name} to #{url}") + yield(url) if block_given? + end end end else logger.warn("Project #{self.name} does not meet the criteria for persistence and can not have remotes") end @@ -635,10 +651,12 @@ if can_persist? localize do config = Config.ensure(options) if url = extension_set(:add_remote_url, url, { :name => name, :config => config }) + url = translate_edit_url(url) if name == :edit && config.get(:translate, true) + logger.info("Adding project remote url #{url} to #{name}") yield(config, url) if block_given? end end else @@ -649,19 +667,19 @@ #--- def set_host_remote(name, hosts, path, options = {}) if can_persist? localize do - config = Config.ensure(options).import({ :path => path }) + config = Config.ensure(options).import({ :path => path, :translate => false }) hosts = array(hosts) unless hosts.empty? if hosts = extension_set(:set_host_remote, hosts, { :name => name, :config => config }) unless ! hosts || hosts.empty? path = config.delete(:path) logger.info("Setting host remote #{name} for #{hosts.inspect} at #{path}") - set_remote(name, translate_url(hosts.shift, path, config.export)) + set_remote(name, translate_url(hosts.shift, path, config.export), config) hosts.each do |host| logger.debug("Adding remote url to #{host}") add_remote_url(name, translate_url(host, path, config.export), config) end