terminal-app 0.1.1 → 0.1.2
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 +4 -4
- data/.DS_Store +0 -0
- data/README.md +9 -2
- data/images/trello.png +0 -0
- data/lib/AppController.rb +14 -44
- data/lib/Display.rb +2 -1
- data/lib/Model.rb +4 -4
- data/lib/app.rb +14 -10
- data/lib/terminal/app/version.rb +1 -1
- data/lib/users/b.csv +0 -0
- data/lib/users/tess.csv +10 -6
- data/lib/users/test.csv +0 -0
- data/terminal-app-0.1.1.gem +0 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25d9fd6e26259c32d6ceff88ba633a9b594cba0a9d785aa0eaa4d2073d7ceb83
|
4
|
+
data.tar.gz: 682fc9d9675a83c67c6facf8a670dbfed64e83d8f53bc0f1cd7c51e9918b92be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d10480c82ef474edd0c9720ff14d05380578e6e2208cd12df29250d711d40430b1cb962c149ff551fb4a81db1beba1debd6199049a75403487e138da575f04f8
|
7
|
+
data.tar.gz: 70a464124a4a73800ebde9538b8cd504861ec050ab1f9f95057db1a3fa8ee1ea92483a1c28841c13b6c8c4c76fd3e7c1460e7f3536a5e4fc9f6e566b9946c2c2
|
data/.DS_Store
ADDED
Binary file
|
data/README.md
CHANGED
@@ -135,9 +135,16 @@ Project Management
|
|
135
135
|
---
|
136
136
|
I will be utilizing trello for project management
|
137
137
|
|
138
|
-
|
138
|
+

|
139
|
+
|
140
|
+
|
141
|
+
Testing
|
139
142
|
---
|
140
143
|
|
144
|
+
Manual Testing documentation
|
145
|
+
|
146
|
+
https://docs.google.com/spreadsheets/d/1gCTDmCn7aAHaRTZWpWSsw2kVUnW_tdpHwY4TgpYB4J0/edit?usp=sharing
|
147
|
+
|
141
148
|
Installation
|
142
149
|
|
143
150
|
```bash
|
@@ -150,7 +157,7 @@ Gemfile
|
|
150
157
|
|
151
158
|
```ruby
|
152
159
|
|
153
|
-
gem 'terminal-app', '~> 0.1.
|
160
|
+
gem 'terminal-app', '~> 0.1.1'
|
154
161
|
|
155
162
|
```
|
156
163
|
|
data/images/trello.png
ADDED
Binary file
|
data/lib/AppController.rb
CHANGED
@@ -7,7 +7,6 @@ require "tty-prompt"
|
|
7
7
|
|
8
8
|
|
9
9
|
class AppController
|
10
|
-
|
11
10
|
# run at start of program to check if new user
|
12
11
|
# either create a file for new user or get activities for returning user
|
13
12
|
def self.check_user(user_name)
|
@@ -30,7 +29,6 @@ class AppController
|
|
30
29
|
elsif answer == 'show-activities'
|
31
30
|
Display.show_activities(user)
|
32
31
|
elsif answer == 'check-completed-activity'
|
33
|
-
# self.find_activities(user)
|
34
32
|
self.check_completed(user)
|
35
33
|
elsif answer == 'get-stats'
|
36
34
|
self.get_stats(user)
|
@@ -44,6 +42,8 @@ class AppController
|
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
45
|
+
# looks up activities based on user input date
|
46
|
+
# returns an array of activities that match date
|
47
47
|
def self.get_activities_by_date(user)
|
48
48
|
begin
|
49
49
|
puts "Activity date: (today or yyyy-mm-dd): "
|
@@ -51,29 +51,33 @@ class AppController
|
|
51
51
|
if date == "today"
|
52
52
|
date = Date.today.to_s
|
53
53
|
else
|
54
|
-
|
54
|
+
# run to test for invalid dates
|
55
|
+
Date.parse(date)
|
55
56
|
end
|
56
|
-
activities = Model.search_activities(user, date)
|
57
|
-
raise "No activities on that date" if activities.length == 0
|
58
|
-
rescue Date::Error, RuntimeError
|
57
|
+
activities = Model.search_activities(user, date)
|
58
|
+
raise "No activities on that date" if activities.length == 0 || is_in_future?(date)
|
59
|
+
rescue Date::Error, RuntimeError
|
59
60
|
puts "Invalid date"
|
60
61
|
self.menu(user)
|
61
62
|
end
|
62
63
|
return activities
|
63
64
|
end
|
64
65
|
|
66
|
+
# takes array of activities and generates a drop down menu
|
67
|
+
# used for selecting activities to check completed or to delete
|
68
|
+
# returns users chosen activity
|
65
69
|
def self.select_activity(user, activities)
|
66
|
-
#activities = self.get_activities_by_date(user)
|
67
70
|
prompt = TTY::Prompt.new
|
68
71
|
options = %w(go-back)
|
69
72
|
activities.each do |activity|
|
70
73
|
options << "#{activity.type}-#{activity.distance}-#{activity.duration}-#{activity.date}"
|
71
74
|
end
|
72
75
|
selected_activity = prompt.select("Select Activity: ", options)
|
73
|
-
# p selected_activity
|
74
76
|
if selected_activity == 'go-back'
|
75
77
|
self.menu(user)
|
76
78
|
end
|
79
|
+
|
80
|
+
# iterates over array of activities, converts to string for comparison with user selection
|
77
81
|
activities.each do |activity|
|
78
82
|
activity_string = "#{activity.type}-#{activity.distance}-#{activity.duration}-#{activity.date}"
|
79
83
|
if activity_string == selected_activity
|
@@ -82,42 +86,11 @@ class AppController
|
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
|
-
def self.find_activities(user)
|
86
|
-
begin
|
87
|
-
puts "Activity date: (today or yyyy-mm-dd): "
|
88
|
-
date = gets.chomp
|
89
|
-
if date == "today"
|
90
|
-
date = Date.today.to_s
|
91
|
-
end
|
92
|
-
Date.parse(date)
|
93
|
-
activities = Model.search_activities(user, date) #an array of activities
|
94
|
-
raise "No activities on that date" if activities.length == 0
|
95
|
-
rescue Date::Error, RuntimeError
|
96
|
-
puts "Invalid date"
|
97
|
-
retry
|
98
|
-
end
|
99
|
-
prompt = TTY::Prompt.new
|
100
|
-
options = %w(go-back)
|
101
|
-
activities.each do |activity|
|
102
|
-
options << "#{activity.type}-#{activity.distance}-#{activity.duration}-#{activity.date}"
|
103
|
-
end
|
104
|
-
selected_activity = prompt.select("Select Activity: ", options)
|
105
|
-
if selected_activity == 'go-back'
|
106
|
-
self.menu(user)
|
107
|
-
end
|
108
|
-
activities.each do |activity|
|
109
|
-
activity_string = "#{activity.type}-#{activity.distance}-#{activity.duration}-#{activity.date}"
|
110
|
-
if activity_string == selected_activity
|
111
|
-
activity.completed = true
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
89
|
def self.check_completed(user)
|
117
90
|
activities = self.get_activities_by_date(user)
|
118
91
|
activity = self.select_activity(user, activities)
|
119
92
|
activity.completed = true
|
120
|
-
Model.update_activities(user
|
93
|
+
Model.update_activities(user)
|
121
94
|
end
|
122
95
|
|
123
96
|
def self.delete_activity(user)
|
@@ -125,6 +98,7 @@ class AppController
|
|
125
98
|
activity = self.select_activity(user, activities)
|
126
99
|
Model.delete_activity(user, activity)
|
127
100
|
end
|
101
|
+
|
128
102
|
def self.add_activity(user)
|
129
103
|
prompt = TTY::Prompt.new
|
130
104
|
type = prompt.select("Select Activity: ", %w(run bike swim walk/hike))
|
@@ -144,7 +118,6 @@ class AppController
|
|
144
118
|
puts "Please enter a number"
|
145
119
|
retry
|
146
120
|
end
|
147
|
-
# need to handle wrong user input
|
148
121
|
begin
|
149
122
|
puts "Date: (today or yyyy-mm-dd)"
|
150
123
|
date = gets.chomp
|
@@ -173,6 +146,3 @@ class AppController
|
|
173
146
|
end
|
174
147
|
end
|
175
148
|
|
176
|
-
|
177
|
-
|
178
|
-
|
data/lib/Display.rb
CHANGED
@@ -24,7 +24,7 @@ class Display
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# if the activity is incomplete, it will turn red if the date has passed
|
27
|
-
if a.completed == false && is_in_past?(a.date)
|
27
|
+
if a.completed == 'false' && is_in_past?(a.date)
|
28
28
|
row = row.map do |cell|
|
29
29
|
cell.to_s.colorize(:red)
|
30
30
|
end
|
@@ -32,6 +32,7 @@ class Display
|
|
32
32
|
rows << row
|
33
33
|
end
|
34
34
|
table = Terminal::Table.new :title => "Activity Log", :headings => ['Activity', 'Distance', 'Duration', 'Date'], :rows => rows
|
35
|
+
puts table
|
35
36
|
end
|
36
37
|
|
37
38
|
def self.display_totals(distance, duration)
|
data/lib/Model.rb
CHANGED
@@ -36,9 +36,9 @@ class Model
|
|
36
36
|
|
37
37
|
# iterates over activities array
|
38
38
|
# overwrites file with updated activities
|
39
|
-
def self.update_activities(user
|
39
|
+
def self.update_activities(user)
|
40
40
|
CSV.open("users/#{user}.csv", "wb") do |file|
|
41
|
-
activities.each do |activity|
|
41
|
+
@@activities.each do |activity|
|
42
42
|
file << [activity.type, activity.distance, activity.duration, activity.date, activity.completed]
|
43
43
|
end
|
44
44
|
end
|
@@ -75,10 +75,10 @@ class Model
|
|
75
75
|
# updates the csv file to remove the deleted activity
|
76
76
|
def self.delete_activity(user, activity)
|
77
77
|
activities = self.get_activities(user)
|
78
|
-
activities = activities.select do |a|
|
78
|
+
@@activities = activities.select do |a|
|
79
79
|
a.type != activity.type || a.distance != activity.distance || a.duration != activity.duration
|
80
80
|
end
|
81
|
-
self.update_activities(user
|
81
|
+
self.update_activities(user)
|
82
82
|
end
|
83
83
|
|
84
84
|
# finds the users longest activities by time and distance
|
data/lib/app.rb
CHANGED
@@ -5,17 +5,21 @@ module Terminal
|
|
5
5
|
module App
|
6
6
|
class Error < StandardError; end
|
7
7
|
# Your code goes here...
|
8
|
+
if ARGV.length != 1
|
9
|
+
puts "One argument required"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
# pass the user name into the terminal
|
14
|
+
user_name = ARGV[0]
|
15
|
+
ARGV.clear
|
16
|
+
|
17
|
+
# Entry point to the app
|
18
|
+
AppController.check_user(user_name)
|
8
19
|
end
|
9
20
|
end
|
10
21
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
# pass the user name into the terminal
|
16
|
-
user_name = ARGV[0]
|
17
|
-
ARGV.clear
|
18
|
-
# Entry point to the app
|
19
|
-
AppController.check_user(user_name)
|
20
|
-
# AppController.check_user
|
22
|
+
|
23
|
+
|
24
|
+
|
21
25
|
|
data/lib/terminal/app/version.rb
CHANGED
data/lib/users/b.csv
ADDED
File without changes
|
data/lib/users/tess.csv
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
run,
|
2
|
-
|
3
|
-
bike,
|
4
|
-
|
5
|
-
run,
|
6
|
-
run,
|
1
|
+
run,10.0,50,2020-04-01,false
|
2
|
+
run,10.0,50,2020-03-13,false
|
3
|
+
bike,20.0,50,2020-03-13,false
|
4
|
+
run,30.0,300,2020-03-13,true
|
5
|
+
run,5.0,25,2020-03-12,true
|
6
|
+
run,4.0,20,2020-03-12,true
|
7
|
+
run,2.0,10,2020-03-09,true
|
8
|
+
swim,2.0,45,2020-02-22,true
|
9
|
+
run,8.0,25,2020-02-12,false
|
10
|
+
bike,23.0,56,2020-02-12,true
|
data/lib/users/test.csv
ADDED
File without changes
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tessssssssy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: my gem
|
14
14
|
email:
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".DS_Store"
|
20
21
|
- ".gitignore"
|
21
22
|
- ".rspec"
|
22
23
|
- ".travis.yml"
|
@@ -34,6 +35,7 @@ files:
|
|
34
35
|
- images/get-stats.png
|
35
36
|
- images/main-menu.png
|
36
37
|
- images/show.png
|
38
|
+
- images/trello.png
|
37
39
|
- lib/Activity.rb
|
38
40
|
- lib/AppController.rb
|
39
41
|
- lib/Display.rb
|
@@ -43,10 +45,13 @@ files:
|
|
43
45
|
- lib/terminal/app/version.rb
|
44
46
|
- lib/testing.rb
|
45
47
|
- lib/users/a.csv
|
48
|
+
- lib/users/b.csv
|
46
49
|
- lib/users/hdjsafk.csv
|
47
50
|
- lib/users/hfrhfuaerhfu.csv
|
48
51
|
- lib/users/hjfakj.csv
|
49
52
|
- lib/users/tess.csv
|
53
|
+
- lib/users/test.csv
|
54
|
+
- terminal-app-0.1.1.gem
|
50
55
|
- terminal-app.gemspec
|
51
56
|
homepage: https://github.com/tessssssssy/terminal-app
|
52
57
|
licenses:
|