In preparation for learning Sinatra next week, I’ve gone poking through through this example of a Sinatra gem that I found on Github. It seemed the ideal first investigation. It’s simple – it’s only function is to write obnoxious text in a command line to annoy one’s coworkers ( a win in itself), and it’s named after the character Bubs from The Wire.
The structure reminds me of poking through video game folders on my computer, trying to
The app has two main folders, lib and bin. Lib is clearly the folder that actually does things. Remember, this is an incredibly simple app. It contains exactly one file, which contains exactly one class, Bubs. Bubs’ main job is converting regular text into annoy-text, which it does in only one line: text.tr(‘A-Za-a1-90’, ‘A-Za z1-90’) . That’s pretty much it, except for a bit of code at the bottom designed to make annoy-text pleasant to all systems.
The bin side is dependent on some code I’ve never heard of, so I have to break my no-Google pledge and look it up. ( $stdin can be used to hold code inputted from a console, thank you Ruby Docs.) It looks entirely focused on the outside, taking content from the user, passing it to Bubs for him to work his magic, and then giving it back to the user. It’s entirely focused on the user’s perspective.
There are also a few files on the root directory. README and LICENSE seem self-explanatory, but there are more mysterious files. There’s a Rakefile, which seemed to be concerned with record keeping and checking to make sure things exist and can be connected to. There’s also a gemfile, which looks to be concerned with telling whatever interface runs Ruby Gems all it needs to know about itself, and introducing the other files. It tells Gems where its executable files are, gives a list of all its files, and as well as its name/date created/whatever else functions. It is the extroverted greeter of Rootdirectoryland. There’s also something called gitignore which seems to be the robots.txt of the git world.
At the end of my exhaustive tour, I feel I’ve gained a good sense of the basic files and what they do. Reconnaissance indicates that there are far more complicated structures out there, with folders packed with more folders, but hopefully this basic understanding will carry me through.