Pratt 1.5.6 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{Pratt}
8
- s.version = "1.5.6"
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-19}
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.6
1
+ 1.5.8
@@ -1,5 +1,5 @@
1
1
  class Pratt
2
- module Models
2
+ module TimeSpent
3
3
  def conditions_for_time_spent scale = nil, when_to = Time.now
4
4
  when_to = Chronic.parse(when_to) if when_to.is_a?(String)
5
5
  cond = ["end_at IS NOT NULL"]
@@ -1,7 +1,7 @@
1
1
  require 'models/pratt'
2
2
 
3
3
  class Project < ActiveRecord::Base
4
- include Pratt::Models
4
+ include Pratt::TimeSpent
5
5
  belongs_to :customer
6
6
 
7
7
  has_many :whences
@@ -35,7 +35,7 @@ class Whence < ActiveRecord::Base
35
35
  end
36
36
 
37
37
  class << self
38
- include Pratt::Models
38
+ include Pratt::TimeSpent
39
39
 
40
40
  def time_spent scale = nil, when_to = Time.now
41
41
  spent(self).call(scale, when_to)
@@ -6,124 +6,130 @@ describe Pratt do
6
6
  @pratt = Pratt.new
7
7
  end
8
8
 
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
- # @pratt.send( :red, 'this' ).should == 'this'.red
48
- # end
49
- #
50
- # it "should not color when not expected" do
51
- # @pratt.color = false
52
- # @pratt.send( :red, 'this' ).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 log.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
- # end
89
- #
90
- # after :each do
91
- # Whence.delete_all
92
- # end
93
- #
94
- #
95
- # def task name, time_spent
96
- # task1 = Project.find_or_create_by_name :name => name
97
- # task1.start! @when_to
98
- # task1.stop! @when_to+time_spent
99
- # end
100
- #
101
- # def populate_with_data
102
- # Project.find_or_create_by_name :name => '**** ********', :weight => 1
103
- # task 'Lunch/Break', 1.hour+21.minutes
104
- # task 'Task1', 1.hour+4.minutes
105
- # task 'Task2', 58.minutes
106
- # task 'Another Task', 5.minutes
107
- # task 'Task3', 1.day+17.hours+32.minutes
108
- # end
109
- #
110
- # def get_expected_display
111
- # Pratt.root('spec', 'fixtures', 'graph.expectation') {|file| File.open(file).read }
112
- # end
113
- #
114
- # it "report no data" do
115
- # Project.expects(:all).returns([])
116
- # @pratt.expects(:process_template!).never
117
- # @pratt.graph.should == "No data to report"
118
- # end
119
- #
120
- # it "should look right with data" do
121
- # populate_with_data
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
- # @pratt.graph.should == get_expected_display
125
- # end
126
- # end
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.6
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-19 00:00:00 -07:00
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