mite-rb 0.4.4 → 0.4.5
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.
- data/CHANGES.md +4 -0
- data/lib/mite/account.rb +1 -1
- data/lib/mite/customer.rb +2 -2
- data/lib/mite/myself.rb +0 -1
- data/lib/mite/project.rb +6 -6
- data/lib/mite/service.rb +3 -3
- data/lib/mite/time_entry/bookmark.rb +5 -5
- data/lib/mite/time_entry.rb +10 -10
- data/lib/mite/time_entry_group.rb +11 -13
- data/lib/mite/tracker.rb +9 -9
- data/lib/mite/user.rb +2 -2
- data/lib/mite/version.rb +1 -1
- data/lib/mite-rb.rb +26 -26
- metadata +10 -5
data/CHANGES.md
CHANGED
data/lib/mite/account.rb
CHANGED
data/lib/mite/customer.rb
CHANGED
data/lib/mite/myself.rb
CHANGED
data/lib/mite/project.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
class Mite::Project < Mite::Base
|
2
|
-
|
2
|
+
|
3
3
|
include Mite::ResourceWithActiveArchived
|
4
|
-
|
4
|
+
|
5
5
|
def time_entries(options = {})
|
6
6
|
Mite::TimeEntry.find(:all, :params => options.update(:project_id => id))
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def name_with_customer
|
10
10
|
respond_to?(:customer_name) && !customer_name.blank? ? "#{name} (#{customer_name})" : name
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def customer
|
14
14
|
@customer ||= Mite::Customer.find(customer_id) unless customer_id.blank?
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def customer=(customer)
|
18
18
|
self.customer_id = customer ? customer.id : nil
|
19
19
|
@customer = customer
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
end
|
data/lib/mite/service.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
class Mite::TimeEntry::Bookmark < Mite::Base
|
2
|
-
|
2
|
+
|
3
3
|
include Mite::ResourceWithoutWriteAccess
|
4
4
|
self.prefix = "/time_entries/"
|
5
|
-
|
5
|
+
|
6
6
|
def team?
|
7
7
|
user_id.blank?
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def params
|
11
11
|
hash = CGI.parse(query)
|
12
12
|
hash.each do |k, v|
|
@@ -14,11 +14,11 @@ class Mite::TimeEntry::Bookmark < Mite::Base
|
|
14
14
|
end
|
15
15
|
hash
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def follow
|
19
19
|
Mite::TimeEntry.all(:params => params)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
class << self
|
23
23
|
def follow(id)
|
24
24
|
get("#{id}/follow")
|
data/lib/mite/time_entry.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
class Mite::TimeEntry < Mite::Base
|
2
|
-
|
2
|
+
|
3
3
|
def service
|
4
4
|
@service ||= Mite::Service.find(service_id) unless service_id.blank?
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def service=(service)
|
8
8
|
self.service_id = service ? service.id : nil
|
9
9
|
@service = service
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def project
|
13
13
|
@project ||= Mite::Project.find(project_id) unless project_id.blank?
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def project=(project)
|
17
17
|
self.project_id = project ? project.id : nil
|
18
18
|
@project = project
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def customer
|
22
22
|
@customer ||= begin
|
23
23
|
p = project
|
24
24
|
p.customer unless p.blank?
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def tracking?
|
29
29
|
!!attributes["tracker"]
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def start_tracker
|
33
33
|
attributes["tracker"] = Mite::Tracker.start(id) || nil
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def stop_tracker
|
37
37
|
Mite::Tracker.stop if tracking?
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def load(attr)
|
41
41
|
super(attr)
|
42
42
|
if attributes["tracking"]
|
@@ -44,7 +44,7 @@ class Mite::TimeEntry < Mite::Base
|
|
44
44
|
end
|
45
45
|
self
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
class << self
|
49
49
|
def find_every(options={})
|
50
50
|
return super(options) if !options[:params] || !options[:params][:group_by]
|
@@ -1,36 +1,34 @@
|
|
1
1
|
class Mite::TimeEntryGroup < Mite::Base
|
2
2
|
self.collection_name = "time_entries"
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :time_entries_params
|
5
|
-
|
5
|
+
|
6
6
|
class << self
|
7
7
|
def find_every(options={})
|
8
8
|
return Mite::TimeEntry.all(options) if !options[:params] || !options[:params][:group_by]
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
record.time_entries_params = record.attributes.delete("time_entries_params").attributes.stringify_keys
|
14
|
-
end
|
9
|
+
|
10
|
+
super(options).each do |record|
|
11
|
+
if record.attributes["time_entries_params"]
|
12
|
+
record.time_entries_params = record.attributes.delete("time_entries_params").attributes.stringify_keys
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
19
|
-
|
17
|
+
|
20
18
|
def time_entries(options={})
|
21
19
|
return [] unless time_entries_params.is_a?(Hash)
|
22
|
-
|
20
|
+
|
23
21
|
empty_result = false
|
24
|
-
|
22
|
+
|
25
23
|
options[:params] ||= {}
|
26
24
|
options[:params].stringify_keys!
|
27
25
|
options[:params].merge!(time_entries_params) do |key, v1, v2|
|
28
26
|
empty_result = (v1 != v2)
|
29
27
|
v2
|
30
28
|
end
|
31
|
-
|
29
|
+
|
32
30
|
return [] if empty_result
|
33
|
-
|
31
|
+
|
34
32
|
Mite::TimeEntry.all(options)
|
35
33
|
end
|
36
34
|
end
|
data/lib/mite/tracker.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
class Mite::Tracker < Mite::Base
|
2
|
-
|
2
|
+
|
3
3
|
self.collection_name = "tracker"
|
4
|
-
|
4
|
+
|
5
5
|
def self.current
|
6
6
|
tracking_time_entry = connection.get(collection_path, headers)["tracking_time_entry"]
|
7
7
|
tracking_time_entry ? instantiate_record(tracking_time_entry) : nil
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def self.start(time_entry_or_id)
|
11
11
|
id = time_entry_or_id.is_a?(Mite::TimeEntry) ? time_entry_or_id.id : time_entry_or_id
|
12
12
|
self.new(:id => id).start
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def self.stop
|
16
|
-
tracker = current
|
16
|
+
tracker = current
|
17
17
|
tracker ? tracker.stop : false
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def start
|
21
21
|
response = connection.put(element_path(prefix_options), encode, self.class.headers)
|
22
22
|
load(self.class.format.decode(response.body)["tracking_time_entry"])
|
23
23
|
response.is_a?(Net::HTTPSuccess) ? self : false
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def stop
|
27
27
|
connection.delete(element_path, self.class.headers).is_a?(Net::HTTPSuccess) ? self : false
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def time_entry
|
31
31
|
Mite::TimeEntry.find(id)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
data/lib/mite/user.rb
CHANGED
data/lib/mite/version.rb
CHANGED
data/lib/mite-rb.rb
CHANGED
@@ -6,7 +6,7 @@ require 'mite/version.rb'
|
|
6
6
|
# a sleek time tracking webapp.
|
7
7
|
|
8
8
|
module Mite
|
9
|
-
|
9
|
+
|
10
10
|
class << self
|
11
11
|
attr_accessor :email, :password, :host_format, :domain_format, :port
|
12
12
|
attr_reader :account, :key, :protocol, :user_agent
|
@@ -37,7 +37,7 @@ module Mite
|
|
37
37
|
end
|
38
38
|
@key = value
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
# Sets the mite.user_agent for all resources.
|
42
42
|
def user_agent=(user_agent)
|
43
43
|
resources.each do |klass|
|
@@ -45,7 +45,7 @@ module Mite
|
|
45
45
|
end
|
46
46
|
@user_agent = user_agent
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def protocol=(protocol)
|
50
50
|
$stderr.puts "WARNING: mite.api can only be accessed over HTTPS." unless protocol == 'https'
|
51
51
|
end
|
@@ -53,31 +53,31 @@ module Mite
|
|
53
53
|
def resources
|
54
54
|
@resources ||= []
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
# Validates connection
|
58
58
|
# returns true when valid false when not
|
59
59
|
def validate
|
60
60
|
validate! rescue false
|
61
61
|
end
|
62
|
-
|
63
|
-
# Same as validate_connection
|
62
|
+
|
63
|
+
# Same as validate_connection
|
64
64
|
# but raises http-error when connection is invalid
|
65
65
|
def validate!
|
66
66
|
!!Mite::Account.find
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def version
|
70
70
|
Mite::VERSION
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
self.host_format = '%s://%s%s'
|
75
75
|
self.domain_format = '%s.mite.yo.lk'
|
76
76
|
self.port = ''
|
77
77
|
self.user_agent = "mite-rb/#{Mite::VERSION}"
|
78
|
-
|
78
|
+
|
79
79
|
class MethodNotAvaible < StandardError; end
|
80
|
-
|
80
|
+
|
81
81
|
module ResourceWithoutWriteAccess
|
82
82
|
def save
|
83
83
|
raise MethodNotAvaible, "Cannot save #{self.class.name} over mite.api"
|
@@ -91,26 +91,26 @@ module Mite
|
|
91
91
|
raise MethodNotAvaible, "Cannot save #{self.class.name} over mite.api"
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
module ResourceWithActiveArchived
|
96
96
|
def self.included(base)
|
97
97
|
base.extend(ClassMethods)
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
module ClassMethods
|
101
101
|
def archived(options={})
|
102
102
|
find(:all, options.update(:from => :archived))
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
def active(options={})
|
106
106
|
find(:all, options)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
class Base < ActiveResource::Base
|
112
112
|
class << self
|
113
|
-
|
113
|
+
|
114
114
|
def inherited(base)
|
115
115
|
unless base == Mite::SingletonBase
|
116
116
|
Mite.resources << base
|
@@ -123,7 +123,7 @@ module Mite
|
|
123
123
|
end
|
124
124
|
super
|
125
125
|
end
|
126
|
-
|
126
|
+
|
127
127
|
# Common shortcuts known from ActiveRecord
|
128
128
|
def all(options={})
|
129
129
|
find(:all, options)
|
@@ -137,17 +137,17 @@ module Mite
|
|
137
137
|
find_every(options).last
|
138
138
|
end
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
private
|
142
|
-
|
142
|
+
|
143
143
|
def query_string2(options)
|
144
144
|
options.is_a?(String) ? "?#{options}" : super
|
145
145
|
end
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
class SingletonBase < Base
|
149
149
|
include ResourceWithoutWriteAccess
|
150
|
-
|
150
|
+
|
151
151
|
class << self
|
152
152
|
def collection_name
|
153
153
|
element_name
|
@@ -158,16 +158,16 @@ module Mite
|
|
158
158
|
"#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
|
159
159
|
end
|
160
160
|
|
161
|
-
def collection_path(prefix_options = {}, query_options = nil)
|
162
|
-
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
163
|
-
"#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
|
161
|
+
def collection_path(prefix_options = {}, query_options = nil)
|
162
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
163
|
+
"#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
|
164
164
|
end
|
165
165
|
end
|
166
|
-
|
166
|
+
|
167
167
|
def find
|
168
168
|
super(1)
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
alias_method :first, :find
|
172
172
|
alias_method :last, :find
|
173
173
|
|
@@ -176,7 +176,7 @@ module Mite
|
|
176
176
|
raise MethodNotAvaible, "Method not supported on #{self.class.name}"
|
177
177
|
end
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
end
|
181
181
|
|
182
182
|
require 'mite/account'
|
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.4.
|
4
|
+
version: 0.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: 2.3.14
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.3.14
|
25
30
|
description: The official ruby library for interacting with the RESTful mite.api.
|
26
31
|
email:
|
27
32
|
- sebastian@yo.lk
|
@@ -68,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
73
|
version: '0'
|
69
74
|
requirements: []
|
70
75
|
rubyforge_project: mite-rb
|
71
|
-
rubygems_version: 1.8.
|
76
|
+
rubygems_version: 1.8.23
|
72
77
|
signing_key:
|
73
78
|
specification_version: 3
|
74
79
|
summary: The official ruby library for interacting with the RESTful mite.api.
|