hbtrack 0.0.5 → 0.0.6

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.
data/lib/hbtrack.rb CHANGED
@@ -1,22 +1,54 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'hbtrack/habit_tracker'
4
- require 'hbtrack/version'
5
- require 'hbtrack/cli'
6
- require 'hbtrack/util'
7
- require 'hbtrack/config'
8
4
  require 'hbtrack/habit'
5
+ require 'hbtrack/config'
9
6
  require 'hbtrack/stat_formatter'
10
7
  require 'hbtrack/habit_printer'
8
+ require 'hbtrack/command/list_command'
9
+ require 'hbtrack/command/update_command'
10
+ require 'hbtrack/command/remove_command'
11
+ require 'hbtrack/command/add_command'
12
+ require 'hbtrack/report/generator'
13
+ require 'hbtrack/error_handler'
11
14
 
12
15
  module Hbtrack
13
16
  class << self
14
- def run(*args)
15
- if ARGV.empty?
16
- HabitTracker.help
17
- else
18
- HabitTracker.new.parse_arguments(*args)
19
- end
17
+ def run(args)
18
+ hbt = HabitTracker.new
19
+ command = case args.shift
20
+ when 'list'
21
+ ListCommand.new(hbt, args)
22
+ when 'done'
23
+ UpdateCommand.new(hbt, args, true)
24
+ when 'undone'
25
+ UpdateCommand.new(hbt, args, false)
26
+ when 'remove'
27
+ RemoveCommand.new(hbt, args)
28
+ when 'add'
29
+ AddCommand.new(hbt, args)
30
+ when 'generate'
31
+ Generator.new(hbt).generate
32
+ exit
33
+ else
34
+ help
35
+ end
36
+ puts command.execute
37
+ end
38
+
39
+ def help
40
+ puts 'Usage: hbtrack <command> [<habit_name>] [options]'
41
+ puts
42
+ puts 'Commands:'
43
+ puts ' add: Add habit(s)'
44
+ puts ' remove: Remove habit(s)'
45
+ puts ' list: List habit(s)'
46
+ puts ' done: Mark habit(s) as done'
47
+ puts ' undone: Mark habit(s) as undone'
48
+ puts
49
+ puts 'Options:'
50
+ puts " -h, --help\t\tShow help messages of the command"
51
+ exit
20
52
  end
21
53
  end
22
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hbtrack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - kw7oe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-03 00:00:00.000000000 Z
11
+ date: 2017-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.6'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -61,20 +75,31 @@ extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
77
  - ".gitignore"
64
- - ".rubocop.yml"
78
+ - ".rspec"
79
+ - ".travis.yml"
65
80
  - CODE_OF_CONDUCT.md
66
81
  - Gemfile
67
82
  - LICENSE.txt
68
83
  - README.md
69
84
  - Rakefile
70
85
  - exe/hbtrack
86
+ - hbtrack.gemspec
71
87
  - lib/hbtrack.rb
72
- - lib/hbtrack/cli.rb
88
+ - lib/hbtrack/command.rb
89
+ - lib/hbtrack/command/add_command.rb
90
+ - lib/hbtrack/command/list_command.rb
91
+ - lib/hbtrack/command/remove_command.rb
92
+ - lib/hbtrack/command/update_command.rb
73
93
  - lib/hbtrack/config.rb
94
+ - lib/hbtrack/error_handler.rb
74
95
  - lib/hbtrack/habit.rb
75
96
  - lib/hbtrack/habit_printer.rb
76
97
  - lib/hbtrack/habit_tracker.rb
98
+ - lib/hbtrack/report/calendar.rb
99
+ - lib/hbtrack/report/generator.rb
100
+ - lib/hbtrack/report/report.html.erb
77
101
  - lib/hbtrack/stat_formatter.rb
102
+ - lib/hbtrack/store.rb
78
103
  - lib/hbtrack/util.rb
79
104
  - lib/hbtrack/version.rb
80
105
  homepage: https://github.com/kw7oe/hbtrack
@@ -97,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
122
  version: '0'
98
123
  requirements: []
99
124
  rubyforge_project:
100
- rubygems_version: 2.5.2
125
+ rubygems_version: 2.6.13
101
126
  signing_key:
102
127
  specification_version: 4
103
128
  summary: A CLI to track your habits.
data/.rubocop.yml DELETED
@@ -1,2 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.3
data/lib/hbtrack/cli.rb DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # A class that contains the helper methods
4
- # used for CLI.
5
- module Hbtrack
6
- class CLI
7
- FONT_COLOR = {
8
- green: "\e[32m",
9
- red: "\e[31m",
10
- blue: "\e[34m"
11
- }.freeze
12
-
13
- class << self
14
- # Define CLI.green, CLI.red, CLI.blue
15
- # which colorize string output in terminal
16
- FONT_COLOR.each do |key, value|
17
- define_method(key) do |string|
18
- value + string + "\e[0m"
19
- end
20
- end
21
- end
22
- end
23
- end