March 18, 2024
flatiron school

My Journey Of Learning Programming Through Flatiron School #32

My name is Mason Ellwood, and I’m currently working on Flatiron School’s Online Full Stack Web Development Program. Each week, I’ll be writing about my experience, what I’m learning, and tips on learning to code.

This week I finally finished one of the final project through The Flatiron School. With that final project we were supposed to write a blog post for the school, stepping out processes and procedures on how we approached this task. Below is the article I wrote for the school. This gives you a brief understanding of what was required of us for the project.

“Hi my name is Mason Ellwood and I finally did it! I created my first working gem. My approach to this came at a rough start. This was my first gem I have ever built and the first project that I have approached without the training wheels of the learn.ide or someone explicitly telling me what to do or how to do it. This was a big task especially when looking at a blank screen…

So for my app, because I have currently traveled I decided on building a weather app that when called asks what state you reside in. If on the chance you forgot how to spell the states, will list out the states as well. Once the user has typed a state they will then be prompted with a new message of which city they would like to know the weather off. If again the user does not know the names of the cities in that area, will also list the cities in that state. Once the user types the city they would like to know more about it will display the weather, all done with Nokogiri.

For this project, I closely followed the setup instructions supplied by Avi here (https://www.youtube.com/watch?v=_lDExWIhYKI). This follows the bundler preset setup instructions using (bundle gem GEMNAME). Using the rails casts (http://railscasts.com/episodes/245-new-gem-with-bundler) to get me started. Once my local environment, and getting my “hello world” message to display upon first initialization of the cli prompt I began to deviate from Avi’s video walkthrough.

For what I wanted to do, I first had to think of where I was going to get this information…. The best site I have found for this is (www.wunderground.com). With this site comes a lot of functionality right out of the box. First I noticed that their URL works great for user input and string interpolation. When I went to a site and searched a state it returned all the cities in that state which is just what I needed. In cli.rb document I allowed for a user input of a variable. With that, I then interpolated the user input of a state to the URL of the site (https://www.wunderground.com/cgi-bin/findweather/getForecast?query=#{USER_INPUT_OFSTATE}). With this, I was in business, now time to scrape.

I created a file that scrapped the state for all the cities in that state. This if prompted returned the user a screen that allowed them to place a city name or list the cities in that state. Depending on what the user wanted they could either place a city name or list out the city. If the user wanted a specific city input then they would just type the city name.

When they type the city name, it checks what city they imputed and then pulls that href from each city that was included on that state’s page interpolating the URL to the home URL. (https://www.wunderground.com/#{CITY_INPUT_URL}). This sends the user now to that URL and scrapes the relevant data they need.

This returns the weather information of that state at that instant displaying a message back to the user of the information they want. This then prompts if they want to get a new city’s weather information or go and get a different state’s information.

And there you have it a weather app! The main issue I did not foresee is naming convention… a weather gem already exists with the same naming conventions of my weather app. This caused issues when I wanted to push it to the rubygems.com website. So in the future, I will make sure to check before hand if something with these naming conventions already exists. This will save tons of time in the future, and major headaches.

Overall once I began to understand how all the files were related to each other, it was easy to proceed. Through this project, I learned how to create a ruby gem, how to create and plan a project from start to finish, how to publish a ruby gem, the importance of naming conventions, and how to build and install a gem to Bundle. Over it was an awesome project.”

Leave a Reply

Your email address will not be published. Required fields are marked *