forked from appdev-projects/ruby-project-hash-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fd2125e
Showing
23 changed files
with
902 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tmp/* | ||
.theia/.ltici_apitoken.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
image: jelaniwoods/appdev2021-hash-chapter@sha256:c3fc3004689b5a36ae53c4d94181158f3f6b2bffb3f11f0f4d5e80aca2347287 | ||
|
||
tasks: | ||
- command: bundle install | ||
- init: bin/setup | ||
ports: | ||
- port: 3000 | ||
onOpen: open-preview | ||
|
||
vscode: | ||
extensions: | ||
- shd101wyy.markdown-preview-enhanced | ||
- vortizhe.simple-ruby-erb | ||
- CraigMaslowski.erb | ||
- Vense.rails-snippets | ||
- wingrunr21.vscode-ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--color | ||
--format documentation | ||
--order default | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.7.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"editor.autoSave": "on", | ||
"editor.tabSize": 2, | ||
"emmet.includeLanguages": { | ||
"erb": "html" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
FROM buildpack-deps:focal | ||
|
||
### base ### | ||
RUN yes | unminimize \ | ||
&& apt-get install -yq \ | ||
zip \ | ||
unzip \ | ||
bash-completion \ | ||
build-essential \ | ||
htop \ | ||
jq \ | ||
less \ | ||
locales \ | ||
man-db \ | ||
nano \ | ||
software-properties-common \ | ||
sudo \ | ||
time \ | ||
vim \ | ||
multitail \ | ||
lsof \ | ||
&& locale-gen en_US.UTF-8 \ | ||
&& mkdir /var/lib/apt/dazzle-marks \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* | ||
|
||
ENV LANG=en_US.UTF-8 | ||
|
||
### Git ### | ||
RUN add-apt-repository -y ppa:git-core/ppa \ | ||
&& apt-get install -yq git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
### Gitpod user ### | ||
# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user | ||
RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \ | ||
# passwordless sudo for users in the 'sudo' group | ||
&& sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers | ||
ENV HOME=/home/gitpod | ||
WORKDIR $HOME | ||
# custom Bash prompt | ||
RUN { echo && echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \\\$ '" ; } >> .bashrc | ||
|
||
### Gitpod user (2) ### | ||
USER gitpod | ||
# use sudo so that user does not get sudo usage info on (the first) login | ||
RUN sudo echo "Running 'sudo' for Gitpod: success" && \ | ||
# create .bashrc.d folder and source it in the bashrc | ||
mkdir /home/gitpod/.bashrc.d && \ | ||
(echo; echo "for i in \$(ls \$HOME/.bashrc.d/*); do source \$i; done"; echo) >> /home/gitpod/.bashrc | ||
|
||
### Ruby ### | ||
LABEL dazzle/layer=lang-ruby | ||
LABEL dazzle/test=tests/lang-ruby.yaml | ||
USER gitpod | ||
RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - \ | ||
&& curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - \ | ||
&& curl -fsSL https://get.rvm.io | bash -s stable \ | ||
&& bash -lc " \ | ||
rvm requirements \ | ||
&& rvm install 2.7.3 \ | ||
&& rvm use 2.7.3 --default \ | ||
&& rvm rubygems current \ | ||
&& gem install bundler --no-document \ | ||
&& gem install solargraph --no-document" \ | ||
&& echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> /home/gitpod/.bashrc.d/70-ruby | ||
RUN echo "rvm_gems_path=/home/gitpod/.rvm" > ~/.rvmrc | ||
|
||
USER gitpod | ||
# AppDev stuff | ||
|
||
WORKDIR /base-rails | ||
|
||
# Install Google Chrome | ||
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | ||
RUN sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | ||
RUN sudo apt-get -y update | ||
RUN sudo apt-get -y install google-chrome-stable | ||
# Install Chromedriver | ||
RUN sudo apt-get -y install google-chrome-stable | ||
RUN wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip | ||
RUN unzip chromedriver_linux64.zip | ||
|
||
RUN sudo mv chromedriver /usr/bin/chromedriver | ||
RUN sudo chown root:root /usr/bin/chromedriver | ||
RUN sudo chmod +x /usr/bin/chromedriver | ||
|
||
RUN /bin/bash -l -c "gem install htmlbeautifier" | ||
RUN /bin/bash -l -c "gem install rufo" | ||
COPY Gemfile /base-rails/Gemfile | ||
COPY --chown=gitpod:gitpod Gemfile.lock /base-rails/Gemfile.lock | ||
RUN /bin/bash -l -c "gem install bundler:2.1.4" | ||
|
||
USER gitpod | ||
|
||
RUN /bin/bash -l -c "bundle install" | ||
|
||
RUN /bin/bash -l -c "curl https://cli-assets.heroku.com/install.sh | sh" | ||
|
||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | ||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | ||
|
||
RUN sudo apt-get update && sudo apt-get install -y nodejs yarn | ||
# postgresql-client | ||
# RUN sudo apt-get update && sudo apt-get install -y yarn | ||
# RUN sudo apt install -y postgresql postgresql-contrib libpq-dev psmisc lsof expect | ||
RUN sudo apt install -y libpq-dev psmisc lsof expect | ||
USER gitpod | ||
RUN echo 'export PATH="$PATH:$GITPOD_REPO_ROOT/bin"' >> ~/.bashrc | ||
RUN echo "rvm use 2.7.3" >> ~/.bashrc | ||
RUN echo "rvm_silence_path_mismatch_check_flag=1" >> ~/.rvmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
source 'https://rubygems.org' | ||
|
||
ruby '2.7.3' | ||
|
||
gem "ruby_grade_runner", :git => "https://github.com/firstdraft/ruby_grade_runner.git" | ||
gem "web_git", :git => "https://github.com/firstdraft/web_git.git", :branch => "spring2020" | ||
|
||
gem "rake" | ||
|
||
group :test do | ||
gem 'rspec' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
GIT | ||
remote: https://github.com/firstdraft/ruby_grade_runner.git | ||
revision: e59261124de647ff09a7d95ac09fe26dbf4d93d8 | ||
specs: | ||
ruby_grade_runner (0.0.5.1) | ||
oj | ||
|
||
GIT | ||
remote: https://github.com/firstdraft/web_git.git | ||
revision: 4dbadc999d057f2bf0f9f74aec4deed79cf07350 | ||
branch: spring2020 | ||
specs: | ||
web_git (0.1.0) | ||
actionview | ||
diffy | ||
git | ||
sinatra | ||
tzinfo-data | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionview (6.1.4) | ||
activesupport (= 6.1.4) | ||
builder (~> 3.1) | ||
erubi (~> 1.4) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.1, >= 1.2.0) | ||
activesupport (6.1.4) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
zeitwerk (~> 2.3) | ||
builder (3.2.4) | ||
concurrent-ruby (1.1.9) | ||
crass (1.0.6) | ||
diff-lcs (1.4.4) | ||
diffy (3.4.0) | ||
erubi (1.10.0) | ||
git (1.8.1) | ||
rchardet (~> 1.8) | ||
i18n (1.8.10) | ||
concurrent-ruby (~> 1.0) | ||
loofah (2.10.0) | ||
crass (~> 1.0.2) | ||
nokogiri (>= 1.5.9) | ||
mini_portile2 (2.5.3) | ||
minitest (5.14.4) | ||
mustermann (1.1.1) | ||
ruby2_keywords (~> 0.0.1) | ||
nokogiri (1.11.7) | ||
mini_portile2 (~> 2.5.0) | ||
racc (~> 1.4) | ||
oj (3.11.7) | ||
racc (1.5.2) | ||
rack (2.2.3) | ||
rack-protection (2.1.0) | ||
rack | ||
rails-dom-testing (2.0.3) | ||
activesupport (>= 4.2.0) | ||
nokogiri (>= 1.6) | ||
rails-html-sanitizer (1.3.0) | ||
loofah (~> 2.3) | ||
rake (13.0.3) | ||
rchardet (1.8.0) | ||
rspec (3.10.0) | ||
rspec-core (~> 3.10.0) | ||
rspec-expectations (~> 3.10.0) | ||
rspec-mocks (~> 3.10.0) | ||
rspec-core (3.10.1) | ||
rspec-support (~> 3.10.0) | ||
rspec-expectations (3.10.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-mocks (3.10.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-support (3.10.2) | ||
ruby2_keywords (0.0.4) | ||
sinatra (2.1.0) | ||
mustermann (~> 1.0) | ||
rack (~> 2.2) | ||
rack-protection (= 2.1.0) | ||
tilt (~> 2.0) | ||
tilt (2.0.10) | ||
tzinfo (2.0.4) | ||
concurrent-ruby (~> 1.0) | ||
tzinfo-data (1.2021.1) | ||
tzinfo (>= 1.0.0) | ||
zeitwerk (2.4.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
rake | ||
rspec | ||
ruby_grade_runner! | ||
web_git! | ||
|
||
RUBY VERSION | ||
ruby 2.7.3p183 | ||
|
||
BUNDLED WITH | ||
2.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Ruby Practice | ||
|
||
Run your Ruby file by typing `ruby ` and then the name of the file you want to run in the Terminal. | ||
|
||
If we want to run `hash_person.rb`, we can write the command: | ||
|
||
```bash | ||
ruby hash_person.rb | ||
``` | ||
|
||
To re-run this command, you can use the UP and DOWN arrow keys to look at the history of commands you've run in a Terminal. | ||
|
||
## Hash | ||
|
||
### hash_person.rb | ||
Input: | ||
``` | ||
Maude 24 Artist | ||
``` | ||
|
||
Key output: | ||
`{ :name => "Maude", :age => 24, :occupation => "Artist" }` | ||
|
||
Complete input and output example: | ||
```bash | ||
"Enter a name, age, and occupation separated by spaces:" | ||
Maude 24 Artist | ||
{ :name => "Maude", :age => 24, :occupation => "Artist" } | ||
``` | ||
###### Make sure the value of the :age key is an Integer | ||
### hash_dig.rb | ||
Write a program that uses the `sample_hash` variable and prints the value of key "history" | ||
```ruby | ||
sample_hash = { | ||
:class => { | ||
:student => { | ||
:name => "Mike", | ||
"marks" => { | ||
"physics" => 70, | ||
"history" => 80 | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
### hash_find_value.rb | ||
Write a program that: | ||
Asks the user for an Integer, then checks to see if that integer is | ||
a value of any of the keys in sample_hash. | ||
If you find the number, print out "100 is under the key: a." | ||
If you don't find the number print out "Could not find the integer 100" | ||
Example: | ||
```bash | ||
"Enter an integer:" | ||
4 | ||
"Could not find the integer 4" | ||
``` | ||
### hash_list.rb | ||
Given this list of people, print only names of people who are at least 16. | ||
Yes, you could just look at it with your eyes and print their names, but imagine that you couldn't because there are a million items in the list. | ||
Use the variable, loops, and conditionals instead. | ||
Output something like: | ||
```bash | ||
"Jerry" | ||
"Sloane" | ||
"Hurly" | ||
``` | ||
## Specs | ||
<details> | ||
<summary>Click here to see names of each test</summary> | ||
hash_person.rb prints Hash of '{:name => "Osi", :age => 24, :occupation => "Songwriter"}', when input is 'Osi 24 Songwriter' | ||
hash_person.rb prints Hash of '{:name => "Lia", :age => 32, :occupation => "Engineer"}', when input is 'Lia 32 Engineer' | ||
hash_find_value.rb prints Hash of 'Could not find the integer 4', when input is '4' | ||
hash_find_value.rb prints Hash of '100 is under the key: a.', when input is '100' | ||
hash_find_value.rb prints Hash of '22 is under the key: e.', when input is '22' | ||
hash_find_value.rb prints Hash of '32 is under the key: e.', when input is '32' | ||
hash_dig.rb prints '80' by retriving the value from the Hash | ||
hash_list.rb prints 'James', 'Yolanda', 'Red', and 'Fatimah' using variables, loops, if statements, and Hash methods' | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env ruby | ||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'rake' | ||
|
||
dir = Gem::Specification.find_by_name('ruby_grade_runner').gem_dir | ||
|
||
load "#{dir}/lib/tasks/grade.rake" | ||
task_name = ARGV[0] | ||
|
||
Rake::Task[task_name].invoke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
parentdir="$(dirname "$DIR")" | ||
pid="$parentdir/tmp/pids/server.pid" | ||
if [ -f $pid ]; then | ||
rm $pid | ||
fi | ||
fuser -k -n tcp 3000 | ||
rackup --port=3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
|
||
puts "== Installing dependencies ==" | ||
`bundle install` | ||
puts "\n== Initial setup complete ==" |
Oops, something went wrong.