Class: Redmine::Scm::Adapters::AbstractAdapter
- Inherits:
-
Object
- Object
- Redmine::Scm::Adapters::AbstractAdapter
show all
- Defined in:
- lib/redmine/scm/adapters/abstract_adapter.rb
Overview
Defined Under Namespace
Classes: ScmCommandAborted
Class Method Summary
collapse
Instance Method Summary
collapse
-
#adapter_name ⇒ Object
-
#branches ⇒ Object
-
#cat(path, identifier = nil) ⇒ Object
-
#default_branch ⇒ Object
-
#diff(path, identifier_from, identifier_to = nil) ⇒ Object
-
#entries(path = nil, identifier = nil, options = {}) ⇒ Object
Returns an Entries collection or nil if the given path doesn't exist in
the repository.
-
#entry(path = nil, identifier = nil) ⇒ Object
Returns the entry identified by path and revision identifier or nil if
entry doesn't exist in the repository.
-
#info ⇒ Object
get info about the svn repository.
-
#initialize(url, root_url = nil, login = nil, password = nil, path_encoding = nil) ⇒ AbstractAdapter
constructor
A new instance of AbstractAdapter.
-
#path_encoding ⇒ Object
-
#properties(path, identifier = nil) ⇒ Object
-
#revisions(path = nil, identifier_from = nil, identifier_to = nil, options = {}) ⇒ Object
-
#root_url ⇒ Object
-
#shell_quote(str) ⇒ Object
-
#supports_annotate? ⇒ Boolean
-
#supports_cat? ⇒ Boolean
-
#tags ⇒ Object
-
#url ⇒ Object
-
#with_leading_slash(path) ⇒ Object
-
#with_trailling_slash(path) ⇒ Object
-
#without_leading_slash(path) ⇒ Object
-
#without_trailling_slash(path) ⇒ Object
Constructor Details
#initialize(url, root_url = nil, login = nil, password = nil, path_encoding = nil) ⇒ AbstractAdapter
Returns a new instance of AbstractAdapter
76
77
78
79
80
81
82
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 76
def initialize(url, root_url=nil, login=nil, password=nil,
path_encoding=nil)
@url = url
@login = login if login && !login.empty?
@password = (password || "") if @login
@root_url = root_url.blank? ? retrieve_root_url : root_url
end
|
Class Method Details
.client_available ⇒ Object
63
64
65
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 63
def client_available
true
end
|
.client_command ⇒ Object
30
31
32
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 30
def client_command
""
end
|
.client_version ⇒ Object
Returns the version of the scm client Eg: [1, 5, 0] or [] if unknown
44
45
46
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 44
def client_version
[]
end
|
.client_version_above?(v, options = {}) ⇒ Boolean
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
59
60
61
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 59
def client_version_above?(v, options={})
((client_version <=> v) >= 0) || (client_version.empty? && options[:unknown])
end
|
.client_version_string ⇒ Object
Returns the version string of the scm client Eg: '1.5.0' or
'Unknown version' if unknown
50
51
52
53
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 50
def client_version_string
v = client_version || 'Unknown version'
v.is_a?(Array) ? v.join('.') : v.to_s
end
|
.shell_quote(str) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 67
def shell_quote(str)
if Redmine::Platform.mswin?
'"' + str.gsub(/"/, '\\"') + '"'
else
"'" + str.gsub(/'/, "'\"'\"'") + "'"
end
end
|
.shell_quote_command ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 34
def shell_quote_command
if Redmine::Platform.mswin? && RUBY_PLATFORM == 'java'
client_command
else
shell_quote(client_command)
end
end
|
Instance Method Details
#adapter_name ⇒ Object
84
85
86
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 84
def adapter_name
'Abstract'
end
|
#branches ⇒ Object
135
136
137
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 135
def branches
return nil
end
|
#cat(path, identifier = nil) ⇒ Object
159
160
161
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 159
def cat(path, identifier=nil)
return nil
end
|
#default_branch ⇒ Object
143
144
145
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 143
def default_branch
return nil
end
|
#diff(path, identifier_from, identifier_to = nil) ⇒ Object
155
156
157
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 155
def diff(path, identifier_from, identifier_to=nil)
return nil
end
|
#entries(path = nil, identifier = nil, options = {}) ⇒ Object
Returns an Entries collection or nil if the given path doesn't exist in
the repository
131
132
133
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 131
def entries(path=nil, identifier=nil, options={})
return nil
end
|
#entry(path = nil, identifier = nil) ⇒ Object
Returns the entry identified by path and revision identifier or nil if
entry doesn't exist in the repository
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 115
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?
Entry.new(:path => '', :kind => 'dir')
else
es = entries(search_path, identifier)
es ? es.detect {|e| e.name == search_name} : nil
end
end
|
#info ⇒ Object
get info about the svn repository
109
110
111
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 109
def info
return nil
end
|
#path_encoding ⇒ Object
104
105
106
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 104
def path_encoding
nil
end
|
#properties(path, identifier = nil) ⇒ Object
147
148
149
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 147
def properties(path, identifier=nil)
return nil
end
|
#revisions(path = nil, identifier_from = nil, identifier_to = nil, options = {}) ⇒ Object
151
152
153
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 151
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
return nil
end
|
#root_url ⇒ Object
96
97
98
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 96
def root_url
@root_url
end
|
#shell_quote(str) ⇒ Object
183
184
185
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 183
def shell_quote(str)
self.class.shell_quote(str)
end
|
#supports_annotate? ⇒ Boolean
92
93
94
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 92
def supports_annotate?
respond_to?('annotate')
end
|
#supports_cat? ⇒ Boolean
88
89
90
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 88
def supports_cat?
true
end
|
139
140
141
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 139
def tags
return nil
end
|
#url ⇒ Object
100
101
102
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 100
def url
@url
end
|
#with_leading_slash(path) ⇒ Object
163
164
165
166
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 163
def with_leading_slash(path)
path ||= ''
(path[0,1]!="/") ? "/#{path}" : path
end
|
#with_trailling_slash(path) ⇒ Object
168
169
170
171
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 168
def with_trailling_slash(path)
path ||= ''
(path[-1,1] == "/") ? path : "#{path}/"
end
|
#without_leading_slash(path) ⇒ Object
173
174
175
176
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 173
def without_leading_slash(path)
path ||= ''
path.gsub(%r{^/+}, '')
end
|
#without_trailling_slash(path) ⇒ Object
178
179
180
181
|
# File 'lib/redmine/scm/adapters/abstract_adapter.rb', line 178
def without_trailling_slash(path)
path ||= ''
(path[-1,1] == "/") ? path[0..-2] : path
end
|