Class: Redmine::Scm::Adapters::FilesystemAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- Redmine::Scm::Adapters::FilesystemAdapter
- Defined in:
- lib/redmine/scm/adapters/filesystem_adapter.rb
Instance Method Summary
- - (Object) cat(path, identifier = nil)
- - (Object) entries(path = "", identifier = nil)
- - (Object) format_path_ends(path, leading = true, trailling = true)
- - (Object) info
-
- (FilesystemAdapter) initialize(url, root_url = nil, login = nil, password = nil)
constructor
A new instance of FilesystemAdapter.
Methods inherited from AbstractAdapter
#adapter_name, #branches, client_version, client_version_above?, client_version_string, #default_branch, #diff, #entry, #properties, #revisions, #root_url, #shell_quote, #supports_annotate?, #supports_cat?, #tags, #url, #with_leading_slash, #with_trailling_slash, #without_leading_slash, #without_trailling_slash
Constructor Details
- (FilesystemAdapter) initialize(url, root_url = nil, login = nil, password = nil)
A new instance of FilesystemAdapter
30 31 32 |
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 30 def initialize(url, root_url=nil, login=nil, password=nil) @url = with_trailling_slash(url) end |
Instance Method Details
- (Object) cat(path, identifier = nil)
74 75 76 |
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 74 def cat(path, identifier=nil) File.new(target(path), "rb").read end |
- (Object) entries(path = "", identifier = nil)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 50 def entries(path="", identifier=nil) entries = Entries.new Dir.new(target(path)).each do |e| relative_path = format_path_ends((format_path_ends(path, false, true) + e), false,false) target = target(relative_path) entries << Entry.new({ :name => File.basename(e), # below : list unreadable files, but dont link them. :path => File.readable?(target) ? relative_path : "", :kind => (File.directory?(target) ? 'dir' : 'file'), :size => (File.directory?(target) ? nil : [File.size(target)].pack('l').unpack('L').first), :lastrev => Revision.new({:time => (File.mtime(target)).localtime, }) }) if File.exist?(target) and # paranoid test %w{file directory}.include?(File.ftype(target)) and # avoid special types not File.basename(e).match(/^\.+$/) # avoid . and .. end entries.sort_by_name end |
- (Object) format_path_ends(path, leading = true, trailling = true)
34 35 36 37 38 39 |
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 34 def format_path_ends(path, leading=true, trailling=true) path = leading ? with_leading_slash(path) : without_leading_slash(path) trailling ? with_trailling_slash(path) : without_trailling_slash(path) end |
- (Object) info
41 42 43 44 45 46 47 48 |
# File 'lib/redmine/scm/adapters/filesystem_adapter.rb', line 41 def info info = Info.new({:root_url => target(), :lastrev => nil }) info rescue CommandFailed return nil end |