tsks 0.0.2 → 0.0.6
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 +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +2 -4
- data/README.md +21 -16
- data/lib/tsks/actions.rb +10 -0
- data/lib/tsks/cli.rb +81 -38
- data/lib/tsks/request.rb +7 -1
- data/lib/tsks/storage.rb +34 -0
- data/lib/tsks/version.rb +1 -1
- data/lib/tsks.rb +0 -1
- data/tsks.gemspec +1 -2
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db9ce658ad547edd5932aef5cf8915bfec4ecf2cffa432fdc9c6682e1626a7de
|
4
|
+
data.tar.gz: d4bd382ab9592760d95af9e0640518ba811c9a353ca045b9d0a3bffa264479c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 480d699bdc149396e4e1cf716173dda23fb3f0506ceb8a0f911c35f4ed980b4567a7aa18ee6d0153e636d799448c80dac2520fd2d41cd195635197f17f38cbd4
|
7
|
+
data.tar.gz: e97aae640703c31732a1582d16c65351ef0c1868f9f13ccfdd1cc1397559509330e4023300bc199a30cd40674e57451ee055ef808110787902dd9eac76b95a22
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tsks (0.0.
|
4
|
+
tsks (0.0.6)
|
5
5
|
httparty
|
6
6
|
sqlite3
|
7
7
|
thor
|
@@ -11,7 +11,6 @@ GEM
|
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
13
|
diff-lcs (1.4.4)
|
14
|
-
dotenv (2.7.6)
|
15
14
|
httparty (0.18.1)
|
16
15
|
mime-types (~> 3.0)
|
17
16
|
multi_xml (>= 0.5.2)
|
@@ -45,7 +44,6 @@ PLATFORMS
|
|
45
44
|
ruby
|
46
45
|
|
47
46
|
DEPENDENCIES
|
48
|
-
dotenv (~> 2.7.6)
|
49
47
|
httparty (~> 0.18.1)
|
50
48
|
rake (~> 12.0)
|
51
49
|
rspec (~> 3.0)
|
@@ -55,4 +53,4 @@ DEPENDENCIES
|
|
55
53
|
uuid (~> 2.3.9)
|
56
54
|
|
57
55
|
BUNDLED WITH
|
58
|
-
2.
|
56
|
+
2.2.22
|
data/README.md
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
# tsks
|
1
|
+
# tsks
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
A stateful command line interface to help you handle your daily tsks (with
|
4
|
+
synchronisation and contexts!).
|
5
|
+
|
6
|
+
[](https://travis-ci.com/luanrvmood/tsks)
|
5
7
|
|
6
8
|
## Features
|
7
9
|
|
8
10
|
* Add tsks, check what is already done and list active or archived tsks
|
9
|
-
*
|
10
|
-
|
11
|
-
|
11
|
+
* Synchronise your tsks and access them from all your terminals!
|
12
|
+
(soon accessible from a webapp as well)
|
13
|
+
* Increase your daily tsks management with contexts using
|
14
|
+
`tsks add tsk --context=today` (see `tsks help add` for more info)
|
12
15
|
|
13
16
|
## Installation
|
14
17
|
|
@@ -20,8 +23,8 @@ gem install tsks
|
|
20
23
|
|
21
24
|
After follow the step above you should be able to run `tsks` from your terminal.
|
22
25
|
|
23
|
-
_It's important to notice that you will need to run `tsks init`
|
24
|
-
|
26
|
+
_It's important to notice that you will need to run `tsks init` to setup stuffs
|
27
|
+
like the storage before any other command._
|
25
28
|
|
26
29
|
### Adding new tsks
|
27
30
|
|
@@ -32,13 +35,13 @@ tsks add "My first tsk"
|
|
32
35
|
**Adding with context**
|
33
36
|
|
34
37
|
```sh
|
35
|
-
tsks add "Bootstraps my pet project environment --context=
|
38
|
+
tsks add "Bootstraps my pet project environment" --context=Today
|
36
39
|
```
|
37
40
|
|
38
|
-
###
|
41
|
+
### Marking tsks as done
|
39
42
|
|
40
43
|
```sh
|
41
|
-
tsks done 2 # Where 2 is the id
|
44
|
+
tsks done 2 # Where 2 is the tsk id
|
42
45
|
```
|
43
46
|
|
44
47
|
### Listing your tsks
|
@@ -50,7 +53,7 @@ tsks list
|
|
50
53
|
**Filtering by context**
|
51
54
|
|
52
55
|
```sh
|
53
|
-
tsks list --context=
|
56
|
+
tsks list --context=Today
|
54
57
|
```
|
55
58
|
|
56
59
|
**Or tsks already done**
|
@@ -61,11 +64,11 @@ tsks list --done
|
|
61
64
|
**Tip:** It's possible to combine the flags `--done` and `--context` when
|
62
65
|
listing.
|
63
66
|
|
64
|
-
###
|
67
|
+
### Synchronising your tsks
|
65
68
|
|
66
69
|
As easy as running `tsks sync`. This command will fetch your tsks from the API,
|
67
|
-
then filter what is not
|
68
|
-
local tsks with most recent data.
|
70
|
+
then filter what is not synchronised yet from local, then update both
|
71
|
+
remote and local tsks with most recent data.
|
69
72
|
|
70
73
|
#### To be able to sync you will need to login or register an account
|
71
74
|
|
@@ -87,7 +90,9 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
87
90
|
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
88
91
|
prompt that will allow you to experiment.
|
89
92
|
|
90
|
-
To install this gem onto your local machine, run `bundle exec rake install
|
93
|
+
To install this gem onto your local machine, run `bundle exec rake install`
|
94
|
+
(This command installs the current tsks version **v0.0.2** in your machine
|
95
|
+
path).
|
91
96
|
|
92
97
|
## Contributing
|
93
98
|
|
data/lib/tsks/actions.rb
CHANGED
@@ -9,5 +9,15 @@ module Tsks
|
|
9
9
|
Tsks::Storage.update tsk[:local_id], {user_id: uuid}
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.update_server_for_removed_tsks token
|
14
|
+
tsks_uuids = Tsks::Storage.select_removed_uuids
|
15
|
+
|
16
|
+
if !tsks_uuids.empty?
|
17
|
+
for id in tsks_uuids
|
18
|
+
Tsks::Request.delete "/tsks/#{id}", token
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
data/lib/tsks/cli.rb
CHANGED
@@ -6,12 +6,21 @@ require "tsks/actions"
|
|
6
6
|
|
7
7
|
module Tsks
|
8
8
|
class CLI < Thor
|
9
|
-
@setup_folder = File.expand_path
|
9
|
+
@setup_folder = File.expand_path "~/.tsks"
|
10
10
|
|
11
11
|
def self.setup_folder
|
12
12
|
@setup_folder
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.setup_folder= folder_path
|
16
|
+
@setup_folder = folder_path
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "version", ""
|
20
|
+
def version
|
21
|
+
puts "tsks #{Tsks::VERSION}"
|
22
|
+
end
|
23
|
+
|
15
24
|
desc "init", "Setup tsks folder and storage"
|
16
25
|
def init
|
17
26
|
if File.directory? CLI.setup_folder
|
@@ -82,16 +91,22 @@ module Tsks
|
|
82
91
|
return puts "tsks was not initialized yet."
|
83
92
|
end
|
84
93
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
94
|
+
begin
|
95
|
+
res = Tsks::Request.post "/register", {email: options[:email],
|
96
|
+
password: options[:password]}
|
97
|
+
|
98
|
+
if res && res[:ok] == true
|
99
|
+
File.write File.join(CLI.setup_folder, "token"), res[:token]
|
100
|
+
File.write File.join(CLI.setup_folder, "user_id"), res[:user_id]
|
101
|
+
Tsks::Actions.update_tsks_with_uuid res[:user_id]
|
102
|
+
puts "Succesfully registered."
|
103
|
+
elsif res && res[:ok] == false
|
104
|
+
puts "This e-mail is already registered."
|
105
|
+
end
|
106
|
+
rescue Errno::ECONNREFUSED, SocketError
|
107
|
+
puts "Failed to connect to the API."
|
108
|
+
rescue JSON::ParserError
|
109
|
+
puts "Error on reading data from the API."
|
95
110
|
end
|
96
111
|
end
|
97
112
|
|
@@ -103,16 +118,22 @@ module Tsks
|
|
103
118
|
return puts "tsks was not initialized yet."
|
104
119
|
end
|
105
120
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
121
|
+
begin
|
122
|
+
res = Tsks::Request.post "/login", {email: options[:email],
|
123
|
+
password: options[:password]}
|
124
|
+
|
125
|
+
if res && res[:ok] == true
|
126
|
+
File.write File.join(CLI.setup_folder, "token"), res[:token]
|
127
|
+
File.write File.join(CLI.setup_folder, "user_id"), res[:user_id]
|
128
|
+
Tsks::Actions.update_tsks_with_uuid res[:user_id]
|
129
|
+
puts "Succesfully logged in."
|
130
|
+
elsif res && res[:ok] == false
|
131
|
+
puts "Invalid e-mail or password."
|
132
|
+
end
|
133
|
+
rescue Errno::ECONNREFUSED, SocketError
|
134
|
+
puts "Failed to connect to the API."
|
135
|
+
rescue JSON::ParserError
|
136
|
+
puts "Error on reading data from the API."
|
116
137
|
end
|
117
138
|
end
|
118
139
|
|
@@ -127,30 +148,52 @@ module Tsks
|
|
127
148
|
end
|
128
149
|
|
129
150
|
user_id = File.read File.join CLI.setup_folder, "user_id"
|
151
|
+
token = File.read File.join CLI.setup_folder, "token"
|
130
152
|
Tsks::Actions.update_tsks_with_uuid user_id
|
153
|
+
Tsks::Actions.update_server_for_removed_tsks token
|
154
|
+
Tsks::Storage.delete_removed_uuids
|
131
155
|
local_tsks = Tsks::Storage.select_all local_id=false
|
132
156
|
|
133
|
-
token = File.read File.join CLI.setup_folder, "token"
|
134
|
-
get_res = Tsks::Request.get "/tsks", token
|
135
157
|
remote_tsks = []
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
158
|
+
begin
|
159
|
+
get_res = Tsks::Request.get "/tsks", token
|
160
|
+
if get_res[:tsks]
|
161
|
+
for tsk in get_res[:tsks]
|
162
|
+
tsk[:created_at] = Time.parse(tsk[:created_at]).strftime "%F %T"
|
163
|
+
tsk[:updated_at] = Time.parse(tsk[:updated_at]).strftime "%F %T"
|
164
|
+
remote_tsks.append tsk
|
165
|
+
end
|
166
|
+
|
167
|
+
if get_res[:ok] == true
|
168
|
+
local_tsks_to_post = local_tsks - remote_tsks
|
169
|
+
if local_tsks_to_post.count > 0
|
170
|
+
Tsks::Request.post "/tsks", token, {tsks: local_tsks_to_post}
|
171
|
+
end
|
172
|
+
|
173
|
+
remote_tsks_to_storage = remote_tsks - local_tsks
|
174
|
+
if remote_tsks_to_storage.count > 0
|
175
|
+
Tsks::Storage.insert_many remote_tsks_to_storage
|
176
|
+
end
|
177
|
+
|
178
|
+
puts "Your tsks were succesfully synchronized."
|
179
|
+
end
|
146
180
|
end
|
181
|
+
rescue Errno::ECONNREFUSED, SocketError
|
182
|
+
puts "Failed to connect to the API."
|
183
|
+
rescue JSON::ParserError
|
184
|
+
puts "Error on reading data from the API."
|
185
|
+
end
|
186
|
+
end
|
147
187
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
188
|
+
desc "remove ID", "..."
|
189
|
+
def remove id
|
190
|
+
if !File.directory? CLI.setup_folder
|
191
|
+
return puts "tsks was not initialized yet."
|
192
|
+
end
|
152
193
|
|
153
|
-
|
194
|
+
op_status = Tsks::Storage.delete id
|
195
|
+
if !op_status
|
196
|
+
puts "The specified tsk do not exist."
|
154
197
|
end
|
155
198
|
end
|
156
199
|
end
|
data/lib/tsks/request.rb
CHANGED
@@ -2,7 +2,7 @@ require "httparty"
|
|
2
2
|
|
3
3
|
module Tsks
|
4
4
|
class Request
|
5
|
-
@base_uri =
|
5
|
+
@base_uri = "https://tsks-api.herokuapp.com/v1"
|
6
6
|
|
7
7
|
def self.base_uri
|
8
8
|
@base_uri
|
@@ -27,6 +27,12 @@ module Tsks
|
|
27
27
|
parsed_res = parse_response res.body
|
28
28
|
end
|
29
29
|
|
30
|
+
def self.delete endpoint, token
|
31
|
+
uri = URI "#{Request.base_uri}#{endpoint}"
|
32
|
+
res = HTTParty.delete uri, headers: {authorization: "Bearer #{token}"}
|
33
|
+
parsed_res = parse_response res.body
|
34
|
+
end
|
35
|
+
|
30
36
|
private
|
31
37
|
|
32
38
|
def self.parse_response body
|
data/lib/tsks/storage.rb
CHANGED
@@ -16,6 +16,12 @@ module Tsks
|
|
16
16
|
updated_at VARCHAR NOT NULL
|
17
17
|
)
|
18
18
|
SQL
|
19
|
+
|
20
|
+
storage.execute <<-SQL
|
21
|
+
CREATE TABLE removed_tsks (
|
22
|
+
tsk_uuid VARCHAR UNIQUE NOT NULL
|
23
|
+
)
|
24
|
+
SQL
|
19
25
|
end
|
20
26
|
|
21
27
|
def self.insert tsk, ctx=nil
|
@@ -103,6 +109,34 @@ module Tsks
|
|
103
109
|
tsks = structure_tsks(raw_tsks, local_id=local_id)
|
104
110
|
end
|
105
111
|
|
112
|
+
def self.delete local_id
|
113
|
+
storage = get_storage_instance
|
114
|
+
removed_tsks = storage
|
115
|
+
.execute("SELECT * FROM tsks WHERE rowid=?", local_id)
|
116
|
+
if removed_tsks.empty?
|
117
|
+
return false
|
118
|
+
end
|
119
|
+
storage
|
120
|
+
.execute("INSERT INTO removed_tsks (tsk_uuid) VALUES (?)", removed_tsks[0][0])
|
121
|
+
storage.execute("DELETE FROM tsks WHERE rowid=?", local_id)
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.select_removed_uuids
|
125
|
+
storage = get_storage_instance
|
126
|
+
result = storage.execute("SELECT * FROM removed_tsks")
|
127
|
+
|
128
|
+
tsk_uuids = []
|
129
|
+
for item in result
|
130
|
+
tsk_uuids.append item[0]
|
131
|
+
end
|
132
|
+
return tsk_uuids
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.delete_removed_uuids
|
136
|
+
storage = get_storage_instance
|
137
|
+
storage.execute("DELETE FROM removed_tsks")
|
138
|
+
end
|
139
|
+
|
106
140
|
private
|
107
141
|
|
108
142
|
def self.get_storage_instance
|
data/lib/tsks/version.rb
CHANGED
data/lib/tsks.rb
CHANGED
data/tsks.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |spec|
|
|
5
5
|
spec.version = Tsks::VERSION
|
6
6
|
spec.authors = ["Luan F. R. Vicente"]
|
7
7
|
spec.email = ["luanrvmood@gmail.com"]
|
8
|
-
spec.summary = "A stateful command line interface to help you handle your daily tsks (with contexts!)"
|
8
|
+
spec.summary = "A stateful command line interface to help you handle your daily tsks (with synchronisation and contexts!)"
|
9
9
|
spec.homepage = "https://github.com/luanrvmood/tsks"
|
10
10
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
11
11
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
spec.add_development_dependency "rspec"
|
21
|
-
spec.add_development_dependency "dotenv"
|
22
21
|
spec.add_dependency "thor"
|
23
22
|
spec.add_dependency "sqlite3"
|
24
23
|
spec.add_dependency "httparty"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luan F. R. Vicente
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: dotenv
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: thor
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,5 +131,5 @@ rubygems_version: 3.1.2
|
|
145
131
|
signing_key:
|
146
132
|
specification_version: 4
|
147
133
|
summary: A stateful command line interface to help you handle your daily tsks (with
|
148
|
-
contexts!)
|
134
|
+
synchronisation and contexts!)
|
149
135
|
test_files: []
|