Class: MetaProject::ScmWeb::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_project/scm_web/browser.rb

Overview

A Browser instance is capable of generating URLs to various files and diffs in an online scm web interface.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir_spec = nil, history_spec = nil, raw_spec = nil, html_spec = nil, diff_spec = nil, child_dirs_pattern = nil, child_files_pattern = nil) ⇒ Browser

The variables to use in uri_specs are:

  • path

  • revision

  • previous_revision



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/meta_project/scm_web/browser.rb', line 17

def initialize(dir_spec=nil, history_spec=nil, raw_spec=nil, html_spec=nil, diff_spec=nil, child_dirs_pattern=nil, child_files_pattern=nil)
  @dir_spec, @history_spec, @raw_spec, @html_spec, @diff_spec, @child_dirs_pattern, @child_files_pattern = dir_spec, history_spec, raw_spec, html_spec, diff_spec, child_dirs_pattern, child_files_pattern
  
  # TODO: move to setters. maybe create a spec class?
  validate_presence_of("dir_spec", @dir_spec, "path")
  validate_presence_of("history_spec", @history_spec, "path")
  validate_presence_of("raw_spec", @raw_spec, "path")
  validate_presence_of("raw_spec", @raw_spec, "revision")
  validate_presence_of("html_spec", @html_spec, "path")
  validate_presence_of("html_spec", @html_spec, "revision")
  #validate_presence_of("diff_spec", @diff_spec, "path")
  validate_presence_of("diff_spec", @diff_spec, "revision")
  #validate_presence_of("diff_spec", @diff_spec, "previous_revision")
end

Instance Attribute Details

#diff_specObject

Returns the value of attribute diff_spec.



9
10
11
# File 'lib/meta_project/scm_web/browser.rb', line 9

def diff_spec
  @diff_spec
end

#dir_specObject

Returns the value of attribute dir_spec.



9
10
11
# File 'lib/meta_project/scm_web/browser.rb', line 9

def dir_spec
  @dir_spec
end

#history_specObject

Returns the value of attribute history_spec.



9
10
11
# File 'lib/meta_project/scm_web/browser.rb', line 9

def history_spec
  @history_spec
end

#html_specObject

Returns the value of attribute html_spec.



9
10
11
# File 'lib/meta_project/scm_web/browser.rb', line 9

def html_spec
  @html_spec
end

#raw_specObject

Returns the value of attribute raw_spec.



9
10
11
# File 'lib/meta_project/scm_web/browser.rb', line 9

def raw_spec
  @raw_spec
end

Instance Method Details

#child_dirs_patternObject

The regexp used to determine child directories of a directory



53
54
55
# File 'lib/meta_project/scm_web/browser.rb', line 53

def child_dirs_pattern
  @child_dirs_pattern
end

#child_files_patternObject

The regexp used to determine child files of a directory



58
59
60
# File 'lib/meta_project/scm_web/browser.rb', line 58

def child_files_pattern
  @child_files_pattern
end

#diff(path, revision, previous_revision) ⇒ Object



48
49
50
# File 'lib/meta_project/scm_web/browser.rb', line 48

def diff(path, revision, previous_revision)
  file_uri(path, revision, @diff_spec, previous_revision)
end

#dir(path) ⇒ Object



32
33
34
# File 'lib/meta_project/scm_web/browser.rb', line 32

def dir(path)
  file_uri(path, nil, @dir_spec, nil)
end

#history(path) ⇒ Object



36
37
38
# File 'lib/meta_project/scm_web/browser.rb', line 36

def history(path)
  file_uri(path, nil, @history_spec, nil)
end

#html(path, revision) ⇒ Object



44
45
46
# File 'lib/meta_project/scm_web/browser.rb', line 44

def html(path, revision)
  file_uri(path, revision, @html_spec, nil)
end

#raw(path, revision) ⇒ Object



40
41
42
# File 'lib/meta_project/scm_web/browser.rb', line 40

def raw(path, revision)
  file_uri(path, revision, @raw_spec, nil)
end

#rootObject

Returns a Pathname representing the root directory of this browser. NOTE: The root of the browser may be at a lower level than the toplevel of the online scm web interface; It depends on the configuration of this instance.



66
67
68
# File 'lib/meta_project/scm_web/browser.rb', line 66

def root
  Pathname.new(self, nil, "", nil, true)
end