Pratt 1.5.6 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Pratt.gemspec +2 -2
- data/VERSION +1 -1
- data/models/pratt.rb +1 -1
- data/models/project.rb +1 -1
- data/models/whence.rb +1 -1
- data/spec/pratt_spec.rb +123 -117
- metadata +2 -2
data/Pratt.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{Pratt}
|
8
|
-
s.version = "1.5.
|
8
|
+
s.version = "1.5.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott Noel-Hemming"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-20}
|
13
13
|
s.default_executable = %q{pratt.rb}
|
14
14
|
s.description = %q{
|
15
15
|
Need a way to keep track of your time, but get caught up in work? Or constant interruptions?
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.8
|
data/models/pratt.rb
CHANGED
data/models/project.rb
CHANGED
data/models/whence.rb
CHANGED
data/spec/pratt_spec.rb
CHANGED
@@ -6,124 +6,130 @@ describe Pratt do
|
|
6
6
|
@pratt = Pratt.new
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
9
|
+
it "should act like an array" do
|
10
|
+
@pratt.should respond_to(:<<)
|
11
|
+
lambda {
|
12
|
+
@pratt << :this
|
13
|
+
}.should change(@pratt.todo, :size).by(1)
|
14
|
+
@pratt.todo.should == [:this]
|
15
|
+
end
|
16
|
+
|
17
|
+
it "correctly report i_should?" do
|
18
|
+
@pratt.send(:i_should?, :this).should be_false
|
19
|
+
@pratt << :this
|
20
|
+
@pratt.send(:i_should?, :this).should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should start a new project when calling begin" do
|
24
|
+
@pratt.project = mock('Refactor')
|
25
|
+
@pratt.when_to = Time.now
|
26
|
+
@pratt.project.expects(:start!).with(@pratt.when_to)
|
27
|
+
|
28
|
+
@pratt.begin
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should allow project to be set by object" do
|
32
|
+
primary = Project.new :name => 'project', :weight => 1
|
33
|
+
Project.expects(:find_or_create_by_name).never
|
34
|
+
@pratt.project = primary
|
35
|
+
@pratt.project.should == primary
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should allow project to be set by a string" do
|
39
|
+
Project.expects(:find_or_create_by_name).with( { :name => 'Refactor' } )
|
40
|
+
@pratt.project = 'Refactor'
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "color" do
|
44
|
+
|
45
|
+
it "should color when expected" do
|
46
|
+
Pratt.color = true
|
47
|
+
'this'.red.should == 'this'.red
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should not color when not expected" do
|
51
|
+
Pratt.color = false
|
52
|
+
'this'.red.should == 'this'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "\b#root" do
|
57
|
+
before :each do
|
58
|
+
Dir.stubs(:pwd).returns("/home/scott/git/pratt")
|
59
|
+
@expected_root = "/home/scott/git/pratt"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "is correct without arguments" do
|
63
|
+
Pratt.root.should == [Pathname.new(@expected_root)]
|
64
|
+
end
|
65
|
+
|
66
|
+
it "is correct with a block but no argument" do
|
67
|
+
received = []
|
68
|
+
Pratt.root {|model| received << model }
|
69
|
+
received.should == [Pathname.new(@expected_root)]
|
70
|
+
end
|
71
|
+
|
72
|
+
it "is correct with an argument but no block" do
|
73
|
+
Pratt.root('models').should == [Pathname.new(File.join(@expected_root, "models"))]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "is correct with an argument and block" do
|
77
|
+
received = []
|
78
|
+
Pratt.root('models', '*.rb') {|model| received << model }
|
79
|
+
received.to_set.should == %w(app.rb customer.rb project.rb payment.rb pratt.rb whence.rb).collect {|model| Pathname.new File.join(@expected_root, "models", model) }.to_set
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "graph" do
|
84
|
+
before :each do
|
85
|
+
@when_to = Chronic.parse('last week').beginning_of_week
|
86
|
+
@pratt.scale = 'week'
|
87
|
+
@pratt.when_to = @when_to
|
88
|
+
@customer = Customer.create :name => 'Bob Hope', :address => '123 Where St', :zip => '22222'
|
89
|
+
@tasks = []
|
90
|
+
end
|
91
|
+
|
92
|
+
after :each do
|
93
|
+
Whence.delete_all
|
94
|
+
@customer.destroy
|
95
|
+
@tasks.each(&:destroy)
|
96
|
+
end
|
97
|
+
|
98
|
+
def task name, time_spent
|
99
|
+
task = Project.find_or_create_by_name :name => name, :customer => @customer
|
100
|
+
task.start! @when_to
|
101
|
+
task.stop! @when_to+time_spent
|
102
|
+
@tasks << task
|
103
|
+
end
|
104
|
+
|
105
|
+
def populate_with_data
|
106
|
+
@tasks << Project.find_or_create_by_name( :name => '**** ********', :weight => 1, :customer => @customer )
|
107
|
+
task 'Lunch/Break', 1.hour+21.minutes
|
108
|
+
task 'Task1', 1.hour+4.minutes
|
109
|
+
task 'Task2', 58.minutes
|
110
|
+
task 'Another Task', 5.minutes
|
111
|
+
task 'Task3', 1.day+17.hours+32.minutes
|
112
|
+
end
|
113
|
+
|
114
|
+
def get_expected_display
|
115
|
+
e = ''
|
116
|
+
Pratt.root('spec', 'fixtures', 'graph.expectation') {|file| e = File.open(file).read }
|
117
|
+
e
|
118
|
+
end
|
119
|
+
|
120
|
+
it "report no data" do
|
121
|
+
Project.expects(:all).returns([])
|
122
|
+
@pratt.expects(:process_template!).never
|
123
|
+
@pratt.graph.should == "No data to report"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should look right with data" do
|
127
|
+
populate_with_data
|
122
128
|
# @pratt.expects(:process_template!)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
129
|
+
|
130
|
+
@pratt.graph.should == get_expected_display
|
131
|
+
end
|
132
|
+
end
|
127
133
|
|
128
134
|
describe "parse" do
|
129
135
|
it "handles cli arg -n setting appropriate environment config"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Pratt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Noel-Hemming
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-20 00:00:00 -07:00
|
13
13
|
default_executable: pratt.rb
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|