xing 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .idea
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in xing.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,38 @@
1
+ module Xing
2
+ class Activity < Xing::Base
3
+ lazy_attr_reader :id, :link, :link_desc, :image, :title, :text, :object, :type, :url
4
+
5
+ # @return String
6
+ def link
7
+ @link ||= @attrs["permalink"] unless @attrs["permalink"].nil?
8
+ end
9
+
10
+ # @return String
11
+ def link_desc
12
+ @name ||= @attrs["name"].nil? ? @attrs["display_name"] : @attrs["name"]
13
+ end
14
+
15
+ def object
16
+ name = @attrs["type"].camelize
17
+ if Xing.const_defined?(name)
18
+ @object ||= Xing.const_get(name).new(@attrs)
19
+ end
20
+ end
21
+
22
+ # @return String
23
+ def text
24
+ @text ||= case @attrs["type"]
25
+ when "status" then @attrs["content"]
26
+ when "bookmark" then @attrs["description"]
27
+ else nil
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ class String
35
+ def camelize
36
+ self.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join
37
+ end
38
+ end
@@ -0,0 +1,34 @@
1
+ module Xing
2
+ module Api
3
+ module Reader
4
+
5
+ def network_feed options={}
6
+ path = "/users/" + user_id(options) + "/network_feed" + params(options).to_s
7
+ raw_posts = get(path, options).fetch("network_activities", [])
8
+ raw_posts.map{|post|
9
+ Xing::Post.new(post)
10
+ }
11
+ end
12
+
13
+ protected
14
+ DEFAULT_PARAMS = {
15
+ :user_fields => "id,display_name,permalink,photo_urls",
16
+ :aggregate => false
17
+ }
18
+
19
+ def user_id options
20
+ user_id = options.delete(:user_id) if options[:user_id]
21
+ user_id || "me"
22
+ end
23
+
24
+ def params options
25
+ params_str = ""
26
+ params = options[:params] || {}
27
+ params.merge!(DEFAULT_PARAMS)
28
+ params.each { |key, value| params_str << "#{key}=#{value}&"}
29
+ ("?" + params_str.chop) unless (params_str == "")
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ module Xing
2
+ module Api
3
+ module Writer
4
+
5
+ end
6
+ end
7
+ end
data/lib/xing/api.rb ADDED
@@ -0,0 +1,6 @@
1
+ module Xing
2
+ module Api
3
+ autoload :Reader, "xing/api/reader"
4
+ autoload :Writer, "xing/api/writer"
5
+ end
6
+ end
data/lib/xing/base.rb ADDED
@@ -0,0 +1,43 @@
1
+ module Xing
2
+
3
+ class Base
4
+ attr_accessor :attrs
5
+ alias :to_hash :attrs
6
+
7
+ # Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
8
+ #
9
+ # @overload self.lazy_attr_reader(attr)
10
+ # @param attr [Symbol]
11
+ # @overload self.lazy_attr_reader(attrs)
12
+ # @param attrs [Array<Symbol>]
13
+ def self.lazy_attr_reader(*attrs)
14
+ attrs.each do |attribute|
15
+ class_eval do
16
+ define_method attribute do
17
+ @attrs[attribute.to_s]
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ # Initializes a new Base object
24
+ #
25
+ # @param attrs [Hash]
26
+ # @return [Xing::Base]
27
+ def initialize(attrs={})
28
+ @attrs = attrs.dup
29
+ end
30
+
31
+ # Initializes a new Base object
32
+ #
33
+ # @param method [String, Symbol] Message to send to the object
34
+ def [](method)
35
+ self.__send__(method.to_sym)
36
+ rescue NoMethodError
37
+ nil
38
+ end
39
+
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,19 @@
1
+ module Xing
2
+
3
+ class Client
4
+ include Helpers::Authorization
5
+ include Helpers::Request
6
+ include Api::Reader
7
+ include Api::Writer
8
+
9
+ attr_reader :consumer_token, :consumer_secret, :consumer_options
10
+
11
+ def initialize(ctoken=Xing.token, csecret=Xing.secret, options={})
12
+ @consumer_token = ctoken
13
+ @consumer_secret = csecret
14
+ @consumer_options = options
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,16 @@
1
+ module Xing
2
+ class Comment < Xing::Base
3
+ lazy_attr_reader :id, :content, :posted_at, :user
4
+
5
+ # @return Time
6
+ def posted_at
7
+ @posted_at ||= Time.parse(@attrs['created_at']).utc unless @attrs['created_at'].nil?
8
+ end
9
+
10
+ # @return Xing::User
11
+ def user
12
+ @user ||= Xing::User.new(@attrs.dup['creator']) unless @attrs["creator"].nil?
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module Xing
2
+ class CompanyProfile < Xing::Base
3
+ lazy_attr_reader :id, :name, :photo, :url
4
+
5
+ # @return Time
6
+ def posted_at
7
+ @posted_at ||= Time.parse(@attrs['created_at']).utc unless @attrs['created_at'].nil?
8
+ end
9
+
10
+ # @return String
11
+ def url
12
+ @url ||= @attrs["permalink"] unless @attrs["permalink"].nil?
13
+ end
14
+
15
+ # @param other [Xing::Event]
16
+ # @return [Boolean]
17
+ def ==(other)
18
+ super || (other.class == self.class && other.id == self.id)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ module Xing
2
+ module Errors
3
+ class XingError < StandardError
4
+ attr_reader :data
5
+ def initialize(data)
6
+ @data = data
7
+ super
8
+ end
9
+ end
10
+
11
+ class UnauthorizedError < XingError; end
12
+ class GeneralError < XingError; end
13
+
14
+ class UnavailableError < StandardError; end
15
+ class ServerError < StandardError; end
16
+ class NotFoundError < StandardError; end
17
+ end
18
+ end
data/lib/xing/event.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Xing
2
+ class Event < Xing::Base
3
+ lazy_attr_reader :id, :name, :url
4
+
5
+ # @return Time
6
+ def posted_at
7
+ @posted_at ||= Time.parse(@attrs['created_at']).utc unless @attrs['created_at'].nil?
8
+ end
9
+
10
+ # @return String
11
+ def url
12
+ @url ||= @attrs["permalink"] unless @attrs["permalink"].nil?
13
+ end
14
+
15
+ # @param other [Xing::Event]
16
+ # @return [Boolean]
17
+ def ==(other)
18
+ super || (other.class == self.class && other.id == self.id)
19
+ end
20
+ end
21
+ end
data/lib/xing/group.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Xing
2
+ class Group < Xing::Base
3
+ lazy_attr_reader :id, :name, :url
4
+
5
+ # @return Time
6
+ def posted_at
7
+ @posted_at ||= Time.parse(@attrs['created_at']).utc unless @attrs['created_at'].nil?
8
+ end
9
+
10
+ # @return String
11
+ def url
12
+ @url ||= @attrs["permalink"] unless @attrs["permalink"].nil?
13
+ end
14
+
15
+ # @param other [Xing::Group]
16
+ # @return [Boolean]
17
+ def ==(other)
18
+ super || (other.class == self.class && other.id == self.id)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ module Xing
2
+ module Helpers
3
+
4
+ module Authorization
5
+
6
+ DEFAULT_OAUTH_OPTIONS = {
7
+ :site => "https://api.xing.com",
8
+ :request_token_path => "/v1/request_token",
9
+ :authorize_path => "/v1/authorize",
10
+ :access_token_path => "/v1/access_token"
11
+ }
12
+
13
+ def consumer
14
+ @consumer ||= ::OAuth::Consumer.new(@consumer_token, @consumer_secret, DEFAULT_OAUTH_OPTIONS)
15
+ end
16
+
17
+ def access_token
18
+ @access_token ||= ::OAuth::AccessToken.new(consumer, @auth_token, @auth_secret)
19
+ end
20
+
21
+ def authorize_from_access(atoken, asecret)
22
+ @auth_token, @auth_secret = atoken, asecret
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,76 @@
1
+ require 'multi_json'
2
+
3
+ module Xing
4
+ module Helpers
5
+
6
+ module Request
7
+
8
+ API_PATH = '/v1'
9
+ DEFAULT_HEADERS = {}
10
+
11
+ protected
12
+
13
+ def get(path, options={})
14
+ response = access_token.get("#{API_PATH}#{path}", DEFAULT_HEADERS.merge(options))
15
+ respond response
16
+ end
17
+
18
+ def post(path, body='', options={})
19
+ response = access_token.post("#{API_PATH}#{path}", body, DEFAULT_HEADERS.merge(options))
20
+ respond response
21
+ end
22
+
23
+ def put(path, body, options={})
24
+ response = access_token.put("#{API_PATH}#{path}", body, DEFAULT_HEADERS.merge(options))
25
+ respond response
26
+ end
27
+
28
+ def delete(path, options={})
29
+ response = access_token.delete("#{API_PATH}#{path}", DEFAULT_HEADERS.merge(options))
30
+ respond response
31
+ end
32
+
33
+ private
34
+
35
+ def respond response
36
+ raise_errors response
37
+ MultiJson.load(response.body)
38
+ end
39
+
40
+ def raise_errors(response)
41
+
42
+ case response.code.to_i
43
+ when 401
44
+ data = Mash.from_json(response.body)
45
+ raise Xing::Errors::UnauthorizedError.new(data), "(#{data.status}): #{data.message}"
46
+ when 400, 403
47
+ data = Mash.from_json(response.body)
48
+ raise Xing::Errors::GeneralError.new(data), "(#{data.status}): #{data.message}"
49
+ when 404
50
+ raise Xing::Errors::NotFoundError, "(#{response.code}): #{response.message}"
51
+ when 500
52
+ raise Xing::Errors::ServerError, "(#{response.code}): #{response.message}"
53
+ when 502..503
54
+ raise Xing::Errors::UnavailableError, "(#{response.code}): #{response.message}"
55
+ end
56
+ end
57
+
58
+ def to_query(options)
59
+ options.inject([]) do |collection, opt|
60
+ collection << "#{opt[0]}=#{opt[1]}"
61
+ collection
62
+ end * '&'
63
+ end
64
+
65
+ def to_uri(path, options)
66
+ uri = URI.parse(path)
67
+
68
+ if options && options != {}
69
+ uri.query = to_query(options)
70
+ end
71
+ uri.to_s
72
+ end
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,6 @@
1
+ module Xing
2
+ module Helpers
3
+ autoload :Authorization, "xing/helpers/authorization"
4
+ autoload :Request, "xing/helpers/request"
5
+ end
6
+ end
data/lib/xing/mash.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'hashie'
2
+ require 'multi_json'
3
+
4
+ module Xing
5
+ class Mash < ::Hashie::Mash
6
+
7
+ def self.from_json(json_string)
8
+ result_hash = MultiJson.load(json_string)
9
+ new(result_hash)
10
+ end
11
+
12
+ end
13
+ end
data/lib/xing/post.rb ADDED
@@ -0,0 +1,109 @@
1
+ module Xing
2
+ class Post < Xing::Base
3
+ lazy_attr_reader :commentable, :comments, :deletable, :id, :image,
4
+ :likable, :liked, :like_count, :link, :link_title,
5
+ :post_type, :posted_at, :sharable, :text, :type, :user
6
+
7
+
8
+ # @return [Xing::Post]
9
+ def initialize(attrs={})
10
+ super
11
+ self.activities
12
+ end
13
+
14
+ # @return [Xing::Activity]
15
+ def activities
16
+ @activities ||= @attrs["objects"].map{|activity| Xing::Activity.new(activity)} unless @attrs["objects"].nil?
17
+ end
18
+
19
+ # @return [Boolean]
20
+ def commentable
21
+ @commentable ||= @attrs["possible_actions"].nil? ? false : @attrs["possible_actions"].include?("COMMENT")
22
+ end
23
+
24
+ # @return [Xing::Comments]
25
+ def comments
26
+ @comments ||= @attrs["comments"].nil? ? [] : @attrs["comments"]["latest_comments"].map{|comment| Xing::Comment.new(comment)}
27
+ end
28
+
29
+ # @return [Boolean]
30
+ def deletable
31
+ @deletable ||= @attrs["possible_actions"].nil? ? false : @attrs["possible_actions"].include?("DELETE")
32
+ end
33
+
34
+ # @return String
35
+ def image
36
+ if @activities.first && @activities.first.type == "bookmark"
37
+ @image ||= @activities.first.image
38
+ end
39
+ end
40
+
41
+ # @return [Boolean]
42
+ def likable
43
+ @likable ||= @attrs["possible_actions"].nil? ? false : @attrs["possible_actions"].include?("LIKE")
44
+ end
45
+
46
+ # @return [Boolean]
47
+ def liked
48
+ @liked ||= @attrs["likes"]["current_user_liked"] unless @attrs["likes"].nil?
49
+ end
50
+
51
+ # @return Fixnum
52
+ def like_count
53
+ @like_count ||= @attrs["likes"]["amount"] unless @attrs["likes"].nil?
54
+ end
55
+
56
+ # @return String
57
+ def link
58
+ if @activities.first && @activities.first.type == "bookmark"
59
+ @link ||= @activities.first.url
60
+ end
61
+ end
62
+
63
+ # @return String
64
+ def link_title
65
+ if @activities.first && @activities.first.type == "bookmark"
66
+ @link_title ||= @activities.first.title
67
+ end
68
+ end
69
+
70
+ # @return Symbol
71
+ def post_type
72
+ if @activities.first && @activities.first.text
73
+ @post_type ||= :text
74
+ elsif @activities.first && self.user == @activities.first.object
75
+ @post_type ||= :profile_update
76
+ else
77
+ @post_type ||= @attrs["verb"].gsub("-","_").to_sym
78
+ end
79
+ end
80
+
81
+ # @return Time
82
+ def posted_at
83
+ @posted_at ||= Time.parse(@attrs['created_at']).utc unless @attrs['created_at'].nil?
84
+ end
85
+
86
+ def sharable
87
+ @commentable ||= @attrs["possible_actions"].include?("SHARE") unless @attrs["possible_actions"].nil?
88
+ end
89
+
90
+ # @return String
91
+ def text
92
+ if @activities.first.text
93
+ @text ||= @activities.first.text
94
+ elsif @attrs["changes"]
95
+ @text ||= (@attrs["verb"] + "_" + @attrs["changes"].first.downcase).gsub("-","_")
96
+ else
97
+ @text ||= (@attrs["verb"] + "_" + @activities.first.type).gsub("-","_")
98
+ end
99
+ rescue
100
+ @text ||= ""
101
+ end
102
+
103
+ # @return Xing::User
104
+ def user
105
+ @user ||= Xing::User.new(@attrs.dup['actors'].first) unless @attrs["actors"].nil?
106
+ end
107
+
108
+ end
109
+ end
data/lib/xing/user.rb ADDED
@@ -0,0 +1,28 @@
1
+ module Xing
2
+ class User < Xing::Base
3
+ lazy_attr_reader :id, :name, :profile_image, :profile_url
4
+
5
+
6
+ # @return String
7
+ def name
8
+ @name ||= @attrs["display_name"] unless @attrs["display_name"].nil?
9
+ end
10
+
11
+ # @return String
12
+ def profile_image
13
+ @profile_image ||= @attrs["photo_urls"]["medium_thumb"] unless (@attrs["photo_urls"].nil? || @attrs["photo_urls"]["medium_thumb"].nil?)
14
+ end
15
+
16
+ # @return String
17
+ def url
18
+ @profile_url ||= @attrs["permalink"] unless @attrs["permalink"].nil?
19
+ end
20
+
21
+ # @param other [Xing::User]
22
+ # @return [Boolean]
23
+ def ==(other)
24
+ super || (other.class == self.class && other.id == self.id)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Xing
2
+ VERSION = "0.0.4"
3
+ end
data/lib/xing.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'oauth'
2
+
3
+ module Xing
4
+ class << self
5
+ attr_accessor :token, :secret
6
+
7
+ def configure
8
+ yield self
9
+ true
10
+ end
11
+ end
12
+
13
+ autoload :Activity, "xing/activity"
14
+ autoload :Api, "xing/api"
15
+ autoload :Base, "xing/base"
16
+ autoload :Client, "xing/client"
17
+ autoload :Comment, "xing/comment"
18
+ autoload :CommpanyProfile, "xing/company_profile"
19
+ autoload :Errors, "xing/errors"
20
+ autoload :Event, "xing/event"
21
+ autoload :Group, "xing/group"
22
+ autoload :Helpers, "xing/helpers"
23
+ autoload :Mash, "xing/mash"
24
+ autoload :Post, "xing/post"
25
+ autoload :User, "xing/user"
26
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xing::Client do
4
+ before do
5
+ client.stub(:consumer).and_return(consumer)
6
+ client.authorize_from_access('atoken', 'asecret')
7
+ end
8
+
9
+ let(:client){Xing::Client.new('token', 'secret')}
10
+ let(:consumer){OAuth::Consumer.new('token', 'secret', {:site => 'https://api.xing.com'})}
11
+
12
+ describe "User's network feed" do
13
+
14
+ it "client should get users feed" do
15
+ stub_http_request(:get, /https:\/\/api.xing.com\/v1\/users\/me\/network_feed.*/).
16
+ to_return(:body => "{}")
17
+ posts = client.network_feed
18
+ posts.length.should == 0
19
+ posts.should be_an_instance_of(Array)
20
+ end
21
+
22
+ it "returned array should contain posts" do
23
+ stub_http_request(:get, /https:\/\/api.xing.com\/v1\/users\/me\/network_feed.*/).
24
+ to_return(:body => fixture("network_feed.json"))
25
+ posts = client.network_feed
26
+ posts.length.should == 9
27
+ posts.first.should be_an_instance_of(Xing::Post)
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xing::Comment do
4
+
5
+ before do
6
+ client.stub(:consumer).and_return(consumer)
7
+ client.authorize_from_access('atoken', 'asecret')
8
+ end
9
+
10
+ let(:client){Xing::Client.new('token', 'secret')}
11
+ let(:consumer){OAuth::Consumer.new('token', 'secret', {:site => 'https://api.xing.com'})}
12
+
13
+ before :each do
14
+ @fixture = MultiJson.load(fixture "post.json")
15
+ @post = Xing::Post.new(@fixture)
16
+ @comment = @post.comments.first
17
+ end
18
+
19
+ it "should contain correct posting date" do
20
+ @comment.posted_at.should == Time.parse(@fixture["comments"]["latest_comments"].first["created_at"]).utc
21
+ end
22
+
23
+ it "should contain user information" do
24
+ @comment.user.should be_instance_of(Xing::User)
25
+ @comment.user.name.should == "Test User"
26
+ @comment.user.id.should == "123456789"
27
+ end
28
+
29
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xing::Post do
4
+
5
+ before do
6
+ client.stub(:consumer).and_return(consumer)
7
+ client.authorize_from_access('atoken', 'asecret')
8
+ @fixture = MultiJson.load(fixture "post.json")
9
+ @post = Xing::Post.new(@fixture)
10
+ end
11
+
12
+ let(:client){Xing::Client.new('token', 'secret')}
13
+ let(:consumer){OAuth::Consumer.new('token', 'secret', {:site => 'https://api.xing.com'})}
14
+
15
+ #before :each do
16
+ #end
17
+
18
+ it "should contain correct posting date" do
19
+ @post.posted_at.should == Time.parse(@fixture["created_at"]).utc
20
+ end
21
+
22
+ it "should contain user information" do
23
+ @post.user.should be_instance_of(Xing::User)
24
+ @post.user.name.should == "Test User"
25
+ @post.user.id.should == "123456789"
26
+ end
27
+
28
+ it "should have information about possibility of adding comment" do
29
+ @post.commentable.should_not == nil
30
+ @post.commentable.should == true
31
+ end
32
+
33
+ it "should have information about possibility of adding like" do
34
+ @post.likable.should_not == nil
35
+ @post.likable.should == true
36
+ end
37
+
38
+ it "should have information if current user liked it already" do
39
+ @post.liked.should_not == nil
40
+ @post.liked.should == false
41
+ end
42
+
43
+ it "should have information about possibility of sharing" do
44
+ @post.sharable.should_not == nil
45
+ @post.sharable.should == false
46
+ end
47
+
48
+ it "should have information about possibility of deleting" do
49
+ @post.deletable.should_not == nil
50
+ @post.deletable.should == false
51
+ end
52
+
53
+ it "should have activity list" do
54
+ @post.activities.should be_instance_of(Array)
55
+ end
56
+
57
+ it "should have comment list" do
58
+ @post.comments.should be_instance_of(Array)
59
+ @post.comments.length.should == 1
60
+ @post.comments.first.should be_instance_of(Xing::Comment)
61
+ end
62
+
63
+ it "should have like count" do
64
+ @post.like_count.should be_instance_of(Fixnum)
65
+ @post.like_count.should == 0
66
+ end
67
+
68
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xing::User do
4
+
5
+ before do
6
+ client.stub(:consumer).and_return(consumer)
7
+ client.authorize_from_access('atoken', 'asecret')
8
+ end
9
+
10
+ let(:client){Xing::Client.new('token', 'secret')}
11
+ let(:consumer){OAuth::Consumer.new('token', 'secret', {:site => 'https://api.xing.com'})}
12
+
13
+ before :each do
14
+ @fixture = MultiJson.load(fixture "post.json")
15
+ @post = Xing::Post.new(@fixture)
16
+ @user = @post.user
17
+ end
18
+
19
+ it "should contain correct name" do
20
+ @user.name.should == "Test User"
21
+ end
22
+
23
+
24
+ end
@@ -0,0 +1 @@
1
+ { "network_activities": [ { "type": "activity","aggregated": false,"ids": ["123456789"],"created_at": "2012-05-17T08:21:25+02:00", "comments": {"type": "meta_comment", "latest_comments": [], "amount": 0, "current_user_commented": false}, "possible_actions": ["COMMENT", "IGNORE", "LIKE"], "objects": [ { "id": "123456789", "type": "status", "content": "Test post", "created_at": "2012-05-17T08:21:25+02:00", "creator": { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } } ], "verb": "post", "actors": [ { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } ], "likes": { "type": "meta_like", "amount": 0, "current_user_liked": false } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-17T07:34:48+02:00", "comments": { "type": "meta_comment", "latest_comments": [], "amount": 0, "current_user_commented": false }, "possible_actions": [ "COMMENT", "IGNORE", "LIKE" ], "objects": [ { "id": "123456789", "type": "status", "content": "Test post", "created_at": "2012-05-17T07:34:48+02:00", "creator": { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } } ], "verb": "post", "actors": [ { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } ], "likes": { "type": "meta_like", "amount": 0, "current_user_liked": false } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-16T22:57:02+02:00", "comments": { "type": "meta_comment", "latest_comments": [ { "type": "comment", "id": "123456789", "content": "Test comment", "created_at": "2012-05-16T22:57:02+02:00", "creator": { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } } ], "amount": 1, "current_user_commented": false }, "possible_actions": [ "COMMENT", "IGNORE", "LIKE", "SHARE" ], "objects": [ { "id": "123456789", "type": "bookmark", "image": "", "created_at": "2012-05-16T20:57:14+02:00", "creator": { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" }, "title": "Test title", "url": "http://example.com/", "description": "Test description" } ], "verb": "post", "actors": [ { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } ], "likes": { "type": "meta_like", "amount": 1, "current_user_liked": false } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-16T19:06:17+02:00", "comments": { "type": "meta_comment", "latest_comments": [], "amount": 0, "current_user_commented": false }, "possible_actions": [ "COMMENT", "IGNORE", "LIKE", "SHARE" ], "objects": [ { "id": "123456789", "type": "bookmark", "image": "", "created_at": "2012-05-16T19:06:07+02:00", "creator": { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" }, "title": "Test link", "url": "http://example.com", "description": "Test link" } ], "verb": "post", "actors": [ { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User"} ], "likes": { "type": "meta_like", "amount": 0, "current_user_liked": false } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-16T16:18:59+02:00", "comments": { "type": "meta_comment", "latest_comments": [], "amount": 0, "current_user_commented": false }, "possible_actions": [ "COMMENT", "IGNORE", "LIKE" ], "objects": [ { "type": "company_profile", "photo": "https://www.xing.com/img/custom/cp/company_files/123.jpg", "permalink": "https://www.xing.com/companies/test", "id": "123456789", "name": "Test Company", "created_at": "2009-07-28T17:46:51+02:00" }], "verb": "update", "changes": [ "SCHOOL" ], "actors": [ { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } ], "likes": { "type": "meta_like", "amount": 0, "current_user_liked": false } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-16T15:52:40+02:00", "comments": { "latest_comments": [], "amount": 0, "type": "meta_comment", "current_user_commented": false } ,"possible_actions": [ "COMMENT", "IGNORE", "LIKE" ], "objects": [ { "id": "123456789", "display_name": "Test User", "permalink": "https://www.xing.com/profile/test", "type": "user" } ], "verb": "make-friend", "actors": [ { "id": "234567890", "display_name": "Example User", "permalink": "https://www.xing.com/profile/example", "type": "user" } ], "likes": { "current_user_liked": false, "amount": 0, "type": "meta_like" } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-16T15:52:40+02:00", "comments": { "latest_comments": [], "amount": 0, "type": "meta_comment", "current_user_commented": false } ,"possible_actions": [ "COMMENT", "IGNORE", "LIKE" ], "objects": [ { "id": "123456789", "display_name": "Test User", "permalink": "https://www.xing.com/profile/test", "type": "user" } ], "verb": "update", "changes": [ "COMPANY_TITLE" ], "actors": [{ "id": "123456789", "display_name": "Test User", "permalink": "https://www.xing.com/profile/test", "type": "user" } ], "likes": { "current_user_liked": false, "amount": 0, "type": "meta_like" } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-16T15:52:40+02:00", "comments": { "latest_comments": [], "amount": 0, "type": "meta_comment", "current_user_commented": false } ,"possible_actions": [ "COMMENT", "IGNORE", "LIKE", "SHARE" ], "objects": [ { "name": "Test Event", "id": "123456789", "permalink": "https://www.xing.com/events/testevent", "type": "event", "created_at": "2012-05-15T22:46:20+02:00" } ], "verb": "rsvp-yes", "actors": [{ "id": "123456789", "display_name": "Test User", "permalink": "https://www.xing.com/profile/test", "type": "user" } ], "likes": { "current_user_liked": false, "amount": 0, "type": "meta_like" } }, { "type": "activity", "aggregated": false, "ids": [ "123456789" ], "created_at": "2012-05-16T15:52:40+02:00", "comments": { "latest_comments": [], "amount": 0, "type": "meta_comment", "current_user_commented": false } ,"possible_actions": [ "COMMENT", "IGNORE", "LIKE", "SHARE" ], "objects": [ { "display_name": "Test Group", "id": "123456789", "permalink": "https://www.xing.com/groups/testgroup", "type": "group", "created_at": "2012-05-15T22:46:20+02:00" } ], "verb": "join", "actors": [{ "id": "123456789", "display_name": "Test User", "permalink": "https://www.xing.com/profile/test", "type": "user" } ], "likes": { "current_user_liked": false, "amount": 0, "type": "meta_like" } } ] }
@@ -0,0 +1 @@
1
+ {"type": "activity","aggregated": false,"ids": ["123456789"],"created_at": "2012-05-17T08:21:25+02:00", "comments": {"type": "meta_comment", "latest_comments": [ { "type": "comment", "id": "123456789", "content": "Test comment", "created_at": "2012-05-16T22:57:02+02:00", "creator": { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } } ], "amount": 1, "current_user_commented": false}, "possible_actions": ["COMMENT", "IGNORE", "LIKE"], "objects": [ { "id": "123456789", "type": "status", "content": "Test post", "created_at": "2012-05-17T08:21:25+02:00", "creator": { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } } ], "verb": "post", "actors": [ { "type": "user", "id": "123456789", "photo_urls": { "maxi_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "medium_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "thumb": "https://www.xing.com/pubimg/users/abc.jpg", "mini_thumb": "https://www.xing.com/pubimg/users/abc.jpg", "large": "https://www.xing.com/pubimg/users/abc.jpg" }, "permalink": "https://www.xing.com/123", "display_name": "Test User" } ], "likes": { "type": "meta_like", "amount": 0, "current_user_liked": false } }
@@ -0,0 +1,15 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'xing'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
7
+
8
+ def fixture_path
9
+ File.expand_path("../fixtures", __FILE__)
10
+ end
11
+
12
+ def fixture(file)
13
+ File.new(fixture_path + '/' + file)
14
+ end
15
+
data/xing.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "xing/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "xing"
7
+ gem.version = Xing::VERSION
8
+ gem.authors = ["Magdalena Sikorska"]
9
+ gem.email = ["madzia.sikorska@gmail.com"]
10
+ gem.homepage = 'http://github.com/elrosa/xing'
11
+ gem.summary = %q{Ruby wrapper for Xing API}
12
+ gem.description = gem.summary
13
+
14
+ gem.rubyforge_project = "xing"
15
+
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.require_paths = ['lib']
18
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+
20
+ gem.add_dependency 'hashie', '~> 1.2.0'
21
+ gem.add_dependency 'multi_json', '~> 1.0.3'
22
+ gem.add_dependency 'oauth', '~> 0.4.5'
23
+
24
+ gem.add_development_dependency 'json', '~> 1.6'
25
+ gem.add_development_dependency 'rake', '~> 0.9'
26
+ gem.add_development_dependency 'rdoc', '~> 3.8'
27
+ gem.add_development_dependency 'rspec', '~> 2.6'
28
+ gem.add_development_dependency 'webmock', '~> 1.8.7'
29
+
30
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Magdalena Sikorska
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashie
16
+ requirement: &21402020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *21402020
25
+ - !ruby/object:Gem::Dependency
26
+ name: multi_json
27
+ requirement: &21400440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.3
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *21400440
36
+ - !ruby/object:Gem::Dependency
37
+ name: oauth
38
+ requirement: &21399000 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.4.5
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *21399000
47
+ - !ruby/object:Gem::Dependency
48
+ name: json
49
+ requirement: &21398140 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *21398140
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: &21396480 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '0.9'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *21396480
69
+ - !ruby/object:Gem::Dependency
70
+ name: rdoc
71
+ requirement: &21395260 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '3.8'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *21395260
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec
82
+ requirement: &21394360 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '2.6'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *21394360
91
+ - !ruby/object:Gem::Dependency
92
+ name: webmock
93
+ requirement: &21393880 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.8.7
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *21393880
102
+ description: Ruby wrapper for Xing API
103
+ email:
104
+ - madzia.sikorska@gmail.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - .gitignore
110
+ - Gemfile
111
+ - Rakefile
112
+ - lib/xing.rb
113
+ - lib/xing/activity.rb
114
+ - lib/xing/api.rb
115
+ - lib/xing/api/reader.rb
116
+ - lib/xing/api/writer.rb
117
+ - lib/xing/base.rb
118
+ - lib/xing/client.rb
119
+ - lib/xing/comment.rb
120
+ - lib/xing/company_profile.rb
121
+ - lib/xing/errors.rb
122
+ - lib/xing/event.rb
123
+ - lib/xing/group.rb
124
+ - lib/xing/helpers.rb
125
+ - lib/xing/helpers/authorization.rb
126
+ - lib/xing/helpers/request.rb
127
+ - lib/xing/mash.rb
128
+ - lib/xing/post.rb
129
+ - lib/xing/user.rb
130
+ - lib/xing/version.rb
131
+ - spec/cases/client_spec.rb
132
+ - spec/cases/comment_spec.rb
133
+ - spec/cases/post_spec.rb
134
+ - spec/cases/user_spec.rb
135
+ - spec/fixtures/network_feed.json
136
+ - spec/fixtures/post.json
137
+ - spec/spec_helper.rb
138
+ - xing.gemspec
139
+ homepage: http://github.com/elrosa/xing
140
+ licenses: []
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project: xing
159
+ rubygems_version: 1.8.11
160
+ signing_key:
161
+ specification_version: 3
162
+ summary: Ruby wrapper for Xing API
163
+ test_files: []