mite.cmd 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source :rubygems
2
+
3
+ gem 'activeresource', '~> 2.3'
4
+ gem 'activesupport', '~> 2.3'
5
+ gem 'mite-rb', '~> 0.4'
6
+
7
+ group :development, :test do
8
+ gem 'rake'
9
+ end
10
+
11
+ group :development do
12
+ gem 'jeweler'
13
+ end
14
+
15
+ group :test do
16
+ gem "rspec", "~> 1.3.2"
17
+ end
@@ -22,6 +22,8 @@ I assume github is in your gem sources. You may need @activesupport@ and @active
22
22
 
23
23
  $ gem install activesupport activeresource
24
24
 
25
+ Note: On debian/ubuntu libopenssl-ruby is required.
26
+
25
27
  h3. After installation instructions:
26
28
 
27
29
  You'll need to configure the client prior using it.
data/Rakefile CHANGED
@@ -12,6 +12,7 @@ begin
12
12
  gem.description = "A simple command line interface for mite, a sleek time tracking webapp."
13
13
  gem.authors = ["Lukas Rieder"]
14
14
  end
15
+ Jeweler::RubygemsDotOrgTasks.new
15
16
  rescue LoadError
16
17
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
18
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.12
@@ -59,7 +59,15 @@ module MiteCmd
59
59
  else
60
60
  tell "Oh my dear! I tried hard, but I could'nt find any time entry for today."
61
61
  end
62
-
62
+
63
+ elsif @arguments.first == 'note'
64
+ if time_entry = Mite::TimeEntry.first(:params => {:at => 'today'})
65
+ @arguments.shift
66
+ time_entry.note = [time_entry.note, *@arguments].compact.join(' ')
67
+ time_entry.save
68
+ tell time_entry.inspect
69
+ end
70
+
63
71
  elsif (1..4).include?(@arguments.size)
64
72
  attributes = {}
65
73
  if time_string = @arguments.select { |a| a =~ TIME_FORMAT }.first
@@ -1,75 +1,72 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{mite.cmd}
5
- s.version = "0.1.10"
8
+ s.version = "0.1.12"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Lukas Rieder"]
9
- s.date = %q{2010-02-11}
12
+ s.date = %q{2012-05-09}
10
13
  s.default_executable = %q{mite}
11
14
  s.description = %q{A simple command line interface for mite, a sleek time tracking webapp.}
12
15
  s.email = %q{l.rieder@gmail.com}
13
16
  s.executables = ["mite"]
14
17
  s.extra_rdoc_files = [
15
18
  "LICENSE",
16
- "README.textile"
19
+ "README.textile",
20
+ "TODO"
17
21
  ]
18
22
  s.files = [
19
- ".gitignore",
20
- "LICENSE",
21
- "README.textile",
22
- "Rakefile",
23
- "TODO",
24
- "VERSION",
25
- "bin/mite",
26
- "lib/mite_cmd.rb",
27
- "lib/mite_cmd/application.rb",
28
- "lib/mite_cmd/autocomplete.rb",
29
- "lib/mite_ext.rb",
30
- "lib/string_ext.rb",
31
- "mite.cmd.gemspec",
32
- "spec/mite_cmd/application_spec.rb",
33
- "spec/mite_cmd/autocomplete_spec.rb",
34
- "spec/mite_cmd_spec.rb",
35
- "spec/mite_ext_spec.rb",
36
- "spec/spec_helper.rb",
37
- "spec/string_ext_spec.rb",
38
- "vendor/yolk-mite-rb-0.0.3/CHANGES.txt",
39
- "vendor/yolk-mite-rb-0.0.3/LICENSE",
40
- "vendor/yolk-mite-rb-0.0.3/README.textile",
41
- "vendor/yolk-mite-rb-0.0.3/Rakefile",
42
- "vendor/yolk-mite-rb-0.0.3/VERSION.yml",
43
- "vendor/yolk-mite-rb-0.0.3/lib/mite-rb.rb",
44
- "vendor/yolk-mite-rb-0.0.3/lib/mite/customer.rb",
45
- "vendor/yolk-mite-rb-0.0.3/lib/mite/project.rb",
46
- "vendor/yolk-mite-rb-0.0.3/lib/mite/service.rb",
47
- "vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry.rb",
48
- "vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb",
49
- "vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb",
50
- "vendor/yolk-mite-rb-0.0.3/lib/mite/user.rb"
23
+ "Gemfile",
24
+ "LICENSE",
25
+ "README.textile",
26
+ "Rakefile",
27
+ "TODO",
28
+ "VERSION",
29
+ "bin/mite",
30
+ "lib/mite_cmd.rb",
31
+ "lib/mite_cmd/application.rb",
32
+ "lib/mite_cmd/autocomplete.rb",
33
+ "lib/mite_ext.rb",
34
+ "lib/string_ext.rb",
35
+ "mite.cmd.gemspec",
36
+ "spec/mite_cmd/application_spec.rb",
37
+ "spec/mite_cmd/autocomplete_spec.rb",
38
+ "spec/mite_cmd_spec.rb",
39
+ "spec/mite_ext_spec.rb",
40
+ "spec/spec_helper.rb",
41
+ "spec/string_ext_spec.rb"
51
42
  ]
52
43
  s.homepage = %q{http://github.com/Overbryd/mite.cmd}
53
- s.rdoc_options = ["--charset=UTF-8"]
54
44
  s.require_paths = ["lib"]
55
- s.rubygems_version = %q{1.3.5}
45
+ s.rubygems_version = %q{1.6.2}
56
46
  s.summary = %q{A simple command line interface for basic mite tasks.}
57
- s.test_files = [
58
- "spec/mite_cmd/application_spec.rb",
59
- "spec/mite_cmd/autocomplete_spec.rb",
60
- "spec/mite_cmd_spec.rb",
61
- "spec/mite_ext_spec.rb",
62
- "spec/spec_helper.rb",
63
- "spec/string_ext_spec.rb"
64
- ]
65
47
 
66
48
  if s.respond_to? :specification_version then
67
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
68
49
  s.specification_version = 3
69
50
 
70
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<activeresource>, ["~> 2.3"])
53
+ s.add_runtime_dependency(%q<activesupport>, ["~> 2.3"])
54
+ s.add_runtime_dependency(%q<mite-rb>, ["~> 0.4"])
55
+ s.add_development_dependency(%q<rake>, [">= 0"])
56
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
71
57
  else
58
+ s.add_dependency(%q<activeresource>, ["~> 2.3"])
59
+ s.add_dependency(%q<activesupport>, ["~> 2.3"])
60
+ s.add_dependency(%q<mite-rb>, ["~> 0.4"])
61
+ s.add_dependency(%q<rake>, [">= 0"])
62
+ s.add_dependency(%q<jeweler>, [">= 0"])
72
63
  end
73
64
  else
65
+ s.add_dependency(%q<activeresource>, ["~> 2.3"])
66
+ s.add_dependency(%q<activesupport>, ["~> 2.3"])
67
+ s.add_dependency(%q<mite-rb>, ["~> 0.4"])
68
+ s.add_dependency(%q<rake>, [">= 0"])
69
+ s.add_dependency(%q<jeweler>, [">= 0"])
74
70
  end
75
71
  end
72
+
@@ -361,6 +361,38 @@ describe MiteCmd::Application, 'run' do
361
361
  end
362
362
  end
363
363
 
364
+ describe 'the note argument' do
365
+ before(:each) do
366
+ @application = MiteCmd::Application.new ['note', 'Current work comment']
367
+ @application.stub!(:tell)
368
+
369
+ @time_entry = stub('time_entry', :note => nil, :note= => nil, :save => true, :inspect => 'I should be commented.')
370
+ Mite::TimeEntry.stub!(:first).and_return @time_entry
371
+ end
372
+
373
+ it "should call .note= on the last time entry of today" do
374
+ Mite::TimeEntry.should_receive(:first).with(:params => {:at => 'today'})
375
+ @time_entry.should_receive(:note=).with('Current work comment')
376
+ @application.run
377
+ end
378
+
379
+ it "should save the entry" do
380
+ @time_entry.should_receive(:save)
381
+ @application.run
382
+ end
383
+
384
+ it "should append to an existing note with a space in between" do
385
+ @time_entry.should_receive(:note).and_return('Existing comment.')
386
+ @time_entry.should_receive(:note=).with('Existing comment. Current work comment')
387
+ @application.run
388
+ end
389
+
390
+ it "should tell the inspection of the tracker's time entry if it has been stopped" do
391
+ @application.should_receive(:tell).with 'I should be commented.'
392
+ @application.run
393
+ end
394
+ end
395
+
364
396
  end
365
397
 
366
398
  describe MiteCmd::Application, 'dynamic time entry creation' do
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe Mite, 'account_url' do
4
4
  it "should return the url for this account" do
5
5
  Mite.account = 'demo'
6
- Mite.account_url.should == 'http://demo.mite.yo.lk'
6
+ Mite.account_url.should == '://demo.mite.yo.lk'
7
7
  end
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mite.cmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ hash: 3
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 12
10
+ version: 0.1.12
5
11
  platform: ruby
6
12
  authors:
7
13
  - Lukas Rieder
@@ -9,10 +15,82 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-11 00:00:00 +01:00
18
+ date: 2012-05-09 00:00:00 +02:00
13
19
  default_executable: mite
14
- dependencies: []
15
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 2
32
+ - 3
33
+ version: "2.3"
34
+ name: activeresource
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ prerelease: false
38
+ type: :runtime
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 5
45
+ segments:
46
+ - 2
47
+ - 3
48
+ version: "2.3"
49
+ name: activesupport
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ type: :runtime
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ - 4
63
+ version: "0.4"
64
+ name: mite-rb
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ prerelease: false
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ name: rake
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ prerelease: false
82
+ type: :development
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ name: jeweler
93
+ version_requirements: *id005
16
94
  description: A simple command line interface for mite, a sleek time tracking webapp.
17
95
  email: l.rieder@gmail.com
18
96
  executables:
@@ -22,8 +100,9 @@ extensions: []
22
100
  extra_rdoc_files:
23
101
  - LICENSE
24
102
  - README.textile
103
+ - TODO
25
104
  files:
26
- - .gitignore
105
+ - Gemfile
27
106
  - LICENSE
28
107
  - README.textile
29
108
  - Rakefile
@@ -42,51 +121,39 @@ files:
42
121
  - spec/mite_ext_spec.rb
43
122
  - spec/spec_helper.rb
44
123
  - spec/string_ext_spec.rb
45
- - vendor/yolk-mite-rb-0.0.3/CHANGES.txt
46
- - vendor/yolk-mite-rb-0.0.3/LICENSE
47
- - vendor/yolk-mite-rb-0.0.3/README.textile
48
- - vendor/yolk-mite-rb-0.0.3/Rakefile
49
- - vendor/yolk-mite-rb-0.0.3/VERSION.yml
50
- - vendor/yolk-mite-rb-0.0.3/lib/mite-rb.rb
51
- - vendor/yolk-mite-rb-0.0.3/lib/mite/customer.rb
52
- - vendor/yolk-mite-rb-0.0.3/lib/mite/project.rb
53
- - vendor/yolk-mite-rb-0.0.3/lib/mite/service.rb
54
- - vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry.rb
55
- - vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
56
- - vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb
57
- - vendor/yolk-mite-rb-0.0.3/lib/mite/user.rb
58
124
  has_rdoc: true
59
125
  homepage: http://github.com/Overbryd/mite.cmd
60
126
  licenses: []
61
127
 
62
128
  post_install_message:
63
- rdoc_options:
64
- - --charset=UTF-8
129
+ rdoc_options: []
130
+
65
131
  require_paths:
66
132
  - lib
67
133
  required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
68
135
  requirements:
69
136
  - - ">="
70
137
  - !ruby/object:Gem::Version
138
+ hash: 3
139
+ segments:
140
+ - 0
71
141
  version: "0"
72
- version:
73
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
74
144
  requirements:
75
145
  - - ">="
76
146
  - !ruby/object:Gem::Version
147
+ hash: 3
148
+ segments:
149
+ - 0
77
150
  version: "0"
78
- version:
79
151
  requirements: []
80
152
 
81
153
  rubyforge_project:
82
- rubygems_version: 1.3.5
154
+ rubygems_version: 1.6.2
83
155
  signing_key:
84
156
  specification_version: 3
85
157
  summary: A simple command line interface for basic mite tasks.
86
- test_files:
87
- - spec/mite_cmd/application_spec.rb
88
- - spec/mite_cmd/autocomplete_spec.rb
89
- - spec/mite_cmd_spec.rb
90
- - spec/mite_ext_spec.rb
91
- - spec/spec_helper.rb
92
- - spec/string_ext_spec.rb
158
+ test_files: []
159
+
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.gem
2
- pkg
3
- doc
4
- coverage
5
- .DS_Store
@@ -1,11 +0,0 @@
1
- = mite-rb Changelog
2
-
3
- == Version 0.0.2
4
-
5
- * Added tracker-resource and methods on time_entry
6
- * Fixed tiny datetimebug
7
- * Dependency of activeresource 2.3.2 and activesupport 2.3.2
8
-
9
- == Version 0.0.1
10
-
11
- * Initial Version
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Yolk Sebastian Munz & Julia Soergel GbR
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,70 +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 github:
6
-
7
- sudo gem install yolk-mite-rb -s http://gems.github.com
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
- 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:
14
-
15
- Mite.account = 'demo'
16
-
17
- 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.
18
-
19
- With basic authentication:
20
-
21
- Mite.authenticate('rick@techno-weenie.net', 'spacemonkey')
22
-
23
- or, use your api key:
24
-
25
- Mite.key = 'cdfeasdaabcdefgssaeabcdefg'
26
-
27
- You should read the complete mite.api documentation at http://mite.yo.lk/en/api
28
-
29
- h4. Project
30
-
31
- Find all active projects of the current account
32
-
33
- Mite::Project.all
34
-
35
- Find single project by ID
36
-
37
- Mite::Project.find(1209)
38
-
39
- Creating a Project
40
-
41
- project = Mite::Project.new(:name => 'Playing with the mite.api')
42
- project.save
43
-
44
- or
45
-
46
- project = Mite::Project.create(:name => 'Playing with the mite.api')
47
-
48
- Updating a Project
49
-
50
- project = Mite::Project.find(1209)
51
- project.name = "mite.api"
52
- project.customer = Mite::Customer.find(384)
53
- project.save
54
-
55
- Get the customer of an project
56
-
57
- project = Mite::Project.find(1209)
58
- project.customer
59
-
60
- Deleting a project
61
-
62
- project = Mite::Project.find(1209)
63
- project.destroy
64
-
65
- Restore a destroyed project
66
- (will only work for aprox. 12 hours after the object was destroyed)
67
-
68
- project = Mite::Project.undo_destroy(1209)
69
-
70
-
@@ -1,24 +0,0 @@
1
- task :default => [:spec]
2
-
3
- $gem_name = "mite-rb"
4
-
5
- desc "Run specs"
6
- task :spec do
7
- sh "spec spec/* --format specdoc --color"
8
- end
9
-
10
- begin
11
- require 'jeweler'
12
- Jeweler::Tasks.new do |s|
13
- s.name = $gem_name
14
- s.summary = "The official ruby library for interacting with the RESTful API of mite, a sleek time tracking webapp."
15
- s.email = "sebastian@yo.lk"
16
- s.homepage = "http://github.com/yolk/mite-rb"
17
- s.description = "The official ruby library for interacting with the RESTful mite.api."
18
- s.authors = ["Sebastian Munz"]
19
- s.add_dependency(%q<activesupport>, [">= 2.3.2"])
20
- s.add_dependency(%q<activeresource>, [">= 2.3.2"])
21
- end
22
- rescue LoadError
23
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
24
- end
@@ -1,4 +0,0 @@
1
- ---
2
- :minor: 0
3
- :patch: 3
4
- :major: 0
@@ -1,105 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__))
2
-
3
- require 'rubygems'
4
- require 'active_support'
5
- require 'active_resource'
6
-
7
- # The official ruby library for interacting with the RESTful API of mite,
8
- # a sleek time tracking webapp.
9
-
10
- module Mite
11
-
12
- class << self
13
- attr_accessor :email, :password, :host_format, :domain_format, :protocol, :port
14
- attr_reader :account, :key
15
-
16
- # Sets the account name, and updates all resources with the new domain.
17
- def account=(name)
18
- resources.each do |klass|
19
- klass.site = klass.site_format % (host_format % [protocol, domain_format % name, ":#{port}"])
20
- end
21
- @account = name
22
- end
23
-
24
- # Sets up basic authentication credentials for all resources.
25
- def authenticate(user, password)
26
- resources.each do |klass|
27
- klass.user = user
28
- klass.password = password
29
- end
30
- @user = user
31
- @password = password
32
- true
33
- end
34
-
35
- # Sets the mite.api key for all resources.
36
- def key=(value)
37
- resources.each do |klass|
38
- klass.headers['X-MiteApiKey'] = value
39
- end
40
- @key = value
41
- end
42
-
43
- def resources
44
- @resources ||= []
45
- end
46
- end
47
-
48
- self.host_format = '%s://%s%s'
49
- self.domain_format = '%s.mite.yo.lk'
50
- self.protocol = 'http'
51
- self.port = ''
52
-
53
- class Base < ActiveResource::Base
54
- class << self
55
-
56
- def inherited(base)
57
- Mite.resources << base
58
- class << base
59
- attr_accessor :site_format
60
- end
61
- base.site_format = '%s'
62
- base.timeout = 20
63
- super
64
- end
65
-
66
- # Common shortcuts known from ActiveRecord
67
- def all(options={})
68
- find_every(options)
69
- end
70
-
71
- def first(options={})
72
- find_every(options).first
73
- end
74
-
75
- def last(options={})
76
- find_every(options).last
77
- end
78
-
79
- # Undo destroy action on the resource with the ID in the +id+ parameter.
80
- def undo_destroy(id)
81
- returning(self.new(:id => id)) { |res| res.undo_destroy }
82
- end
83
- end
84
-
85
- # Undo destroy action.
86
- def undo_destroy
87
- path = element_path(prefix_options).sub(/\.([\w]+)/, '/undo_delete.\1')
88
-
89
- returning connection.post(path, "", self.class.headers) do |response|
90
- load_attributes_from_response(response)
91
- end
92
- end
93
-
94
- end
95
-
96
- class Error < StandardError; end
97
- end
98
-
99
- require 'mite/customer'
100
- require 'mite/project'
101
- require 'mite/service'
102
- require 'mite/time_entry'
103
- require 'mite/time_entry_group'
104
- require 'mite/tracker'
105
- require 'mite/user'
@@ -1,9 +0,0 @@
1
- class Mite::Customer < Mite::Base
2
- def time_entries(options = {})
3
- TimeEntry.find(:all, :params => options.update(:customer_id => id))
4
- end
5
-
6
- def projects(options = {})
7
- Project.find(:all, :params => options.update(:customer_id => id))
8
- end
9
- end
@@ -1,16 +0,0 @@
1
- class Mite::Project < Mite::Base
2
-
3
- def time_entries(options = {})
4
- TimeEntry.find(:all, :params => options.update(:project_id => id))
5
- end
6
-
7
- def customer
8
- @customer ||= Customer.find(customer_id) unless customer_id.blank?
9
- end
10
-
11
- def customer=(customer)
12
- self.customer_id = customer ? customer.id : nil
13
- @customer = customer
14
- end
15
-
16
- end
@@ -1,7 +0,0 @@
1
- class Mite::Service < Mite::Base
2
-
3
- def time_entries(options = {})
4
- TimeEntry.find(:all, :params => options.update(:service_id => id))
5
- end
6
-
7
- end
@@ -1,54 +0,0 @@
1
- class Mite::TimeEntry < Mite::Base
2
-
3
- def service
4
- @service ||= Service.find(service_id) unless service_id.blank?
5
- end
6
-
7
- def service=(service)
8
- self.service_id = service ? service.id : nil
9
- @service = service
10
- end
11
-
12
- def project
13
- @project ||= Project.find(project_id) unless project_id.blank?
14
- end
15
-
16
- def project=(project)
17
- self.project_id = project ? project.id : nil
18
- @project = project
19
- end
20
-
21
- def customer
22
- @customer ||= begin
23
- p = project
24
- p.customer unless p.blank?
25
- end
26
- end
27
-
28
- def tracking?
29
- !!attributes["tracker"]
30
- end
31
-
32
- def start_tracker
33
- attributes["tracker"] = Mite::Tracker.start(id) || nil
34
- end
35
-
36
- def stop_tracker
37
- Mite::Tracker.stop if tracking?
38
- end
39
-
40
- def load(attr)
41
- super(attr)
42
- if attributes["tracking"]
43
- attributes["tracker"] = Mite::Tracker.new.load(attributes.delete("tracking").attributes)
44
- end
45
- self
46
- end
47
-
48
- class << self
49
- def find_every(options={})
50
- return super(options) if !options[:params] || !options[:params][:group_by]
51
- TimeEntryGroup.all(options)
52
- end
53
- end
54
- end
@@ -1,36 +0,0 @@
1
- class Mite::TimeEntryGroup < Mite::Base
2
- self.collection_name = "time_entries"
3
-
4
- attr_accessor :time_entries_params
5
-
6
- class << self
7
- def find_every(options={})
8
- return TimeEntry.all(options) if !options[:params] || !options[:params][:group_by]
9
-
10
- returning super(options) do |records|
11
- records.each do |record|
12
- if record.attributes["time_entries_params"]
13
- record.time_entries_params = record.attributes.delete("time_entries_params").attributes.stringify_keys
14
- end
15
- end
16
- end
17
- end
18
- end
19
-
20
- def time_entries(options={})
21
- return [] unless time_entries_params.is_a?(Hash)
22
-
23
- empty_result = false
24
-
25
- options[:params] ||= {}
26
- options[:params].stringify_keys!
27
- options[:params].merge!(time_entries_params) do |key, v1, v2|
28
- empty_result = (v1 != v2)
29
- v2
30
- end
31
-
32
- return [] if empty_result
33
-
34
- TimeEntry.all(options)
35
- end
36
- end
@@ -1,34 +0,0 @@
1
- class Mite::Tracker < Mite::Base
2
-
3
- self.collection_name = "tracker"
4
-
5
- def self.current
6
- tracking_time_entry = connection.get(collection_path, headers)["tracking_time_entry"]
7
- tracking_time_entry ? instantiate_record(tracking_time_entry) : nil
8
- end
9
-
10
- def self.start(time_entry_or_id)
11
- id = time_entry_or_id.is_a?(Mite::TimeEntry) ? time_entry_or_id.id : time_entry_or_id
12
- self.new(:id => id).start
13
- end
14
-
15
- def self.stop
16
- tracker = current
17
- tracker ? tracker.stop : false
18
- end
19
-
20
- def start
21
- response = connection.put(element_path(prefix_options), encode, self.class.headers)
22
- load(self.class.format.decode(response.body)["tracking_time_entry"])
23
- response.is_a?(Net::HTTPSuccess) ? self : false
24
- end
25
-
26
- def stop
27
- connection.delete(element_path, self.class.headers).is_a?(Net::HTTPSuccess) ? self : false
28
- end
29
-
30
- def time_entry
31
- Mite::TimeEntry.find(id)
32
- end
33
-
34
- end
@@ -1,19 +0,0 @@
1
- class Mite::User < Mite::Base
2
-
3
- def time_entries(options = {})
4
- TimeEntry.find(:all, :params => options.update(:user_id => id))
5
- end
6
-
7
- def save
8
- raise Error, "Cannot modify users over mite.api"
9
- end
10
-
11
- def create
12
- raise Error, "Cannot create users over mite.api"
13
- end
14
-
15
- def destroy
16
- raise Error, "Cannot destroy users over mite.api"
17
- end
18
-
19
- end