thyme_habitica 1.0.0
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.
- checksums.yaml +7 -0
- data/README.md +16 -0
- data/lib/thyme_habitica.rb +42 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34ca9abdcb3357447d903f273f0bc524b6278642ffd00dca11ec12b8207e1552
|
4
|
+
data.tar.gz: 7ad183b4056e4b1ab20e1eac302d53f360939f4c774c746acc4f98315db4c77d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4483588f9d1459600dde82f54fc61aafb563f42e3d703547d189e4563b6196e2e129217f55490cf76dd9feabe0499d78b7679b05ce5b7da58590936dcd46f52
|
7
|
+
data.tar.gz: d6cc50a3cddabe8caa3e9a0467a4898bf372cc1547fb0839ae248ebf4ce85d3cf3d2642fc56948f7771d0e8d8e40ca1d02e5ece715a6acd77277fb0a401ffe35
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# thyme_habitica
|
2
|
+
|
3
|
+
Is a plugin for [thyme pomodoro timer](https://github.com/hughbien/thyme), which scores tasks every time a pomodoro is successfully completed.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install thyme_habitica
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Require thyme_habitica in `~/.thymerc` and initialize plugins.
|
12
|
+
|
13
|
+
# ~/.thymerc
|
14
|
+
require 'thyme_habitica'
|
15
|
+
use ThymePluginHabitica
|
16
|
+
use ThymePluginHabitica, api_user: '11111111-1111-1111-1111-111111111111', api_key: '11111111-1111-1111-1111-111111111111', task_ids: ['11111111-1111-1111-1111-111111111111', '11111111-1111-1111-1111-111111111111']
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
class ThymePluginHabitica
|
5
|
+
def initialize(thyme, options={})
|
6
|
+
@thyme = thyme
|
7
|
+
@task_ids = options[:task_ids]
|
8
|
+
@api_url_base = "https://habitica.com/api/v3"
|
9
|
+
@api_headers = {'x-api-user': options[:api_user],
|
10
|
+
'x-api-key': options[:api_key]}
|
11
|
+
end
|
12
|
+
|
13
|
+
# Hooks
|
14
|
+
|
15
|
+
def after(seconds_left)
|
16
|
+
return if @thyme.break or seconds_left > 0
|
17
|
+
|
18
|
+
for task_id in @task_ids
|
19
|
+
score_task(task_id) if !get_task(task_id)['completed']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def get_task(task_id)
|
26
|
+
habitica_request(:get, "/tasks/#{task_id}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def score_task(task_id)
|
30
|
+
habitica_request(:post, "/tasks/#{task_id}/score/up")
|
31
|
+
end
|
32
|
+
|
33
|
+
def habitica_request(method, path)
|
34
|
+
response = RestClient::Request.execute(
|
35
|
+
'method': method,
|
36
|
+
'url': "#{@api_url_base}#{path}",
|
37
|
+
'headers': @api_headers
|
38
|
+
)
|
39
|
+
JSON.parse(response)['data']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thyme_habitica
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilya Shmygol
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: " A plugin for 'thyme' pomodoro timer, which scores tasks every time
|
28
|
+
a pomodoro is successfully completed.\n"
|
29
|
+
email:
|
30
|
+
- ishmygol@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- README.md
|
36
|
+
- lib/thyme_habitica.rb
|
37
|
+
homepage: https://github.com/trilliput/thyme_habitica
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.6
|
55
|
+
requirements: []
|
56
|
+
rubygems_version: 3.0.1
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Habitica plugin for thyme
|
60
|
+
test_files: []
|