class Devinstall::Provider

Public Class Methods

new(pkg, type, env, action=nil) click to toggle source
# File lib/devinstall/provider.rb, line 10
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)
  provider_settings = load_provider_plugin(provider)
  Settings.instance.register_provider(provider.to_sym, provider_settings)
  provider_init
  ObjectSpace.define_finalizer(self, Proc.new{
                                 provider_final
                                 Settings.instance.unregister_provider(provider)})
end

Public Instance Methods

copy_sources() click to toggle source
# File lib/devinstall/provider.rb, line 23
def copy_sources # that's upload sources
  config = Settings.instance
  remote = config.send(@action, :folder, pkg: @pkg, type: @type, env: @env)
  local  = File.expand_path config.local(:folder, pkg: @pkg, type: @type, env: @env)
  cfg    = config.send(@action, pkg: @pkg, type: @type, env: @env)
  upload_sources(cfg, local, remote)
end
do_action(to=nil) click to toggle source
# File lib/devinstall/provider.rb, line 45
def do_action(to=nil)
  config  = Settings.instance
  cfg     =config.send(@action, pkg: @pkg, type: @type, env: @env)
  command = cfg[:command].
      gsub('%f', cfg[:folder]).
      gsub('%p', @pkg.to_s).
      gsub('%T', @type.to_s)
  command = command.gsub('%t', cfg[:target]) if cfg.has_key? :target
  command = command.gsub('%a', to) unless to.nil?

  exec_command(cfg, command)
end
get_file(file) click to toggle source
# File lib/devinstall/provider.rb, line 31
def get_file(file)
  config = Settings.instance
  local  = File.expand_path config.local(:temp, pkg: @pkg, type: @type, env: @env)
  cfg    = config.send(@action, pkg: @pkg, type: @type, env: @env)
  download_file(cfg, file, local)
end
load_provider_plugin(provider) click to toggle source
# File lib/devinstall/provider.rb, line 4
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
put_file(file) click to toggle source
# File lib/devinstall/provider.rb, line 38
def put_file(file)
  config = Settings.instance
  local  = File.expand_path config.local(:temp, pkg: @pkg, type: @type, env: @env)
  cfg    = config.send(@action, pkg: @pkg, type: @type, env: @env)
  upload_file(cfg, file, local)
end