tsks 0.0.9 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +32 -0
- data/.env.sample +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +8 -2
- data/bin/install +6 -0
- data/bin/release +5 -0
- data/bin/test +3 -0
- data/lib/tsks/actions.rb +6 -6
- data/lib/tsks/cli.rb +47 -32
- data/lib/tsks/request.rb +1 -3
- data/lib/tsks/storage.rb +7 -1
- data/lib/tsks/version.rb +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5642476a95ebd615e61b0461eb61f2ea9a3408d249b3a85ba1ea2e028427badc
|
4
|
+
data.tar.gz: 65e8fea2affb40c031b86aed5db037426eacf8d953deaf8f13a7a3b2d0d633bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f6093f9d0a12c050e0384d316dfbf388ef39c4eb2b02cb3677e5b468f9ff71f8cafb85b937aed67c3cabbf9bb026931b5d84fe762759fd0bb3f798d8a643beb
|
7
|
+
data.tar.gz: 1287812074eab7b75d580be496b52d34c915505b45a8b7c6254e3135939a02e89295893b34a625a62cde190ab48d685fbb3e52ae0da807ba4b8838b76f3b3db5
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
2
|
+
# See: https://circleci.com/docs/2.0/configuration-reference
|
3
|
+
version: 2.1
|
4
|
+
|
5
|
+
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
|
6
|
+
# See: https://circleci.com/docs/2.0/orb-intro/
|
7
|
+
orbs:
|
8
|
+
ruby: circleci/ruby@1.4.0
|
9
|
+
|
10
|
+
# Define a job to be invoked later in a workflow.
|
11
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
docker:
|
15
|
+
- image: cimg/ruby:3.1.0
|
16
|
+
executor: ruby/default
|
17
|
+
steps:
|
18
|
+
- checkout
|
19
|
+
- run:
|
20
|
+
name: bundle install
|
21
|
+
command: bundle install
|
22
|
+
- run:
|
23
|
+
name: test
|
24
|
+
command: ./bin/test
|
25
|
+
|
26
|
+
# Invoke jobs via workflows
|
27
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
28
|
+
workflows:
|
29
|
+
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
|
30
|
+
# Inside the workflow, you define the jobs you want to run.
|
31
|
+
jobs:
|
32
|
+
- build
|
data/.env.sample
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
SETUP_FOLDER=~/.tsks_test
|
2
|
-
BASE_API_URI=http://localhost:
|
2
|
+
BASE_API_URI=http://localhost:5000/v1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# tsks
|
2
2
|
|
3
|
-
[![build](https://
|
3
|
+
[![build](https://dl.circleci.com/status-badge/img/gh/luanrv/tsks-cli/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/luanrv/tsks-cli/tree/main)
|
4
4
|
|
5
5
|
A stateful command line interface to help you handle your daily tsks (with
|
6
6
|
synchronisation and contexts!).
|
@@ -85,7 +85,7 @@ Or this to register an account:
|
|
85
85
|
tsks register --email=sample@mail.com --password=secret
|
86
86
|
```
|
87
87
|
|
88
|
-
##
|
88
|
+
## Developing
|
89
89
|
|
90
90
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
91
91
|
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
@@ -94,6 +94,12 @@ prompt that will allow you to experiment.
|
|
94
94
|
To install this gem onto your local machine, run `bundle exec rake install`
|
95
95
|
(This command installs the current tsks version in your machine).
|
96
96
|
|
97
|
+
## Releasing
|
98
|
+
|
99
|
+
```sh
|
100
|
+
./bin/release
|
101
|
+
```
|
102
|
+
|
97
103
|
## Contributing
|
98
104
|
|
99
105
|
Bug reports and pull requests are welcome on GitHub at https://github.com/luanrvmood/tsks.
|
data/bin/install
ADDED
data/bin/release
ADDED
data/bin/test
ADDED
data/lib/tsks/actions.rb
CHANGED
@@ -2,11 +2,11 @@ require "tsks/storage"
|
|
2
2
|
|
3
3
|
module Tsks
|
4
4
|
class Actions
|
5
|
-
def self.
|
5
|
+
def self.update_tsks_with_user_id user_id
|
6
6
|
current_tsks = Tsks::Storage.select_all
|
7
7
|
|
8
8
|
for tsk in current_tsks
|
9
|
-
Tsks::Storage.update tsk[:local_id], {user_id:
|
9
|
+
Tsks::Storage.update tsk[:local_id], {user_id: user_id}
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -22,10 +22,10 @@ module Tsks
|
|
22
22
|
|
23
23
|
def self.get_tsk_status status
|
24
24
|
available_status = {
|
25
|
-
todo: '
|
26
|
-
done: '
|
27
|
-
doing: '
|
28
|
-
freezed: '
|
25
|
+
todo: '-',
|
26
|
+
done: '*',
|
27
|
+
doing: '+',
|
28
|
+
freezed: '!',
|
29
29
|
archived: 'x',
|
30
30
|
}
|
31
31
|
|
data/lib/tsks/cli.rb
CHANGED
@@ -21,7 +21,7 @@ module Tsks
|
|
21
21
|
puts "tsks #{Tsks::VERSION}"
|
22
22
|
end
|
23
23
|
|
24
|
-
desc "init", "
|
24
|
+
desc "init", "setup tsks folder and storage"
|
25
25
|
def init
|
26
26
|
if File.directory? CLI.setup_folder
|
27
27
|
return puts "tsks was already initialized."
|
@@ -31,7 +31,7 @@ module Tsks
|
|
31
31
|
Tsks::Storage.init
|
32
32
|
end
|
33
33
|
|
34
|
-
desc "add TSK", "
|
34
|
+
desc "add TSK", "add a new tsk (Use --context to specify one e.g. Work)"
|
35
35
|
option :context
|
36
36
|
def add tsk
|
37
37
|
if !File.directory? CLI.setup_folder
|
@@ -45,16 +45,19 @@ module Tsks
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
desc "done ID", "
|
48
|
+
desc "done ID", "mark a tsk you have already done"
|
49
49
|
def done id
|
50
50
|
if !File.directory? CLI.setup_folder
|
51
51
|
return puts "tsks was not initialized yet."
|
52
52
|
end
|
53
53
|
|
54
|
-
Tsks::Storage.update id
|
54
|
+
op_status = Tsks::Storage.update id
|
55
|
+
if !op_status
|
56
|
+
puts "the specified tsk do not exist."
|
57
|
+
end
|
55
58
|
end
|
56
59
|
|
57
|
-
desc "list", "
|
60
|
+
desc "list", "see all active tsks, filter by context or that are done"
|
58
61
|
option :done, type: :boolean
|
59
62
|
option :context
|
60
63
|
def list
|
@@ -71,7 +74,7 @@ module Tsks
|
|
71
74
|
elsif options[:context]
|
72
75
|
tsks = Tsks::Storage.select_by({context: options[:context]})
|
73
76
|
else
|
74
|
-
tsks = Tsks::Storage.
|
77
|
+
tsks = Tsks::Storage.select_active
|
75
78
|
end
|
76
79
|
|
77
80
|
if tsks.count > 0
|
@@ -80,11 +83,11 @@ module Tsks
|
|
80
83
|
puts "#{tsk_status} | #{tsk[:local_id]} #{tsk[:tsk]} @#{tsk[:context]}"
|
81
84
|
end
|
82
85
|
else
|
83
|
-
puts "
|
86
|
+
puts "no tsks found."
|
84
87
|
end
|
85
88
|
end
|
86
89
|
|
87
|
-
desc "register", "
|
90
|
+
desc "register", "register an e-mail to be able to sync your tsks"
|
88
91
|
option :email, required: true
|
89
92
|
option :password, required: true
|
90
93
|
def register
|
@@ -94,24 +97,24 @@ module Tsks
|
|
94
97
|
|
95
98
|
begin
|
96
99
|
res = Tsks::Request.post "/signup", {email: options[:email],
|
97
|
-
|
100
|
+
password: options[:password]}
|
98
101
|
|
99
102
|
if res && res[:ok] == true
|
100
|
-
File.write File.join(CLI.setup_folder, "token"), res[:auth_token]
|
101
|
-
File.write File.join(CLI.setup_folder, "user_id"), res[:
|
102
|
-
Tsks::Actions.
|
103
|
-
puts "
|
103
|
+
File.write File.join(CLI.setup_folder, "token"), res[:user][:auth_token]
|
104
|
+
File.write File.join(CLI.setup_folder, "user_id"), res[:user][:id]
|
105
|
+
Tsks::Actions.update_tsks_with_user_id res[:user][:id]
|
106
|
+
puts "succesfully registered."
|
104
107
|
elsif res && res[:ok] == false
|
105
|
-
puts "
|
108
|
+
puts "this e-mail is already registered."
|
106
109
|
end
|
107
110
|
rescue Errno::ECONNREFUSED, SocketError
|
108
|
-
puts "
|
111
|
+
puts "failed to connect to API."
|
109
112
|
rescue JSON::ParserError
|
110
|
-
puts "
|
113
|
+
puts "error on reading data from API."
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
114
|
-
desc "login", "
|
117
|
+
desc "login", "login to be able to sync your tsks"
|
115
118
|
option :email, required: true
|
116
119
|
option :password, required: true
|
117
120
|
def login
|
@@ -121,36 +124,36 @@ module Tsks
|
|
121
124
|
|
122
125
|
begin
|
123
126
|
res = Tsks::Request.post "/signin", {email: options[:email],
|
124
|
-
|
127
|
+
password: options[:password]}
|
125
128
|
|
126
129
|
if res && res[:ok] == true
|
127
|
-
File.write File.join(CLI.setup_folder, "token"), res[:auth_token]
|
128
|
-
File.write File.join(CLI.setup_folder, "user_id"), res[:
|
129
|
-
Tsks::Actions.
|
130
|
-
puts "
|
130
|
+
File.write File.join(CLI.setup_folder, "token"), res[:user][:auth_token]
|
131
|
+
File.write File.join(CLI.setup_folder, "user_id"), res[:user][:id]
|
132
|
+
Tsks::Actions.update_tsks_with_user_id res[:user][:id]
|
133
|
+
puts "succesfully logged in."
|
131
134
|
elsif res && res[:ok] == false
|
132
|
-
puts "
|
135
|
+
puts "invalid e-mail or password."
|
133
136
|
end
|
134
137
|
rescue Errno::ECONNREFUSED, SocketError
|
135
|
-
puts "
|
138
|
+
puts "failed to connect to API."
|
136
139
|
rescue JSON::ParserError
|
137
|
-
puts "
|
140
|
+
puts "error on reading data from API."
|
138
141
|
end
|
139
142
|
end
|
140
143
|
|
141
|
-
desc "sync", "
|
144
|
+
desc "sync", "synchronize your tsks"
|
142
145
|
def sync
|
143
146
|
if !File.directory? CLI.setup_folder
|
144
147
|
return puts "tsks was not initialized yet."
|
145
148
|
end
|
146
149
|
|
147
150
|
if !File.exist? File.join CLI.setup_folder, "token"
|
148
|
-
return puts "
|
151
|
+
return puts "please, login before try to sync."
|
149
152
|
end
|
150
153
|
|
151
154
|
user_id = File.read File.join CLI.setup_folder, "user_id"
|
152
155
|
token = File.read File.join CLI.setup_folder, "token"
|
153
|
-
Tsks::Actions.
|
156
|
+
Tsks::Actions.update_tsks_with_user_id user_id
|
154
157
|
Tsks::Actions.update_server_for_removed_tsks token
|
155
158
|
Tsks::Storage.delete_removed_uuids
|
156
159
|
local_tsks = Tsks::Storage.select_all local_id=false
|
@@ -178,13 +181,13 @@ module Tsks
|
|
178
181
|
Tsks::Storage.insert_many remote_tsks_to_storage
|
179
182
|
end
|
180
183
|
|
181
|
-
puts "
|
184
|
+
puts "your tsks were succesfully synchronized."
|
182
185
|
end
|
183
186
|
end
|
184
187
|
rescue Errno::ECONNREFUSED, SocketError
|
185
|
-
puts "
|
188
|
+
puts "failed to connect to API."
|
186
189
|
rescue JSON::ParserError
|
187
|
-
puts "
|
190
|
+
puts "error on reading data from API."
|
188
191
|
end
|
189
192
|
end
|
190
193
|
|
@@ -196,7 +199,19 @@ module Tsks
|
|
196
199
|
|
197
200
|
op_status = Tsks::Storage.delete id
|
198
201
|
if !op_status
|
199
|
-
puts "
|
202
|
+
puts "the specified tsk do not exist."
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
desc "doing ID", "mark a tsk you started doing"
|
207
|
+
def doing id
|
208
|
+
if !File.directory? CLI.setup_folder
|
209
|
+
return puts "tsks was not initialized yet."
|
210
|
+
end
|
211
|
+
|
212
|
+
op_status = Tsks::Storage.update id, {status: 'doing'}
|
213
|
+
if !op_status
|
214
|
+
puts "the specified tsk do not exist."
|
200
215
|
end
|
201
216
|
end
|
202
217
|
end
|
data/lib/tsks/request.rb
CHANGED
data/lib/tsks/storage.rb
CHANGED
@@ -11,7 +11,7 @@ module Tsks
|
|
11
11
|
user_id INTEGER DEFAULT 1,
|
12
12
|
tsk VARCHAR NOT NULL,
|
13
13
|
status VARCHAR DEFAULT todo,
|
14
|
-
context VARCHAR DEFAULT
|
14
|
+
context VARCHAR DEFAULT inbox,
|
15
15
|
created_at VARCHAR NOT NULL,
|
16
16
|
updated_at VARCHAR NOT NULL
|
17
17
|
)
|
@@ -109,6 +109,12 @@ module Tsks
|
|
109
109
|
tsks = structure_tsks(raw_tsks, local_id=local_id)
|
110
110
|
end
|
111
111
|
|
112
|
+
def self.select_active
|
113
|
+
storage = get_storage_instance
|
114
|
+
raw_tsks = storage.execute("SELECT rowid, * FROM tsks WHERE status NOT LIKE 'done'")
|
115
|
+
tsks = structure_tsks raw_tsks
|
116
|
+
end
|
117
|
+
|
112
118
|
def self.delete local_id
|
113
119
|
storage = get_storage_instance
|
114
120
|
removed_tsks = storage
|
data/lib/tsks/version.rb
CHANGED
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luan Ramos Vicente
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- luanrvmood@gmail.com
|
86
86
|
executables:
|
@@ -88,6 +88,7 @@ executables:
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
+
- ".circleci/config.yml"
|
91
92
|
- ".env.sample"
|
92
93
|
- ".gitignore"
|
93
94
|
- ".rspec"
|
@@ -97,7 +98,10 @@ files:
|
|
97
98
|
- README.md
|
98
99
|
- Rakefile
|
99
100
|
- bin/console
|
101
|
+
- bin/install
|
102
|
+
- bin/release
|
100
103
|
- bin/setup
|
104
|
+
- bin/test
|
101
105
|
- exe/tsks
|
102
106
|
- lib/tsks.rb
|
103
107
|
- lib/tsks/actions.rb
|
@@ -112,7 +116,7 @@ metadata:
|
|
112
116
|
allowed_push_host: https://rubygems.org
|
113
117
|
homepage_uri: https://github.com/luanrv/tsks
|
114
118
|
source_code_uri: https://github.com/luanrv/tsks
|
115
|
-
post_install_message:
|
119
|
+
post_install_message:
|
116
120
|
rdoc_options: []
|
117
121
|
require_paths:
|
118
122
|
- lib
|
@@ -127,8 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
131
|
- !ruby/object:Gem::Version
|
128
132
|
version: '0'
|
129
133
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
131
|
-
signing_key:
|
134
|
+
rubygems_version: 3.4.6
|
135
|
+
signing_key:
|
132
136
|
specification_version: 4
|
133
137
|
summary: A stateful command line interface to help you handle your daily tsks (with
|
134
138
|
synchronisation and contexts)
|