trebbiatrice 0.1.1 → 0.2

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: 7f36f3a5a8bdc961ee820b3dbc1830a415ce6522
4
- data.tar.gz: b3c3ac3a922887524d75ecfda177ef76e62cf079
3
+ metadata.gz: a80063d2dc3e210891f3e8ce8c69a90cc35528dd
4
+ data.tar.gz: 0f26c4d8765e4cdaa50631b1e99c25dd8dc16189
5
5
  SHA512:
6
- metadata.gz: 2ff17b760c18a93835548bb575765ebe4866a7cae3714554a74ba517be2f9a7cd04767d9f52038070d76651a647d81dfceca43d11231cafdb45faa30d5d2cdb5
7
- data.tar.gz: 65265c68ed1836fc590e9fc951b5707032521dca75d8729399b1965aaeff69ba6fc8bab6f2e4b7433dd5765422b371e4471b16f037d74b922f98db478bd86cf9
6
+ metadata.gz: 62693076e41d52c1acfc8b159a8f759020f53a1f14547a9408b1398dbf523468977d1ce16f4c4e148b56db6f77c05802c425450cff3cc4c0864f0bf258044cb3
7
+ data.tar.gz: adfc713277f1f482af215e8bdc37fd13d2ef8f003ae61d7e5474c98e2e24d4a3548d6271a9d79854483686093dfe75bb903ed3248015de82ac767e749d4d7752
data/bin/trebbiatrice CHANGED
@@ -26,4 +26,4 @@ testata = {
26
26
  :name => File.join(File.dirname(__FILE__), 'testate/osx/sublime.scpt')
27
27
  }
28
28
 
29
- Trebbiatrice::Trebbia.new(login_data).run! testata, task, frequency
29
+ Trebbiatrice.run! login_data, task, testata, frequency
@@ -10,7 +10,7 @@
10
10
 
11
11
  module Trebbiatrice
12
12
  class Trebbia
13
- attr_accessor :working_on
13
+ attr_accessor :working_on, :project
14
14
 
15
15
  def initialize(login_data)
16
16
  @harvest = Harvest.new(login_data)
@@ -18,9 +18,11 @@ module Trebbiatrice
18
18
  @tracking = false
19
19
  end
20
20
 
21
- def get_task(name)
22
- @project = active_projects.last unless @project
21
+ def active_projects
22
+ @harvest.projects.select { |project| /#{project[:name]}/i.match(@working_on) }
23
+ end
23
24
 
25
+ def get_task(name)
24
26
  @project.tasks.select { |t| t.name == name }.last
25
27
  end
26
28
 
@@ -48,42 +50,6 @@ module Trebbiatrice
48
50
  !!@tracking
49
51
  end
50
52
 
51
- def active_projects
52
- @harvest.projects.select { |project| /#{project[:name]}/i.match(@working_on) }
53
- end
54
-
55
- def run!(task, testata, frequency)
56
- last_project, project = nil
57
-
58
- loop do
59
- response = Trebbia.invoke!(testata[:engine], testata[:name])
60
- @working_on = response[:contents].select do |content|
61
- @working_on = content
62
- active_projects.any?
63
- end.last
64
-
65
- if response[:status] == 'failure' || !@working_on
66
- if tracking?
67
- p "stopping #{project[:name]}" if project
68
- stop_tracking!
69
- end
70
-
71
- last_project = nil
72
- sleep frequency
73
- else
74
- if @working_on && (last_project != @working_on || !project)
75
- last_project = @working_on
76
- track!(task)
77
-
78
- project = active_projects.last
79
- p "tracking #{project[:name]}"
80
- end
81
-
82
- sleep frequency
83
- end
84
- end
85
- end
86
-
87
53
  class << self
88
54
  def invoke!(*input)
89
55
  stdin, stdout, stderr = Open3.popen3(*input)
@@ -0,0 +1,36 @@
1
+ module Trebbiatrice
2
+ class << self
3
+ def run!(login_data, task, testata, frequency)
4
+ trebbia = Trebbia.new(login_data)
5
+ last_project, project = nil
6
+
7
+ loop do
8
+ response = Trebbia.invoke!(testata[:engine], testata[:name])
9
+
10
+ trebbia.working_on = response[:contents].select do |content|
11
+ trebbia.working_on = content
12
+ trebbia.active_projects.any?
13
+ end.last
14
+
15
+ if response[:status] == 'failure' || !trebbia.working_on
16
+ if trebbia.tracking?
17
+ p "stopping #{trebbia.project[:name]}" if trebbia.project
18
+ trebbia.stop_tracking!
19
+ end
20
+
21
+ last_project = nil
22
+ else
23
+ if trebbia.working_on && (last_project != trebbia.working_on || !trebbia.project)
24
+ trebbia.project = trebbia.active_projects.last
25
+ trebbia.track! task
26
+
27
+ last_project = trebbia.working_on
28
+ p "tracking #{trebbia.project[:name]}"
29
+ end
30
+ end
31
+
32
+ sleep frequency
33
+ end
34
+ end
35
+ end
36
+ end
@@ -9,5 +9,5 @@
9
9
  #++
10
10
 
11
11
  module Trebbiatrice
12
- VERSION = '0.1.1'
12
+ VERSION = '0.2'
13
13
  end
data/lib/trebbiatrice.rb CHANGED
@@ -13,4 +13,5 @@ require 'harvested'
13
13
 
14
14
  require 'trebbiatrice/harvest.rb'
15
15
  require 'trebbiatrice/trebbia.rb'
16
+ require 'trebbiatrice/trebbiatrice.rb'
16
17
  require 'trebbiatrice/version.rb'
data/trebbiatrice.gemspec CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.version = Trebbiatrice::VERSION
6
6
  s.author = 'Giovanni Capuano'
7
7
  s.email = 'webmaster@giovannicapuano.net'
8
- s.homepage = 'https://github.com/RoxasShadow/Trebbiatrice'
8
+ s.homepage = 'https://github.com/mozestudio/Trebbiatrice'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.summary = "Track the time on Harvest automatically watching what you're working on."
11
11
  s.description = "Track the time on Harvest automatically watching what you're working on. So you've just to work without thinking about starting and stopping the tracker."
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.1.1
4
+ version: '0.2'
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-07 00:00:00.000000000 Z
11
+ date: 2015-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: harvested
@@ -42,9 +42,10 @@ files:
42
42
  - lib/trebbiatrice.rb
43
43
  - lib/trebbiatrice/harvest.rb
44
44
  - lib/trebbiatrice/trebbia.rb
45
+ - lib/trebbiatrice/trebbiatrice.rb
45
46
  - lib/trebbiatrice/version.rb
46
47
  - trebbiatrice.gemspec
47
- homepage: https://github.com/RoxasShadow/Trebbiatrice
48
+ homepage: https://github.com/mozestudio/Trebbiatrice
48
49
  licenses:
49
50
  - WTFPL
50
51
  metadata: {}