init and spike
This commit is contained in:
		
							
								
								
									
										25
									
								
								Gemfile.lock
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Gemfile.lock
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
GEM
 | 
			
		||||
  specs:
 | 
			
		||||
    daemons (1.2.2)
 | 
			
		||||
    eventmachine (1.0.7)
 | 
			
		||||
    json (1.8.2)
 | 
			
		||||
    rack (1.6.0)
 | 
			
		||||
    rack-protection (1.5.3)
 | 
			
		||||
      rack
 | 
			
		||||
    sinatra (1.4.6)
 | 
			
		||||
      rack (~> 1.4)
 | 
			
		||||
      rack-protection (~> 1.4)
 | 
			
		||||
      tilt (>= 1.3, < 3)
 | 
			
		||||
    thin (1.6.3)
 | 
			
		||||
      daemons (~> 1.0, >= 1.0.9)
 | 
			
		||||
      eventmachine (~> 1.0)
 | 
			
		||||
      rack (~> 1.0)
 | 
			
		||||
    tilt (1.4.1)
 | 
			
		||||
 | 
			
		||||
PLATFORMS
 | 
			
		||||
  ruby
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES
 | 
			
		||||
  json
 | 
			
		||||
  sinatra
 | 
			
		||||
  thin
 | 
			
		||||
							
								
								
									
										3
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
## HEllo Slack
 | 
			
		||||
 | 
			
		||||
Yet another gif generating slackbot, more to come.
 | 
			
		||||
							
								
								
									
										7
									
								
								app/workers/animations.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								app/workers/animations.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
class Animations
 | 
			
		||||
 | 
			
		||||
  def find string
 | 
			
		||||
    "looking for a gif related to: #{string}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										15
									
								
								app/workers/random_salutation.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/workers/random_salutation.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
class RandomSalutation
 | 
			
		||||
 | 
			
		||||
  def short
 | 
			
		||||
    'Hi there!'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def medium
 | 
			
		||||
    "Well hello! So nice to see you here."
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def long
 | 
			
		||||
    "My, what a wonderful day. Wouldn't you agree? I mean, it's even better now that you are here! Amirite?"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										13
									
								
								config.ru
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								config.ru
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
require 'rubygems'
 | 
			
		||||
require 'bundler'
 | 
			
		||||
require 'thin'
 | 
			
		||||
require 'sinatra'
 | 
			
		||||
 | 
			
		||||
$LOAD_PATH.unshift( File.join( File.dirname(__FILE__), 'app' ) )
 | 
			
		||||
 | 
			
		||||
Bundler.require
 | 
			
		||||
 | 
			
		||||
require './meme_bot'
 | 
			
		||||
 | 
			
		||||
#\ -p 3000
 | 
			
		||||
run Sinatra::Application
 | 
			
		||||
							
								
								
									
										23
									
								
								meme_bot.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								meme_bot.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
require 'json'
 | 
			
		||||
require 'workers/random_salutation'
 | 
			
		||||
require 'workers/animations'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
get '/?' do
 | 
			
		||||
  content_type :json
 | 
			
		||||
  greeting = RandomSalutation.new
 | 
			
		||||
  { message: greeting.short }.to_json
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
get '/greet/:length/?' do
 | 
			
		||||
  content_type :json
 | 
			
		||||
  greeting = RandomSalutation.new
 | 
			
		||||
  { message: greeting.send(params[:length]) }.to_json
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
post '/animate/?' do
 | 
			
		||||
  content_type :json
 | 
			
		||||
  gif = Animations.new
 | 
			
		||||
  @json = JSON.parse(request.body.read)
 | 
			
		||||
  { message: gif.find( @json['search'] ) }.to_json
 | 
			
		||||
end
 | 
			
		||||
		Reference in New Issue
	
	Block a user