ath_vega 0.1.1
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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +129 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +9 -0
- data/ath_vega-0.1.0.gem +0 -0
- data/ath_vega.gemspec +50 -0
- data/bin/ath-vega +4 -0
- data/bin/console +20 -0
- data/bin/setup +8 -0
- data/config/environment.rb +24 -0
- data/lib/api_error.rb +5 -0
- data/lib/ath_vega.rb +10 -0
- data/lib/ath_vega/cli.rb +92 -0
- data/lib/ath_vega/version.rb +5 -0
- data/lib/category.rb +33 -0
- data/lib/exercise.rb +16 -0
- data/lib/ninja-gaiden.png +0 -0
- data/lib/vega_api.rb +83 -0
- data/lib/workout.rb +31 -0
- metadata +265 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9d1d98c5d71f197ff8b25ba6ad58eeed3a5adc4d2e09796660a049413a081bdb
|
|
4
|
+
data.tar.gz: 274648fb57e645beac6d9d2d18f303b6d2c6b5c3b2a7fc5a60a4ced850417014
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a52a46f6b5a70cb6c7346a31a0170075a93aa670ef6897f63cbc4f2ce62a441fed4774445d78274537398fc0451b2636a036a31bbc5c4a9fd9e0f94eb37d041d
|
|
7
|
+
data.tar.gz: 6a42de43f1a4a947d207302a58d817597f1ba095a07923d5b6aaeaaf06da17ec7d96c114230a725bf58620c4d84b2e40923cae270d28e297b5053575f35641e4
|
data/.DS_Store
ADDED
|
Binary file
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in ath_vega.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
gem "rake", "~> 13.0"
|
|
9
|
+
|
|
10
|
+
gem "rubocop", "~> 1.7", require: false
|
|
11
|
+
gem "json"
|
|
12
|
+
gem "require_all"
|
|
13
|
+
gem "pry", :groups => [:development, :test]
|
|
14
|
+
gem "tty-prompt"
|
|
15
|
+
gem "tty-progressbar"
|
|
16
|
+
gem "tco"
|
|
17
|
+
gem "rmagick"
|
|
18
|
+
gem "catpix"
|
|
19
|
+
gem "tty-table"
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
ath_vega (0.2.0)
|
|
5
|
+
awesome_print
|
|
6
|
+
catpix
|
|
7
|
+
json
|
|
8
|
+
net-http
|
|
9
|
+
nokogiri
|
|
10
|
+
pry
|
|
11
|
+
require_all
|
|
12
|
+
rmagick
|
|
13
|
+
tco
|
|
14
|
+
tty-progressbar
|
|
15
|
+
tty-prompt
|
|
16
|
+
tty-table
|
|
17
|
+
uri
|
|
18
|
+
|
|
19
|
+
GEM
|
|
20
|
+
remote: https://rubygems.org/
|
|
21
|
+
specs:
|
|
22
|
+
ast (2.4.2)
|
|
23
|
+
awesome_print (1.8.0)
|
|
24
|
+
catpix (0.2.0)
|
|
25
|
+
docopt (~> 0.5, >= 0.5.0)
|
|
26
|
+
rmagick (~> 2.15, >= 2.15.2)
|
|
27
|
+
ruby-terminfo (~> 0.1, >= 0.1.1)
|
|
28
|
+
tco (~> 0.1, >= 0.1.8)
|
|
29
|
+
coderay (1.1.3)
|
|
30
|
+
diff-lcs (1.4.4)
|
|
31
|
+
docopt (0.6.1)
|
|
32
|
+
json (2.5.1)
|
|
33
|
+
method_source (1.0.0)
|
|
34
|
+
net-http (0.1.1)
|
|
35
|
+
net-protocol
|
|
36
|
+
uri
|
|
37
|
+
net-protocol (0.1.0)
|
|
38
|
+
nokogiri (1.11.1-x86_64-darwin)
|
|
39
|
+
racc (~> 1.4)
|
|
40
|
+
parallel (1.20.1)
|
|
41
|
+
parser (3.0.0.0)
|
|
42
|
+
ast (~> 2.4.1)
|
|
43
|
+
pastel (0.8.0)
|
|
44
|
+
tty-color (~> 0.5)
|
|
45
|
+
pry (0.14.0)
|
|
46
|
+
coderay (~> 1.1)
|
|
47
|
+
method_source (~> 1.0)
|
|
48
|
+
racc (1.5.2)
|
|
49
|
+
rainbow (3.0.0)
|
|
50
|
+
rake (13.0.3)
|
|
51
|
+
regexp_parser (2.1.1)
|
|
52
|
+
require_all (3.0.0)
|
|
53
|
+
rexml (3.2.4)
|
|
54
|
+
rmagick (2.16.0)
|
|
55
|
+
rspec (2.99.0)
|
|
56
|
+
rspec-core (~> 2.99.0)
|
|
57
|
+
rspec-expectations (~> 2.99.0)
|
|
58
|
+
rspec-mocks (~> 2.99.0)
|
|
59
|
+
rspec-core (2.99.2)
|
|
60
|
+
rspec-expectations (2.99.2)
|
|
61
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
62
|
+
rspec-mocks (2.99.4)
|
|
63
|
+
rubocop (1.11.0)
|
|
64
|
+
parallel (~> 1.10)
|
|
65
|
+
parser (>= 3.0.0.0)
|
|
66
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
67
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
68
|
+
rexml
|
|
69
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
70
|
+
ruby-progressbar (~> 1.7)
|
|
71
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
72
|
+
rubocop-ast (1.4.1)
|
|
73
|
+
parser (>= 2.7.1.5)
|
|
74
|
+
ruby-progressbar (1.11.0)
|
|
75
|
+
ruby-terminfo (0.1.1)
|
|
76
|
+
strings (0.2.0)
|
|
77
|
+
strings-ansi (~> 0.2)
|
|
78
|
+
unicode-display_width (~> 1.5)
|
|
79
|
+
unicode_utils (~> 1.4)
|
|
80
|
+
strings-ansi (0.2.0)
|
|
81
|
+
tco (0.1.8)
|
|
82
|
+
tty-color (0.6.0)
|
|
83
|
+
tty-cursor (0.7.1)
|
|
84
|
+
tty-progressbar (0.18.1)
|
|
85
|
+
strings-ansi (~> 0.2)
|
|
86
|
+
tty-cursor (~> 0.7)
|
|
87
|
+
tty-screen (~> 0.8)
|
|
88
|
+
unicode-display_width (>= 1.6, < 3.0)
|
|
89
|
+
tty-prompt (0.23.0)
|
|
90
|
+
pastel (~> 0.8)
|
|
91
|
+
tty-reader (~> 0.8)
|
|
92
|
+
tty-reader (0.9.0)
|
|
93
|
+
tty-cursor (~> 0.7)
|
|
94
|
+
tty-screen (~> 0.8)
|
|
95
|
+
wisper (~> 2.0)
|
|
96
|
+
tty-screen (0.8.1)
|
|
97
|
+
tty-spinner (0.9.3)
|
|
98
|
+
tty-cursor (~> 0.7)
|
|
99
|
+
tty-table (0.12.0)
|
|
100
|
+
pastel (~> 0.8)
|
|
101
|
+
strings (~> 0.2.0)
|
|
102
|
+
tty-screen (~> 0.8)
|
|
103
|
+
unicode-display_width (1.7.0)
|
|
104
|
+
unicode_utils (1.4.0)
|
|
105
|
+
uri (0.10.1)
|
|
106
|
+
wisper (2.0.1)
|
|
107
|
+
|
|
108
|
+
PLATFORMS
|
|
109
|
+
x86_64-darwin-20
|
|
110
|
+
|
|
111
|
+
DEPENDENCIES
|
|
112
|
+
ath_vega!
|
|
113
|
+
catpix
|
|
114
|
+
json
|
|
115
|
+
pry
|
|
116
|
+
rake (~> 13.0)
|
|
117
|
+
require_all
|
|
118
|
+
rmagick
|
|
119
|
+
rspec (~> 2.4)
|
|
120
|
+
rubocop (~> 1.7)
|
|
121
|
+
tco
|
|
122
|
+
tty-color
|
|
123
|
+
tty-progressbar
|
|
124
|
+
tty-prompt
|
|
125
|
+
tty-spinner
|
|
126
|
+
tty-table
|
|
127
|
+
|
|
128
|
+
BUNDLED WITH
|
|
129
|
+
2.2.9
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Ahmaud R. Templeton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# AthVega
|
|
2
|
+
|
|
3
|
+
<!-- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ath_vega`. To experiment with that code, run `bin/console` for an interactive prompt. -->
|
|
4
|
+
|
|
5
|
+
This command line interface (CLI) application allows a user to create a workout by selecting exercises from wger (pronounced 'vega') Workout Manager software.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'ath_vega'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle install
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install ath_vega
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
This is a command line interface that uses the open source workout app, 'wger' (pronounced vega) to create workouts with three exercises. To use, firstly follow the directions above to install the gem.
|
|
26
|
+
|
|
27
|
+
To run the app:
|
|
28
|
+
|
|
29
|
+
$ bin/ath_vega
|
|
30
|
+
|
|
31
|
+
You are then presented with a series of options for muscle groups (i.e. legs, back, etc.) to choose from. When you select a muscle, you will be presented with a list of exercises for that muscle group. Selecting an exercise adds it to the workout. Once you have selected three exercises, the terminal will output a table of your exercises.
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
36
|
+
|
|
37
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/<github username>/ath_vega.
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/ath_vega-0.1.0.gem
ADDED
|
Binary file
|
data/ath_vega.gemspec
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/ath_vega/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "ath_vega"
|
|
7
|
+
spec.version = AthVega::VERSION
|
|
8
|
+
spec.authors = ["Ahmaud R. Templeton"]
|
|
9
|
+
spec.email = ["ahmaud@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "workout planner."
|
|
12
|
+
spec.description = "Ath helps you plan your workout using exercises from the open source app, 'wger'."
|
|
13
|
+
spec.homepage = "https://github.com/ahmaudt/ath_vega"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
|
16
|
+
|
|
17
|
+
spec.metadata["allowed_push_host"] = 'http://rubygems.org'
|
|
18
|
+
|
|
19
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
|
20
|
+
spec.metadata = { "source_code_uri" => "https://github.com/ahmaudt/ath_vega" }
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = "exe"
|
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = ["lib"]
|
|
30
|
+
spec.add_development_dependency "rspec", "~> 2.4"
|
|
31
|
+
spec.add_dependency "nokogiri", "~> 1.11.1"
|
|
32
|
+
spec.add_dependency "net-http", "~> 0.1.1"
|
|
33
|
+
spec.add_dependency "uri", "~> 0.10.1"
|
|
34
|
+
spec.add_dependency "awesome_print", "~> 1.8.0"
|
|
35
|
+
spec.add_dependency "json", "~> 2.5.1"
|
|
36
|
+
spec.add_dependency "require_all", "~> 3.0.0"
|
|
37
|
+
spec.add_dependency "pry", "~> 0.14.0"
|
|
38
|
+
spec.add_dependency "tty-progressbar", "~> 0.18.1"
|
|
39
|
+
spec.add_dependency "tty-prompt", "~> 0.23.0"
|
|
40
|
+
spec.add_dependency "tco", "~> 0.1.8"
|
|
41
|
+
spec.add_dependency "rmagick", "~> 2.16.0"
|
|
42
|
+
spec.add_dependency "catpix", "~> 0.2.0"
|
|
43
|
+
spec.add_dependency "tty-table", "~> 0.12.0"
|
|
44
|
+
|
|
45
|
+
# Uncomment to register a new dependency of your gem
|
|
46
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
47
|
+
|
|
48
|
+
# For more information and examples about making a new gem, checkout our
|
|
49
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
50
|
+
end
|
data/bin/ath-vega
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative '../config/environment.rb'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
puts "Welcome to the console. Command line interface methods are located in cli.rb, which can be found in the 'config' folder."
|
|
14
|
+
|
|
15
|
+
def reload!
|
|
16
|
+
load_all '../lib'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
require "irb"
|
|
20
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'bundler/setup'
|
|
2
|
+
Bundler.require(:default, :development)
|
|
3
|
+
|
|
4
|
+
require "ath_vega"
|
|
5
|
+
require "require_all"
|
|
6
|
+
require 'net/http'
|
|
7
|
+
require 'uri'
|
|
8
|
+
require 'open-uri'
|
|
9
|
+
require 'awesome_print'
|
|
10
|
+
require 'json'
|
|
11
|
+
require 'nokogiri'
|
|
12
|
+
require 'pry'
|
|
13
|
+
require 'catpix'
|
|
14
|
+
require 'rmagick'
|
|
15
|
+
require_relative '../lib/ath_vega'
|
|
16
|
+
require_relative '../lib/vega_api'
|
|
17
|
+
require_relative '../lib/workout'
|
|
18
|
+
require_relative '../lib/exercise'
|
|
19
|
+
require_relative '../lib/category'
|
|
20
|
+
require_relative '../lib/cli_error'
|
|
21
|
+
require_relative '../lib/ath_vega/cli'
|
|
22
|
+
|
|
23
|
+
# require_relative '../lib/ninja-gaiden.png'
|
|
24
|
+
|
data/lib/api_error.rb
ADDED
data/lib/ath_vega.rb
ADDED
data/lib/ath_vega/cli.rb
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# CLI Controller
|
|
2
|
+
|
|
3
|
+
class CLI
|
|
4
|
+
|
|
5
|
+
def list_categories # lists categories as hash w/ index for use in menu
|
|
6
|
+
categories = {}
|
|
7
|
+
API.new.get_category_objects.each.with_index { |cat, idx| categories[:"#{cat.muscle}"] = idx }
|
|
8
|
+
categories
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def selected_category(user_category_selection)
|
|
12
|
+
API.new.get_category_objects[user_category_selection] #receives index location and returns object instance from array of instances in Category class
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def prompt
|
|
16
|
+
prompt = TTY::Prompt.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def category_menu
|
|
20
|
+
cat_obj = selected_category(prompt.select("Select muscle group to see exercises", list_categories, cycle:true)) # menu to select muscle category. It returns index value to get instance of category from Category class array
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def list_items(cat_obj) # takes instance of Category class as argument, and returns list of exercises that belong to it
|
|
24
|
+
exercises = {}
|
|
25
|
+
cat_obj.get_exercises.each.with_index { |exr, idx| exercises[:"#{exr.name}\n#{exr.description}"] = idx }
|
|
26
|
+
exercises
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def selected_exercise(user_exrcise_selection)
|
|
30
|
+
get_exercise_objects[user_exrcise_selection] #receives index location and returns object instance from array of instances in Category class
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def exercise_menu(cat_obj) # takes value of user_selection variable returned from category_menu method as argument
|
|
34
|
+
exr_obj = API.new.get_exercise_for_cat(cat_obj, prompt.select("Select an exercise to add to your workout", list_items(cat_obj), cycle:true))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def show_workout(workout_session)
|
|
38
|
+
table = TTY::Table.new(["Session Exercises:", "#{workout_session.session_exercises[2].name}","#{workout_session.session_exercises[1].name}", "#{workout_session.session_exercises[0].name}"], [["Set/Reps:", "", "", ""]])
|
|
39
|
+
puts table.render :unicode
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def start
|
|
43
|
+
puts "
|
|
44
|
+
∎
|
|
45
|
+
∎∎∎
|
|
46
|
+
∎∎∎∎∎
|
|
47
|
+
| |
|
|
48
|
+
∎∎∎∎∎
|
|
49
|
+
∎∎∎∎∎ Ivory Tower Studios presents...
|
|
50
|
+
"
|
|
51
|
+
sleep 2
|
|
52
|
+
puts "ATH 'vega' the workout app for ninjas."
|
|
53
|
+
puts "\n(built on the open source 'wger' platform)"
|
|
54
|
+
sleep 1
|
|
55
|
+
Catpix::print_image "./lib/ninja-gaiden.png",
|
|
56
|
+
:limit_x => 0.15,
|
|
57
|
+
:limit_y => 0,
|
|
58
|
+
:center_x => false,
|
|
59
|
+
:center_y => false,
|
|
60
|
+
:bg => "white",
|
|
61
|
+
:bg_fill => false
|
|
62
|
+
puts "Let's get started!"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def api_call
|
|
66
|
+
vega_api = API.new
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def create_session(vega_api)
|
|
70
|
+
new_workout_session = vega_api.create_workout
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def create_objects(vega_api)
|
|
74
|
+
vega_api.call_data
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def call
|
|
78
|
+
start
|
|
79
|
+
vega_api = api_call
|
|
80
|
+
new_workout_session = vega_api.create_workout
|
|
81
|
+
create_objects(vega_api)
|
|
82
|
+
prompt
|
|
83
|
+
while new_workout_session.session_exercises.length < 3
|
|
84
|
+
cat_obj = nil
|
|
85
|
+
exr_obj = nil
|
|
86
|
+
cat_obj = category_menu
|
|
87
|
+
exr_obj = exercise_menu(cat_obj)
|
|
88
|
+
exr_obj.workout = new_workout_session
|
|
89
|
+
end
|
|
90
|
+
show_workout(new_workout_session)
|
|
91
|
+
end
|
|
92
|
+
end
|
data/lib/category.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class Category
|
|
2
|
+
attr_accessor :muscle, :exercises
|
|
3
|
+
|
|
4
|
+
@@all_categories = []
|
|
5
|
+
def initialize
|
|
6
|
+
@muscle = muscle
|
|
7
|
+
@@all_categories << self
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.all
|
|
11
|
+
@@all_categories
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.set_exercises # sets what category instance of exercise object belongs to
|
|
15
|
+
self.all.each do |category|
|
|
16
|
+
Exercise.all.select do |exr|
|
|
17
|
+
if category.muscle == exr.muscle
|
|
18
|
+
exr.category = category
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_exercises # gets exercises belonging to an instance of Category
|
|
25
|
+
Exercise.all.select { |exr| exr.category == self }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.get_exr_by_cat(user_input)
|
|
29
|
+
selected_category = self.all[user_input]
|
|
30
|
+
selected_category.get_exercises
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
data/lib/exercise.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Exercise # exercise belongs to a category
|
|
2
|
+
attr_accessor :name, :muscle, :description, :workout, :category
|
|
3
|
+
|
|
4
|
+
@@all_exercises = []
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@name = name
|
|
8
|
+
@muscle = muscle # each instance of exercise will set its muscle equal to instance of muscle category
|
|
9
|
+
@description = description
|
|
10
|
+
@@all_exercises << self
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.all
|
|
14
|
+
@@all_exercises
|
|
15
|
+
end
|
|
16
|
+
end
|
|
Binary file
|
data/lib/vega_api.rb
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class API
|
|
2
|
+
EXR_PATH = "https://wger.de/api/v2/exercise/?limit=227&language=2"
|
|
3
|
+
EXR_CAT_PATH = "https://wger.de/api/v2/exercisecategory/?language=2&format=json"
|
|
4
|
+
EXR_AUTH = "Authorization: Token 7f49dbc8baed11960d576e35b45fe34c060eaeab"
|
|
5
|
+
EXR_WORKOUT = 'https://wger.de/api/v2/workout/?format=json'
|
|
6
|
+
EXR_MAKE_WRKOUT = 'https://wger.de/api/v2/workout/?format=json'
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_exercises
|
|
13
|
+
exr_list = `curl --silent -H "#{EXR_AUTH}" -X GET "#{EXR_PATH}"`
|
|
14
|
+
exr_list = JSON.parse(exr_list)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_categories
|
|
18
|
+
exr_cat = `curl --silent -H "#{EXR_AUTH}" -X GET "#{EXR_CAT_PATH}"`
|
|
19
|
+
exr_cat = JSON.parse(exr_cat)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_categories
|
|
23
|
+
exr_cat = get_categories
|
|
24
|
+
exr_cat["results"].each do |cat|
|
|
25
|
+
category = Category.new
|
|
26
|
+
category.muscle = cat["name"]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def create_exercises
|
|
31
|
+
exr_cat = get_categories
|
|
32
|
+
exr_list = get_exercises
|
|
33
|
+
exr_list["results"].each do |idx|
|
|
34
|
+
new_exercise = Exercise.new
|
|
35
|
+
exr_cat["results"].each do |val|
|
|
36
|
+
#! set key category equal to value of category in other hash
|
|
37
|
+
if idx["category"] == val["id"] && idx["language"] == 2 && idx["description"] != ""
|
|
38
|
+
new_exercise.muscle = val["name"]
|
|
39
|
+
new_exercise.name = idx["name"]
|
|
40
|
+
new_exercise.description = "#{idx["description"][/\b(?<=<p>).*(?=<\/p>)/]}".insert(0, "\u{1F3CB} ")
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
Category.set_exercises
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def call_data
|
|
48
|
+
bar = TTY::ProgressBar.new("getting workout data... [:bar]", total: 40)
|
|
49
|
+
create_categories
|
|
50
|
+
create_exercises
|
|
51
|
+
40.times do
|
|
52
|
+
sleep(0.2)
|
|
53
|
+
bar.advance # by default increases by 1
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def get_category_objects
|
|
58
|
+
Category.all
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def get_exercise_for_cat(cat_obj, index)
|
|
62
|
+
cat_obj.get_exercises[index]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def get_last_workout_id
|
|
66
|
+
workout = `curl --silent -H "#{EXR_AUTH}" -X GET "#{EXR_WORKOUT}"`
|
|
67
|
+
workout = JSON.parse(workout)
|
|
68
|
+
if workout["results"].to_a.length == 0
|
|
69
|
+
last_id = 258370
|
|
70
|
+
else
|
|
71
|
+
last_id = workout["results"].to_a.last["id"]
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def create_workout
|
|
76
|
+
last_id = get_last_workout_id
|
|
77
|
+
new_workout_id = last_id + 1
|
|
78
|
+
new_workout = Workout.new(new_workout_id)
|
|
79
|
+
send_workout = `curl --silent -H "#{EXR_AUTH}" -X POST --data "{ "id": #{new_workout.id}, "creation_date": #{new_workout.creation_date}, "comments": #{new_workout.comments} }" "#{EXR_WORKOUT}"`
|
|
80
|
+
new_workout
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
data/lib/workout.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class Workout
|
|
2
|
+
attr_accessor :id, :creation_date, :comments, :workout_hash
|
|
3
|
+
|
|
4
|
+
@@all = []
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def initialize(id, comments=nil, creation_date=Time.new.strftime("%Y-%m-%d"))
|
|
8
|
+
@id = id
|
|
9
|
+
@comments = comments
|
|
10
|
+
@creation_date = creation_date
|
|
11
|
+
@@all << self
|
|
12
|
+
@workout_hash = self.hash_workout
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def hash_workout
|
|
16
|
+
workout_hash = Hash.new
|
|
17
|
+
workout_hash = {:id => id, :comments => comments, :creation_date => creation_date}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.all
|
|
21
|
+
@@all
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def add_selected_to_current_workout(exr)
|
|
25
|
+
exr.workout = self
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def session_exercises
|
|
29
|
+
Exercise.all.select { |exr| exr.workout == self }
|
|
30
|
+
end
|
|
31
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ath_vega
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ahmaud R. Templeton
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-03-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rspec
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.4'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.4'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: nokogiri
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 1.11.1
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 1.11.1
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: net-http
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.1.1
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.1.1
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: uri
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.10.1
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.10.1
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: awesome_print
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 1.8.0
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 1.8.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: json
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 2.5.1
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 2.5.1
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: require_all
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 3.0.0
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 3.0.0
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: pry
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.14.0
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.14.0
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: tty-progressbar
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 0.18.1
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 0.18.1
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: tty-prompt
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: 0.23.0
|
|
146
|
+
type: :runtime
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: 0.23.0
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: tco
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - "~>"
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: 0.1.8
|
|
160
|
+
type: :runtime
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - "~>"
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: 0.1.8
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: rmagick
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - "~>"
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: 2.16.0
|
|
174
|
+
type: :runtime
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - "~>"
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: 2.16.0
|
|
181
|
+
- !ruby/object:Gem::Dependency
|
|
182
|
+
name: catpix
|
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
|
184
|
+
requirements:
|
|
185
|
+
- - "~>"
|
|
186
|
+
- !ruby/object:Gem::Version
|
|
187
|
+
version: 0.2.0
|
|
188
|
+
type: :runtime
|
|
189
|
+
prerelease: false
|
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
191
|
+
requirements:
|
|
192
|
+
- - "~>"
|
|
193
|
+
- !ruby/object:Gem::Version
|
|
194
|
+
version: 0.2.0
|
|
195
|
+
- !ruby/object:Gem::Dependency
|
|
196
|
+
name: tty-table
|
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
|
198
|
+
requirements:
|
|
199
|
+
- - "~>"
|
|
200
|
+
- !ruby/object:Gem::Version
|
|
201
|
+
version: 0.12.0
|
|
202
|
+
type: :runtime
|
|
203
|
+
prerelease: false
|
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
205
|
+
requirements:
|
|
206
|
+
- - "~>"
|
|
207
|
+
- !ruby/object:Gem::Version
|
|
208
|
+
version: 0.12.0
|
|
209
|
+
description: Ath helps you plan your workout using exercises from the open source
|
|
210
|
+
app, 'wger'.
|
|
211
|
+
email:
|
|
212
|
+
- ahmaud@gmail.com
|
|
213
|
+
executables: []
|
|
214
|
+
extensions: []
|
|
215
|
+
extra_rdoc_files: []
|
|
216
|
+
files:
|
|
217
|
+
- ".DS_Store"
|
|
218
|
+
- ".gitignore"
|
|
219
|
+
- ".rubocop.yml"
|
|
220
|
+
- CHANGELOG.md
|
|
221
|
+
- Gemfile
|
|
222
|
+
- Gemfile.lock
|
|
223
|
+
- LICENSE.txt
|
|
224
|
+
- README.md
|
|
225
|
+
- Rakefile
|
|
226
|
+
- ath_vega-0.1.0.gem
|
|
227
|
+
- ath_vega.gemspec
|
|
228
|
+
- bin/ath-vega
|
|
229
|
+
- bin/console
|
|
230
|
+
- bin/setup
|
|
231
|
+
- config/environment.rb
|
|
232
|
+
- lib/api_error.rb
|
|
233
|
+
- lib/ath_vega.rb
|
|
234
|
+
- lib/ath_vega/cli.rb
|
|
235
|
+
- lib/ath_vega/version.rb
|
|
236
|
+
- lib/category.rb
|
|
237
|
+
- lib/exercise.rb
|
|
238
|
+
- lib/ninja-gaiden.png
|
|
239
|
+
- lib/vega_api.rb
|
|
240
|
+
- lib/workout.rb
|
|
241
|
+
homepage: https://github.com/ahmaudt/ath_vega
|
|
242
|
+
licenses:
|
|
243
|
+
- MIT
|
|
244
|
+
metadata:
|
|
245
|
+
source_code_uri: https://github.com/ahmaudt/ath_vega
|
|
246
|
+
post_install_message:
|
|
247
|
+
rdoc_options: []
|
|
248
|
+
require_paths:
|
|
249
|
+
- lib
|
|
250
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
|
+
requirements:
|
|
252
|
+
- - ">="
|
|
253
|
+
- !ruby/object:Gem::Version
|
|
254
|
+
version: 2.4.0
|
|
255
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
|
+
requirements:
|
|
257
|
+
- - ">="
|
|
258
|
+
- !ruby/object:Gem::Version
|
|
259
|
+
version: '0'
|
|
260
|
+
requirements: []
|
|
261
|
+
rubygems_version: 3.2.9
|
|
262
|
+
signing_key:
|
|
263
|
+
specification_version: 4
|
|
264
|
+
summary: workout planner.
|
|
265
|
+
test_files: []
|