Class: Gitcamp::Github::Milestone

Inherits:
Object
  • Object
show all
Defined in:
lib/gitcamp/github/milestone.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Milestone

Returns a new instance of Milestone.



6
7
8
9
10
11
12
13
14
# File 'lib/gitcamp/github/milestone.rb', line 6

def initialize(options = {})
  unless options[:todolist]
    raise ArgumentError, 'no Basecamp todolist given'
  end

  @repo = options[:repo]
  @github = options[:github]
  @todolist = options[:todolist]
end

Instance Attribute Details

#milestoneObject (readonly)

Returns the value of attribute milestone.



4
5
6
# File 'lib/gitcamp/github/milestone.rb', line 4

def milestone
  @milestone
end

#repoObject (readonly)

Returns the value of attribute repo.



4
5
6
# File 'lib/gitcamp/github/milestone.rb', line 4

def repo
  @repo
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/gitcamp/github/milestone.rb', line 4

def title
  @title
end

#todolistObject (readonly)

Returns the value of attribute todolist.



4
5
6
# File 'lib/gitcamp/github/milestone.rb', line 4

def todolist
  @todolist
end

Instance Method Details

#numberObject



16
17
18
# File 'lib/gitcamp/github/milestone.rb', line 16

def number
  @milestone.number
end

#saveObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gitcamp/github/milestone.rb', line 20

def save
  milestones = @github.list_milestones(repo)
  @milestone = milestones.find { |mls| mls.title == todolist.name.strip }

  unless @milestone
    @milestone = @github.create_milestone(repo, @todolist.name)
  end

  if @milestone
    say "Using milestone '#{milestone.title}' in GitHub #{repo}"
  end
end