Class: VCLog::Adapters::Abstract
- Inherits:
-
Object
- Object
- VCLog::Adapters::Abstract
- Defined in:
- lib/vclog/adapters/abstract.rb
Overview
Abstract base class for all version control system adapters.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#heuristics ⇒ Object
readonly
Heuristics object.
-
#root ⇒ Object
readonly
Root location.
Instance Method Summary collapse
-
#change_by_date(date) ⇒ Object
Return the latest commit as of a given date.
- #change_points ⇒ Object
- #changes ⇒ Object
-
#email ⇒ Object
Fallback for email address is ‘ENV`.
- #extract_changes ⇒ Object
- #extract_tags ⇒ Object
-
#initialize(repo) ⇒ Abstract
constructor
A new instance of Abstract.
-
#initialize_framework ⇒ Object
This is used if the adapter is using an external library to interface with the repository.
- #repository ⇒ Object
- #tag?(name) ⇒ Boolean
- #tags ⇒ Object
- #tempfile(name, content) ⇒ Object private
-
#user ⇒ Object
Fallback for user is ‘ENV`.
- #uuid ⇒ Object
-
#version ⇒ Object
Returns the current verion string.
- #version_tag?(tag_name) ⇒ Boolean private
Constructor Details
#initialize(repo) ⇒ Abstract
Returns a new instance of Abstract.
31 32 33 34 35 36 37 |
# File 'lib/vclog/adapters/abstract.rb', line 31 def initialize(repo) @repo = repo @root = repo.root @heuristics = repo.heuristics initialize_framework end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/vclog/adapters/abstract.rb', line 22 def config @config end |
#heuristics ⇒ Object (readonly)
Heuristics object.
28 29 30 |
# File 'lib/vclog/adapters/abstract.rb', line 28 def heuristics @heuristics end |
#root ⇒ Object (readonly)
Root location.
25 26 27 |
# File 'lib/vclog/adapters/abstract.rb', line 25 def root @root end |
Instance Method Details
#change_by_date(date) ⇒ Object
Return the latest commit as of a given date.
88 89 90 91 |
# File 'lib/vclog/adapters/abstract.rb', line 88 def change_by_date(date) list = changes.select{ |c| c.date <= date } list.sort_by{ |c| c.date }.last end |
#change_points ⇒ Object
65 66 67 68 69 |
# File 'lib/vclog/adapters/abstract.rb', line 65 def change_points @change_points ||= ( changes.inject([]){ |list, change| list.concat(change.points); list } ) end |
#changes ⇒ Object
60 61 62 |
# File 'lib/vclog/adapters/abstract.rb', line 60 def changes @changes ||= extract_changes end |
#email ⇒ Object
Fallback for email address is ‘ENV`.
99 100 101 |
# File 'lib/vclog/adapters/abstract.rb', line 99 def email ENV['EMAIL'] end |
#extract_changes ⇒ Object
50 51 52 |
# File 'lib/vclog/adapters/abstract.rb', line 50 def extract_changes raise "Not Implemented" end |
#extract_tags ⇒ Object
45 46 47 |
# File 'lib/vclog/adapters/abstract.rb', line 45 def raise "Not Implemented" end |
#initialize_framework ⇒ Object
This is used if the adapter is using an external library to interface with the repository.
41 42 |
# File 'lib/vclog/adapters/abstract.rb', line 41 def initialize_framework end |
#repository ⇒ Object
104 105 106 |
# File 'lib/vclog/adapters/abstract.rb', line 104 def repository nil end |
#tag?(name) ⇒ Boolean
72 73 74 |
# File 'lib/vclog/adapters/abstract.rb', line 72 def tag?(name) .find{ |t| t.name == name } end |
#tags ⇒ Object
55 56 57 |
# File 'lib/vclog/adapters/abstract.rb', line 55 def @tags ||= end |
#tempfile(name, content) ⇒ Object (private)
121 122 123 124 125 |
# File 'lib/vclog/adapters/abstract.rb', line 121 def tempfile(name, content) mfile = Tempfile.new(name) File.open(mfile.path, 'w'){ |f| f << content } mfile.path end |
#user ⇒ Object
Fallback for user is ‘ENV`.
94 95 96 |
# File 'lib/vclog/adapters/abstract.rb', line 94 def user ENV['USER'] end |
#uuid ⇒ Object
109 110 111 |
# File 'lib/vclog/adapters/abstract.rb', line 109 def uuid nil end |
#version ⇒ Object
Returns the current verion string.
77 78 79 80 81 82 83 84 85 |
# File 'lib/vclog/adapters/abstract.rb', line 77 def version if .last v = [-1].name # TODO: ensure the latest version v = [-2].name if v == 'HEAD' else v = '0.0.0' end return v end |
#version_tag?(tag_name) ⇒ Boolean (private)
116 117 118 |
# File 'lib/vclog/adapters/abstract.rb', line 116 def version_tag?(tag_name) /(v|\d)/i =~ tag_name end |