forked from hexgnu/linkedin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commented out references to ROXML in linked_in/*.rb commented most cl…
…assed while they are being updated. Added methods to LinkedIn::Profile. Commented out failing test while the code is refactored
- Loading branch information
Brad Cantin
committed
Jun 24, 2010
1 parent
d3083f9
commit 7d68120
Showing
16 changed files
with
309 additions
and
173 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
module LinkedIn | ||
class ApiStandardProfileRequest | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :url | ||
xml_reader :headers, :as => {:key => 'name', :value => 'value'}, :in => 'headers/http-header' | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :url | ||
# xml_reader :headers, :as => {:key => 'name', :value => 'value'}, :in => 'headers/http-header' | ||
|
||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
module LinkedIn | ||
class Company | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :type | ||
xml_reader :name | ||
xml_reader :industry | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :type | ||
# xml_reader :name | ||
# xml_reader :industry | ||
|
||
def initialize(doc) | ||
@doc = doc | ||
end | ||
|
||
%w[type name industry].each do |f| | ||
define_method(f.to_sym) do | ||
@doc.xpath("./#{f.gsub(/_/,'-')}").text | ||
end | ||
end | ||
|
||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module LinkedIn | ||
class Connections | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :profiles, :as => [Profile], :from => 'person' | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :profiles, :as => [Profile], :from => 'person' | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module LinkedIn | ||
class Country | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :code | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :code | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
module LinkedIn | ||
class Education | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :id | ||
xml_reader :school_name | ||
xml_reader :degree | ||
xml_reader :field_of_study | ||
xml_reader :activities | ||
xml_reader :start_year, :from => "start-date/year", :as => Integer | ||
xml_reader :start_month, :from => "start-date/month", :as => Integer | ||
xml_reader :end_year, :from => "end-date/year", :as => Integer | ||
xml_reader :end_month, :from => "end-date/month", :as => Integer | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :id | ||
# xml_reader :school_name | ||
# xml_reader :degree | ||
# xml_reader :field_of_study | ||
# xml_reader :activities | ||
# xml_reader :start_year, :from => "start-date/year", :as => Integer | ||
# xml_reader :start_month, :from => "start-date/month", :as => Integer | ||
# xml_reader :end_year, :from => "end-date/year", :as => Integer | ||
# xml_reader :end_month, :from => "end-date/month", :as => Integer | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module LinkedIn | ||
class Error | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :status, :as => Integer | ||
xml_reader :timestamp, :as => Integer | ||
xml_reader :code, :as => Integer, :from => "error-code" | ||
xml_reader :message | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :status, :as => Integer | ||
# xml_reader :timestamp, :as => Integer | ||
# xml_reader :code, :as => Integer, :from => "error-code" | ||
# xml_reader :message | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
module LinkedIn | ||
class Group | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :id | ||
xml_reader :name | ||
xml_reader :site_group_request, :as => ApiStandardProfileRequest | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :id | ||
# xml_reader :name | ||
# xml_reader :site_group_request, :as => ApiStandardProfileRequest | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
module LinkedIn | ||
class Location | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :name | ||
xml_reader :country, :as => {:key => :name, :value => :content} | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :name | ||
# xml_reader :country, :as => {:key => :name, :value => :content} | ||
def initialize(doc) | ||
@doc = doc | ||
end | ||
|
||
def name | ||
@doc.xpath("//location/name").text | ||
end | ||
|
||
def country | ||
@doc.xpath("//location/country/code").text | ||
end | ||
|
||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module LinkedIn | ||
class Network | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :updates, :as => [Update] | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :updates, :as => [Update] | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module LinkedIn | ||
class People | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :total, :as => Integer, :from => "@total" | ||
xml_reader :start, :as => Integer, :from => "@start" | ||
xml_reader :count, :as => Integer, :from => "@count" | ||
xml_reader :profiles, :as => [Profile], :from => 'person' | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :total, :as => Integer, :from => "@total" | ||
# xml_reader :start, :as => Integer, :from => "@start" | ||
# xml_reader :count, :as => Integer, :from => "@count" | ||
# xml_reader :profiles, :as => [Profile], :from => 'person' | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,81 @@ | ||
module LinkedIn | ||
class Position | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :id | ||
xml_reader :title | ||
xml_reader :summary | ||
xml_reader :start_year, :from => "start-date/year", :as => Integer | ||
xml_reader :start_month, :from => "start-date/month", :as => Integer | ||
xml_reader :end_year, :from => "end-date/year", :as => Integer | ||
xml_reader :end_month, :from => "end-date/month", :as => Integer | ||
xml_reader :is_current | ||
xml_reader :company, :as => Company | ||
end | ||
end | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :id | ||
# xml_reader :title | ||
# xml_reader :summary | ||
# xml_reader :start_year, :from => "start-date/year", :as => Integer | ||
# xml_reader :start_month, :from => "start-date/month", :as => Integer | ||
# xml_reader :end_year, :from => "end-date/year", :as => Integer | ||
# xml_reader :end_month, :from => "end-date/month", :as => Integer | ||
# xml_reader :is_current | ||
# xml_reader :company, :as => Company | ||
def initialize(doc) | ||
@doc = doc | ||
end | ||
|
||
def positions | ||
@doc.children | ||
@arry ||= begin | ||
@arry = [] | ||
@doc.children.each do |position| | ||
@arry << Resource.new(position) unless position.xpath('id').blank? | ||
end | ||
@arry | ||
end | ||
end | ||
|
||
class Resource | ||
# <position> | ||
# <id>4891362</id> | ||
# <title>Solution Architect</title> | ||
# <summary>blob of text</summary> | ||
# <start-date> | ||
# <year>2004</year> | ||
# <month>10</month> | ||
# </start-date> | ||
# <end-date> | ||
# <year>2007</year> | ||
# <month>6</month> | ||
# </end-date> | ||
# <is-current>false</is-current> | ||
# <company> | ||
# <name>Hewlett-Packard</name> | ||
# </company> | ||
# </position> | ||
|
||
def initialize(position) | ||
@position = position | ||
end | ||
|
||
%w[id title summary].each do |f| | ||
define_method(f.to_sym) do | ||
@position.xpath("./#{f.gsub(/_/,'-')}").text | ||
end | ||
end | ||
|
||
def start_month | ||
@position.xpath('./start-date/month').text.to_i | ||
end | ||
|
||
def start_year | ||
@position.xpath('./start-date/year').text.to_i | ||
end | ||
|
||
def end_month | ||
@position.xpath('./end-date/month').text.to_i | ||
end | ||
|
||
def end_year | ||
@position.xpath('./end-date/year').text.to_i | ||
end | ||
|
||
def company | ||
@company ||= Company.new(@position.xpath('./company')) | ||
end | ||
|
||
end | ||
|
||
end # class | ||
end # module |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,75 @@ | ||
module LinkedIn | ||
class Profile | ||
include ROXML | ||
xml_convention {|val| val.gsub("_","-") } | ||
xml_reader :id | ||
xml_reader :first_name | ||
xml_reader :last_name | ||
xml_reader :headline | ||
xml_reader :location, :as => Location | ||
xml_reader :industry | ||
xml_reader :distance, :as => Integer | ||
xml_reader :relation_to_viewer, :as => {:key => :name, :value => :content} | ||
xml_reader :num_recommenders, :as => Integer | ||
xml_reader :current_status | ||
xml_reader :current_status_timestamp | ||
xml_reader :connections, :as => [Profile], :from => "connections/person" | ||
xml_reader :summary | ||
xml_reader :specialties | ||
xml_reader :proposal_comments | ||
xml_reader :associations | ||
xml_reader :honors | ||
xml_reader :interests | ||
xml_reader :positions, :as => [Position] | ||
xml_reader :education, :as => [Education] | ||
xml_reader :three_current_positions, :as => [Position] | ||
xml_reader :member_url_resources, :as => [UrlResource], :from => 'member-url-resources/member-url' | ||
xml_reader :api_standard_profile_request | ||
xml_reader :site_standard_profile_request, :as => ApiStandardProfileRequest | ||
xml_reader :picture_url | ||
# include ROXML | ||
# xml_convention {|val| val.gsub("_","-") } | ||
# xml_reader :id | ||
# xml_reader :first_name | ||
# xml_reader :last_name | ||
# xml_reader :headline | ||
# xml_reader :location, :as => Location | ||
# xml_reader :industry | ||
# xml_reader :distance, :as => Integer | ||
# xml_reader :relation_to_viewer, :as => {:key => :name, :value => :content} | ||
# xml_reader :num_recommenders, :as => Integer | ||
# xml_reader :current_status | ||
# xml_reader :current_status_timestamp | ||
# xml_reader :connections, :as => [Profile], :from => "connections/person" | ||
# xml_reader :summary | ||
# xml_reader :specialties | ||
# xml_reader :proposal_comments | ||
# xml_reader :associations | ||
# xml_reader :honors | ||
# xml_reader :interests | ||
# xml_reader :positions, :as => [Position] | ||
# xml_reader :education, :as => [Education] | ||
# xml_reader :three_current_positions, :as => [Position] | ||
# xml_reader :member_url_resources, :as => [UrlResource], :from => 'member-url-resources/member-url' | ||
# xml_reader :api_standard_profile_request | ||
# xml_reader :site_standard_profile_request, :as => ApiStandardProfileRequest | ||
# xml_reader :picture_url | ||
|
||
FIELDS = %w[id first_name last_name headline industry current_status | ||
current_status_timestamp summary specialties proposal_comments | ||
associations honors interests picture_url distance | ||
num_recommenders] | ||
|
||
FIELDS.each do |f| | ||
define_method(f.to_sym) do | ||
@doc.xpath("./person/#{f.gsub(/_/,'-')}").text | ||
end | ||
end | ||
|
||
def self.from_xml(doc) | ||
new(doc) | ||
end | ||
|
||
def initialize(doc) | ||
@doc = Nokogiri::XML(doc) | ||
end | ||
|
||
def location | ||
@location ||= Location.new(@doc.xpath('//location')) | ||
end | ||
|
||
def api_standard_profile_request | ||
@api_standard ||= ApiStandardProfileRequest.new(@doc.xpath('//api-standard-profile-request')) | ||
end | ||
|
||
def site_standard_profile_request | ||
api_standard_profile_request | ||
end | ||
|
||
def relation_to_viewer | ||
@doc.xpath('//relation-to-viewer/distance').text | ||
end | ||
|
||
def member_url_resources | ||
@url_resources ||= UrlResource.new(@doc.xpath('//member-url-resources')) | ||
end | ||
|
||
def positions | ||
@positions ||= Position.new(@doc.xpath('//positions')).positions | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.