Class: Redmine::Scm::Adapters::FilesystemAdapter
Class Method Summary
collapse
Instance Method Summary
collapse
#adapter_name, #branches, client_command, client_version, client_version_above?, client_version_string, #default_branch, #diff, #entry, logger, #properties, #revisions, #root_url, shell_quote, shell_quote_command, shellout, #supports_annotate?, #supports_cat?, #tags, #url, #valid_name?, #with_leading_slash, #with_trailing_slash, #without_leading_slash, #without_trailing_slash
shell_quote, shell_quote_command
Constructor Details
#initialize(url, root_url = nil, login = nil, password = nil, path_encoding = nil) ⇒ FilesystemAdapter
Returns a new instance of FilesystemAdapter.
35
36
37
38
|
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 35
def initialize(url, root_url=nil, login=nil, password=nil,
path_encoding=nil)
super(with_trailing_slash(url), nil, nil, nil, path_encoding)
end
|
Class Method Details
.client_available ⇒ Object
30
31
32
|
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 30
def client_available
true
end
|
Instance Method Details
#cat(path, identifier = nil) ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 100
def cat(path, identifier=nil)
p = scm_iconv(@path_encoding, 'UTF-8', target(path))
File.new(p, "rb").read
rescue => err
logger.error "scm: filesystem: error: #{err.message}"
raise CommandFailed.new(err.message)
end
|
#entries(path = "", identifier = nil, options = {}) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 58
def entries(path="", identifier=nil, options={})
entries = Entries.new
trgt_utf8 = target(path)
trgt = scm_iconv(@path_encoding, 'UTF-8', trgt_utf8)
Dir.new(trgt).each do |e1|
e_utf8 = scm_iconv('UTF-8', @path_encoding, e1)
next if e_utf8.blank?
relative_path_utf8 =
format_path_ends(
(format_path_ends(path, false, true) + e_utf8),
false,
false
)
t1_utf8 = target(relative_path_utf8)
t1 = scm_iconv(@path_encoding, 'UTF-8', t1_utf8)
relative_path = scm_iconv(@path_encoding, 'UTF-8', relative_path_utf8)
e1 = scm_iconv(@path_encoding, 'UTF-8', e_utf8)
if File.exist?(t1) and %w{file directory}.include?(File.ftype(t1)) and not File.basename(e1).match(/^\.+$/) p1 = File.readable?(t1) ? relative_path : ""
utf_8_path = scm_iconv('UTF-8', @path_encoding, p1)
entries <<
Entry.new(
{
:name => scm_iconv('UTF-8', @path_encoding, File.basename(e1)),
:path => utf_8_path,
:kind => (File.directory?(t1) ? 'dir' : 'file'),
:size => (File.directory?(t1) ? nil : File.size(t1)),
:lastrev => Revision.new({:time => (File.mtime(t1))})
}
)
end
end
entries.sort_by_name
rescue => err
logger.error "scm: filesystem: error: #{err.message}"
raise CommandFailed.new(err.message)
end
|
44
45
46
47
48
49
|
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 44
def format_path_ends(path, leading=true, trailing=true)
path = leading ? with_leading_slash(path) :
without_leading_slash(path)
trailing ? with_trailing_slash(path) :
without_trailing_slash(path)
end
|
#info ⇒ Object
51
52
53
54
55
56
|
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 51
def info
info = Info.new({:root_url => target(), :lastrev => nil})
info
rescue CommandFailed
return nil
end
|
#path_encoding ⇒ Object
40
41
42
|
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 40
def path_encoding
@path_encoding
end
|