Sha256: f768eda16c39f9f0f03e3aff85b915b99076a5a1f2f86d6e644ca125bc971c68
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
module GitReflow module GitServer autoload :Base, 'git_reflow/git_server/base' autoload :GitHub, 'git_reflow/git_server/git_hub' autoload :PullRequest, 'git_reflow/git_server/pull_request' extend self class ConnectionError < StandardError; end def connect(options = {}) options ||= {} options[:provider] = 'GitHub' if "#{options[:provider]}".length <= 0 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 def create_pull_request(options = {}) raise "#{self.class.to_s}#create_pull_request method must be implemented" end def find_open_pull_request(options = {}) raise "#{self.class.to_s}#find_open_pull_request method must be implemented" 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
git_reflow-0.7.1 | lib/git_reflow/git_server.rb |
git_reflow-0.7.0 | lib/git_reflow/git_server.rb |