lib/devinstall/provider.rb in devinstall-1.2.2 vs lib/devinstall/provider.rb in devinstall-1.2.3

- old
+ new

@@ -1,19 +1,25 @@ module Devinstall class Provider - #noinspection RubyResolve + def load_provider_plugin(provider) + require "devinstall/provider/provider_#{provider}" + self.singleton_class.send(:include, Kernel.const_get('Provider').const_get("#{provider.capitalize}")) + provider_settings=Kernel.const_get('Provider').const_get("#{provider.capitalize}")::SETTINGS + end + def initialize(pkg, type, env, action=nil) providers={build: :build, install: :install, upload: :repos, run_tests: :tests} @pkg, @type, @env = (pkg.to_sym rescue pkg), (type.to_sym rescue type), (env.to_sym rescue env) @action = action || providers[caller_locations(1, 1)[0].label.to_sym] # that's realy stupid! - provider = Settings.instance.send(action, :provider, pkg: pkg, type: type, env: env) - require "devinstall/provider/provider_#{provider}" - self.singleton_class.send(:include, Kernel.const_get('Provider').const_get("#{provider.capitalize}")) - provider_settings=Kernel.const_get('Provider').const_get("#{provider.capitalize}")::SETTINGS + provider = Settings.instance.send(action, :provider, pkg: @pkg, type: @type, env: @env) + provider_settings = load_provider_plugin(provider) Settings.instance.register_provider(provider.to_sym, provider_settings) - ObjectSpace.define_finalizer(self, Proc.new{Settings.instance.unregister_provider(provider)}) + provider_init + ObjectSpace.define_finalizer(self, Proc.new{ + provider_final + Settings.instance.unregister_provider(provider)}) end def copy_sources # that's upload sources config = Settings.instance remote = config.send(@action, :folder, pkg: @pkg, type: @type, env: @env) @@ -49,5 +55,6 @@ exec_command(cfg, command) end end end +