Created
July 28, 2014 21:22
-
-
Save warmfusion/30288be509e7a3e6d726 to your computer and use it in GitHub Desktop.
GoogleChart Imgur HipChat Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'hipchat' | |
gem 'imgur-api' | |
gem 'googlecharts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'hipchat' | |
require 'imgur' | |
require 'googlecharts' | |
imgur_client_id='keyskeyskeys' | |
hipchat_api_token='keyskeyskeys' | |
#Make a chart (See documentation) and save to local filesystem | |
chart = Gchart.new( :type => 'line', | |
:title => "example title", | |
:theme => :keynote, | |
:data => [[17, 17, 11, 8, 2],[10, 20, 15, 5, 7],[2, 3, 7, 9, 12]], | |
:line_colors => 'e0440e,e62ae5,287eec', | |
:legend => ['courbe 1','courbe 2','courbe 3'], | |
:axis_with_labels => ['x', 'y'], | |
:axis_range => [[0,100,20], [0,20,5]], | |
:filename => "chart.png") | |
# Record file in filesystem | |
chart.file | |
#Create an imgur client | |
client = Imgur.new(imgur_client_id) | |
# To upload an image, first create a Imgur::LocalImage ruby object | |
image = Imgur::LocalImage.new('chart.png', title: 'Test Chart') | |
#Then use the client to upload it and receive a Imgur::Image object | |
uploaded = client.upload(image) | |
#Now make a connection to Hipchat | |
client = HipChat::Client.new(hipchat_api_token) | |
# Imgur images only seem to embed if its the only text in the message | |
client['my room'].send('Stash', uploaded.link, :message_format => 'text') | |
client['my room'].send('Stash', '@mention - check out my big graph :-D (dance)', :message_format => 'text') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment