tacgo 0.0.1

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 (6) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +29 -0
  4. data/bin/tacgo +106 -0
  5. data/tacgo.gemspec +24 -0
  6. metadata +90 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8c11881ceab4a0960318ed682550fc826107355
4
+ data.tar.gz: 203d1e210c915821127f9e6958a841a1e5162610
5
+ SHA512:
6
+ metadata.gz: b4f741275357053ae5b53d550289b744de6d30367528f502dc46ba7726435ff82c4f20d04df6d319ac01eb410c5a3ae96c97518447db92a65f77e71f87b47a18
7
+ data.tar.gz: 95bd8e9a5d6f6343e485fa369a6be096e49e62b95332d0b4828b3986531bd87af958da6beb4cec9f62f7e9b8108923eef397a82160905db990eff450fe127493
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Larry Marburger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # tacgo
2
+
3
+ Time and track pomodori against the top task in [Taco].
4
+
5
+ [taco]: https://tacoapp.com
6
+
7
+ ## Getting Started
8
+
9
+ It's still rough around the edges.
10
+
11
+ 1. Install the gem:
12
+
13
+ ```
14
+ $ gem install tacgo
15
+ ```
16
+
17
+ 2. Add your Taco credentials to `~/.netrc`.
18
+
19
+ ```
20
+ machine tacoapp.com
21
+ login larry@marburger.cc
22
+ password xxxxxxxxxxxxxxxxxxxx
23
+ ```
24
+
25
+ 3. Work!
26
+
27
+ ```
28
+ $ tacgo
29
+ ```
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'json'
5
+ require 'netrc'
6
+ require 'ruby-progressbar'
7
+ require 'yaml/store'
8
+
9
+ END { start }
10
+
11
+ class Credentials
12
+ attr_reader :netrc, :label
13
+
14
+ def initialize(netrc = Netrc.read, label = 'tacoapp.com')
15
+ @netrc = netrc
16
+ @label = label
17
+ end
18
+
19
+ def email
20
+ credentials.first
21
+ end
22
+
23
+ def password
24
+ credentials.last
25
+ end
26
+
27
+ private
28
+
29
+ def credentials
30
+ Array netrc[label]
31
+ end
32
+ end
33
+
34
+
35
+ Task = Struct.new(:id, :label) do
36
+ def self.parse(data)
37
+ Task.new(data['id'], data['label'])
38
+ end
39
+ end
40
+
41
+ Pomodoro = Struct.new(:task, :started, :completed) do
42
+ def start(store)
43
+ self.started = Time.now
44
+ store.transaction do
45
+ store['pomodori'] ||= []
46
+ store['pomodori'] << self
47
+ end
48
+ end
49
+
50
+ def complete(store)
51
+ store.transaction do
52
+ store['pomodori'].delete_if {|pomodoro| pomodoro == self }
53
+ self.completed = Time.now
54
+ store['pomodori'] << self
55
+ end
56
+ end
57
+ end
58
+
59
+
60
+ def start
61
+ task = fetch_top_task(agent)
62
+ pomodoro = Pomodoro.new(task)
63
+ pomodoro.start(store)
64
+
65
+ duration = 20 * 60
66
+ progress = ProgressBar.create(title: task.label[0..40], total: duration)
67
+
68
+ Thread.abort_on_exception = true
69
+ Thread.new(pomodoro, duration, progress) do |pomodoro, duration, progress|
70
+ while (now = Time.now) < pomodoro.started + duration
71
+ progress.progress = now - pomodoro.started
72
+ sleep 1
73
+ end
74
+ end.join
75
+ progress.finish
76
+
77
+ pomodoro.complete(store)
78
+ end
79
+
80
+ def store
81
+ @store ||= YAML::Store.new('tacgo.yaml')
82
+ end
83
+
84
+ def fetch_top_task(agent)
85
+ require 'mechanize'
86
+ agent = Mechanize.new
87
+ sign_in agent
88
+
89
+ Task.parse(JSON(agent.get('https://tacoapp.com/tasks.json').body)[0])
90
+ end
91
+
92
+ def signed_in?(page)
93
+ page.form_with(id: 'new_user').nil?
94
+ end
95
+
96
+ def sign_in(agent)
97
+ page = agent.get('https://tacoapp.com/tasks')
98
+ login_form = page.form_with(id: 'new_user')
99
+
100
+ credentials = Credentials.new
101
+ login_form.field_with(name: 'user[email]').value = credentials.email
102
+ login_form.field_with(name: 'user[password]').value = credentials.password
103
+ page = agent.submit(login_form)
104
+
105
+ raise 'bad credentials' unless signed_in?(page)
106
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'tacgo'
3
+ spec.version = '0.0.1'
4
+ spec.summary = 'Taco and Pomodoro'
5
+ spec.description = 'Time and track pomodori against the top task in Taco'
6
+ spec.authors = ['Larry Marburger']
7
+ spec.email = 'larry@marburger.cc'
8
+ spec.homepage = 'https://github.com/lmarburger/tacgo'
9
+ spec.licenses = ['MIT']
10
+
11
+ spec.add_dependency 'mechanize', '~> 2.7'
12
+ spec.add_dependency 'netrc', '~> 0.7'
13
+ spec.add_dependency 'ruby-progressbar', '~> 1.4'
14
+
15
+ spec.bindir = 'bin'
16
+ spec.executables = ['tacgo']
17
+
18
+ spec.files = %w(LICENSE README.md tacgo.gemspec)
19
+ spec.files += Dir.glob('bin/*')
20
+ spec.files += Dir.glob('lib/**/*.rb')
21
+ spec.files += Dir.glob('man/*')
22
+
23
+ spec.required_rubygems_version = '>= 1.3.6'
24
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tacgo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Larry Marburger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: netrc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ruby-progressbar
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ description: Time and track pomodori against the top task in Taco
56
+ email: larry@marburger.cc
57
+ executables:
58
+ - tacgo
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE
63
+ - README.md
64
+ - bin/tacgo
65
+ - tacgo.gemspec
66
+ homepage: https://github.com/lmarburger/tacgo
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.3.6
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.2.0
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Taco and Pomodoro
90
+ test_files: []