Class: AssEmBlr
Instance Attribute Summary collapse
-
#page ⇒ Object
Returns the value of attribute page.
-
#parsed ⇒ Object
Returns the value of attribute parsed.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #find_assigned_to(to = @me) ⇒ Object
- #find_id(id) ⇒ Object
- #find_my_active_tickets ⇒ Object
- #find_with_status(status = "New") ⇒ Object
-
#initialize(config_file = "~/.assembla") ⇒ AssEmBlr
constructor
This metod requires for the config file to be present.
- #print(tickets) ⇒ Object
- #print_tickets ⇒ Object
-
#tickets ⇒ Object
This method parsess all active tickets in your Assembla space.
- #update_ticket_to_new(id) ⇒ Object
Constructor Details
#initialize(config_file = "~/.assembla") ⇒ AssEmBlr
This metod requires for the config file to be present
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/assembla.rb', line 25 def initialize(config_file = "~/.assembla") config = YAML::parse( File.open(File.(config_file))) @url = config["url"].value @user = config["user"].value @password = config["password"].value @me = config["me"].value (@url =~ /http/) ? \ self.page = Hpricot(open(@url, :http_basic_authentication=>[@user, @password])) \ : self.page = Hpricot(open(@url)) tickets end |
Instance Attribute Details
#page ⇒ Object
Returns the value of attribute page.
22 23 24 |
# File 'lib/assembla.rb', line 22 def page @page end |
#parsed ⇒ Object
Returns the value of attribute parsed.
22 23 24 |
# File 'lib/assembla.rb', line 22 def parsed @parsed end |
#password ⇒ Object
Returns the value of attribute password.
22 23 24 |
# File 'lib/assembla.rb', line 22 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
22 23 24 |
# File 'lib/assembla.rb', line 22 def url @url end |
#user ⇒ Object
Returns the value of attribute user.
22 23 24 |
# File 'lib/assembla.rb', line 22 def user @user end |
Instance Method Details
#find_assigned_to(to = @me) ⇒ Object
52 53 54 55 |
# File 'lib/assembla.rb', line 52 def find_assigned_to(to = @me) ass = AssignedTo.new assigned_to = ass.evaluate(self.parsed, to) end |
#find_id(id) ⇒ Object
74 75 76 77 |
# File 'lib/assembla.rb', line 74 def find_id(id) result = Id.new result.evaluate(self.parsed, id) end |
#find_my_active_tickets ⇒ Object
57 58 59 60 61 62 |
# File 'lib/assembla.rb', line 57 def find_my_active_tickets ass = find_assigned_to(@me) new = find_with_status("New") accepted = find_with_status("Accepted") (accepted + new + ass).uniq end |
#find_with_status(status = "New") ⇒ Object
64 65 66 67 |
# File 'lib/assembla.rb', line 64 def find_with_status(status = "New") st = Status.new active = st.evaluate(self.parsed, status) end |
#print(tickets) ⇒ Object
69 70 71 72 |
# File 'lib/assembla.rb', line 69 def print(tickets) puts_title_line tickets.each { |t| puts t.to_s } end |
#print_tickets ⇒ Object
45 46 47 48 49 50 |
# File 'lib/assembla.rb', line 45 def print_tickets puts_title_line self.parsed.each do |ticket| puts ticket.to_s end end |
#tickets ⇒ Object
This method parsess all active tickets in your Assembla space
40 41 42 43 |
# File 'lib/assembla.rb', line 40 def tickets all = All.new self.parsed = all.evaluate(self.page) end |
#update_ticket_to_new(id) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/assembla.rb', line 79 def update_ticket_to_new(id) space = @url.gsub(/https:\/\/www\.assembla.com(.+)/, '\1') url = space + '/' + id.to_s puts url request = Net::HTTP::Put.new(url, initheader = {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'}) request.body = "<ticket><status type='integer'>0</status></ticket>" request.basic_auth @user, @password Net::HTTP.start("www.assembla.com", 80 ) do |http| response = http.request(request) puts response end end |