Class: Project
- Inherits:
-
Object
- Object
- Project
- Defined in:
- lib/helpers/project.rb
Overview
Project represents a Git project
Instance Attribute Summary collapse
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
Instance Method Summary collapse
- #all(group = nil) ⇒ Object
- #create_root_path(path) ⇒ Object
- #first ⇒ Object
-
#initialize(config) ⇒ Project
constructor
A new instance of Project.
- #new_group(remote, name) ⇒ Object
- #new_remote(remote, name, url) ⇒ Object
Constructor Details
#initialize(config) ⇒ Project
Returns a new instance of Project.
8 9 10 |
# File 'lib/helpers/project.rb', line 8 def initialize(config) @projects = YAML.load_file(config) end |
Instance Attribute Details
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
6 7 8 |
# File 'lib/helpers/project.rb', line 6 def projects @projects end |
Instance Method Details
#all(group = nil) ⇒ Object
12 13 14 |
# File 'lib/helpers/project.rb', line 12 def all(group = nil) group ? @projects.select { |_k, v| v['group'].include?(group) } : @projects end |
#create_root_path(path) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/helpers/project.rb', line 20 def create_root_path(path) @projects.tap do |project| project.each do |_k, v| v['root_dir'] = path end end end |
#first ⇒ Object
16 17 18 |
# File 'lib/helpers/project.rb', line 16 def first all.sort.first end |
#new_group(remote, name) ⇒ Object
34 35 36 37 38 |
# File 'lib/helpers/project.rb', line 34 def new_group(remote, name) @projects.tap do |project| project[remote]['group'] = name end end |
#new_remote(remote, name, url) ⇒ Object
28 29 30 31 32 |
# File 'lib/helpers/project.rb', line 28 def new_remote(remote, name, url) @projects.tap do |project| project[remote][name] = url end end |