Sha256: b3f944198fe6aea3743300ab19df2548405199f031e7a16708c1e2df42d2eaad
Contents?: true
Size: 1.4 KB
Versions: 15
Compression:
Stored size: 1.4 KB
Contents
module GitReflow module GitServer autoload :Base, 'git_reflow/git_server/base' autoload :GitHub, 'git_reflow/git_server/git_hub' extend self class ConnectionError < StandardError; end def connect(options = nil) options ||= { provider: 'GitHub' } begin provider_name = options[:provider] provider = provider_class_for(options.delete(:provider)).new(options) provider.authenticate(options.keep_if {|key, value| key == :silent }) provider rescue ConnectionError => e puts "Error connecting to #{provider_name}: #{e.message}" end end def connection return nil unless current_provider current_provider.connection end def current_provider if (provider = GitReflow::Config.get('reflow.git-server')) and provider.length > 0 begin provider_class_for(provider) rescue ConnectionError => e puts e.message nil end else puts "[notice] Reflow hasn't been setup yet. Run 'git reflow setup' to continue" nil end end def can_connect_to?(provider) GitReflow::GitServer.const_defined?(provider) end private def provider_class_for(provider) raise ConnectionError, "GitServer not setup for \"#{provider}\"" unless self.can_connect_to?(provider) GitReflow::GitServer.const_get(provider) end end end
Version data entries
15 entries across 15 versions & 1 rubygems