SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question twitter ruby gem not working

    hi guys,

    new to ruby and rails. read a good chunk of simply rails 2 and i want to play around with the twitter api. instead of parsing it all myself i saw there was a twitter ruby gem on rubyforge

    i'm on ubuntu linux. i ran
    sudo gem install twitter
    and
    sudo install twitter

    when i run the code:
    Code:
    require 'rubygems'
    require 'twitter'
    
    #searches all tweets for httparty
    Twitter::Search.new('httparty').each { |r| puts r.inspect }
    i get the error:
    ./twitter.rb:5: uninitialized constant Twitter (NameError)
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    from -:2

    any idea of what i'm doing wrong? thanks!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,264
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    Hi stevekl, welcome to the forums,

    If you do "$ gem list", is twitter there?

  3. #3
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey,

    twitter is listed there. any insight?

    thanks!

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,264
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    I haven't installed the twitter gem to try it, but I did download it and take a quick look. Several of the files in the examples folder start with
    Code Ruby:
    require 'rubygems'
    require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
    config = YAML::load(open(ENV['HOME'] + '/.twitter'))
     
    twitter = Twitter::Base.new(config['email'], config['password'])
    But your code
    Code Ruby:
    require 'rubygems'
    require 'twitter'
     
    #searches all tweets for httparty
    Twitter::Search.new('httparty').each { |r| puts r.inspect }
    looks similar to
    search.rb
    Code Ruby:
    require 'rubygems'
    require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
     
    Twitter::Search.new('httparty').each { |r| puts r.inspect,'' }
    .....
    Are you sure your path to "twitter" is correct?

  5. #5
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it seems like my path to twitter is correct, because it's not throwing an error on the require line. while if i put require 'twitter-fake' or something that doesnt exist an error is thrown. but, also i can't be positive because i don't know where the ruby gem installer installs the twitter lib.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,264
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    I have Windows OS, my "plugin" gems are in the ["my app"]\vendor\plugins\ folder. The Ruby gems are in ["ruby install dir"]\lib\ruby\gems\1.8\gems\


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •