tickspot-ruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ === 0.1.0 / 2008-04-12
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/tickspot.rb
6
+ lib/tickspot_entry.rb
7
+ spec/tickspot_spec.rb
@@ -0,0 +1,61 @@
1
+ = tickspot-ruby
2
+
3
+ http://github.com/bricooke/tickspot-ruby
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ruby wrapper around the Tickspot API
8
+ http://tickspot.com/api
9
+
10
+ == SYNOPSIS:
11
+
12
+ ts = Tickspot.new("company.tickspot.com", "email@example.com", "password")
13
+
14
+ ts.users[0].email
15
+ => "email@example.com"
16
+
17
+ ts.users[0].created_at
18
+ => "Fri May 11 15:00:08 EDT 2007"
19
+
20
+
21
+ ts.projects[0].name
22
+ => "Best Project Ever"
23
+
24
+ ts.tasks(ts.projects[0].id)[0].sum_hours
25
+ => "5.5"
26
+
27
+ ts.entries(5.years.ago, Time.now, :project_id => ts.projects[0].id)[0].hours
28
+ => "0.5"
29
+
30
+ == REQUIREMENTS:
31
+
32
+ activesupport xml-simple
33
+
34
+ == INSTALL:
35
+
36
+ sudo gem install tickspot-ruby
37
+
38
+ == LICENSE:
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2008 Brian Cooke
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/tickspot.rb'
6
+ require 'spec/rake/spectask'
7
+
8
+ Hoe.new('tickspot-ruby', Tickspot::VERSION) do |p|
9
+ p.rubyforge_name = 'tickspot-ruby' # if different than lowercase project name
10
+ p.developer('Brian Cooke', 'bcooke@roobasoft.com')
11
+ end
12
+
13
+ desc "Run specifications"
14
+ Spec::Rake::SpecTask.new('spec') do |t|
15
+ t.spec_opts = ["--format", "specdoc", "--colour"]
16
+ t.spec_files = './spec/**/*_spec.rb'
17
+ end
18
+
19
+
20
+ # vim: syntax=Ruby
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'net/http'
3
+ require 'xmlsimple'
4
+ require 'activesupport'
5
+ require File.dirname(__FILE__) + '/tickspot_entry'
6
+
7
+ class Tickspot
8
+ VERSION = '0.1.0'
9
+
10
+ def initialize(domain, email, password)
11
+ @domain = domain
12
+ @email = email
13
+ @password = password
14
+ end
15
+
16
+ def users(params={})
17
+ te = request("users", params)
18
+ te.empty? ? [] : te.users
19
+ end
20
+
21
+ def projects
22
+ te = request("projects")
23
+ te.empty? ? [] : te.projects
24
+ end
25
+
26
+ def tasks(project_id)
27
+ te = request("tasks", :project_id => project_id)
28
+ te.empty? ? [] : te.tasks
29
+ end
30
+
31
+ def entries(start_date, end_date, params={})
32
+ te = request("entries", params.merge({:start_date => start_date, :end_date => end_date}))
33
+ te.empty? ? [] : te.entries
34
+ end
35
+
36
+ private
37
+ def request(path, params={})
38
+ request = Net::HTTP::Post.new("/api/" + path)
39
+ request.form_data = {
40
+ 'email' => @email,
41
+ 'password' => @password
42
+ }.merge(params)
43
+
44
+ ret = nil
45
+ Net::HTTP.new(@domain).start {|http|
46
+ response = http.request(request)
47
+ ret = TickspotEntry.new(XmlSimple.xml_in(response.body))
48
+ }
49
+ ret
50
+ end
51
+ end
@@ -0,0 +1,35 @@
1
+ class TickspotEntry
2
+ def initialize(parsed)
3
+ @hash = parsed
4
+ end
5
+
6
+ def id
7
+ self.method_missing(:id)
8
+ end
9
+
10
+ def empty?
11
+ if @hash["type"] == "array" && @hash["content"] == "\n"
12
+ true
13
+ else
14
+ false
15
+ end
16
+ end
17
+
18
+ def method_missing(method, *args)
19
+ if @hash.has_key?(method.to_s.singularize)
20
+ entry = @hash[method.to_s.singularize]
21
+ if method.to_s.pluralize == method.to_s && entry.class == Array
22
+ return entry.collect {|e| TickspotEntry.new(e)}
23
+ else
24
+ return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
25
+ return entry[0]["content"]
26
+ end
27
+ elsif @hash.has_key?(method.to_s)
28
+ entry = @hash[method.to_s]
29
+ return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
30
+ return entry[0]["content"]
31
+ else
32
+ super
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,6 @@
1
+ require './lib/tickspot'
2
+
3
+ describe "Tickspot" do
4
+ it "should do some things"
5
+ end
6
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tickspot-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Cooke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-04-12 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.5.1
23
+ version:
24
+ description: Ruby wrapper around the Tickspot API http://tickspot.com/api
25
+ email:
26
+ - bcooke@roobasoft.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ files:
36
+ - History.txt
37
+ - Manifest.txt
38
+ - README.txt
39
+ - Rakefile
40
+ - lib/tickspot.rb
41
+ - lib/tickspot_entry.rb
42
+ - spec/tickspot_spec.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/bricooke/tickspot-ruby
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --main
48
+ - README.txt
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project: tickspot-ruby
66
+ rubygems_version: 1.1.1
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: Ruby wrapper around the Tickspot API http://tickspot.com/api
70
+ test_files: []
71
+