Klout API not working - klout

i try to follow this: tutorial --use klout api to calculate my follower's klout score.(at the bottom of the link page )here is the instruction:
First, hop into Terminal and run this line:
1. gem install klout
Next, open irb so you can experiment with the Klout API. Run the following lines:
API_KEY="your-api-key"
k = Klout::API.new(API_KEY)
k.klout("jack")["users"][0]["kscore"]
=> 74.61
i did exactly the same, but return "nameError:uninitialized constant Klout"

It's also bad form to post API keys publicly. They are licensed to you and you alone.
That said, it looks like either the gem didn't install properly, or you need to require Klout first.

Related

Can't Load my Ruby File

OK SO I Am just picking Ruby up pretty much for the kicks and giggles... and Believe me when I say I'm stumped.
I want to create a bot for my Twitch stream and do it in Ruby because I found a fairly easy tut to follow along with, along with my reasoning skills. However I'm having a very hard time getting my command prompt or pry to load the file.
Here is my file JUST IN CASE
require 'socket'
TWITCH_HOST = "irc.twitch.tv"
TWITCH_PORT = 6667
class Fox
def initialize
#nickname = "mybotsname"
#password = "I have the proper oauth here"
#channel = "mytwitchchannel"
#socket = TCPSocket.open(TWITCH_HOST, TWITCH_PORT)
write_to_system "PASS #{#password}"
write_to_system "NICK #{#nickname}"
write_to_system "USER #{#nickname} 0 * #{#nickname}"
write_to_system "JOIN ##{#Channel}"
end
def write_to_system(message)
#socket.puts message
end
def write_to_chat(message)
write_to_system "PRIVMSG ##{#channel} :{message}"
end
end
Now, From what I gathered, I should beable to go into my command prompt and type pry
I get this.
Pry
Now, I want to run my program which is located in a dropbox (Private use)
I'm Still very new to the concept of Repl's as I've been working with Java mostly along with very LITTLE Experience in other languages. What am I doing wrong here? Why can I not get my file to load properly? I've also tried filepathing and got this.FilePathing
I'm sorry if this is a stupid question. It's just driving me absolutely bat-brain crazy. The reason this is driving me bonkers is the video I was watching, he didn't do anything different other than my guess is he was using Terminal instead of Command Prompt. I Wanted originally to do this through Cygwin but upon install of Pry I lost a bunch of Cygwin files and can no longer load Cygwin, I will re-install the over all program later and see what I can from there.
Sorry for no embedded pics.
Also, any easier way to do this I'm all ears. I've tried Komodo Edit 10 but it's not playing nice ether.
Require from LOAD_PATH
A Ruby module or class file needs to be in the LOAD_PATH to require it with Kernel#require. For example, if your file is named just_in_case.rb, you can use:
$LOAD_PATH.unshift '/path/to/dropbox/directory'
# Leave off the path and .rb extension.
require 'just_in_case'
Load from an absolute path
If you need to provide an absolute path, then you should use Kernel#load instead. For example:
# Use the absolute path and the .rb extension.
load '/path/to/dropbox/just_in_case.rb'
Caveats
There are some other differences in behavior between require, require_relative, and load, but they probably don't really matter within the limited scope of the question you asked except that there have historically been issues with Kernel#require_relative within the REPL. It may or may not work as expected now, but I would still recommend require or load for your specific use case.

Ruby gem for retrieving details/information on a torrent via info hash

Is there a ruby gem that I can use with Ruby or Ruby on Rails that accepts an info hash and returns information on the torrent? Like seeders, leachers, size, etc.?
If not is there any other way I can get this information using Ruby? Is there an API that I can easily digest?
Thanks in advance.
Take a look at the thepiratebay.
Although, it seems like it's not maintained actively anymore. But, should solve your problem.
You can find a torrent:
ThePirateBay::Torrent.find("123123123")
Also, you can get all the seeders, leechers and size:
ThePirateBay::SortBy::Size # Size, largest first
ThePirateBay::SortBy::Seeders # Most seeders first
ThePirateBay::SortBy::Leechers # Most leechers first
So, why not giving it a try?
It really depends what torrents you are talking about. Different torrent trackers have different APIs.
You might want to dig into specific tracker API (please be mindful these ones are not Ruby APIs):
https://getstrike.net/api/
https://www.npmjs.com/package/thepiratebay

How do I use the Ruby twitter gem to get a list of followers for a given ID/handle?

I want to use v5.0 of the Twitter gem, and I can't figure out the documentation to understand how to get a list of followers, given a handle.
It looks like previous versions had a method that looked something like Twitter.follower_ids('ID to lookup'), but that doesn't work any more.
I don't know if there's some easier way to navigate the RDoc documentation but I had to first root around in the code, to notice the RDoc comments, to then realize that this is the page which documents some of the behavior I wanted.
# configure client with secrets and access keys
client.followers 'screen_name_of_interest'
This returns a certain number of followers - but I still can't figure out how to figure out how many followers, and how to use cursors to retrieve more.

How do I add documentation to my gem that will show up on rubygems.org?

Experimenting with pushing my first gem to rubygems.org, and I'm trying to figure out how to generate online documentation for it. For most gems 'show' page, when I click the 'Documentation' link, I am brought to http://rubydoc.info/gems/gemname/version/frames. Is this something that will happen automagically if I generate the docs in the right place? Do I have to specify something in the gemspec? Thanks!
rubydoc.info will automatically generate API docs for your gem. At a minimum, those docs will contain the signature of all classes, modules and methods, as well as the comments you put before each method and class.
If you add yardoc markup to your files, the documentation will get better. Here's a small bit of yardoc markup for a method:
# Validate the value.
# #param long_mailer_id truthy if the mailer ID is long (9 digits).
# #raise ArgumentError if invalid
def validate(long_mailer_id)
yardoc, the documentation engine that rubydoc.info uses, will look for comments in a certain format and format them into spiffy documentation.
You can also add, to the root of your gem, a README.md in Markdown format. This will be formatted and used as the "main page" of your documentation.
Here is the response that I received from someone in the RubyDoc community:
Hi there,
New gems can take up to a day to make it into RubyGems' master gem
list. Not much we can do about this one. From then on, it's about an
hour for new versions of your gem to be populated into the list (we
run a cron job at *:15 to update our copy).
It was a matter of letting enough time elapse.

Using Google Search REST API in Ruby

I'm trying to do a google search using Ruby, and print the 1st 3 results.
Could anyone point me to a sample code? I'm unable to find it.
The gem googleajax is there for that:
require 'googleajax'
GoogleAjax.referer = "your_domain_name_here.com"
GoogleAjax::Search.web("Hello world")[:results][0...3]
Now Google wants you to use this http://code.google.com/p/google-api-ruby-client/ with a limit of 100 courtesy queries, and a pricing structure for anything above that.

Resources