我是一個完整的新手。在Ruby中使用寶石*基本*
我有一塊寶石,我想安裝和使用,讓我們說這是這一個:
https://rubygems.org/gems/linkedindata/versions/0.0.22
我使用CMD:
gem install linkedindata
#1 gem installed
之後,我將它添加到我的的Gemfile:
gemrat 'linkedindata'
#gem 'linkedindata', '0.0.22' added to your Gemfile.
現在使用linkedindata我要創建一個新的對象和規範如果我的搜索。所以,我做的:
**test.rb**
l = LinkedinData.new(1, "c:/users/proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
現在我從命令提示符下運行test.rb:
test.rb:1:in `<main>': undefined local variable or meth
od `linkedindata' for main:Object (NameError)
所以,我顯然需要在這裏需要 'linkedindata' 寶石。我說:
**test.rb**
require 'LinkedinData'
l = LinkedinData.new(1, "c:/users/proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
我得到以下錯誤:
C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `re
quire': cannot load such file -- linkedin-scraper (LoadError)
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:54:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin
data.rb:1:in `<top (required)>'
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:128:in `require'
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:128:in `rescue in require'
from C:/Ruby22/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require
.rb:39:in `require'
from C:/Users/test.rb:1:in `<main>'
我在做某種根本性錯誤嗎?或者這個寶石有問題嗎?
UPDATE
的問題是創業板中,見下文遁的答案。
require 'rubygems'
require 'bundler/setup'
require 'linkedindata'
l = LinkedinData.new(1, "proxylist.txt", true, true)
searchTerms = ['First', 'Second', 'Third']
l.getByKeywords(searchTerms)
++++糾正寶石如何要求 「linkedin_scraper」 在linkedindata.rb
發生
C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin.rb:6:in `<cl
ass:Profile>': uninitialized constant Linkedin::Profile::ProxyManager (NameError
)
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin
.rb:5:in `<module:Linkedin>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin
.rb:4:in `<top (required)>'
from linkedinscrape.rb:4:in `require'
from linkedinscrape.rb:4:in `<main>'
這顯然與代理設置,下一步的問題。清單:
**proxylist.txt**
220.248.224.242:8089
165.139.179.225:8080
54.207.114.172:3333
190.63.174.246:8081
的方式我加載它:
l = LinkedinData.new(1, "c:/users/proxylist.txt")
解決了一些錯誤,但我仍然得到:'C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedindata.rb:1: 'require':無法加載這樣的文件 - linkedin-scraper(LoadError) from C:/Ruby22/lib/ruby/gems/2.2.0/gems/linkedindata-0.0.22/lib/linkedin data.rb:1:in < '要求' 來自C:/Users/test.rb:4:''' –
user3471881
嗯看起來,寶石doesn'在'要求'' '從'C:/Users/test.rb'沒有它的依賴關係。你可以嘗試添加'gem'linkedin-scraper'',但我也有問題得到它加載,並不知道爲什麼... – Doon
好吧,它似乎像寶石本身有點破,並沒有宣佈全部它的依賴關係正確..將用我發現的內容編輯... – Doon