wip-cli 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb9c05cd1f964991c2b44e8d235846ebaf3da18dd2ab0c47d8731801a75c4232
4
- data.tar.gz: 6d439e90a3ad971779e7cabbde4f4790f4a3884286c9ec70d97954f8e13ec81d
3
+ metadata.gz: d82933e6cb8f40235f6ac0f64ce48cd7cef3b2b9cd7db993d080a6a2713392c4
4
+ data.tar.gz: 56dc25b33282f766d3714dab200a6915bcf59f686c6f6f7db734de174e4c31da
5
5
  SHA512:
6
- metadata.gz: '059174a36ae832449877c49cf88695c9530006c04737702dc60e593e092194ebb5aa8af38c0e648eda813cbd01f829a6aa135bb81d7b5c7e316c0ae041f53f97'
7
- data.tar.gz: f2a19480b29b25bb41dc0ad35336e127b737bbfa0ecf671fff8ea2dd8e596fbb08a09aa2a178274901743d74f29175e3107bc0958373a8bb607b763458675ec4
6
+ metadata.gz: e470170e797827cb0ce81070bec1c6e5388659fc868edbce9c284f193a3a971296c27a193d7f93c5ba3906318893240c9efca56bae2023361e225f988c0ffb0b
7
+ data.tar.gz: 231a561c87e1d5aac68fa894e48a9d6d426763151fdd80249779e5734c81531eadfa914527db8f1118b74e9e31b2476f0f1367257ad9f4c2836f623baf36f849
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ### Added
6
+
7
+ - Added shortcut command to get your profile: `wip me`
8
+ - Added command to get a user profile: `wip user 2051` or `wip user sowenjub`
9
+
10
+ ### Changed
11
+
12
+ - Removed # before todo ids for easier copy/paste
13
+
5
14
  ## [1.2.0] - 2020-11-12
6
15
 
7
16
  ### Added
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wip-cli (1.2.0)
4
+ wip-cli (1.3.0)
5
5
  thor (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  byebug (11.1.3)
11
+ concurrent-ruby (1.1.7)
11
12
  diff-lcs (1.4.4)
12
13
  rake (13.0.1)
13
14
  rspec (3.10.0)
@@ -24,6 +25,8 @@ GEM
24
25
  rspec-support (~> 3.10.0)
25
26
  rspec-support (3.10.0)
26
27
  thor (1.0.1)
28
+ tzinfo (2.0.3)
29
+ concurrent-ruby (~> 1.0)
27
30
 
28
31
  PLATFORMS
29
32
  ruby
@@ -32,6 +35,7 @@ DEPENDENCIES
32
35
  byebug (~> 11.0)
33
36
  rake (~> 13.0)
34
37
  rspec (~> 3.9)
38
+ tzinfo (~> 2.0)
35
39
  wip-cli!
36
40
 
37
41
  BUNDLED WITH
@@ -1,5 +1,6 @@
1
1
  require "date"
2
2
  require "thor"
3
+ require "tzinfo"
3
4
  require "wip"
4
5
  require "wip/todo"
5
6
 
@@ -25,6 +26,11 @@ class Wip::CLI < Thor
25
26
  puts todo.description
26
27
  end
27
28
 
29
+ desc "me", "Outputs your profile summary"
30
+ def me
31
+ print_user_profile Wip::User.viewer
32
+ end
33
+
28
34
  desc "todo [BODY]", "Create a new todo"
29
35
  def todo(body)
30
36
  todo = Wip::Todo.create(body: body)
@@ -44,4 +50,29 @@ class Wip::CLI < Thor
44
50
  puts todo.description
45
51
  end
46
52
  end
53
+
54
+ desc "user [ID] or [USERNAME]", "Outputs a profile summary"
55
+ def user(identifier)
56
+ user = identifier.to_i > 0 ? Wip::User.find(identifier.to_i) : Wip::User.find(username: identifier)
57
+ print_user_profile user
58
+ end
59
+
60
+ no_commands{
61
+ def print_user_profile(user)
62
+ puts "👤 #{user.name}, aka @#{user.username} (User #{user.id})"
63
+ puts "🌍 Lives in #{user.time_zone} where it currently is #{user.tz.to_local(Time.now).strftime("%H:%M")}"
64
+ puts "✅ #{user.completed_todos_count} completed todos"
65
+ if user.streaking
66
+ puts "#{user.streak_icon} On a streak of #{user.streak}"
67
+ else
68
+ last_todo = user.todos.first
69
+ if last_todo.nil?
70
+ puts "#{user.streak_icon} No todo"
71
+ else
72
+ puts "#{user.streak_icon} Last todo created @ #{last_todo.created_at}"
73
+ end
74
+ end
75
+ puts "🔗 #{user.url}"
76
+ end
77
+ }
47
78
  end
@@ -4,7 +4,7 @@ require "wip/client"
4
4
 
5
5
  class Wip::Todo
6
6
 
7
- ATTRIBUTES = %i(id body completed_at)
7
+ ATTRIBUTES = %i(id body completed_at created_at)
8
8
 
9
9
  attr_accessor *ATTRIBUTES
10
10
  attr_accessor :deleted
@@ -37,7 +37,8 @@ class Wip::Todo
37
37
  def self.parse(data)
38
38
  todo_id = data["id"].to_i
39
39
  completed_at = DateTime.parse(data["completed_at"]) unless data["completed_at"].nil?
40
- new id: todo_id, body: data["body"], completed_at: completed_at
40
+ created_at = DateTime.parse(data["created_at"]) unless data["created_at"].nil?
41
+ new id: todo_id, body: data["body"], completed_at: completed_at, created_at: created_at
41
42
  end
42
43
 
43
44
  def self.complete(id)
@@ -59,10 +60,11 @@ class Wip::Todo
59
60
  end
60
61
 
61
62
 
62
- def initialize(id: nil, body: nil, completed_at: nil)
63
+ def initialize(id: nil, body: nil, completed_at: nil, created_at: nil)
63
64
  @id = id
64
65
  @body = body
65
66
  @completed_at = completed_at
67
+ @created_at = created_at
66
68
  end
67
69
 
68
70
 
@@ -71,7 +73,7 @@ class Wip::Todo
71
73
  end
72
74
 
73
75
  def description
74
- [icon, body, "##{id}"].join " "
76
+ [icon, body, "- #{id}"].join " "
75
77
  end
76
78
 
77
79
  def done?
@@ -116,6 +118,7 @@ class Wip::Todo
116
118
  id
117
119
  body
118
120
  completed_at
121
+ created_at
119
122
  }
120
123
  }
121
124
  }
@@ -136,6 +139,7 @@ class Wip::Todo
136
139
  id
137
140
  body
138
141
  completed_at
142
+ created_at
139
143
  }
140
144
  }
141
145
  }
@@ -148,6 +152,7 @@ class Wip::Todo
148
152
  id
149
153
  body
150
154
  completed_at
155
+ created_at
151
156
  }
152
157
  }
153
158
  }
@@ -76,4 +76,23 @@ class Wip::User
76
76
  end
77
77
  end
78
78
  end
79
+
80
+ def name
81
+ [first_name, last_name].join(" ")
82
+ end
83
+
84
+ def tz
85
+ TZInfo::Timezone.get(time_zone)
86
+ end
87
+
88
+ def streak_icon
89
+ case streak
90
+ when 0
91
+ "⛱"
92
+ when 1..99
93
+ "🔥"
94
+ else
95
+ "🌶"
96
+ end
97
+ end
79
98
  end
@@ -1,3 +1,3 @@
1
1
  module Wip
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
+ spec.add_development_dependency 'tzinfo', "~> 2.0"
28
+
27
29
  spec.add_development_dependency 'byebug', "~> 11.0"
28
30
  spec.add_development_dependency 'rake', "~> 13.0"
29
31
  spec.add_development_dependency 'rspec', "~> 3.9"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wip-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Joubay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-12 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tzinfo
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: byebug
15
29
  requirement: !ruby/object:Gem::Requirement