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
18
19
# 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 = {
    'backlog' => [], 'in-progress' => [], 'completed' => [], 'accepted' => []
  }
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



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

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



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

def backlog
  @items['backlog']
end

#completeObject



58
59
60
# File 'lib/sly/project.rb', line 58

def complete
  @items['completed']
end

#currentObject



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

def current
  @items['in-progress']
end

#save!Object



21
22
23
# File 'lib/sly/project.rb', line 21

def save!
  # Reserved for updating the API
end

#to_sObject



25
26
27
# File 'lib/sly/project.rb', line 25

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

#update(status = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sly/project.rb', line 37

def update(status = nil)
  load_state rescue nil
  begin
    download_child_items(status)
    save_state
  rescue Exception => e
    puts e.message
    puts e.backtrace
    puts " Failed to connect to the Sprint.ly service, using last known values. ".colour(:white).background(:red)
    load_state
  end
end