Class: Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/issue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, data) ⇒ Issue

Returns a new instance of Issue.



4
5
6
7
8
9
10
# File 'lib/issue.rb', line 4

def initialize(repository, data)
  @repository = repository
  @number = data['number']
  @title = data['title']
  @body = data['body']
  parse_labels data
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



2
3
4
# File 'lib/issue.rb', line 2

def body
  @body
end

#labelsObject (readonly)

Returns the value of attribute labels.



2
3
4
# File 'lib/issue.rb', line 2

def labels
  @labels
end

#numberObject (readonly)

Returns the value of attribute number.



2
3
4
# File 'lib/issue.rb', line 2

def number
  @number
end

#repositoryObject (readonly)

Returns the value of attribute repository.



2
3
4
# File 'lib/issue.rb', line 2

def repository
  @repository
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'lib/issue.rb', line 2

def title
  @title
end

Instance Method Details

#assign_to_self!Object



18
19
20
# File 'lib/issue.rb', line 18

def assign_to_self!
  repository.assign_issue number
end

#create_local_branch!Object



12
13
14
15
16
# File 'lib/issue.rb', line 12

def create_local_branch!
  branch_name = "##{number}-#{Helper.slug title}"
  puts "Creating branch #{branch_name}"
  `git checkout -b '#{branch_name}'`
end

#mark_in_progress!Object



22
23
24
25
26
27
28
# File 'lib/issue.rb', line 22

def mark_in_progress!
  labels.delete 'ready'
  labels.delete 'to do'
  labels << 'in progress'

  repository.export_labels self
end

#mark_ready!Object



30
31
32
33
34
35
36
# File 'lib/issue.rb', line 30

def mark_ready!
  labels << 'ready'
  labels << 'to do'
  labels.delete 'in progress'

  repository.export_labels self
end