ruboty-toggl_team 0.3.0 → 0.4.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: 387fc35235be107052ab84dab491fb8e9147288fb712d53fa625693fe74f1a34
4
- data.tar.gz: '069ae7fad28b761f950d37dc21fc20f745258f79f6f179844e5003e80a6427df'
3
+ metadata.gz: 4d16ae0a27e1c79ebc3e64251dcb911f4e961c8a68543bc79d4034a7bba325c7
4
+ data.tar.gz: 520664ee511f8b960d8156c0b8e830949e010054f86c9493fc78ebb8c9a77f57
5
5
  SHA512:
6
- metadata.gz: 3ade8193f092dfc8daa1b0e419929e9a772c1452b974af6c9148133661878dae514ead63d4c3670ffed1491be018e5c78dbe05787dbdaea6f8f18e3145c18540
7
- data.tar.gz: 9317ef42b3f628105fb7f9ef65412f86e0c571360095728a370dc28bf0e86726b9dbef41e2cf34f5cf31fc788d22452edda01e365abb17a2c47a26c11dd11f7d
6
+ metadata.gz: 1406f87467a50ca0510fc5e3ac1022cb585312ca660fb72cc9524dbf5dfc6dea45e198a3e73e4213c0291fc49c96ace0d865670283aa01672a255563f58e830e
7
+ data.tar.gz: 170716da0cf675b7de6fe502dc568bb49c1c0630bf1f36249c1b996be2393dd705ff6dc17bfe34695515f5e85daf5640d81d060a7d6d06fc992f26b8fbb8aaa6
data/README.md CHANGED
@@ -42,6 +42,12 @@ start <task> <project-name>
42
42
  stop
43
43
  ```
44
44
 
45
+ ### Get report
46
+
47
+ ```
48
+ today
49
+ ```
50
+
45
51
  ## Contributing
46
52
 
47
53
  Bug reports and pull requests are welcome on GitHub at https://github.com/kimromi/ruboty-toggl_team. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -36,6 +36,13 @@ module Ruboty
36
36
  all: true
37
37
  )
38
38
 
39
+ on(
40
+ /^today$/,
41
+ name: 'today',
42
+ description: 'get today time report',
43
+ all: true
44
+ )
45
+
39
46
  def set_token(message)
40
47
  action(message).set_token
41
48
  end
@@ -56,6 +63,10 @@ module Ruboty
56
63
  action(message).stop
57
64
  end
58
65
 
66
+ def today(message)
67
+ action(message).today
68
+ end
69
+
59
70
  private
60
71
 
61
72
  def action(message)
@@ -1,5 +1,6 @@
1
1
  require 'togglv8'
2
2
  require 'active_support/core_ext/hash/keys'
3
+ require 'active_support/core_ext/time/calculations'
3
4
 
4
5
  module Ruboty
5
6
  module TogglTeam
@@ -84,6 +85,25 @@ module Ruboty
84
85
  message.reply("error! #{e}")
85
86
  end
86
87
 
88
+ def today
89
+ unless user_token && user_workspace
90
+ message.reply("please set #{user}'s toggl token and workspace!") and return
91
+ end
92
+
93
+ entries = toggl.get_time_entries(
94
+ start_date: DateTime.parse(Time.now.beginning_of_day.to_s),
95
+ end_date: DateTime.parse(Time.now.end_of_day.to_s)
96
+ )
97
+
98
+ report = entries.map do |e|
99
+ start_at = Time.parse(e['start']).localtime.strftime('%R')
100
+ end_at = Time.parse(e['stop']).localtime.strftime('%R')
101
+ "#{start_at}-#{end_at} : #{e['description']}"
102
+ end.join("\n")
103
+
104
+ message.reply(report)
105
+ end
106
+
87
107
  private
88
108
 
89
109
  def brain
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module TogglTeam
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-toggl_team
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kimromi