├── Driver.rb ├── Gemfile ├── Gemfile.lock ├── QuoteData.txt ├── README.md ├── config.ru ├── demo.gif └── prisonMike.png /Driver.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # @author Kevin Bohinski 3 | # @version 1.0 4 | # @since 2015-10-7 5 | # 6 | # Project Name: Michael-Scott-API 7 | # Description: Just a simple Sinatra REST API server to learn more about Sinatra/Ruby. 8 | # 9 | # Filename: Driver.rb 10 | # Description: Simple Sinatra app to serve Michael Scott quotes. 11 | # Last Modified: 2016-10-1 12 | # 13 | # Copyright (c) 2015 Kevin Bohinski. All rights reserved. 14 | ## 15 | 16 | # Inspired by: https://github.com/jamesseanwright/ron-swanson-quotes # 17 | 18 | # Importing Sinatra, JSON # 19 | require 'sinatra' 20 | require 'json' 21 | class Driver < Sinatra::Base 22 | 23 | set :protection, :except => [:json_csrf] 24 | 25 | # If a user get requests path /quote , return a quote. # 26 | get '/quote' do 27 | content_type :json 28 | { :quote => File.readlines("QuoteData.txt").sample[0..-2], :author => 'Michael Scott' }.to_json 29 | end 30 | 31 | end 32 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | gem 'sinatra' 3 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | rack (1.6.4) 5 | rack-protection (1.5.3) 6 | rack 7 | sinatra (1.4.6) 8 | rack (~> 1.4) 9 | rack-protection (~> 1.4) 10 | tilt (>= 1.3, < 3) 11 | tilt (2.0.1) 12 | 13 | PLATFORMS 14 | x86-mingw32 15 | 16 | DEPENDENCIES 17 | sinatra 18 | -------------------------------------------------------------------------------- /QuoteData.txt: -------------------------------------------------------------------------------- 1 | "You miss 100% of the shots you don't take." - Wayne Gretzky 2 | Do you think that smoking drugs is cool? 3 | Do you think that doing alcohol is cool? 4 | Sometimes I'll start a sentence and I don't even know where it's going. I just hope I find it along the way. 5 | I'm not superstitious, but I am a little stitous. 6 | There's such a thing as good grief. Just ask Charlie Brown. 7 | Oh God, my mind is going a mile an hour. 8 | I am Beyoncé, always. 9 | I love Burlington Coat Factory. 10 | PowerPoint. PowerPoint. 11 | I feel like all my kids grew up, and then they married each other, it's every parent's dream. 12 | I DECLARE BANKRUPTCY! 13 | Dwight, you ignorant sl*t. 14 | That's what she said. 15 | NO! GOD! NO GOD PLEASE NO! NO! NOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 16 | STANLEY STANLEY YOU WILL NOT DIE STANLEY STANLEY BARACK IS PRESIDENT 17 | I am downloading some n3p music. 18 | WHERE ARE THE TURTLES?! 19 | The worst thing about prison was the dementors. 20 | Occasionally, I'll hit somebody with my car. So sue me. 21 | If I had a gun with two bullets and I was in a room with Hitler, Bin Laden, and Toby, I would shoot Toby twice. 22 | Just tell him to call me as asap as possible. 23 | It's a good thing Russia doesn't exist anymore. 24 | Well, happy birthday, Jesus. Sorry your party's so lame. 25 | You know what's gonna be on your tombstone? "Loser." 26 | I love inside jokes. Love to be a part of one someday. 27 | Would I rather be feared or loved? Easy, both. I want people to be afraid of how much they love me. 28 | I like waking up to the smell of bacon. 29 | I don't want to do anything. I'm dying. 30 | I. Understand. Nothing. 31 | I feel very blessed. 32 | I am dead inside. 33 | I'm running away from my responsibilities. 34 | You are a thief of joy. 35 | PARKOUR. 36 | Okay, I am going to throw up. 37 | I am a victim of a hate crime. 38 | I knew exactly what to do. But in a much more real sense, I had no idea what to do. 39 | I don't need fresh air. Because I have the freshest air around. A/C. 40 | I'm optimistic, because every day I get a little more desperate. 41 | Oh my God! Okay, it's happening! 42 | Maybe there's some sort of animal we can make a sacrifice to. 43 | I've made some empty promises in my life. 44 | I hate looking at your face. I wanna smash it. 45 | Only thing that could make this day better is ice cream. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Michael-Scott-API 2 | [Try it out! https://michael-scott-quotes.herokuapp.com/quote](https://michael-scott-quotes.herokuapp.com/quote) 3 | 4 | ![Prison Mike](prisonMike.png) 5 | 6 | Just a simple Sinatra REST API server to learn more about Sinatra/Ruby. 7 | 8 | ![Demo](demo.gif) 9 | 10 | Inspired by: https://github.com/jamesseanwright/ron-swanson-quotes 11 | 12 | ## API 13 | 14 | ### `GET /quote` 15 | Returns a random quote in this format: 16 | ```javascript 17 | { 18 | "quote": "NO! GOD! NO GOD PLEASE NO! NO! NOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", 19 | "author": "Michael Scott" 20 | } 21 | ``` 22 | 23 | ## How to run it 24 | ```gem install sinatra``` 25 | 26 | ```ruby Driver.rb``` 27 | 28 | Go to: [http://localhost:4567/quote](http://localhost:4567/quote) 29 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler' 3 | 4 | Bundler.require 5 | 6 | require './Driver' 7 | run Driver.new 8 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbohinski/Michael-Scott-API/1ec14de7a63ac8767aa62a9a2585c19e538b7efc/demo.gif -------------------------------------------------------------------------------- /prisonMike.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbohinski/Michael-Scott-API/1ec14de7a63ac8767aa62a9a2585c19e538b7efc/prisonMike.png --------------------------------------------------------------------------------