tsks 0.0.5 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8f7497ae6a59643d79502f8bb6ff5eb6a09b56e8d2ff2663f8c8edefeac4d77
4
- data.tar.gz: 534fe43eed703d5b7a00b19a056569acbd2b6513bbb750ca71fe08e059a8cdd2
3
+ metadata.gz: bc64bfc231b5bdddc48e461c610e21564cb6e84cacf98ec865669c9f9326aa4d
4
+ data.tar.gz: bdf3d97cb380ebd6e014b99a86557af4db94716339a2c6d7fc7ef40f664aa652
5
5
  SHA512:
6
- metadata.gz: 1d06f1380203bd0b9459ef13a378406bbe06f9c3b57ca3e11a5c16d0134e6ddf6919fe10e989409cd324fa4dce7fd2305dab6d5ff2d3f722b713f2740737e837
7
- data.tar.gz: a0977da59193c4b7e6748a9933f26b40154806573e9001abefe168d39c5c73d965bbe4578e3e497acb1716aa69513aabf46b372cb9d40c5d4eddacec4799852c
6
+ metadata.gz: '0301898a19b38ca228ced6c841cefbc24a8ce595ccaa54ee8a9b5c616f27e278e5c592e37cde8498927b5fad1664a15d23dca9d0f14985bb3703129b3b661430'
7
+ data.tar.gz: d3c2d5f445335576c3be41ef095b432f52a75f7c8acee1346ed5fc2823cd904fbe6c8a9b35b6ef5145f58aa3709a82ec2a6f0205f973c61ec473dc397c3f9c3a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tsks (0.0.5)
4
+ tsks (0.0.8)
5
5
  httparty
6
6
  sqlite3
7
7
  thor
@@ -53,4 +53,4 @@ DEPENDENCIES
53
53
  uuid (~> 2.3.9)
54
54
 
55
55
  BUNDLED WITH
56
- 2.1.2
56
+ 2.2.22
data/README.md CHANGED
@@ -91,10 +91,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
91
91
  prompt that will allow you to experiment.
92
92
 
93
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).
94
+ (This command installs the current tsks version in your machine).
96
95
 
97
96
  ## Contributing
98
97
 
99
- Bug reports and pull requests are welcome on GitHub at
100
- https://github.com/luanrvmood/tsks-cli.
98
+ Bug reports and pull requests are welcome on GitHub at https://github.com/luanrvmood/tsks.
data/lib/tsks/actions.rb CHANGED
@@ -19,5 +19,17 @@ module Tsks
19
19
  end
20
20
  end
21
21
  end
22
+
23
+ def self.get_tsk_status status
24
+ available_status = {
25
+ todo: '+',
26
+ done: '-',
27
+ doing: '*',
28
+ freezed: '||',
29
+ archived: 'x',
30
+ }
31
+
32
+ available_status[status.to_sym]
33
+ end
22
34
  end
23
35
  end
data/lib/tsks/cli.rb CHANGED
@@ -65,18 +65,19 @@ module Tsks
65
65
  tsks = nil
66
66
 
67
67
  if options[:done] && options[:context]
68
- tsks = Tsks::Storage.select_by({done: 1, context: options[:context]})
68
+ tsks = Tsks::Storage.select_by({status: 'done', context: options[:context]})
69
69
  elsif options[:done]
70
- tsks = Tsks::Storage.select_by({done: 1})
70
+ tsks = Tsks::Storage.select_by({status: 'done'})
71
71
  elsif options[:context]
72
72
  tsks = Tsks::Storage.select_by({context: options[:context]})
73
73
  else
74
- tsks = Tsks::Storage.select_by({done: 0})
74
+ tsks = Tsks::Storage.select_by({status: 'todo'})
75
75
  end
76
76
 
77
77
  if tsks.count > 0
78
78
  for tsk in tsks
79
- puts "#{tsk[:local_id]} @#{tsk[:context]} #{tsk[:tsk]}"
79
+ tsk_status = Tsks::Actions.get_tsk_status tsk[:status]
80
+ puts "#{tsk_status} | #{tsk[:local_id]} #{tsk[:tsk]} @#{tsk[:context]}"
80
81
  end
81
82
  else
82
83
  puts "No tsks found."
@@ -95,12 +96,12 @@ module Tsks
95
96
  res = Tsks::Request.post "/register", {email: options[:email],
96
97
  password: options[:password]}
97
98
 
98
- if res && res[:status_code] == 201
99
+ if res && res[:ok] == true
99
100
  File.write File.join(CLI.setup_folder, "token"), res[:token]
100
101
  File.write File.join(CLI.setup_folder, "user_id"), res[:user_id]
101
102
  Tsks::Actions.update_tsks_with_uuid res[:user_id]
102
103
  puts "Succesfully registered."
103
- elsif res && res[:status_code] == 409
104
+ elsif res && res[:ok] == false
104
105
  puts "This e-mail is already registered."
105
106
  end
106
107
  rescue Errno::ECONNREFUSED, SocketError
@@ -122,12 +123,12 @@ module Tsks
122
123
  res = Tsks::Request.post "/login", {email: options[:email],
123
124
  password: options[:password]}
124
125
 
125
- if res && res[:status_code] == 200
126
+ if res && res[:ok] == true
126
127
  File.write File.join(CLI.setup_folder, "token"), res[:token]
127
128
  File.write File.join(CLI.setup_folder, "user_id"), res[:user_id]
128
129
  Tsks::Actions.update_tsks_with_uuid res[:user_id]
129
130
  puts "Succesfully logged in."
130
- elsif res && res[:status_code] == 403
131
+ elsif res && res[:ok] == false
131
132
  puts "Invalid e-mail or password."
132
133
  end
133
134
  rescue Errno::ECONNREFUSED, SocketError
@@ -164,7 +165,7 @@ module Tsks
164
165
  remote_tsks.append tsk
165
166
  end
166
167
 
167
- if get_res[:status_code] == 200
168
+ if get_res[:ok] == true
168
169
  local_tsks_to_post = local_tsks - remote_tsks
169
170
  if local_tsks_to_post.count > 0
170
171
  Tsks::Request.post "/tsks", token, {tsks: local_tsks_to_post}
data/lib/tsks/storage.rb CHANGED
@@ -10,8 +10,8 @@ module Tsks
10
10
  id VARCHAR PRIMARY KEY UNIQUE NOT NULL,
11
11
  user_id INTEGER DEFAULT 1,
12
12
  tsk VARCHAR NOT NULL,
13
+ status VARCHAR DEFAULT todo,
13
14
  context VARCHAR DEFAULT Inbox,
14
- done BOOLEAN DEFAULT false,
15
15
  created_at VARCHAR NOT NULL,
16
16
  updated_at VARCHAR NOT NULL
17
17
  )
@@ -31,15 +31,15 @@ module Tsks
31
31
 
32
32
  if ctx
33
33
  storage.execute("
34
- INSERT INTO tsks (id, tsk, context, created_at, updated_at)
35
- VALUES (?, ?, ?, ?, ?)",
36
- [uuid, tsk, ctx, now, now]
34
+ INSERT INTO tsks (id, tsk, status, context, created_at, updated_at)
35
+ VALUES (?, ?, ?, ?, ?, ?)",
36
+ [uuid, tsk, 'todo', ctx, now, now]
37
37
  )
38
38
  else
39
39
  storage.execute("
40
- INSERT INTO tsks (id, tsk, created_at, updated_at)
41
- VALUES (?, ?, ?, ?)",
42
- [uuid, tsk, now, now]
40
+ INSERT INTO tsks (id, tsk, status, created_at, updated_at)
41
+ VALUES (?, ?, ?, ?, ?)",
42
+ [uuid, tsk, 'todo', now, now]
43
43
  )
44
44
  end
45
45
  end
@@ -50,13 +50,13 @@ module Tsks
50
50
  for tsk in tsks
51
51
  storage.execute("
52
52
  INSERT INTO tsks
53
- (id, user_id, tsk, context, done, created_at, updated_at) VALUES
53
+ (id, user_id, tsk, status, context, created_at, updated_at) VALUES
54
54
  (?, ?, ?, ?, ?, ?, ?)",
55
55
  [tsk[:id],
56
56
  tsk[:user_id],
57
57
  tsk[:tsk],
58
+ tsk[:status],
58
59
  tsk[:context],
59
- tsk[:done],
60
60
  tsk[:created_at],
61
61
  tsk[:updated_at]]
62
62
  )
@@ -77,7 +77,7 @@ module Tsks
77
77
  "WHERE rowid=?",
78
78
  [params.values.first, local_id])
79
79
  else
80
- storage.execute "UPDATE tsks SET done=true WHERE rowid=?", local_id
80
+ storage.execute "UPDATE tsks SET status='done' WHERE rowid=?", local_id
81
81
  end
82
82
  end
83
83
 
@@ -154,16 +154,16 @@ module Tsks
154
154
  t[:id] = tsk[1]
155
155
  t[:user_id] = tsk[2]
156
156
  t[:tsk] = tsk[3]
157
- t[:context] = tsk[4]
158
- t[:done] = tsk[5]
157
+ t[:status] = tsk[4]
158
+ t[:context] = tsk[5]
159
159
  t[:created_at] = tsk[6]
160
160
  t[:updated_at] = tsk[7]
161
161
  else
162
162
  t[:id] = tsk[0]
163
163
  t[:user_id] = tsk[1]
164
164
  t[:tsk] = tsk[2]
165
- t[:context] = tsk[3]
166
- t[:done] = tsk[4]
165
+ t[:status] = tsk[3]
166
+ t[:context] = tsk[4]
167
167
  t[:created_at] = tsk[5]
168
168
  t[:updated_at] = tsk[6]
169
169
  end
data/lib/tsks/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tsks
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.8"
3
3
  end
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.5
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luan F. R. Vicente
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2022-04-16 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:
@@ -112,7 +112,7 @@ metadata:
112
112
  allowed_push_host: https://rubygems.org
113
113
  homepage_uri: https://github.com/luanrvmood/tsks
114
114
  source_code_uri: https://github.com/luanrvmood/tsks
115
- post_install_message:
115
+ post_install_message:
116
116
  rdoc_options: []
117
117
  require_paths:
118
118
  - lib
@@ -127,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubygems_version: 3.1.2
131
- signing_key:
130
+ rubygems_version: 3.3.7
131
+ signing_key:
132
132
  specification_version: 4
133
133
  summary: A stateful command line interface to help you handle your daily tsks (with
134
134
  synchronisation and contexts!)