Class: Redmine::Scm::Adapters::AbstractAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine/scm/adapters/abstract_adapter.rb

Overview

:nodoc:

Direct Known Subclasses

BazaarAdapter, CvsAdapter, DarcsAdapter, FilesystemAdapter, GitAdapter, MercurialAdapter, SubversionAdapter

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (AbstractAdapter) initialize(url, root_url = nil, login = nil, password = nil, path_encoding = nil)

Returns a new instance of AbstractAdapter



66
67
68
69
70
71
72
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 66

def initialize(url, root_url=nil, =nil, password=nil,
               path_encoding=nil)
  @url = url
  @login =  if  && !.empty?
  @password = (password || "") if @login
  @root_url = root_url.blank? ? retrieve_root_url : root_url
end

Class Method Details

+ (Object) client_available



53
54
55
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 53

def client_available
  true
end

+ (Object) client_command



28
29
30
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 28

def client_command
  ""
end

+ (Object) client_version

Returns the version of the scm client Eg: [1, 5, 0] or [] if unknown



34
35
36
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 34

def client_version
  []
end

+ (Boolean) client_version_above?(v, options = {})

Returns true if the current client version is above or equals the given one If option is :unknown is set to true, it will return true if the client version is unknown

Returns:

  • (Boolean)


49
50
51
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 49

def client_version_above?(v, options={})
  ((client_version <=> v) >= 0) || (client_version.empty? && options[:unknown])
end

+ (Object) client_version_string

Returns the version string of the scm client Eg: '1.5.0' or 'Unknown version' if unknown



40
41
42
43
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 40

def client_version_string
  v = client_version || 'Unknown version'
  v.is_a?(Array) ? v.join('.') : v.to_s
end

+ (Object) shell_quote(str)



57
58
59
60
61
62
63
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 57

def shell_quote(str)
  if Redmine::Platform.mswin?
    '"' + str.gsub(/"/, '\\"') + '"'
  else
    "'" + str.gsub(/'/, "'\"'\"'") + "'"
  end
end

Instance Method Details

- (Object) adapter_name



74
75
76
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 74

def adapter_name
  'Abstract'
end

- (Object) branches



121
122
123
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 121

def branches
  return nil
end

- (Object) cat(path, identifier = nil)



145
146
147
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 145

def cat(path, identifier=nil)
  return nil
end

- (Object) default_branch



129
130
131
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 129

def default_branch
  return nil
end

- (Object) diff(path, identifier_from, identifier_to = nil)



141
142
143
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 141

def diff(path, identifier_from, identifier_to=nil)
  return nil
end

- (Object) entries(path = nil, identifier = nil)

Returns an Entries collection or nil if the given path doesn't exist in the repository



117
118
119
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 117

def entries(path=nil, identifier=nil)
  return nil
end

- (Object) entry(path = nil, identifier = nil)

Returns the entry identified by path and revision identifier or nil if entry doesn't exist in the repository



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 101

def entry(path=nil, identifier=nil)
  parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?}
  search_path = parts[0..-2].join('/')
  search_name = parts[-1]
  if search_path.blank? && search_name.blank?
    # Root entry
    Entry.new(:path => '', :kind => 'dir')
  else
    # Search for the entry in the parent directory
    es = entries(search_path, identifier)
    es ? es.detect {|e| e.name == search_name} : nil
  end
end

- (Object) info

get info about the svn repository



95
96
97
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 95

def info
  return nil
end

- (Object) properties(path, identifier = nil)



133
134
135
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 133

def properties(path, identifier=nil)
  return nil
end

- (Object) revisions(path = nil, identifier_from = nil, identifier_to = nil, options = {})



137
138
139
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 137

def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
  return nil
end

- (Object) root_url



86
87
88
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 86

def root_url
  @root_url
end

- (Object) shell_quote(str)



169
170
171
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 169

def shell_quote(str)
  self.class.shell_quote(str)
end

- (Boolean) supports_annotate?

Returns:

  • (Boolean)


82
83
84
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 82

def supports_annotate?
  respond_to?('annotate')
end

- (Boolean) supports_cat?

Returns:

  • (Boolean)


78
79
80
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 78

def supports_cat?
  true
end

- (Object) tags



125
126
127
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 125

def tags 
  return nil
end

- (Object) url



90
91
92
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 90

def url
  @url
end

- (Object) with_leading_slash(path)



149
150
151
152
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 149

def with_leading_slash(path)
  path ||= ''
  (path[0,1]!="/") ? "/#{path}" : path
end

- (Object) with_trailling_slash(path)



154
155
156
157
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 154

def with_trailling_slash(path)
  path ||= ''
  (path[-1,1] == "/") ? path : "#{path}/"
end

- (Object) without_leading_slash(path)



159
160
161
162
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 159

def without_leading_slash(path)
  path ||= ''
  path.gsub(%r{^/+}, '')
end

- (Object) without_trailling_slash(path)



164
165
166
167
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 164

def without_trailling_slash(path)
 path ||= ''
 (path[-1,1] == "/") ? path[0..-2] : path
end