Module: Hab
- Defined in:
- lib/hab.rb,
lib/hab/config.rb,
lib/hab/filter.rb,
lib/hab/version.rb,
lib/hab/formatter.rb
Defined Under Namespace
Modules: Filter, Formatter
Classes: Config
Constant Summary
collapse
- VERSION =
'0.0.6'
Class Method Summary
collapse
Class Method Details
.add_task(task, type) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/hab.rb', line 27
def self.add_task(task, type)
client.user.tasks.create({
text: task,
type: type
})
end
|
.add_tasks(tasks, type) ⇒ Object
34
35
36
37
38
|
# File 'lib/hab.rb', line 34
def self.add_tasks(tasks, type)
tasks.each do |task|
self.add_task(task, type)
end
end
|
.client ⇒ Object
15
16
17
|
# File 'lib/hab.rb', line 15
def self.client
@@client ||= HabitClient.new(config.user_id, config.api_token)
end
|
.config ⇒ Object
11
12
13
|
# File 'lib/hab.rb', line 11
def self.config
@@config ||= Config.new
end
|
.dailies(options) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/hab.rb', line 49
def self.dailies(options)
tasks = Filter.by_status(client.user.tasks.dailies,
options)
Formatter.tasks(tasks, emoji: options.emoji)
end
|
.habits(options) ⇒ Object
44
45
46
|
# File 'lib/hab.rb', line 44
def self.habits(options)
Formatter.tasks(client.user.tasks.habits, emoji: options.emoji)
end
|
.stats ⇒ Object
23
24
25
|
# File 'lib/hab.rb', line 23
def self.stats
Formatter.stats(client.user.stats)
end
|
.status ⇒ Object
19
20
21
|
# File 'lib/hab.rb', line 19
def self.status
Formatter.status(client.user)
end
|
.stdin_tasks ⇒ Object
40
41
42
|
# File 'lib/hab.rb', line 40
def self.stdin_tasks
!STDIN.tty? ? STDIN.read.split("\n") : []
end
|
.todos(options) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/hab.rb', line 56
def self.todos(options)
tasks = Filter.by_status(client.user.tasks.todos,
options)
Formatter.tasks(tasks, emoji: options.emoji)
end
|