habittracker 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/Rakefile +5 -5
- data/exe/ht +23 -6
- data/habittracker.gemspec +16 -16
- data/lib/habittracker/archive.rb +10 -5
- data/lib/habittracker/version.rb +1 -1
- data/lib/habittracker.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 546be2a9bca1b4182ae87a703a29caf75a1ea377
|
4
|
+
data.tar.gz: fe5bdbb348ba33c18c79cec0ba91205e0508f866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09321ebc8e1228ccf42595a2c7633b48cb17dcd174aec5c91489526fc0c2858a8e7f8ed4bd65f45255ecdb0420c0f936b93d945a01d56988dcaaef198376fc98'
|
7
|
+
data.tar.gz: 4a83603c97e9a48fbcdb748a1c4fbd9d420f7a7e1069d45e651a5146ad401710cde285dabba0b0d4924e8c04d58dac66ed2c34de0ac96332f4f6a6b147720e02
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
7
|
t.test_files = FileList['test/**/*_test.rb']
|
8
8
|
end
|
9
9
|
|
10
|
-
task :
|
10
|
+
task default: :test
|
data/exe/ht
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require
|
2
|
+
require 'habittracker'
|
3
3
|
|
4
4
|
program :name, 'ht'
|
5
|
-
program :version, '0.
|
5
|
+
program :version, '0.1.1'
|
6
6
|
program :description, 'Track your monthly habits'
|
7
|
+
default_command :today
|
7
8
|
|
8
9
|
command :add do |c|
|
9
|
-
c.syntax = 'ht add <habits>'
|
10
|
+
c.syntax = 'ht add <habits> [--schedule 1,2,4]'
|
10
11
|
c.summary = 'Add one or more habits to the list'
|
11
12
|
c.description = 'Add one or more habits to the list'
|
12
|
-
c.example '
|
13
|
-
c.
|
13
|
+
c.example 'Add a "Learn math" habit for Monday, Wednesday and Friday ', 'ht add_habit "Learn math" --schedule 1,3,5'
|
14
|
+
c.option '--schedule STRING', String, 'Days when this habit should be done. 0=Sunday,6=Saturday Multiple days must be separated by comma 1,2,4'
|
15
|
+
c.action do |args, options|
|
16
|
+
days = []
|
17
|
+
days = options.schedule.split(',').map(&:strip).map(&:to_i) unless options.schedule.nil?
|
14
18
|
archive = Archive.new
|
15
19
|
args.each do |habit|
|
16
|
-
archive.add_habit(habit)
|
20
|
+
archive.add_habit(habit, days)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -76,3 +80,16 @@ command :do do |c|
|
|
76
80
|
archive.save(habit, selected_date)
|
77
81
|
end
|
78
82
|
end
|
83
|
+
|
84
|
+
command :today do |c|
|
85
|
+
c.syntax = 'ht today'
|
86
|
+
c.summary = 'Shows the list of habits you should do today'
|
87
|
+
c.description = 'Shows the list of habits you should do today'
|
88
|
+
c.example 'description', 'ht today'
|
89
|
+
c.action do |_args, _options|
|
90
|
+
archive = Archive.new
|
91
|
+
puts 'Today you should do:'
|
92
|
+
day_of_the_week = Time.now.strftime('%w').to_i
|
93
|
+
archive.habits_per_day(day_of_the_week).each { |h| puts "* #{h}" }
|
94
|
+
end
|
95
|
+
end
|
data/habittracker.gemspec
CHANGED
@@ -4,37 +4,37 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'habittracker/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'habittracker'
|
8
8
|
spec.version = Habittracker::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Ignazio Calò']
|
10
|
+
spec.email = ['ignazioc@gmail.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
12
|
+
spec.summary = 'This is a monthly tracker for geeks.'
|
13
|
+
spec.description = 'This is a monthly tracker for geeks.'
|
14
|
+
spec.homepage = 'https://github.com/ignazioc/HabitTracker'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata['allowed_push_host'] =
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
21
|
else
|
22
|
-
raise
|
23
|
-
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
24
|
end
|
25
25
|
|
26
|
-
spec.files
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
27
|
f.match(%r{^(test|spec|features)/})
|
28
28
|
end
|
29
29
|
spec.required_ruby_version = '~> 2.3'
|
30
30
|
|
31
|
-
spec.bindir =
|
31
|
+
spec.bindir = 'exe'
|
32
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
-
spec.require_paths = [
|
33
|
+
spec.require_paths = ['lib']
|
34
34
|
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
38
38
|
|
39
39
|
spec.add_dependency 'commander'
|
40
40
|
spec.add_dependency 'terminal-table'
|
data/lib/habittracker/archive.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
class Archive
|
2
|
-
|
3
2
|
def initialize
|
4
3
|
@db_file = File.join(ENV['HOME'], '/.ht')
|
5
4
|
load_archive
|
6
5
|
end
|
7
6
|
|
8
|
-
def add_habit(habit)
|
7
|
+
def add_habit(habit, days = [])
|
9
8
|
from = Date.new(Time.now.year, 1, 1)
|
10
9
|
to = Date.new(Time.now.year, 12, 31)
|
11
10
|
|
@@ -13,6 +12,8 @@ class Archive
|
|
13
12
|
mem[date_to_key(day)] = false
|
14
13
|
mem
|
15
14
|
end
|
15
|
+
@archive[habit][:schedule] = days
|
16
|
+
|
16
17
|
store
|
17
18
|
load_archive
|
18
19
|
end
|
@@ -58,6 +59,12 @@ class Archive
|
|
58
59
|
load_archive
|
59
60
|
end
|
60
61
|
|
62
|
+
def habits_per_day(day)
|
63
|
+
@archive.keys.select do |habit|
|
64
|
+
@archive[habit][:schedule].include?(day)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
61
68
|
#-- Private Methods
|
62
69
|
|
63
70
|
private def load_archive
|
@@ -67,7 +74,7 @@ class Archive
|
|
67
74
|
end
|
68
75
|
end
|
69
76
|
@archive = YAML.load_file(@db_file)
|
70
|
-
|
77
|
+
end
|
71
78
|
|
72
79
|
private def store
|
73
80
|
File.open(@db_file, 'w') do |file|
|
@@ -92,6 +99,4 @@ class Archive
|
|
92
99
|
private def row_item(value)
|
93
100
|
value ? { value: 'X', alignment: :center } : { value: '', alignment: :center }
|
94
101
|
end
|
95
|
-
|
96
|
-
|
97
102
|
end
|
data/lib/habittracker/version.rb
CHANGED
data/lib/habittracker.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: habittracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignazio Calò
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|