Class: Sly::Project

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/sly/project.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_attributes = {}) ⇒ Project

Returns a new instance of Project.



11
12
13
14
15
16
17
# File 'lib/sly/project.rb', line 11

def initialize(project_attributes = {})
  @id = project_attributes["id"]
  @name = project_attributes["name"]
  @archived = project_attributes["archived"]
  @admin = project_attributes["admin"]
  @items = []
end

Instance Attribute Details

#adminObject

Returns the value of attribute admin.



9
10
11
# File 'lib/sly/project.rb', line 9

def admin
  @admin
end

#archivedObject

Returns the value of attribute archived.



9
10
11
# File 'lib/sly/project.rb', line 9

def archived
  @archived
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/sly/project.rb', line 9

def id
  @id
end

#itemsObject

Returns the value of attribute items.



9
10
11
# File 'lib/sly/project.rb', line 9

def items
  @items
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/sly/project.rb', line 9

def name
  @name
end

Class Method Details

.load(file) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/sly/project.rb', line 27

def self.load(file)
  begin
    YAML::load(File.open(file))
  rescue Exception => e
    raise "Unable to locate project file #{file}"
  end
end

Instance Method Details

#backlogObject



45
46
47
# File 'lib/sly/project.rb', line 45

def backlog
  @items.select { |item| item.status == "backlog" }
end

#completeObject



53
54
55
# File 'lib/sly/project.rb', line 53

def complete
  @items.select { |item| item.status == "complete" }
end

#currentObject



49
50
51
# File 'lib/sly/project.rb', line 49

def current
  @items.select { |item| item.status == "in-progress" }
end

#save!Object



19
20
21
# File 'lib/sly/project.rb', line 19

def save!
  # Reserved for updating the API
end

#to_sObject



23
24
25
# File 'lib/sly/project.rb', line 23

def to_s
  return "#{@id} - #{@name}"
end

#updateObject



35
36
37
38
39
40
41
42
43
# File 'lib/sly/project.rb', line 35

def update
  begin
    download_child_items
    save_child_items
  rescue Exception
    puts " Failed to connect to the Sprint.ly service, using last known values. ".colour(:white).background(:red)
    load_child_items
  end
end