mite-rb 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,6 +1,10 @@
1
1
  = mite-rb Changelog
2
2
 
3
- == Version 0.2.0 (not completed)
3
+ == Version 0.2.1
4
+
5
+ * Added archived and active collection-methods to Customer, Project, Service and User
6
+
7
+ == Version 0.2.0
4
8
 
5
9
  * Added singleton resources account and myself (current authenticated user)
6
10
  * Removed depreciated undo method
data/README.markdown ADDED
@@ -0,0 +1,96 @@
1
+ ## mite-rb
2
+
3
+ The official ruby library for interacting with the [RESTful API](http://mite.yo.lk/en/api) of [mite](http://mite.yo.lk/en), a sleek time tracking webapp.
4
+
5
+ ## Install
6
+
7
+ Install the lib as a ruby gem from gemcutter:
8
+
9
+ sudo gem install mite-rb -s http://gemcutter.org
10
+
11
+ mite-rb requires activeresource and activesupport in version 2.3.2 or above.
12
+
13
+ ## Documentation
14
+
15
+ You should read the complete *mite*.api documentation at [http://mite.yo.lk/en/api](http://mite.yo.lk/en/api)
16
+
17
+ ### Authenticate
18
+
19
+ **IMPORTANT:** To use mite-rb you **must** enable the *mite*.api for your user within the webinterface of *mite*! It is disabled by default.
20
+
21
+ The first thing you need to set is the account name. This is the same as the web address (subdomain) for your account. For example if you use *mite* from the domain *demo.mite.yo.lk* set the account to 'demo':
22
+
23
+ Mite.account = 'demo'
24
+
25
+ Then, you should set the authentication. You can either use your mite.api key (recommanded) or your login credentials (email and password).
26
+
27
+ Mite.key = 'cdfeasdaabcdefgssaeabcdefg'
28
+
29
+ or
30
+
31
+ Mite.authenticate('rick@techno-weenie.net', 'spacemonkey')
32
+
33
+ ### Validate connection
34
+
35
+ You can validate the connection/authentication with
36
+
37
+ Mite.validate
38
+
39
+ This will return true when the connection is valid and false if not.
40
+
41
+ Use
42
+
43
+ Mite.validate!
44
+
45
+ and mite-rb will raise an exception with further details when the connection is not valid.
46
+
47
+ ### Project
48
+
49
+ #### Find all active projects
50
+
51
+ Mite::Project.all
52
+
53
+ #### Find all archived projects
54
+
55
+ Mite::Project.archived
56
+
57
+ #### Find projects where name contains 'web'
58
+
59
+ Mite::Project.all(:params => {:name => 'web'})
60
+
61
+ #### Find single project by ID
62
+
63
+ Mite::Project.find(1209)
64
+
65
+ #### Get all time entries of a project
66
+
67
+ project = Mite::Project.find(1209)
68
+ project.time_entries
69
+
70
+ #### Get the customer of a project
71
+
72
+ project = Mite::Project.find(1209)
73
+ project.customer
74
+
75
+ #### Creating
76
+
77
+ project = Mite::Project.new(:name => 'Playing with the mite.api')
78
+ project.save
79
+
80
+ or in a single step
81
+
82
+ project = Mite::Project.create(:name => 'Playing with the mite.api')
83
+
84
+ #### Updating
85
+
86
+ project = Mite::Project.find(1209)
87
+ project.name = "mite.api"
88
+ project.customer = Mite::Customer.find(384)
89
+ project.save
90
+
91
+ #### Deleting
92
+
93
+ project = Mite::Project.find(1209)
94
+ project.destroy
95
+
96
+
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 0
4
+ :patch: 1
data/lib/mite/customer.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  class Mite::Customer < Mite::Base
2
+
3
+ include Mite::ResourceWithActiveArchived
4
+
2
5
  def time_entries(options = {})
3
6
  Mite::TimeEntry.find(:all, :params => options.update(:customer_id => id))
4
7
  end
data/lib/mite/project.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  class Mite::Project < Mite::Base
2
2
 
3
+ include Mite::ResourceWithActiveArchived
4
+
3
5
  def time_entries(options = {})
4
6
  Mite::TimeEntry.find(:all, :params => options.update(:project_id => id))
5
7
  end
data/lib/mite/service.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  class Mite::Service < Mite::Base
2
2
 
3
+ include Mite::ResourceWithActiveArchived
4
+
3
5
  def time_entries(options = {})
4
6
  Mite::TimeEntry.find(:all, :params => options.update(:service_id => id))
5
7
  end
data/lib/mite/user.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  class Mite::User < Mite::Base
2
2
 
3
- include Mite::NoWriteAccess
3
+ include Mite::ResourceWithoutWriteAccess
4
+ include Mite::ResourceWithActiveArchived
4
5
 
5
6
  def time_entries(options = {})
6
7
  Mite::TimeEntry.find(:all, :params => options.update(:user_id => id))
data/lib/mite-rb.rb CHANGED
@@ -61,7 +61,7 @@ module Mite
61
61
 
62
62
  class MethodNotAvaible < StandardError; end
63
63
 
64
- module NoWriteAccess
64
+ module ResourceWithoutWriteAccess
65
65
  def save
66
66
  raise MethodNotAvaible, "Cannot save #{self.class.name} over mite.api"
67
67
  end
@@ -75,6 +75,22 @@ module Mite
75
75
  end
76
76
  end
77
77
 
78
+ module ResourceWithActiveArchived
79
+ def self.included(base)
80
+ base.extend(ClassMethods)
81
+ end
82
+
83
+ module ClassMethods
84
+ def archived(options={})
85
+ find(:all, options.update(:from => :archived))
86
+ end
87
+
88
+ def active(options={})
89
+ find(:all, options)
90
+ end
91
+ end
92
+ end
93
+
78
94
  class Base < ActiveResource::Base
79
95
  class << self
80
96
 
@@ -92,7 +108,7 @@ module Mite
92
108
 
93
109
  # Common shortcuts known from ActiveRecord
94
110
  def all(options={})
95
- find_every(options)
111
+ find(:all, options)
96
112
  end
97
113
 
98
114
  def first(options={})
@@ -106,7 +122,7 @@ module Mite
106
122
  end
107
123
 
108
124
  class SingletonBase < Base
109
- include NoWriteAccess
125
+ include ResourceWithoutWriteAccess
110
126
 
111
127
  class << self
112
128
  def collection_name
data/mite-rb.gemspec CHANGED
@@ -5,22 +5,22 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mite-rb}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sebastian Munz"]
12
- s.date = %q{2009-11-05}
12
+ s.date = %q{2009-11-06}
13
13
  s.description = %q{The official ruby library for interacting with the RESTful mite.api.}
14
14
  s.email = %q{sebastian@yo.lk}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.textile"
17
+ "README.markdown"
18
18
  ]
19
19
  s.files = [
20
20
  ".gitignore",
21
21
  "CHANGES.txt",
22
22
  "LICENSE",
23
- "README.textile",
23
+ "README.markdown",
24
24
  "Rakefile",
25
25
  "VERSION.yml",
26
26
  "lib/mite-rb.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mite-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Munz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-05 00:00:00 +01:00
12
+ date: 2009-11-06 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -40,12 +40,12 @@ extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
42
  - LICENSE
43
- - README.textile
43
+ - README.markdown
44
44
  files:
45
45
  - .gitignore
46
46
  - CHANGES.txt
47
47
  - LICENSE
48
- - README.textile
48
+ - README.markdown
49
49
  - Rakefile
50
50
  - VERSION.yml
51
51
  - lib/mite-rb.rb
data/README.textile DELETED
@@ -1,81 +0,0 @@
1
- The official ruby library for interacting with the "RESTful API":http://mite.yo.lk/en/api of "mite":http://mite.yo.lk/en, a sleek time tracking webapp.
2
-
3
- h3. Install
4
-
5
- As a ruby gem from gemcutter:
6
-
7
- sudo gem install mite-rb -s http://gemcutter.org
8
-
9
- mite-rb requires activeresource and activesupport gems in a current version (2.3.2) to be installed.
10
-
11
- h3. Documentation
12
-
13
- You should read the complete mite.api documentation at http://mite.yo.lk/en/api
14
-
15
- h4. Authenticate
16
-
17
- The first thing you need to set is the account name. This is the same as the web address (subdomain) for your account. For example if you use mite from the domain demo.mite.yo.lk:
18
-
19
- Mite.account = 'demo'
20
-
21
- Then, you should set the authentication. You can either use your login credentials (email and password) with HTTP Basic Authentication or your mite.api key. In both cases you must enable the mite.api in your user settings.
22
-
23
- With basic authentication:
24
-
25
- Mite.authenticate('rick@techno-weenie.net', 'spacemonkey')
26
-
27
- or, use your api key:
28
-
29
- Mite.key = 'cdfeasdaabcdefgssaeabcdefg'
30
-
31
- h4. Validate connection
32
-
33
- You can validate the connection/authentication with
34
-
35
- Mite.validate
36
-
37
- This will return true when the connection is valid and false if not.
38
-
39
- Use
40
-
41
- Mite.validate!
42
-
43
- and mite-rb will raise an exception with further details when the connection is not valid.
44
-
45
- h4. Project
46
-
47
- Find all active projects of the current account
48
-
49
- Mite::Project.all
50
-
51
- Find single project by ID
52
-
53
- Mite::Project.find(1209)
54
-
55
- Creating a Project
56
-
57
- project = Mite::Project.new(:name => 'Playing with the mite.api')
58
- project.save
59
-
60
- or
61
-
62
- project = Mite::Project.create(:name => 'Playing with the mite.api')
63
-
64
- Updating a Project
65
-
66
- project = Mite::Project.find(1209)
67
- project.name = "mite.api"
68
- project.customer = Mite::Customer.find(384)
69
- project.save
70
-
71
- Get the customer of an project
72
-
73
- project = Mite::Project.find(1209)
74
- project.customer
75
-
76
- Deleting a project
77
-
78
- project = Mite::Project.find(1209)
79
- project.destroy
80
-
81
-