trebbiatrice 0.2.3 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d64df67fc7516538b2c8bb487259796ec1b9caa2
4
- data.tar.gz: d90efeb9af9273c8df565e806189cbd87d0a89fd
3
+ metadata.gz: c8d9ec205fd99b391308137e51a7c121d5936a39
4
+ data.tar.gz: 953a6f7fe4a80c99d601f8a9aab204308f1c6bc9
5
5
  SHA512:
6
- metadata.gz: c73fe821ed0a263b480be8ebb2ed78046aaa805932c2cb52bb50cd5e1d0a262307321b2a134bb84b36424c9a038b6c928825ba8848c31007b55ffe1b5da2bb01
7
- data.tar.gz: 176f5472149147c85ebd5df0dca5713fe568e4a16944a57d8a2c140b1df280e45d2b9034ad189ab2886f393de279600bbce52aa5d1de60cdfb944827a69605ba
6
+ metadata.gz: 773ac236d2f72ee26635070c0d602338fe83fa022c39bc767f379737647fdda2d778a5c332ccac0cf3109c1f68b519214c0ba35454b910eb009b0e4621381098
7
+ data.tar.gz: 037494c92697ab0cda72032fd0d951a4ea515f60e6fb86f722798ed1b459d8805cb5c62919a34890bf184af545a26c562594af368979432133786d95f18d3c3b
@@ -18,8 +18,19 @@ module Trebbiatrice
18
18
  @harvest.time.trackable_projects
19
19
  end
20
20
 
21
- def new_entry!(entry)
22
- @harvest.time.create(entry)
21
+ def new_entry!(entry_data, find = true)
22
+ if find
23
+ entry = @harvest.time.all.select { |entry| entry[:project_id].to_s == entry_data[:project_id].to_s }.last
24
+
25
+ if entry
26
+ toggle!(entry[:id])
27
+ entry
28
+ else
29
+ new_entry!(entry_data, false)
30
+ end
31
+ else
32
+ @harvest.time.create(entry_data)
33
+ end
23
34
  end
24
35
 
25
36
  def toggle!(entry_id)
@@ -33,12 +33,8 @@ module Trebbiatrice
33
33
  def track!(task = 'Development', notes = '')
34
34
  return if tracking?
35
35
 
36
- if @entry
37
- @harvest.toggle!(@entry[:id])
38
- else
39
- task_id = get_task(task)[:id]
40
- @entry = @harvest.new_entry! notes: notes, hours: 0, spent_at: today, project_id: @project[:id], task_id: task_id
41
- end
36
+ task_id = get_task(task)[:id]
37
+ @entry = @harvest.new_entry! notes: notes, hours: 0, spent_at: today, project_id: @project[:id], task_id: task_id
42
38
 
43
39
  @tracking = true
44
40
  end
@@ -47,6 +43,7 @@ module Trebbiatrice
47
43
  if @entry && tracking?
48
44
  @tracking = false
49
45
  @harvest.toggle!(@entry[:id])
46
+ @entry = nil
50
47
  end
51
48
  end
52
49
 
@@ -19,14 +19,13 @@ module Trebbiatrice
19
19
  end.last
20
20
 
21
21
  if response[:status] == 'failure' || !trebbia.working_on
22
- if trebbia.tracking?
23
- puts "stopping #{trebbia.project[:name]}" if trebbia.project
24
- trebbia.stop_tracking!
25
- end
22
+ stop_tracking!(trebbia)
26
23
 
27
24
  last_project = nil
28
25
  else
29
26
  if trebbia.working_on && (last_project != trebbia.working_on || !trebbia.project)
27
+ stop_tracking!(trebbia)
28
+
30
29
  trebbia.project = trebbia.active_projects.last
31
30
  trebbia.track! task
32
31
 
@@ -38,5 +37,14 @@ module Trebbiatrice
38
37
  sleep frequency
39
38
  end
40
39
  end
40
+
41
+ private
42
+
43
+ def stop_tracking!(trebbia)
44
+ if trebbia.tracking?
45
+ puts "stopping #{trebbia.project[:name]}" if trebbia.project
46
+ trebbia.stop_tracking!
47
+ end
48
+ end
41
49
  end
42
50
  end
@@ -9,5 +9,5 @@
9
9
  #++
10
10
 
11
11
  module Trebbiatrice
12
- VERSION = '0.2.3'
12
+ VERSION = '0.3'
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trebbiatrice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-19 00:00:00.000000000 Z
11
+ date: 2015-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: harvested