Overbryd-mighty-mite 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.
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.textile +156 -0
- data/Rakefile +23 -0
- data/TODO +4 -0
- data/VERSION +1 -0
- data/bin/mite +13 -0
- data/lib/mighty_mite/application.rb +169 -0
- data/lib/mighty_mite/autocomplete.rb +48 -0
- data/lib/mighty_mite.rb +34 -0
- data/lib/mite_ext.rb +53 -0
- data/lib/string_ext.rb +50 -0
- data/mighty-mite.gemspec +76 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/unit/mighty_mite/application_spec.rb +509 -0
- data/spec/unit/mighty_mite/autocomplete_spec.rb +100 -0
- data/spec/unit/mighty_mite_spec.rb +51 -0
- data/spec/unit/mite_ext_spec.rb +99 -0
- data/spec/unit/string_ext_spec.rb +67 -0
- data/vendor/yolk-mite-rb-0.0.3/CHANGES.txt +11 -0
- data/vendor/yolk-mite-rb-0.0.3/LICENSE +20 -0
- data/vendor/yolk-mite-rb-0.0.3/README.textile +70 -0
- data/vendor/yolk-mite-rb-0.0.3/Rakefile +24 -0
- data/vendor/yolk-mite-rb-0.0.3/VERSION.yml +4 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite/customer.rb +9 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite/project.rb +16 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite/service.rb +7 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry.rb +54 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb +36 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite/tracker.rb +34 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite/user.rb +19 -0
- data/vendor/yolk-mite-rb-0.0.3/lib/mite-rb.rb +105 -0
- metadata +90 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Mite, 'account_url' do
|
4
|
+
it "should return the url for this account" do
|
5
|
+
Mite.account = 'demo'
|
6
|
+
Mite.account_url.should == 'http://demo.mite.yo.lk'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Mite::TimeEntry, 'formatted_time' do
|
11
|
+
it "should output minutes formatted in h:mm" do
|
12
|
+
time_entry = Mite::TimeEntry.new
|
13
|
+
time_entry.stub!(:minutes).and_return 12
|
14
|
+
time_entry.formatted_time.should == '0:12'
|
15
|
+
time_entry.stub!(:minutes).and_return 2
|
16
|
+
time_entry.formatted_time.should == '0:02'
|
17
|
+
time_entry.stub!(:minutes).and_return 61
|
18
|
+
time_entry.formatted_time.should == '1:01'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should use the minutes from the tracker if there is a tracker running for this time entry" do
|
22
|
+
time_entry = Mite::TimeEntry.new
|
23
|
+
time_entry.stub!(:tracking?).and_return true
|
24
|
+
time_entry.stub!(:tracker).and_return stub('tracking', :minutes => 123)
|
25
|
+
time_entry.formatted_time.should == '2:03'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Mite::TimeEntry, 'formatted_revenue' do
|
30
|
+
it "should output the revenue in a readable money format" do
|
31
|
+
time_entry = Mite::TimeEntry.new
|
32
|
+
time_entry.stub!(:revenue).and_return 1050
|
33
|
+
time_entry.formatted_revenue.should == '10.50 $'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should output an empty string if revenue is nil" do
|
37
|
+
time_entry = Mite::TimeEntry.new
|
38
|
+
time_entry.revenue = nil
|
39
|
+
time_entry.formatted_revenue.should == ''
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe Mite::TimeEntry, 'inspect' do
|
44
|
+
before(:each) do
|
45
|
+
@time_entry = Mite::TimeEntry.new
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'with time' do
|
49
|
+
before(:each) do
|
50
|
+
@time_entry.stub!(:minutes).and_return 15
|
51
|
+
@time_entry.stub!(:revenue).and_return nil
|
52
|
+
@time_entry.stub!(:service).and_return nil
|
53
|
+
@time_entry.stub!(:project).and_return nil
|
54
|
+
@time_entry.stub!(:note).and_return nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should output the current formatted_minutes colorized in lightred" do
|
58
|
+
@time_entry.inspect.should == "\e[1;31;49m0:15\e[0m"
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'and revenue' do
|
62
|
+
it "should append the current formatted_revenue colorized in lightgreen" do
|
63
|
+
@time_entry.stub!(:revenue).and_return 1500
|
64
|
+
@time_entry.inspect.should be_include("\e[1;32;49m15.00 $\e[0m")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'and service' do
|
69
|
+
it "should append the service name" do
|
70
|
+
@time_entry.stub!(:service).and_return stub('service', :name => 'programming')
|
71
|
+
@time_entry.inspect.should be_include("doing programming")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'and project' do
|
76
|
+
it "should append the project name" do
|
77
|
+
@time_entry.stub!(:project).and_return stub('project', :name => 'mite command line client')
|
78
|
+
@time_entry.inspect.should be_include("for mite command line client")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'and a note' do
|
83
|
+
it "should append the note" do
|
84
|
+
@time_entry.stub!(:note).and_return 'would be more fun in pair programming'
|
85
|
+
@time_entry.inspect.should be_include("would be more fun in pair programming")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe Mite::Tracker, 'inspect' do
|
93
|
+
it "should call inspect on its time entry" do
|
94
|
+
time_entry = stub('time_entry')
|
95
|
+
Mite::TimeEntry.stub!(:find).and_return time_entry
|
96
|
+
time_entry.should_receive(:inspect)
|
97
|
+
Mite::Tracker.new.inspect
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe String, 'quote' do
|
4
|
+
it "should wrap a string in quotes" do
|
5
|
+
'Gimme quotes'.quote.should == '"Gimme quotes"'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe String, 'quote_if_spaced' do
|
10
|
+
it "should wrap a string in quotes if it contains spaces" do
|
11
|
+
'I want quotes'.quote_if_spaced.should == '"I want quotes"'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should leave the string unmodified if it doesn't contain spaces" do
|
15
|
+
'I_hate_spaces_and_quotes'.quote_if_spaced.should == 'I_hate_spaces_and_quotes'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe String, 'close_unmatched_quotes' do
|
20
|
+
it "should close unmatched quotes" do
|
21
|
+
'"arg '.close_unmatched_quotes.should == '"arg "'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should leave an healthy string intact" do
|
25
|
+
'I am happy.'.close_unmatched_quotes.should == 'I am happy.'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe String, 'colorize' do
|
30
|
+
describe 'defaults' do
|
31
|
+
it "should use default background" do
|
32
|
+
'1995'.colorize.should == "\e[0;39;49m1995\e[0m"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should use default foreground" do
|
36
|
+
'1995'.colorize.should == "\e[0;39;49m1995\e[0m"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should default to no effect" do
|
40
|
+
'1995'.colorize.should == "\e[0;39;49m1995\e[0m"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'empty string' do
|
45
|
+
it "should return the empty string" do
|
46
|
+
''.colorize.should == ''
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
[:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :default].each do |color|
|
51
|
+
it "should set #{color} as foreground color" do
|
52
|
+
'The seventies'.colorize(:color => color).should == "\e[0;#{String::BASH_COLOR[color]};49mThe seventies\e[0m"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should set #{color} as background color" do
|
56
|
+
'The eighties'.colorize(:background => color).should == "\e[0;39;#{String::BASH_COLOR[color]+10}mThe eighties\e[0m"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should set the effect code to bright with light#{color} as foreground" do
|
60
|
+
'The nineties'.colorize(:color => "light#{color}".to_sym).should == "\e[1;#{String::BASH_COLOR[color]};49mThe nineties\e[0m"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should take a foreground color like #{color} as shorthand argument" do
|
64
|
+
'The year 2000'.colorize(color.to_sym).should == "\e[0;#{String::BASH_COLOR[color]};49mThe year 2000\e[0m"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,20 @@
|
|
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.
|
@@ -0,0 +1,70 @@
|
|
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
|
+
|
@@ -0,0 +1,24 @@
|
|
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
|
@@ -0,0 +1,16 @@
|
|
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
|
@@ -0,0 +1,54 @@
|
|
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
|
@@ -0,0 +1,36 @@
|
|
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
|
@@ -0,0 +1,34 @@
|
|
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
|
@@ -0,0 +1,19 @@
|
|
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
|
@@ -0,0 +1,105 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'activesupport'
|
5
|
+
require 'activeresource'
|
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'
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Overbryd-mighty-mite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lukas Rieder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-22 00:00:00 -07:00
|
13
|
+
default_executable: mite
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A simple command line interface for mite, a sleek time tracking webapp.
|
17
|
+
email: l.rieder@gmail.com
|
18
|
+
executables:
|
19
|
+
- mite
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.textile
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- LICENSE
|
28
|
+
- README.textile
|
29
|
+
- Rakefile
|
30
|
+
- TODO
|
31
|
+
- VERSION
|
32
|
+
- bin/mite
|
33
|
+
- lib/mighty_mite.rb
|
34
|
+
- lib/mighty_mite/application.rb
|
35
|
+
- lib/mighty_mite/autocomplete.rb
|
36
|
+
- lib/mite_ext.rb
|
37
|
+
- lib/string_ext.rb
|
38
|
+
- mighty-mite.gemspec
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
- spec/unit/mighty_mite/application_spec.rb
|
41
|
+
- spec/unit/mighty_mite/autocomplete_spec.rb
|
42
|
+
- spec/unit/mighty_mite_spec.rb
|
43
|
+
- spec/unit/mite_ext_spec.rb
|
44
|
+
- spec/unit/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
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/Overbryd/mighty-mite
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --charset=UTF-8
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.2.0
|
81
|
+
signing_key:
|
82
|
+
specification_version: 2
|
83
|
+
summary: A simple command line interface for basic mite tasks.
|
84
|
+
test_files:
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- spec/unit/mighty_mite/application_spec.rb
|
87
|
+
- spec/unit/mighty_mite/autocomplete_spec.rb
|
88
|
+
- spec/unit/mighty_mite_spec.rb
|
89
|
+
- spec/unit/mite_ext_spec.rb
|
90
|
+
- spec/unit/string_ext_spec.rb
|