forked from boblail/unfuzzle
/
unfuzzle.rb
84 lines (72 loc) · 1.88 KB
/
unfuzzle.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
$:.unshift File.dirname(__FILE__)
require 'uri'
require 'net/http'
require 'json'
require 'builder'
require 'graft'
require 'unfuzzle/request'
require 'unfuzzle/response'
require 'unfuzzle/project'
require 'unfuzzle/milestone'
require 'unfuzzle/ticket'
require 'unfuzzle/severity'
require 'unfuzzle/priority'
require 'unfuzzle/component'
# = Unfuzzle: A simple wrapper around the Unfuddle JSON API
#
# == Quick Start
#
# To get started, you need to set the subdomain and a valid username /
# password combination:
#
# require 'rubygems'
# require 'unfuzzle'
#
# Unfuzzle.subdomain = 'viget'
# Unfuzzle.username = 'bopbip'
# Unfuzzle.password = 'bleep'
#
# From there, you can start accessing a list of projects:
#
# >> Unfuzzle.projects
# => [#<Unfuzzle::Project:0x5f5c44 @id=1, @name="BlipCo", ...>, ... ]
#
# Or a specific project by its 'short name':
#
# >> Unfuzzle.project('sample')
# => #<Unfuzzle::Project:0x123f888 @id=2, @name="Sample Project", ... >
#
# For more usage documentation, see README.doc.
#
module Unfuzzle
# Set the subdomain for all requests
def self.subdomain=(subdomain)
@subdomain = subdomain
end
# Set the username for all requests. Data retrieved from the API will be
# scoped to the data that this user has access to.
def self.username=(username)
@username = username
end
# Set the password for the supplied username
def self.password=(password)
@password = password
end
# Retrieve a project for the current user by its ID or slug
def self.project(id_or_slug)
id_or_slug.is_a?(String) ? Project.find_by_slug(id_or_slug) : Project.find_by_id(id_or_slug)
end
# Get a list of all projects for this user
def self.projects
Project.all
end
def self.subdomain # :nodoc:
@subdomain
end
def self.username # :nodoc:
@username
end
def self.password # :nodoc:
@password
end
end