My Experience writing a CLI app
So I have all but completed my Ruby CLI Project. It was a rather large undertaking but once I got moving it came together alot more fluidly than I thought it would. The first hurdle I had to complete was to determine weather I was going to scrape a site for data or use an API. I wanted to make this decision before I chose a topic as the data that I could find might have an impact on what topic I chose. It turns out that was very much the case. I originally was planning on coming up with an app that would tell you airport codes and information based on selecting a location. Through researching I decided to go the API route as it was clear that would be a safer way to produce an app that with scraping. Reason being when you scrape a website you are taking data off of a live site which always has the possiblity of changing. If the data changes format it could really impact how your app works. An API on the other hand does not change the way it is formatted as the point of the API is to be a database made to pull data to a person’s application from a specfic source. Where I ran in to trouble was th topic I picked. There were many API’s out there however they were all not great for sourcing the information I needed and the one’s that were good, all had a cost connected to using them. While I was searching for an API I did find one that was a great source for data about MicroBreweries in the country, so I decided to pivot to design an app that when you enter the state it would pull up a list of breweries and from there you could chose a specific brewery and find out more data IE address, phone and website.
Now that I had my API and my topic it was time to start coding. I needed a framework to give my app its structure and I remembered from our lessons that using the bundler gem would set up a perfect app framework including all necessary files, licenses and a Readme. Once I ran the Bundler and set up my files I connected it to github and made my initial commit. From there I was off! I knew I needed three classes, One for my API, One for my brewery data and One for the CLI to manage how the program would run. From there I was off, I decided to use a technique Avi talked about where I just wrote out in my CLI class the methods I needed to make this app work. I didn’t write the code to acctually make it work, that took a little more time but that gave me a place to start. From there I used the API data I found from the API’s website to make an API services class and write two methods, one to pull the whole list I could use to search from and the other would allow me to pull just the data on one brewery I could use when drilling down to my apps second level. I was then able to create a brewery class that would allow my app to take the information I was pulling from the API and use it to pull specific data. Once I had that I went back to my CLI Class and was able to write the code to ask the user what state they were looking for and present them with a list, from there I could ask them to select which brewery they wanted to learn more about and it presented them with more data.