Class: V::Adapters::Git::Environment
- Inherits:
-
Object
- Object
- V::Adapters::Git::Environment
- Defined in:
- lib/v/adapters/git/environment.rb
Instance Attribute Summary collapse
-
#bare ⇒ Object
readonly
Returns the value of attribute bare.
-
#branches ⇒ Object
readonly
Returns the value of attribute branches.
-
#git_dir ⇒ Object
readonly
Returns the value of attribute git_dir.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
-
#work_tree ⇒ Object
readonly
Returns the value of attribute work_tree.
Class Method Summary collapse
Instance Method Summary collapse
-
#commits(path = '.') ⇒ Object
Returns collection of commits for current branch.
-
#head ⇒ Object
Returns head for current branch.
-
#initialize(attrs = {}) ⇒ Environment
constructor
A new instance of Environment.
- #inspect ⇒ Object
-
#method_missing(op_sym, *args, &callback) ⇒ Object
Tries to schedule an operation.
- #new? ⇒ Boolean
- #origin ⇒ Object
-
#remotes ⇒ Object
Convenience.
-
#schedule(op = nil, &block) ⇒ Object
Schedules operation or proc for execution.
Constructor Details
#initialize(attrs = {}) ⇒ Environment
Returns a new instance of Environment.
12 13 14 15 16 17 18 19 |
# File 'lib/v/adapters/git/environment.rb', line 12 def initialize(attrs = {}) assign attrs assign_directories assign_git assign_string assign_worker end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(op_sym, *args, &callback) ⇒ Object
Tries to schedule an operation.
31 32 33 |
# File 'lib/v/adapters/git/environment.rb', line 31 def method_missing(op_sym, *args, &callback) schedule Operations.new(op_sym, *args, &callback) end |
Instance Attribute Details
#bare ⇒ Object (readonly)
Returns the value of attribute bare.
7 8 9 |
# File 'lib/v/adapters/git/environment.rb', line 7 def @bare end |
#branches ⇒ Object (readonly)
Returns the value of attribute branches.
7 8 9 |
# File 'lib/v/adapters/git/environment.rb', line 7 def branches @branches end |
#git_dir ⇒ Object (readonly)
Returns the value of attribute git_dir.
7 8 9 |
# File 'lib/v/adapters/git/environment.rb', line 7 def git_dir @git_dir end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
7 8 9 |
# File 'lib/v/adapters/git/environment.rb', line 7 def index @index end |
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
7 8 9 |
# File 'lib/v/adapters/git/environment.rb', line 7 def to_s @to_s end |
#work_tree ⇒ Object (readonly)
Returns the value of attribute work_tree.
7 8 9 |
# File 'lib/v/adapters/git/environment.rb', line 7 def work_tree @work_tree end |
Class Method Details
.which_git=(path) ⇒ Object
9 |
# File 'lib/v/adapters/git/environment.rb', line 9 def self.which_git=(path) @@which_git = path end |
Instance Method Details
#commits(path = '.') ⇒ Object
Returns collection of commits for current branch.
53 54 55 |
# File 'lib/v/adapters/git/environment.rb', line 53 def commits(path = '.') @branches.current.commits path end |
#head ⇒ Object
Returns head for current branch. This is a moving target.
57 58 59 |
# File 'lib/v/adapters/git/environment.rb', line 57 def head @branches.current.head end |
#inspect ⇒ Object
40 41 42 |
# File 'lib/v/adapters/git/environment.rb', line 40 def inspect @git_dir end |
#new? ⇒ Boolean
21 22 23 24 25 26 27 28 |
# File 'lib/v/adapters/git/environment.rb', line 21 def new? schedule { path = File.join @git_dir, 'refs', 'heads' entries = Dir.entries(path) - %w[ . .. ] entries.size == 0 } end |
#origin ⇒ Object
49 50 51 |
# File 'lib/v/adapters/git/environment.rb', line 49 def origin @remotes['origin'] end |
#remotes ⇒ Object
Convenience
46 47 48 |
# File 'lib/v/adapters/git/environment.rb', line 46 def remotes @remotes end |
#schedule(op = nil, &block) ⇒ Object
Schedules operation or proc for execution.
36 37 38 |
# File 'lib/v/adapters/git/environment.rb', line 36 def schedule(op = nil, &block) @worker.enq block || op, self end |