Let’s be honest, sometimes the best thing you can do when you’re stuck on a problem is to take your mind off of it. I created the Bored Wikipedia Explorer gem to randomly serve a overview pages for topics in order to help frustrated developers to temporarily take their mind off the problem they’re stuck on by getting drawn into random Wikipedia pages.

The most difficult part about creating this gem was the scraping because the Wikipedia Portal pages tend to be extremely inconsistent with styling, ids, classes, etc. Originally this gem was intended to serve a random ‘Did you know’ fact but the inconsistencies with the pages and lack of classes/ids used on nodes made it impossible to account for every edge case. It took me a longer than I’d like to admit to come to terms with the fact that scraping doesn’t always make for the prettiest or most reliable code outputs. Instead, to deal with the unknown, I’ve restructured the purpose of the app and created it to automatically open one of these sub-topic portal pages in the computer’s default browser once the user confirms that they’d like to view said topic.

The CLI first welcomes the user and then asks which of these main topics from the all portals contents page they would like to explore.

1. Culture and the arts
2. Geography and places
3. Health and fitness
4. History and events
5. Human activities
6. Mathematics and logic
7. Natural and physical sciences
8. People and self
9. Philosophy and thinking
10. Religion and belief systems
11. Society and social sciences
12. Technology and applied sciences

The user enters the number of the main topic that they would like to explore and then the app scrapes the sub-topics under the selected main topic on the main topics contents portals page. Then the app randomly selects one of the sub-topics, visits the sub-topic page, and scrapes title from the sub-topic page. Next, the CLI asks the user if they would like to view the randomly selected page. If the user confirms then the CLI will automatically open the page in the computer’s default browser using the awesome Launchy gem.

Pushing an Update to Your Published Gem

Besides the scraping difficulties, the only other thing I had trouble with was finding documentation, StackOverflow forms, or blog posts covering just HOW someone that has already published a gem to Rubygems.org should submit a new version. As it turns out it’s actually pretty intuitive to submit a new version of your gem.

Step 1: Update your .gemspec file’s version number

Gem::Specification.new do |s|
  s.name        = 'bored-wikipedia-explorer'
  s.version     = '0.1.2'
  s.date        = '2018-09-01'
  s.summary     = "If you're bored this is the CLI app for you to explore new topics on Wikipedia."
  s.description = "A simple content discovery gem"
  s.authors     = ["Katrina Brinson"]
  s.email       = 'kbrinso@gmail.com'
  s.files       = ["lib/portal.rb","lib/command_line_interface.rb","lib/topic.rb", "lib/scraper.rb", "bin/run"]
  s.homepage    =
    'http://rubygems.org/gems/bored-wikipedia-explorer'
  s.license       = 'MIT'
end

Step 2: Save and push changes to Github

Step 3: Build the gem (again)

It sounds a bit counter-intuitive to build the gem again but this is how it’s done 🙂

gem build bored-wikipedia-explorer.gemspec

Step 4: Push the gem

Be sure to include the new version number

gem push bored-wikipedia-explorer-0.1.2.gem