public this repo is viewable by everyone
Description: A gem that provides a ruby wrapper around the tickspot.com api
Homepage: http://tickspot.com/api/
Clone URL: git://github.com/bricooke/tickspot-ruby.git
now in gem format, soon to be on rubyforge as tickspot-ruby (waiting 
approval)
bricooke (author)
about 1 month ago
commit  ce8d129d4791c49543c7a4076947947319d39a3f
tree    04143582e0ff92663ce661bf7eefe011019f0a94
parent  cf9fc64560793613483360224098687608e4569b
...
 
 
...
1
2
0
@@ -0,0 +1,2 @@
0
+coverage
0
+pkg
...
 
 
 
 
 
 
...
1
2
3
4
5
6
0
@@ -0,0 +1,6 @@
0
+=== 1.0.0 / 2008-04-12
0
+
0
+* 1 major enhancement
0
+
0
+ * Birthday!
0
+
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,14 +0,0 @@
0
-# Copyright (c) 2008, Brian Cooke <bcooke@roobasoft.com>
0
-#
0
-# Permission to use, copy, modify, and/or distribute this software for any
0
-# purpose with or without fee is hereby granted, provided that the above
0
-# copyright notice and this permission notice appear in all copies.
0
-#
0
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0
-
...
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
0
@@ -0,0 +1,7 @@
0
+History.txt
0
+Manifest.txt
0
+README.txt
0
+Rakefile
0
+lib/tickspot.rb
0
+lib/tickspot_entry.rb
0
+spec/tickspot_spec.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
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,28 +0,0 @@
0
-This is a ruby wrapper for talking to the tickspot.com API. See http://tickspot.com/api/ for details.
0
-
0
-Still a work in progress.
0
-
0
-*Usage*
0
-ts = Tickspot.new("company.tickspot.com", "email@example.com", "password")
0
-
0
-ts.users[0].email
0
-=> "email@example.com"
0
-
0
-ts.users[0].created_at
0
-=> "Fri May 11 15:00:08 EDT 2007"
0
-
0
-
0
-ts.projects[0].name
0
-=> "Best Project Ever"
0
-
0
-ts.tasks(ts.projects[0].id)[0].sum_hours
0
-=> "5.5"
0
-
0
-ts.entries(5.years.ago, Time.now, :project_id => ts.projects[0].id)[0].hours
0
-=> "0.5"
0
-
0
-
0
-*TODO*
0
- - Make a gem
0
- - Write specs
0
- - Convert the return values to their actual data types instead of always returning strings
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,61 @@
0
+= tickspot-ruby
0
+
0
+http://github.com/bricooke/tickspot-ruby
0
+
0
+== DESCRIPTION:
0
+
0
+Ruby wrapper around the Tickspot API
0
+http://tickspot.com/api
0
+
0
+== SYNOPSIS:
0
+
0
+ts = Tickspot.new("company.tickspot.com", "email@example.com", "password")
0
+
0
+ts.users[0].email
0
+=> "email@example.com"
0
+
0
+ts.users[0].created_at
0
+=> "Fri May 11 15:00:08 EDT 2007"
0
+
0
+
0
+ts.projects[0].name
0
+=> "Best Project Ever"
0
+
0
+ts.tasks(ts.projects[0].id)[0].sum_hours
0
+=> "5.5"
0
+
0
+ts.entries(5.years.ago, Time.now, :project_id => ts.projects[0].id)[0].hours
0
+=> "0.5"
0
+
0
+== REQUIREMENTS:
0
+
0
+activesupport xml-simple
0
+
0
+== INSTALL:
0
+
0
+sudo gem install tickspot-ruby
0
+
0
+== LICENSE:
0
+
0
+(The MIT License)
0
+
0
+Copyright (c) 2008 Brian Cooke
0
+
0
+Permission is hereby granted, free of charge, to any person obtaining
0
+a copy of this software and associated documentation files (the
0
+'Software'), to deal in the Software without restriction, including
0
+without limitation the rights to use, copy, modify, merge, publish,
0
+distribute, sublicense, and/or sell copies of the Software, and to
0
+permit persons to whom the Software is furnished to do so, subject to
0
+the following conditions:
0
+
0
+The above copyright notice and this permission notice shall be
0
+included in all copies or substantial portions of the Software.
0
+
0
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
0
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
0
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
0
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
0
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -0,0 +1,20 @@
0
+# -*- ruby -*-
0
+
0
+require 'rubygems'
0
+require 'hoe'
0
+require './lib/tickspot.rb'
0
+require 'spec/rake/spectask'
0
+
0
+Hoe.new('tickspot-ruby', Tickspot::VERSION) do |p|
0
+ p.rubyforge_name = 'tickspot-ruby' # if different than lowercase project name
0
+ p.developer('Brian Cooke', 'bcooke@roobasoft.com')
0
+end
0
+
0
+desc "Run specifications"
0
+Spec::Rake::SpecTask.new('spec') do |t|
0
+ t.spec_opts = ["--format", "specdoc", "--colour"]
0
+ t.spec_files = './spec/**/*_spec.rb'
0
+end
0
+
0
+
0
+# vim: syntax=Ruby
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,51 @@
0
+require 'rubygems'
0
+require 'net/http'
0
+require 'xmlsimple'
0
+require 'activesupport'
0
+require File.dirname(__FILE__) + '/tickspot_entry'
0
+
0
+class Tickspot
0
+ VERSION = '0.1.0'
0
+
0
+ def initialize(domain, email, password)
0
+ @domain = domain
0
+ @email = email
0
+ @password = password
0
+ end
0
+
0
+ def users
0
+ te = request("users")
0
+ te.users
0
+ end
0
+
0
+ def projects
0
+ te = request("projects")
0
+ te.projects
0
+ end
0
+
0
+ def tasks(project_id)
0
+ te = request("tasks", :project_id => project_id)
0
+ te.tasks
0
+ end
0
+
0
+ def entries(start_date, end_date, params={})
0
+ te = request("entries", params.merge({:start_date => start_date, :end_date => end_date}))
0
+ te.entries
0
+ end
0
+
0
+private
0
+ def request(path, params={})
0
+ request = Net::HTTP::Post.new("/api/" + path)
0
+ request.form_data = {
0
+ 'email' => @email,
0
+ 'password' => @password
0
+ }.merge(params)
0
+
0
+ ret = nil
0
+ Net::HTTP.new(@domain).start {|http|
0
+ response = http.request(request)
0
+ ret = TickspotEntry.new(XmlSimple.xml_in(response.body))
0
+ }
0
+ ret
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -0,0 +1,27 @@
0
+class TickspotEntry
0
+ def initialize(parsed)
0
+ @hash = parsed
0
+ end
0
+
0
+ def id
0
+ self.method_missing(:id)
0
+ end
0
+
0
+ def method_missing(method, *args)
0
+ if @hash.has_key?(method.to_s.singularize)
0
+ entry = @hash[method.to_s.singularize]
0
+ if method.to_s.pluralize == method.to_s && entry.class == Array
0
+ return entry.collect {|e| TickspotEntry.new(e)}
0
+ else
0
+ return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
0
+ return entry[0]["content"]
0
+ end
0
+ elsif @hash.has_key?(method.to_s)
0
+ entry = @hash[method.to_s]
0
+ return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
0
+ return entry[0]["content"]
0
+ else
0
+ super
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
...
1
2
3
4
5
6
0
@@ -0,0 +1,6 @@
0
+require './lib/tickspot'
0
+
0
+describe "Tickspot" do
0
+ it "should do some things"
0
+end
0
+
...
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
85
86
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,86 +0,0 @@
0
-require 'rubygems'
0
-require 'net/http'
0
-require 'xmlsimple'
0
-require 'activesupport'
0
-
0
-# Usage:
0
-# ts = Tickspot.new("company.tickspot.com", "email@example.com", "password")
0
-# users = ts.users
0
-# users[0].email => "email@example.com"
0
-#
0
-# Refer to http://tickspot.com/api/ to see all the fields returned
0
-# or simply print the TickspotEntry returned as it will dump the hash
0
-#
0
-class Tickspot
0
- def initialize(domain, email, password)
0
- @domain = domain
0
- @email = email
0
- @password = password
0
- end
0
-
0
- def users
0
- te = request("users")
0
- te.users
0
- end
0
-
0
- def projects
0
- te = request("projects")
0
- te.projects
0
- end
0
-
0
- def tasks(project_id)
0
- te = request("tasks", :project_id => project_id)
0
- te.tasks
0
- end
0
-
0
- def entries(start_date, end_date, params={})
0
- te = request("entries", params.merge({:start_date => start_date, :end_date => end_date}))
0
- te.entries
0
- end
0
-
0
-private
0
- def request(path, params={})
0
- request = Net::HTTP::Post.new("/api/" + path)
0
- request.form_data = {
0
- 'email' => @email,
0
- 'password' => @password
0
- }.merge(params)
0
-
0
- ret = nil
0
- Net::HTTP.new(@domain).start {|http|
0
- response = http.request(request)
0
- ret = TickspotEntry.new(XmlSimple.xml_in(response.body))
0
- }
0
- ret
0
- end
0
-end
0
-
0
-
0
-
0
-class TickspotEntry
0
- def initialize(parsed)
0
- @hash = parsed
0
- end
0
-
0
- def id
0
- self.method_missing(:id)
0
- end
0
-
0
- def method_missing(method, *args)
0
- if @hash.has_key?(method.to_s.singularize)
0
- entry = @hash[method.to_s.singularize]
0
- if method.to_s.pluralize == method.to_s && entry.class == Array
0
- return entry.collect {|e| TickspotEntry.new(e)}
0
- else
0
- return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
0
- return entry[0]["content"]
0
- end
0
- elsif @hash.has_key?(method.to_s)
0
- entry = @hash[method.to_s]
0
- return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
0
- return entry[0]["content"]
0
- else
0
- super
0
- end
0
- end
0
-end

Comments

    No one has commented yet.