tracco 0.0.14 → 0.0.15

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.
Files changed (45) hide show
  1. data/CHANGELOG +16 -0
  2. data/Gemfile.lock +1 -1
  3. data/README.md +4 -4
  4. data/lib/patches/trello/card.rb +3 -2
  5. data/lib/patches/trello/member.rb +4 -2
  6. data/lib/tasks/tasks.rake +2 -2
  7. data/lib/tracco/google_docs_exporter.rb +50 -47
  8. data/lib/tracco/models/effort.rb +40 -0
  9. data/lib/tracco/models/estimate.rb +29 -0
  10. data/lib/tracco/models/member.rb +64 -0
  11. data/lib/tracco/models/tracked_card.rb +148 -0
  12. data/lib/tracco/tracking/base.rb +68 -65
  13. data/lib/tracco/tracking/card_done_tracking.rb +9 -6
  14. data/lib/tracco/tracking/effort_tracking.rb +32 -29
  15. data/lib/tracco/tracking/estimate_tracking.rb +16 -13
  16. data/lib/tracco/tracking/factory.rb +18 -16
  17. data/lib/tracco/tracking/invalid_tracking.rb +15 -13
  18. data/lib/tracco/trello_tracker.rb +34 -30
  19. data/lib/tracco/version.rb +2 -2
  20. data/lib/tracco.rb +4 -4
  21. data/spec/factories/effort_factory.rb +2 -2
  22. data/spec/factories/estimate_factory.rb +1 -1
  23. data/spec/factories/tracked_card_factory.rb +1 -1
  24. data/spec/integration/trello_tracker_spec.rb +49 -47
  25. data/spec/models/effort_spec.rb +61 -0
  26. data/spec/models/estimate_spec.rb +40 -0
  27. data/spec/models/member_spec.rb +83 -0
  28. data/spec/models/tracked_card_spec.rb +467 -0
  29. data/spec/support/spec_helper_methods.rb +7 -1
  30. data/spec/tracking/card_done_tracking_spec.rb +11 -9
  31. data/spec/tracking/effort_tracking_spec.rb +77 -75
  32. data/spec/tracking/estimate_tracking_spec.rb +30 -28
  33. data/spec/tracking/factory_spec.rb +39 -0
  34. data/spec/trello_tracker_spec.rb +20 -18
  35. data/tracco.gemspec +1 -1
  36. metadata +12 -12
  37. data/lib/tracco/effort.rb +0 -37
  38. data/lib/tracco/estimate.rb +0 -26
  39. data/lib/tracco/member.rb +0 -61
  40. data/lib/tracco/tracked_card.rb +0 -145
  41. data/spec/effort_spec.rb +0 -59
  42. data/spec/estimate_spec.rb +0 -38
  43. data/spec/member_spec.rb +0 -81
  44. data/spec/tracked_card_spec.rb +0 -465
  45. data/spec/tracking_factory_spec.rb +0 -42
@@ -1,114 +1,116 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Tracking
4
- describe EffortTracking do
3
+ module Tracco
4
+ module Tracking
5
+ describe EffortTracking do
5
6
 
6
- describe "#effort" do
7
+ describe "#effort" do
7
8
 
8
- %w{pietrodibello michelepangrazzi alessandrodescovi michelevincenzi}.each do |username|
9
- let(username.to_sym) { Member.new(username: username) }
10
- end
11
-
12
- before(:each) do
13
- Trello::Member.stub(:find).and_return(Member.new(username: "any"))
14
- end
15
-
16
- it "is nil when the notification does not contain an estimate" do
17
- with(unrecognized_notification) { |tracking| tracking.effort.should be_nil }
18
- end
9
+ %w{pietrodibello michelepangrazzi alessandrodescovi michelevincenzi}.each do |username|
10
+ let(username.to_sym) { Member.new(username: username) }
11
+ end
19
12
 
20
- it "does not parse effort in minutes (e.g. +30m)" do
21
- with_message("@trackinguser +30m") { |tracking| tracking.effort.should be_nil }
22
- end
13
+ before(:each) do
14
+ Trello::Member.stub(:find).and_return(Member.new(username: "any"))
15
+ end
23
16
 
24
- it "is the hour-based effort when the notification contains an effort in hours" do
25
- Trello::Member.should_receive(:find).with("michelepangrazzi").and_return(michelepangrazzi)
17
+ it "is nil when the notification does not contain an estimate" do
18
+ with(unrecognized_notification) { |tracking| tracking.effort.should be_nil }
19
+ end
26
20
 
27
- raw_data = create_notification(data: { 'text' => "@trackinguser +2h" },
28
- date: "2012-10-28T21:06:14.801Z",
29
- member_creator: stub(username: "michelepangrazzi"))
21
+ it "does not parse effort in minutes (e.g. +30m)" do
22
+ with_message("@trackinguser +30m") { |tracking| tracking.effort.should be_nil }
23
+ end
30
24
 
31
- Tracking::Factory.build_from(raw_data).effort.should == Effort.new(amount: 2.0, date: Date.parse('2012-10-28'), members: [michelepangrazzi])
32
- end
25
+ it "is the hour-based effort when the notification contains an effort in hours" do
26
+ Trello::Member.should_receive(:find).with("michelepangrazzi").and_return(michelepangrazzi)
33
27
 
34
- it "converts the effort in hours when the notification contains an effort in days" do
35
- with_message("@trackinguser +1.5d") { |t| t.effort.amount.should == 8+4 }
36
- with_message("@trackinguser +1.5g") { |t| t.effort.amount.should == 8+4 }
37
- end
28
+ raw_data = create_notification(data: { 'text' => "@trackinguser +2h" },
29
+ date: "2012-10-28T21:06:14.801Z",
30
+ member_creator: stub(username: "michelepangrazzi"))
38
31
 
39
- it "converts the effort in hours when the notification contains an effort in pomodori" do
40
- with_message("@trackinguser +10p") { |t| t.effort.amount.should == 5}
41
- end
32
+ Tracking::Factory.build_from(raw_data).effort.should == Effort.new(amount: 2.0, date: Date.parse('2012-10-28'), members: [michelepangrazzi])
33
+ end
42
34
 
43
- it "fetch the effort from a complex effort message" do
44
- with_message "@trackinguser ho speso +2h e spero che stavolta possiamo rilasciarla" do |tracking|
45
- tracking.effort.amount.should == 2.0
35
+ it "converts the effort in hours when the notification contains an effort in days" do
36
+ with_message("@trackinguser +1.5d") { |t| t.effort.amount.should == 8+4 }
37
+ with_message("@trackinguser +1.5g") { |t| t.effort.amount.should == 8+4 }
46
38
  end
47
- end
48
39
 
49
- it "fetch the effort even when beween square brackets" do
50
- with_message "@trackinguser [+0.5h]" do |tracking|
51
- tracking.effort.amount.should == 0.5
40
+ it "converts the effort in hours when the notification contains an effort in pomodori" do
41
+ with_message("@trackinguser +10p") { |t| t.effort.amount.should == 5}
52
42
  end
53
- end
54
43
 
55
- it "computes the effort considering all the mentioned team mates in the message" do
56
- with_message "@trackinguser +2h assieme a @michelepangrazzi e @alessandrodescovi" do |tracking|
57
- tracking.effort.amount.should == 2.0 * 3
44
+ it "fetch the effort from a complex effort message" do
45
+ with_message "@trackinguser ho speso +2h e spero che stavolta possiamo rilasciarla" do |tracking|
46
+ tracking.effort.amount.should == 2.0
47
+ end
58
48
  end
59
- end
60
49
 
61
- it "tracks all the team mates which spent that effort on the card" do
62
- %w{pietrodibello michelepangrazzi alessandrodescovi}.each do |username|
63
- Trello::Member.should_receive(:find).with(username).and_return(self.send(username))
50
+ it "fetch the effort even when beween square brackets" do
51
+ with_message "@trackinguser [+0.5h]" do |tracking|
52
+ tracking.effort.amount.should == 0.5
53
+ end
64
54
  end
65
55
 
66
- notification = create_notification(data: { 'text' => "@trackinguser +2h assieme a @michelepangrazzi e @alessandrodescovi" },
67
- member_creator: stub(username: "pietrodibello"))
68
- with notification do |tracking|
69
- tracking.effort.members.should == [michelepangrazzi, alessandrodescovi, pietrodibello]
56
+ it "computes the effort considering all the mentioned team mates in the message" do
57
+ with_message "@trackinguser +2h assieme a @michelepangrazzi e @alessandrodescovi" do |tracking|
58
+ tracking.effort.amount.should == 2.0 * 3
59
+ end
70
60
  end
71
- end
72
61
 
73
- it "tracks the effort only on the team members listed between round brackets" do
74
- %w{michelevincenzi alessandrodescovi}.each do |username|
75
- Trello::Member.should_receive(:find).with(username).and_return(self.send(username))
62
+ it "tracks all the team mates which spent that effort on the card" do
63
+ %w{pietrodibello michelepangrazzi alessandrodescovi}.each do |username|
64
+ Trello::Member.should_receive(:find).with(username).and_return(self.send(username))
65
+ end
66
+
67
+ notification = create_notification(data: { 'text' => "@trackinguser +2h assieme a @michelepangrazzi e @alessandrodescovi" },
68
+ member_creator: stub(username: "pietrodibello"))
69
+ with notification do |tracking|
70
+ tracking.effort.members.should == [michelepangrazzi, alessandrodescovi, pietrodibello]
71
+ end
76
72
  end
77
73
 
78
- notification = create_notification(data: { 'text' => "@trackinguser +3p (@alessandrodescovi @michelevincenzi)" },
79
- member_creator: stub(username: "pietrodibello"))
74
+ it "tracks the effort only on the team members listed between round brackets" do
75
+ %w{michelevincenzi alessandrodescovi}.each do |username|
76
+ Trello::Member.should_receive(:find).with(username).and_return(self.send(username))
77
+ end
78
+
79
+ notification = create_notification(data: { 'text' => "@trackinguser +3p (@alessandrodescovi @michelevincenzi)" },
80
+ member_creator: stub(username: "pietrodibello"))
80
81
 
81
- with notification do |tracking|
82
- tracking.effort.members.should == [alessandrodescovi, michelevincenzi]
83
- tracking.effort.amount.should == 1.5 * 2
82
+ with notification do |tracking|
83
+ tracking.effort.members.should == [alessandrodescovi, michelevincenzi]
84
+ tracking.effort.amount.should == 1.5 * 2
85
+ end
84
86
  end
85
- end
86
87
 
87
- it "tracks the effort with the date given in the notification text, not the actual notification date" do
88
- raw_data = create_notification(data: { 'text' => "@trackinguser 22.11.2012 +6p" }, date: "2012-09-19T12:46:13.713Z")
88
+ it "tracks the effort with the date given in the notification text, not the actual notification date" do
89
+ raw_data = create_notification(data: { 'text' => "@trackinguser 22.11.2012 +6p" }, date: "2012-09-19T12:46:13.713Z")
89
90
 
90
- tracking = Tracking::Factory.build_from(raw_data)
91
+ tracking = Tracking::Factory.build_from(raw_data)
91
92
 
92
- tracking.effort.date.should == Date.parse('2012-11-22')
93
- end
93
+ tracking.effort.date.should == Date.parse('2012-11-22')
94
+ end
94
95
 
95
- it "tracks the effort to yesterday when the keyword 'yesterday' is present before the effort amount" do
96
- raw_data = create_notification(data: { 'text' => "@trackinguser yesterday +6p" }, date: "2012-09-19T12:46:13.713Z")
96
+ it "tracks the effort to yesterday when the keyword 'yesterday' is present before the effort amount" do
97
+ raw_data = create_notification(data: { 'text' => "@trackinguser yesterday +6p" }, date: "2012-09-19T12:46:13.713Z")
97
98
 
98
- tracking = Tracking::Factory.build_from(raw_data)
99
+ tracking = Tracking::Factory.build_from(raw_data)
99
100
 
100
- tracking.effort.date.should == Date.parse('2012-09-18')
101
- end
101
+ tracking.effort.date.should == Date.parse('2012-09-18')
102
+ end
102
103
 
103
- it "tracks the effort to yesterday when the keyword 'yesterday' is present before the effort amount" do
104
- raw_data = create_notification(data: { 'text' => "@trackinguser +6p yesterday" }, date: "2012-09-19T12:46:13.713Z")
104
+ it "tracks the effort to yesterday when the keyword 'yesterday' is present before the effort amount" do
105
+ raw_data = create_notification(data: { 'text' => "@trackinguser +6p yesterday" }, date: "2012-09-19T12:46:13.713Z")
105
106
 
106
- tracking = Tracking::Factory.build_from(raw_data)
107
+ tracking = Tracking::Factory.build_from(raw_data)
108
+
109
+ tracking.effort.date.should == Date.parse('2012-09-18')
110
+ end
107
111
 
108
- tracking.effort.date.should == Date.parse('2012-09-18')
109
112
  end
110
113
 
111
114
  end
112
-
113
115
  end
114
116
  end
@@ -1,44 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Tracking
4
- describe EstimateTracking do
3
+ module Tracco
4
+ module Tracking
5
+ describe EstimateTracking do
5
6
 
6
- describe "#estimate" do
7
+ describe "#estimate" do
7
8
 
8
- it "is nil when the notification does not contain an estimate" do
9
- Tracking::Factory.build_from(unrecognized_notification).estimate.should be_nil
10
- end
9
+ it "is nil when the notification does not contain an estimate" do
10
+ Tracking::Factory.build_from(unrecognized_notification).estimate.should be_nil
11
+ end
11
12
 
12
- it "is the hour-based estimate when the notification contains an estimate in hours" do
13
- raw_data = create_notification(data: { 'text' => "@trackinguser [2h]" }, date: "2012-10-28T21:06:14.801Z")
13
+ it "is the hour-based estimate when the notification contains an estimate in hours" do
14
+ raw_data = create_notification(data: { 'text' => "@trackinguser [2h]" }, date: "2012-10-28T21:06:14.801Z")
14
15
 
15
- Tracking::Factory.build_from(raw_data).estimate.should == Estimate.new(amount: 2.0, date: Date.parse('2012-10-28'))
16
- end
16
+ Tracking::Factory.build_from(raw_data).estimate.should == Estimate.new(amount: 2.0, date: Date.parse('2012-10-28'))
17
+ end
17
18
 
18
- it "converts the estimate in hours when the notification contains an estimate in days" do
19
- Tracking::Factory.build_from(create_notification(data: { 'text' => "@trackinguser [1.5d]" })).estimate.amount.should == 8+4
20
- Tracking::Factory.build_from(create_notification(data: { 'text' => "@trackinguser [1.5g]" })).estimate.amount.should == 8+4
21
- end
19
+ it "converts the estimate in hours when the notification contains an estimate in days" do
20
+ Tracking::Factory.build_from(create_notification(data: { 'text' => "@trackinguser [1.5d]" })).estimate.amount.should == 8+4
21
+ Tracking::Factory.build_from(create_notification(data: { 'text' => "@trackinguser [1.5g]" })).estimate.amount.should == 8+4
22
+ end
22
23
 
23
- it "converts the estimate in hours when the notification contains an estimate in pomodori" do
24
- raw_data = create_notification(data: { 'text' => "@trackinguser [10p]" })
25
- Tracking::Factory.build_from(raw_data).estimate.amount.should == 5
26
- end
24
+ it "converts the estimate in hours when the notification contains an estimate in pomodori" do
25
+ raw_data = create_notification(data: { 'text' => "@trackinguser [10p]" })
26
+ Tracking::Factory.build_from(raw_data).estimate.amount.should == 5
27
+ end
27
28
 
28
- it "fetch the estimate from a complex estimate message" do
29
- raw_data = create_notification(data: { 'text' => "@maxmazza Dobbiamo ancora lavorarci.\n@trackinguser ristimo ancora [3h] per il fix" })
30
- Tracking::Factory.build_from(raw_data).estimate.amount.should == 3.0
31
- end
29
+ it "fetch the estimate from a complex estimate message" do
30
+ raw_data = create_notification(data: { 'text' => "@maxmazza Dobbiamo ancora lavorarci.\n@trackinguser ristimo ancora [3h] per il fix" })
31
+ Tracking::Factory.build_from(raw_data).estimate.amount.should == 3.0
32
+ end
32
33
 
33
- it "tracks the effort with the date given in the notification text, not the actual notification date" do
34
- raw_data = create_notification( data: { 'text' => "@trackinguser 22.11.2012 [6p]" }, date: "2012-09-19T12:46:13.713Z")
34
+ it "tracks the effort with the date given in the notification text, not the actual notification date" do
35
+ raw_data = create_notification( data: { 'text' => "@trackinguser 22.11.2012 [6p]" }, date: "2012-09-19T12:46:13.713Z")
35
36
 
36
- tracking = Tracking::Factory.build_from(raw_data)
37
+ tracking = Tracking::Factory.build_from(raw_data)
37
38
 
38
- tracking.estimate.date.should == Date.parse('2012-11-22')
39
- end
39
+ tracking.estimate.date.should == Date.parse('2012-11-22')
40
+ end
40
41
 
42
+ end
41
43
  end
42
- end
43
44
 
45
+ end
44
46
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ module Tracco
4
+ module Tracking
5
+ describe Factory do
6
+
7
+ context "unknown tracking format" do
8
+ it "builds an invalid tracking instance" do
9
+ Tracking::Factory.build_from(unrecognized_notification).class.should == Tracking::InvalidTracking
10
+
11
+ with_message("@trackinguser +30m") { |tracking| tracking.class.should == Tracking::InvalidTracking }
12
+ end
13
+ end
14
+
15
+ TIME_MEASUREMENTS.each_key do |time_measurement|
16
+
17
+ context "estimate tracking notification in #{time_measurement}" do
18
+ it "builds an estimate tracking instance" do
19
+ Tracking::Factory.build_from(create_estimate(time_measurement)).class.should == Tracking::EstimateTracking
20
+ end
21
+ end
22
+
23
+ context "effort tracking notification in #{time_measurement}" do
24
+ it "builds an effort tracking instance" do
25
+ Tracking::Factory.build_from(create_effort(time_measurement)).class.should == Tracking::EffortTracking
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ context "card done tracking notification" do
32
+ it "builds a card done tracking instance" do
33
+ with_message("@trackinguser DONE") { |tracking| tracking.class.should == Tracking::CardDoneTracking }
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -1,26 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe TrelloTracker do
3
+ module Tracco
4
+ describe TrelloTracker do
4
5
 
5
- before(:each) do
6
- @original = ENV["tracker_username"]
7
- ENV["tracker_username"] = "my_tracker"
8
- end
9
-
10
- after(:each) do
11
- ENV["tracker_username"] = @original
12
- end
13
-
14
- it "force the trello tracker username in the constructor" do
15
- tracker = TrelloTracker.new(tracker_username: "any_other_tracker")
6
+ before(:each) do
7
+ @original = ENV["tracker_username"]
8
+ ENV["tracker_username"] = "my_tracker"
9
+ end
16
10
 
17
- tracker.tracker_username.should == "any_other_tracker"
18
- end
11
+ after(:each) do
12
+ ENV["tracker_username"] = @original
13
+ end
19
14
 
20
- it "takes the tracker username from the ENV var tracker_username" do
21
- tracker = TrelloTracker.new
15
+ it "force the trello tracker username in the constructor" do
16
+ tracker = TrelloTracker.new(tracker_username: "any_other_tracker")
22
17
 
23
- tracker.tracker_username.should == "my_tracker"
24
- end
18
+ tracker.tracker_username.should == "any_other_tracker"
19
+ end
25
20
 
21
+ it "takes the tracker username from the ENV var tracker_username" do
22
+ tracker = TrelloTracker.new
23
+
24
+ tracker.tracker_username.should == "my_tracker"
25
+ end
26
+
27
+ end
26
28
  end
data/tracco.gemspec CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../lib/tracco/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "tracco"
6
- gem.version = TrelloEffortTracker::VERSION
6
+ gem.version = Tracco::VERSION
7
7
  gem.platform = Gem::Platform::RUBY
8
8
 
9
9
  gem.description = "Tracco is a Trello effort tracker: the purpose of Tracco is to extract and track estimates and actual efforts out of the cards on your Trello boards."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-27 00:00:00.000000000 Z
12
+ date: 2013-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-trello
@@ -262,12 +262,12 @@ files:
262
262
  - lib/tasks/rspec.rake
263
263
  - lib/tasks/tasks.rake
264
264
  - lib/tracco.rb
265
- - lib/tracco/effort.rb
266
- - lib/tracco/estimate.rb
267
265
  - lib/tracco/google_docs_exporter.rb
268
- - lib/tracco/member.rb
266
+ - lib/tracco/models/effort.rb
267
+ - lib/tracco/models/estimate.rb
268
+ - lib/tracco/models/member.rb
269
+ - lib/tracco/models/tracked_card.rb
269
270
  - lib/tracco/mongoid_helper.rb
270
- - lib/tracco/tracked_card.rb
271
271
  - lib/tracco/tracking/base.rb
272
272
  - lib/tracco/tracking/card_done_tracking.rb
273
273
  - lib/tracco/tracking/effort_tracking.rb
@@ -282,23 +282,23 @@ files:
282
282
  - script/ci/run_build.sh
283
283
  - script/crontab.template
284
284
  - script/mate.sh
285
- - spec/effort_spec.rb
286
- - spec/estimate_spec.rb
287
285
  - spec/factories/effort_factory.rb
288
286
  - spec/factories/estimate_factory.rb
289
287
  - spec/factories/tracked_card_factory.rb
290
288
  - spec/integration/trello_authorization_spec.rb
291
289
  - spec/integration/trello_tracker_spec.rb
292
- - spec/member_spec.rb
290
+ - spec/models/effort_spec.rb
291
+ - spec/models/estimate_spec.rb
292
+ - spec/models/member_spec.rb
293
+ - spec/models/tracked_card_spec.rb
293
294
  - spec/patches/trello/card_spec.rb
294
295
  - spec/spec_helper.rb
295
296
  - spec/support/database_cleaner.rb
296
297
  - spec/support/spec_helper_methods.rb
297
- - spec/tracked_card_spec.rb
298
298
  - spec/tracking/card_done_tracking_spec.rb
299
299
  - spec/tracking/effort_tracking_spec.rb
300
300
  - spec/tracking/estimate_tracking_spec.rb
301
- - spec/tracking_factory_spec.rb
301
+ - spec/tracking/factory_spec.rb
302
302
  - spec/trello_authorize_spec.rb
303
303
  - spec/trello_configuration_spec.rb
304
304
  - spec/trello_tracker_spec.rb
@@ -318,7 +318,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
318
318
  version: '0'
319
319
  segments:
320
320
  - 0
321
- hash: -1097737159014714198
321
+ hash: -2610639466740555589
322
322
  required_rubygems_version: !ruby/object:Gem::Requirement
323
323
  none: false
324
324
  requirements:
data/lib/tracco/effort.rb DELETED
@@ -1,37 +0,0 @@
1
- class Effort
2
- include Mongoid::Document
3
- include Mongoid::Timestamps
4
- include Mongoid::MultiParameterAttributes
5
-
6
- field :amount, type: BigDecimal
7
- field :date, type: Date
8
- field :tracking_notification_id
9
- field :muted, type: Boolean, default: false
10
-
11
- embeds_many :members
12
- embedded_in :tracked_card
13
-
14
- default_scope where(muted: false).asc(:date)
15
-
16
- validates_presence_of :amount, :date, :members
17
-
18
- def amount_per_member
19
- amount / members.size
20
- end
21
-
22
- def include?(member)
23
- members.include?(member)
24
- end
25
-
26
- def ==(other)
27
- return true if other.equal?(self)
28
- return false unless other.kind_of?(self.class)
29
-
30
- amount == other.amount && date == other.date && Set.new(members) == Set.new(other.members)
31
- end
32
-
33
- def to_s
34
- "[#{date}] spent #{amount} hours by #{members.map(&:at_username).join(", ")}"
35
- end
36
-
37
- end
@@ -1,26 +0,0 @@
1
- class Estimate
2
- include Mongoid::Document
3
- include Mongoid::Timestamps
4
- include Mongoid::MultiParameterAttributes
5
-
6
- field :amount, type: BigDecimal
7
- field :date, type: Date
8
- field :tracking_notification_id
9
-
10
- embedded_in :tracked_card
11
-
12
- default_scope asc(:date)
13
-
14
- validates_presence_of :amount, :date
15
-
16
- def ==(other)
17
- return true if other.equal?(self)
18
- return false unless other.kind_of?(self.class)
19
-
20
- amount == other.amount && date == other.date
21
- end
22
-
23
- def to_s
24
- "[#{date}] estimated #{amount} hours"
25
- end
26
- end
data/lib/tracco/member.rb DELETED
@@ -1,61 +0,0 @@
1
- class Member
2
- include Mongoid::Document
3
- include Mongoid::Timestamps
4
-
5
- field :trello_id
6
- field :username
7
- field :full_name
8
- field :avatar_id
9
- field :bio
10
- field :url
11
-
12
- embedded_in :effort
13
-
14
- validates_presence_of :username
15
-
16
- def self.build_from(trello_member)
17
- trello_member_id = trello_member.id
18
- trello_member.attributes.delete(:id)
19
- new(trello_member.attributes.merge(trello_id: trello_member_id))
20
- end
21
-
22
- def at_username
23
- "@#{username}"
24
- end
25
-
26
- def avatar_url
27
- trello_member.avatar_url(size: :small)
28
- end
29
-
30
- def effort_spent(from_date=nil)
31
- cards = TrackedCard.with_effort_spent_by(username)
32
- efforts = cards.map(&:efforts).compact.flatten
33
- efforts = efforts.select {|e| e.date >= from_date} if from_date
34
- efforts.select { |effort| effort.include?(self) }.inject(0) { |total, effort| total + effort.amount_per_member }
35
- end
36
- alias_method :effort_spent_since, :effort_spent
37
-
38
- def ==(other)
39
- return true if other.equal?(self)
40
- return false unless other.kind_of?(self.class)
41
-
42
- username == other.username
43
- end
44
-
45
- def eql?(other)
46
- return false unless other.instance_of?(self.class)
47
- username == other.username
48
- end
49
-
50
- def hash
51
- username.hash
52
- end
53
-
54
- private
55
-
56
- def trello_member
57
- @trello_member ||= Trello::Member.new("id" => trello_id, "fullName" => full_name, "username" => username,
58
- "avatarHash" => avatar_id, "bio" => bio, "url" => url)
59
- end
60
-
61
- end