Class: Pickler::Tracker::Project

Inherits:
Abstract
  • Object
show all
Defined in:
lib/pickler/tracker/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

accessor, date_reader, reader, #to_xml

Constructor Details

#initialize(tracker, attributes = {}, id = nil) ⇒ Project

Returns a new instance of Project.



21
22
23
24
25
26
27
28
29
# File 'lib/pickler/tracker/project.rb', line 21

def initialize(tracker, attributes = {}, id = nil)
  @tracker = tracker
  if id
    @attributes_fetcher = attributes
    @id = id
  else
    super(attributes)
  end
end

Instance Attribute Details

#trackerObject (readonly)

Returns the value of attribute tracker.



5
6
7
# File 'lib/pickler/tracker/project.rb', line 5

def tracker
  @tracker
end

Instance Method Details

#attributesObject



12
13
14
15
16
17
18
19
# File 'lib/pickler/tracker/project.rb', line 12

def attributes
  unless defined?(@attributes)
    self.class.superclass.instance_method(:initialize).bind(self).call(
      @attributes_fetcher.call
    )
  end
  @attributes
end

#deliver_all_finished_storiesObject



52
53
54
# File 'lib/pickler/tracker/project.rb', line 52

def deliver_all_finished_stories
  request_xml(:put,"/projects/#{id}/stories_deliver_all_finished")
end

#idObject



8
9
10
# File 'lib/pickler/tracker/project.rb', line 8

def id
  id = @id || attributes['id'] and Integer(id)
end

#new_story(attributes = {}, &block) ⇒ Object



48
49
50
# File 'lib/pickler/tracker/project.rb', line 48

def new_story(attributes = {}, &block)
  Story.new(self, attributes, &block)
end

#stories(*args) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/pickler/tracker/project.rb', line 40

def stories(*args)
  filter = encode_term(args) if args.any?
  path = "/projects/#{id}/stories"
  path << "?filter=#{CGI.escape(filter)}" if filter
  response = tracker.get_xml(path)
  [response["stories"]].flatten.compact.map {|s| Story.new(self,s)}
end

#story(story_id) ⇒ Object

Raises:



35
36
37
38
# File 'lib/pickler/tracker/project.rb', line 35

def story(story_id)
  raise Error, "No story id given" if story_id.to_s.empty?
  Story.new(self,tracker.get_xml("/projects/#{id}/stories/#{story_id}")["story"])
end

#use_https?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/pickler/tracker/project.rb', line 31

def use_https?
  attributes['use_https'].to_s == 'true'
end