Module: Assembla

Includes:
HTTParty
Defined in:
lib/assembla_cli.rb

Class Method Summary collapse

Class Method Details

.add_comment(comment) ⇒ Object



90
91
92
# File 'lib/assembla_cli.rb', line 90

def self.add_comment (comment)
  update_ticket("<ticket><user-comment>#{comment}</user-comment></ticket>")
end

.change_status(status_name) ⇒ Object



94
95
96
# File 'lib/assembla_cli.rb', line 94

def self.change_status (status_name)
  update_ticket("<ticket><status>#{status_name}</status></ticket>")
end

.custom_report(report_id) ⇒ Object



86
87
88
# File 'lib/assembla_cli.rb', line 86

def self.custom_report (report_id)
  get("/spaces/#{space['space']['id']}/tickets/custom_report/#{report_id}", xml_headers)
end

.custom_reportsObject



82
83
84
# File 'lib/assembla_cli.rb', line 82

def self.custom_reports
  get("/spaces/#{space['space']['id']}/custom_reports", xml_headers)
end

.login(login_name, password) ⇒ Object



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

def self. (, password)
  @login_name = 
  @password = password

  basic_auth(, password)
end

.milestonesObject



63
64
65
# File 'lib/assembla_cli.rb', line 63

def self.milestones
  @milestones ||= get("/spaces/#{space['space']['id']}/milestones/", xml_headers)
end

.my_report_id(report_id = nil) ⇒ Object



48
49
50
51
52
53
# File 'lib/assembla_cli.rb', line 48

def self.my_report_id (report_id = nil)
  if report_id
      @my_report_id = report_id
  end
  @my_report_id
end

.my_ticketsObject



78
79
80
# File 'lib/assembla_cli.rb', line 78

def self.my_tickets
  get("/spaces/#{space['space']['id']}/tickets/report/8", xml_headers)
end

.reset!Object



16
17
18
# File 'lib/assembla_cli.rb', line 16

def self.reset!
  @current_space = @milestones = @my_report_id = @statuses, @users = nil
end

.setup_credentialsObject



24
25
26
27
28
# File 'lib/assembla_cli.rb', line 24

def self.setup_credentials
   = ask('Username:')
  password   = ask('Password:') { |prompt| prompt.echo = false }
  [ , password ]
end

.space(space_name = nil) ⇒ Object



41
42
43
44
45
46
# File 'lib/assembla_cli.rb', line 41

def self.space (space_name = nil)
  if space_name
      @current_space = get("/spaces/#{space_name.gsub(/ /, '-').downcase}", xml_headers)
  end
  @current_space
end

.spacesObject



37
38
39
# File 'lib/assembla_cli.rb', line 37

def self.spaces
  get('/spaces/my_spaces', xml_headers)
end

.statusesObject



55
56
57
# File 'lib/assembla_cli.rb', line 55

def self.statuses
  @statuses ||= get("/spaces/#{space['space']['id']}/tickets/custom_statuses", xml_headers)
end

.ticket(ticket_id = nil) ⇒ Object



67
68
69
70
71
72
# File 'lib/assembla_cli.rb', line 67

def self.ticket (ticket_id = nil)
  if ticket_id
    @current_ticket = get("/spaces/#{space['space']['id']}/tickets/#{ticket_id}", xml_headers)
  end
  @current_ticket
end

.ticketsObject



74
75
76
# File 'lib/assembla_cli.rb', line 74

def self.tickets
  get("/spaces/#{space['space']['id']}/tickets/report/3", xml_headers)
end

.update_ticket(body) ⇒ Object



98
99
100
# File 'lib/assembla_cli.rb', line 98

def self.update_ticket (body)
  put("/spaces/#{space['space']['id']}/tickets/#{ticket['ticket']['number']}", xml_headers.merge!(:body => "#{body}"))
end

.usersObject



59
60
61
# File 'lib/assembla_cli.rb', line 59

def self.users
  @users ||= get("/spaces/#{space['space']['id']}/users", xml_headers)
end

.xml_headersObject



20
21
22
# File 'lib/assembla_cli.rb', line 20

def self.xml_headers
 {:headers => {'Accept' => 'application/xml', 'Content-Type' => 'application/xml'}}
end