Module: Builderator::Control::Version::SCM
- Included in:
- Git
- Defined in:
- lib/builderator/control/version/scm.rb
Overview
Generic SCM interface
Defined Under Namespace
Classes: Commit
Class Method Summary collapse
- .history ⇒ Object
-
.provider ⇒ Object
Find a version provider for this build.
- .providers ⇒ Object
- .register(klass) ⇒ Object
- .tags ⇒ Object
- .unregister(klass) ⇒ Object
Instance Method Summary collapse
-
#_history ⇒ Object
OVERRIDE: Return an array of hashes with keys - id -> SCM commit identity - message -> SCM commit message - tags -> nil or an array of strings.
-
#_tags ⇒ Object
OVERRIDE: Return an array of [tag, commit-id] tuples.
-
#history ⇒ Object
Fetch and cache history for the current HEAD/TIP.
-
#supported? ⇒ Boolean
OVERRIDE: Return true if this provider will work for ‘path`.
-
#tags ⇒ Object
Find all tags in the branch’s history.
Class Method Details
.history ⇒ Object
48 49 50 |
# File 'lib/builderator/control/version/scm.rb', line 48 def history provider.history end |
.provider ⇒ Object
Find a version provider for this build
74 75 76 77 78 79 |
# File 'lib/builderator/control/version/scm.rb', line 74 def provider providers.find(&:supported?).tap do |found| fail 'Builderator::Control::Version: '\ 'Unsupported SCM' if found.nil? end end |
.providers ⇒ Object
69 70 71 |
# File 'lib/builderator/control/version/scm.rb', line 69 def providers @providers ||= [] end |
.register(klass) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/builderator/control/version/scm.rb', line 56 def register(klass) fail 'Provider module must extend '\ 'Builderator::Control::Version::SCM' unless klass.singleton_class.include?(SCM) ## Make newer providers override those with the same capability providers.unshift(klass) end |
.tags ⇒ Object
52 53 54 |
# File 'lib/builderator/control/version/scm.rb', line 52 def provider. end |
.unregister(klass) ⇒ Object
65 66 67 |
# File 'lib/builderator/control/version/scm.rb', line 65 def unregister(klass) providers.delete(klass) end |
Instance Method Details
#_history ⇒ Object
OVERRIDE: Return an array of hashes with keys
-
id -> SCM commit identity
-
message -> SCM commit message
-
tags -> nil or an array of strings
34 35 36 |
# File 'lib/builderator/control/version/scm.rb', line 34 def _history fail 'Method `_history` must be implemented in SCM providers!' end |
#_tags ⇒ Object
OVERRIDE: Return an array of [tag, commit-id] tuples
41 42 43 44 45 |
# File 'lib/builderator/control/version/scm.rb', line 41 def history.reject { |commit| commit..empty? } .map { |commit| commit..map { |tag| [tag, commit.id] } } .each_with_object([]) { |commit, | .push(*commit) } end |
#history ⇒ Object
Fetch and cache history for the current HEAD/TIP
9 10 11 |
# File 'lib/builderator/control/version/scm.rb', line 9 def history @history ||= _history.map { |commit| Commit.new(commit) } end |
#supported? ⇒ Boolean
OVERRIDE: Return true if this provider will work for ‘path`
24 25 26 |
# File 'lib/builderator/control/version/scm.rb', line 24 def supported? fail 'Method `supported?` must be implemented in SCM providers!' end |
#tags ⇒ Object
Find all tags in the branch’s history
14 15 16 17 18 19 |
# File 'lib/builderator/control/version/scm.rb', line 14 def ||= .map { |tag, ref| Version.from_string(tag, :ref => ref) } .compact .sort end |