Class: Dandelion::Workspace
- Inherits:
-
Object
- Object
- Dandelion::Workspace
- Defined in:
- lib/dandelion/workspace.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #changeset ⇒ Object
-
#initialize(repo, adapter, config = nil) ⇒ Workspace
constructor
A new instance of Workspace.
- #local_commit ⇒ Object
- #lookup(val) ⇒ Object
- #remote_commit ⇒ Object
- #remote_commit=(commit) ⇒ Object
- #tree ⇒ Object
Constructor Details
#initialize(repo, adapter, config = nil) ⇒ Workspace
Returns a new instance of Workspace.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dandelion/workspace.rb', line 7 def initialize(repo, adapter, config = nil) @repo = repo @adapter = adapter if config.is_a?(Hash) @config = Config.new(data: config) else @config = config || Config.new end @config.defaults(revision_file: '.revision', local_path: '') end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/dandelion/workspace.rb', line 5 def adapter @adapter end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/dandelion/workspace.rb', line 5 def config @config end |
Instance Method Details
#changeset ⇒ Object
24 25 26 |
# File 'lib/dandelion/workspace.rb', line 24 def changeset Changeset.new(tree, remote_commit, @config) end |
#local_commit ⇒ Object
28 29 30 |
# File 'lib/dandelion/workspace.rb', line 28 def local_commit lookup(local_sha) end |
#lookup(val) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dandelion/workspace.rb', line 41 def lookup(val) result = lookup_sha(val) || lookup_ref(val) || lookup_ref("refs/tags/#{val}") || lookup_ref("refs/branches/#{val}") || lookup_ref("refs/heads/#{val}") raise RevisionError.new(val) unless result result end |
#remote_commit ⇒ Object
32 33 34 35 |
# File 'lib/dandelion/workspace.rb', line 32 def remote_commit sha = remote_sha sha ? lookup(remote_sha) : nil end |
#remote_commit=(commit) ⇒ Object
37 38 39 |
# File 'lib/dandelion/workspace.rb', line 37 def remote_commit=(commit) self.remote_sha = commit.oid end |