rtt 0.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ require 'lib/rtt'
@@ -0,0 +1,106 @@
1
+ require 'mocha'
2
+ require File.join( File.dirname(__FILE__), '..', '..', 'datamapper_spec_helper')
3
+
4
+ describe Rtt::Task do
5
+
6
+ before do
7
+ Rtt.init(:test)
8
+ Rtt.migrate
9
+ @task_name = 'a_name'
10
+ @now = Time.now
11
+ end
12
+
13
+ describe '#duration' do
14
+
15
+ context 'task has start_at: 2010-05-10 13:45' do
16
+
17
+ before do
18
+ start_at = Time.parse('May 10 13:45:00 2010', @now)
19
+ @task = Rtt::Task.create :name => @task_name, :start_at => start_at.to_datetime, :date => start_at.to_date
20
+ end
21
+
22
+ context 'task has end_at: 2010-05-10 14:15:01' do
23
+
24
+ before do
25
+ now = Time.now
26
+ @end_at = Time.parse('May 10 14:15:01 2010', @now)
27
+ DateTime.stubs(:now => @end_at)
28
+ Date.stubs(:today => @end_at.to_date)
29
+ @task.stop
30
+ end
31
+
32
+ it 'should return 0h30m' do
33
+ @task.duration.should == '0h30m'
34
+ end
35
+ end
36
+
37
+ context 'task has end_at: 2010-05-10 15:20:01' do
38
+
39
+ before do
40
+ @end_at = Time.parse('May 10 15:20:01 2010', @now)
41
+ DateTime.stubs(:now => @end_at)
42
+ Date.stubs(:today => @end_at.to_date)
43
+ @task.stop
44
+ end
45
+
46
+ it 'should return 1h35m' do
47
+ @task.duration.should == '1h35m'
48
+ end
49
+ end
50
+
51
+ context 'task has end_at: 2010-05-11 15:20:01' do
52
+
53
+ before do
54
+ @end_at = Time.parse('May 11 15:20:00 2010', @now)
55
+ DateTime.stubs(:now => @end_at)
56
+ Date.stubs(:today => @end_at.to_date)
57
+ @task.stop
58
+ end
59
+
60
+ it 'should have 2 tasks with the same name' do
61
+ Rtt::Task.all(:name => @task_name).length.should == 2
62
+ end
63
+
64
+ it 'should return 11h15m for 2010-05-10' do
65
+ date = Time.parse('2010-05-10', @now).to_date
66
+ task = Rtt::Task.first(:name => @task_name, :date => date)
67
+ task.duration.should == '10h14m'
68
+ end
69
+
70
+ it 'should return 14h35m' do
71
+ @task.duration.should == '15h19m'
72
+ end
73
+ end
74
+
75
+ context 'task has end_at: 2010-05-12 15:20:01' do
76
+
77
+ before do
78
+ @end_at = Time.parse('May 12 15:20:00 2010', @now)
79
+ DateTime.stubs(:now => @end_at)
80
+ Date.stubs(:today => @end_at.to_date)
81
+ @task.stop
82
+ end
83
+
84
+ it 'should have 3 tasks with the same name' do
85
+ Rtt::Task.all(:name => @task_name).length.should == 3
86
+ end
87
+
88
+ it 'should return 11h15m for 2010-05-11' do
89
+ date = Time.parse('2010-05-11', @now).to_date
90
+ task = Rtt::Task.first(:name => @task_name, :date => date)
91
+ task.duration.should == '23h59m'
92
+ end
93
+
94
+ it 'should return 11h15m for 2010-05-10' do
95
+ date = Time.parse('2010-05-10', @now).to_date
96
+ task = Rtt::Task.first(:name => @task_name, :date => date)
97
+ task.duration.should == '10h14m'
98
+ end
99
+
100
+ it 'should return 14h35m' do
101
+ @task.duration.should == '15h19m'
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,186 @@
1
+ require File.join( File.dirname(__FILE__), '..', 'datamapper_spec_helper')
2
+
3
+ describe Rtt do
4
+
5
+ before do
6
+ Rtt.init(:test)
7
+ Rtt.migrate
8
+ end
9
+
10
+ describe '#set_project' do
11
+
12
+ it 'should set the project as current at system-level' do
13
+ Rtt.set_project 'project_name'
14
+ Rtt::Project.first(:active => true).name.should == 'project_name'
15
+ end
16
+
17
+ end
18
+
19
+ describe '#set_client' do
20
+
21
+ it 'should set the client as current at system-level' do
22
+ Rtt.set_client 'client_name'
23
+ Rtt::Client.first(:active => true).name.should == 'client_name'
24
+ end
25
+
26
+ end
27
+
28
+ describe '#rename' do
29
+
30
+ describe 'when there is no current task' do
31
+
32
+ it 'should not create a task' do
33
+ Rtt.start 'development_task'
34
+ Rtt::Task.all.length == 0
35
+ end
36
+
37
+ end
38
+ end
39
+
40
+ describe '#start' do
41
+
42
+ describe 'when there is no current task' do
43
+
44
+ it 'should start a task for the name given' do
45
+ Rtt.start 'development_task'
46
+ task = Rtt::Task.first(:name => 'development_task')
47
+ task.should_not be_nil
48
+ end
49
+
50
+ end
51
+
52
+ describe 'when there is a current task' do
53
+
54
+ before do
55
+ @current_task = Rtt::Task.create :name => 'older_task', :start_at => Date.today.beginning_of_day, :active => true
56
+ end
57
+
58
+ it 'should create a new task' do
59
+ task = Rtt.start 'development_task'
60
+ Rtt::Task.all.length.should == 2
61
+ end
62
+
63
+ it 'should change end_at of older_task' do
64
+ @end_at = @current_task.end_at
65
+ Rtt.start 'development_task'
66
+ Rtt::Task.first(:name => 'development_task').end_at.should == @end_at
67
+ end
68
+
69
+ it 'should change set active to false of older_task' do
70
+ Rtt.start 'development_task'
71
+ Rtt::Task.first(:name => 'development_task').active.should be_true
72
+ end
73
+
74
+ describe 'task name is passed' do
75
+
76
+ it 'should use name and desciption if present' do
77
+ task = Rtt.start 'development_task'
78
+ task.name.should == 'development_task'
79
+ end
80
+ end
81
+
82
+ describe 'task name is absent' do
83
+
84
+ it 'should use use the existing active task' do
85
+ task = Rtt.start
86
+ task.name.should == 'older_task'
87
+ end
88
+ end
89
+ end
90
+
91
+ describe 'with default active project and client' do
92
+
93
+ it 'should reference the default client' do
94
+ task = Rtt.start 'development_task'
95
+ task.client.name.should == Rtt::Client::DEFAULT_NAME
96
+ end
97
+
98
+ it 'should reference the default project' do
99
+ task = Rtt.start 'development_task'
100
+ task.project.name.should == Rtt::Project::DEFAULT_NAME
101
+ end
102
+ end
103
+
104
+ describe 'with custom active project and client' do
105
+
106
+ before do
107
+ @client = Rtt.set_client 'custom_client'
108
+ @project = Rtt.set_project 'custom_project'
109
+ end
110
+
111
+ end
112
+ end
113
+
114
+ describe '#stop' do
115
+
116
+ describe 'when there is a current task' do
117
+
118
+ before do
119
+ Rtt::Task.create :name => 'older_task', :start_at => Date.today.beginning_of_day, :active => true
120
+ end
121
+
122
+ it 'should finish the task' do
123
+ Rtt.stop
124
+ Rtt::Task.first(:name => 'older_task').active.should be_false
125
+ end
126
+ end
127
+
128
+ describe 'when there is no current task' do
129
+
130
+ it 'should not raise an exception' do
131
+ lambda {
132
+ Rtt.stop
133
+ }.should_not raise_error
134
+ end
135
+
136
+ it 'should keep the same number of Tasks' do
137
+ Rtt.stop
138
+ Rtt::Task.all.length.should be_zero
139
+ end
140
+ end
141
+ end
142
+
143
+ describe '#rename' do
144
+
145
+ describe 'When there is a current task' do
146
+
147
+ before do
148
+ @current_task = Rtt::Task.create :name => 'older_task', :start_at => Date.today.beginning_of_day, :active => true
149
+ end
150
+
151
+ it 'should change the name' do
152
+ @id = @current_task.id
153
+ Rtt.rename 'newer_task'
154
+ Rtt::Task.get(@id).name.should == 'newer_task'
155
+ end
156
+
157
+ it 'should keep the number of tasks' do
158
+ counter = Rtt::Task.all.length
159
+ Rtt.rename 'newer_task'
160
+ Rtt::Task.all.length.should == counter
161
+ end
162
+ end
163
+
164
+ describe 'When there is NO current task' do
165
+
166
+ it 'should not create a new task' do
167
+ Rtt.rename 'newer_task'
168
+ Rtt::Task.all.length.should be_zero
169
+ end
170
+ end
171
+ end
172
+
173
+ describe '#report' do
174
+
175
+ it 'should call report_for_csv when :pdf is recevied' do
176
+ Rtt.should_receive(:report_to_pdf).with('/somepath')
177
+ Rtt.report :pdf => '/somepath'
178
+ end
179
+
180
+ it 'should call report_for_csv when :csv is recevied' do
181
+ pending
182
+ Rtt.should_receive(:report_to_csv).with('/somepath_csv')
183
+ Rtt.report :csv => '/somepath_csv'
184
+ end
185
+ end
186
+ end
data/tasks/rtt.rake ADDED
@@ -0,0 +1,66 @@
1
+ require 'rake/clean'
2
+ require 'fileutils'
3
+ require 'date'
4
+ require 'spec/rake/spectask'
5
+ require 'mocha'
6
+ require 'hanna/rdoctask'
7
+
8
+ # Removes spec task defiened in dependency gems
9
+ module Rake
10
+ def self.remove_task(task_name)
11
+ Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
12
+ end
13
+ end
14
+ Rake.remove_task 'spec'
15
+
16
+ def source_version
17
+ line = File.read('lib/rtt.rb')[/^\s*VERSION = .*/]
18
+ line.match(/.*VERSION = '(.*)'/)[1]
19
+ end
20
+
21
+ # SPECS ===============================================================
22
+
23
+ Spec::Rake::SpecTask.new(:spec) do |t|
24
+ t.spec_opts = ['--color']
25
+ t.rcov = false
26
+ t.spec_files = FileList['spec/lib/*_spec.rb', 'spec/lib/rtt/*_spec.rb']
27
+ end
28
+
29
+ task :default => :spec
30
+
31
+ # Rcov ================================================================
32
+ namespace :spec do
33
+ desc 'Mesures test coverage'
34
+ task :coverage do
35
+ rm_f "coverage"
36
+ rcov = "rcov --text-summary -Ilib"
37
+ system("#{rcov} --no-html --no-color spec/lib/*_spec.rb")
38
+ end
39
+ end
40
+
41
+ # Website =============================================================
42
+ # Building docs requires HAML and the hanna gem:
43
+ # gem install mislav-hanna --source=http://gems.github.com
44
+
45
+ desc 'Generate RDoc under doc/api'
46
+ task 'doc' => ['doc:api']
47
+
48
+ task 'doc:api' => ['doc/api/index.html']
49
+
50
+ file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
51
+ require 'rbconfig'
52
+ hanna = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'hanna')
53
+ rb_files = f.prerequisites
54
+ sh((<<-end).gsub(/\s+/, ' '))
55
+ #{hanna}
56
+ --charset utf8
57
+ --fmt html
58
+ --inline-source
59
+ --line-numbers
60
+ --main README.rdoc
61
+ --op doc/api
62
+ --title 'RTT API Documentation'
63
+ #{rb_files.join(' ')}
64
+ end
65
+ end
66
+ CLEAN.include 'doc/api'
data/todo.txt ADDED
@@ -0,0 +1,3 @@
1
+ 1) Acomodar la firma del user en el pdf
2
+ 2) Un script para inicializar el user
3
+ 1) Hacer q el current project cambie el client
metadata ADDED
@@ -0,0 +1,207 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtt
3
+ version: !ruby/object:Gem::Version
4
+ hash: 77
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ - 1
11
+ version: 0.0.0.1
12
+ platform: ruby
13
+ authors:
14
+ - Marcelo Giorgi
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-06-19 00:00:00 -03:00
20
+ default_executable: rtt
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: highline
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 7
31
+ segments:
32
+ - 1
33
+ - 5
34
+ - 2
35
+ version: 1.5.2
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: activesupport
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 2
49
+ - 3
50
+ - 0
51
+ version: 2.3.0
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: prawn
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 63
63
+ segments:
64
+ - 0
65
+ - 8
66
+ - 0
67
+ version: 0.8.0
68
+ type: :runtime
69
+ version_requirements: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ name: dm-core
72
+ prerelease: false
73
+ requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 23
79
+ segments:
80
+ - 1
81
+ - 0
82
+ - 0
83
+ version: 1.0.0
84
+ type: :runtime
85
+ version_requirements: *id004
86
+ - !ruby/object:Gem::Dependency
87
+ name: dm-migrations
88
+ prerelease: false
89
+ requirement: &id005 !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 23
95
+ segments:
96
+ - 1
97
+ - 0
98
+ - 0
99
+ version: 1.0.0
100
+ type: :runtime
101
+ version_requirements: *id005
102
+ - !ruby/object:Gem::Dependency
103
+ name: spec
104
+ prerelease: false
105
+ requirement: &id006 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ type: :development
115
+ version_requirements: *id006
116
+ description: RTT is a tool for tracking time
117
+ email: marklazz.uy@gmail.com
118
+ executables:
119
+ - rtt
120
+ extensions: []
121
+
122
+ extra_rdoc_files:
123
+ - LICENSE
124
+ - README.rdoc
125
+ - bin/rtt
126
+ - lib/rtt.rb
127
+ - lib/rtt/client.rb
128
+ - lib/rtt/cmd_line_interpreter.rb
129
+ - lib/rtt/hash_extensions.rb
130
+ - lib/rtt/project.rb
131
+ - lib/rtt/query_builder.rb
132
+ - lib/rtt/report_generator.rb
133
+ - lib/rtt/storage.rb
134
+ - lib/rtt/task.rb
135
+ - lib/rtt/user.rb
136
+ - lib/rtt/user_configurator.rb
137
+ - tasks/rtt.rake
138
+ files:
139
+ - LICENSE
140
+ - Manifest
141
+ - README.rdoc
142
+ - Rakefile
143
+ - USAGE.txt
144
+ - bin/rtt
145
+ - db/rtt.sqlite3
146
+ - db/test.sqlite3
147
+ - init.sh
148
+ - lib/rtt.rb
149
+ - lib/rtt/client.rb
150
+ - lib/rtt/cmd_line_interpreter.rb
151
+ - lib/rtt/hash_extensions.rb
152
+ - lib/rtt/project.rb
153
+ - lib/rtt/query_builder.rb
154
+ - lib/rtt/report_generator.rb
155
+ - lib/rtt/storage.rb
156
+ - lib/rtt/task.rb
157
+ - lib/rtt/user.rb
158
+ - lib/rtt/user_configurator.rb
159
+ - rtt.gemspec
160
+ - rtt_report
161
+ - spec/datamapper_spec_helper.rb
162
+ - spec/lib/rtt/task_spec.rb
163
+ - spec/lib/rtt_spec.rb
164
+ - tasks/rtt.rake
165
+ - todo.txt
166
+ has_rdoc: true
167
+ homepage: http://www.marklazz.com
168
+ licenses: []
169
+
170
+ post_install_message:
171
+ rdoc_options:
172
+ - --line-numbers
173
+ - --inline-source
174
+ - --title
175
+ - Rtt
176
+ - --main
177
+ - README.rdoc
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ hash: 3
186
+ segments:
187
+ - 0
188
+ version: "0"
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ hash: 11
195
+ segments:
196
+ - 1
197
+ - 2
198
+ version: "1.2"
199
+ requirements: []
200
+
201
+ rubyforge_project: rtt
202
+ rubygems_version: 1.3.7
203
+ signing_key:
204
+ specification_version: 3
205
+ summary: RTT is a tool for tracking time
206
+ test_files: []
207
+