socialshare 0.0.1

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODQxMDkzODU0MmRlNzE4MWExOGEwODMyZmE3N2Q4ZDcyN2Y1Zjc1MQ==
5
+ data.tar.gz: !binary |-
6
+ YzZlYTJmOWIwY2U3NjNlZDA4MDkzMmU1NmZmYjY1YWQ3ZDg0YjA5Nw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZjIzZDRjMmIyYWFkNmU3NTU3MzdjMTk4ZWQzZGFiNTJiYzAwMmY0ZmZhMjNk
10
+ MzZhMGVmOWJiNDQ3MmZiZjEzZDZkYWYwY2VkZmRhNmYwYTJjZTIxZGEzZTBm
11
+ Y2RkZDBlN2QzNmE2OTJmY2RhN2I0OTM0ZDVlODkzNTVkNzIwYmQ=
12
+ data.tar.gz: !binary |-
13
+ NDhhZjE0YmJmNDdkNzUwYTgyYWE0MDc4YzNmN2YzZWM1MTVkZThhMzI1NzU5
14
+ OTUyNjk5M2I2YTAzOThiM2NiMGQ2OWE4ZDEyMDJjODlhNmMwMmIxZTRmMTRm
15
+ NWE3OGUxNjZlNmIxZTZjNjMwZThhN2VjMjg0ZjVjYmQ2ZDk5ZGY=
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in socialshare.gemspec
4
+ gemspec
5
+ gem 'twitter'
6
+ gem 'linkedin', :git => "git://github.com/pengwynn/linkedin.git"
7
+ gem 'koala'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 pandurang
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ # Socialshare
2
+
3
+ Ruby interface to update status on social networking sites.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'socialshare'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install socialshare
18
+
19
+ ## Usage
20
+
21
+ 1) for twitter
22
+
23
+ s = Socialshare::Tweeter.new(:consumer_key => TWITTER_CONSUMER_KEY,
24
+ :consumer_secret => TWITTER_CONSUMER_SECRET,
25
+ :user_token => twitter_user_token,
26
+ :user_secret => twitter_user_secret)
27
+
28
+ s.post(text) #to tweet on twitter
29
+
30
+ s.get_twitter_profile #to get your twitter timeline
31
+
32
+ s.get_twitter_followers #to get your twitter followers
33
+
34
+ s.fetch_tweet_by_id(tweet_id) #fetch any tweet using tweet id
35
+
36
+ s.fetch_twitter_friends(:name => "abc") #fetch twitter friend by name
37
+
38
+ s.fetch_twitter_friends(:id => "abc") #fetch twitter friend by id
39
+
40
+ s.fetch_twitter_friends # get all friends
41
+
42
+ 2) for facebook
43
+
44
+ s = Socialshare::Facebook.new(:fb_token => facebook_user_token)
45
+
46
+ s.post(text) #to post on facebook
47
+
48
+ s.get_facebook_profile #to get your facebook profile
49
+
50
+ s.get_facebook_connections #to get your facebook connections
51
+
52
+ 3) for Linkedin
53
+
54
+ s = Socialshare::Linkdin.new(:api_key => LINKEDIN_API_KEY,
55
+ :secret_key => LINKEDIN_SECRET_KEY,
56
+ :user_token => twitter_user_token,
57
+ :user_secret => twitter_user_secret)
58
+
59
+ s.post(text) #to post on linkedin
60
+
61
+ s.get_linkedin_profile #to get your linkedin profile
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ require "socialshare/version"
2
+ require "socialshare/tweeter"
3
+ require "socialshare/facebook"
4
+ require "socialshare/linkdin"
5
+
6
+ module Socialshare
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,32 @@
1
+ require 'koala'
2
+
3
+ module Socialshare
4
+ class Facebook
5
+ attr_accessor :fb_token, :fb_user
6
+
7
+ def initialize(options = {})
8
+ @fb_token = options[:fb_token]
9
+ @fb_user = get_fb_user(options[:fb_token])
10
+ end
11
+ def post(text)
12
+ begin
13
+ self.fb_user.put_wall_post(text)
14
+ rescue Exception => e
15
+ return e
16
+ end
17
+ end
18
+
19
+ def get_facebook_profile
20
+ profile = self.fb_user.get_object("me")
21
+ end
22
+
23
+ def get_facebook_connections
24
+ self.fb_user.get_connections("me", "friends")
25
+ end
26
+
27
+ protected
28
+ def get_fb_user(token)
29
+ Koala::Facebook::API.new(token)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,44 @@
1
+ require 'linkedin'
2
+
3
+ module Socialshare
4
+ class Linkdin
5
+ attr_accessor :api_key, :secret_key, :linkdin_user,:user_token, :user_secret
6
+
7
+ def initialize(options = {})
8
+ @api_key = options[:api_key]
9
+ @secret_key = options[:secret_key]
10
+ @user_token = options[:user_token]
11
+ @user_secret = options[:user_secret]
12
+ @linkdin_user = get_linkedin_user(options)
13
+ end
14
+
15
+ def post(text)
16
+ begin
17
+ self.linkdin_user.add_share(:comment => text)
18
+ rescue Exception => e
19
+ return e
20
+ end
21
+ end
22
+
23
+ def get_linkedin_profile(options = {})
24
+ begin
25
+ if options[:id]
26
+ self.linkdin_user.profile(:id => options[:id])
27
+ else
28
+ self.linkdin_user.profile
29
+ end
30
+ rescue Exception => e
31
+ return e
32
+ end
33
+ end
34
+
35
+ protected
36
+ def get_linkedin_user(options = {})
37
+ user = LinkedIn::Client.new(options[:api_key], options[:secret_key])
38
+ user.authorize_from_access(options[:user_token], options[:user_secret])
39
+ user
40
+ end
41
+ end
42
+ end
43
+
44
+
@@ -0,0 +1,72 @@
1
+ require 'twitter'
2
+
3
+ module Socialshare
4
+ class Tweeter
5
+ attr_accessor :consumer_key, :consumer_secret, :user_token, :user_secret, :twitter_user
6
+
7
+ def initialize(options = {})
8
+ @consumer_key = options[:consumer_key]
9
+ @consumer_secret = options[:consumer_secret]
10
+ @user_token = options[:token]
11
+ @user_secret = options[:secret]
12
+ @twitter_user = get_twitter_client(options)
13
+ end
14
+
15
+ def post(text)
16
+ begin
17
+ self.twitter_user.update(text)
18
+ rescue Exception => e
19
+ return e
20
+ end
21
+ end
22
+
23
+ def get_twitter_profile
24
+ begin
25
+ self.twitter_user.home_timeline
26
+ rescue Exception => e
27
+ return e
28
+ end
29
+ end
30
+
31
+ def get_twitter_followers
32
+ begin
33
+ self.twitter_user.followers
34
+ rescue Exception => e
35
+ return e
36
+ end
37
+ end
38
+
39
+
40
+ def fetch_tweet_by_id(tweet_id)
41
+ begin
42
+ self.twitter_user.status(tweet_id)
43
+ rescue Exception => e
44
+ return e
45
+ end
46
+ end
47
+
48
+ def fetch_twitter_friends(options = {})
49
+ begin
50
+ if options[:name]
51
+ self.twitter_user.friends(options[:name])
52
+ elsif options[:id]
53
+ self.twitter_user.friends(options[:id])
54
+ else
55
+ self.twitter_user.friends
56
+ end
57
+ rescue Exception => e
58
+ return e
59
+ end
60
+ end
61
+
62
+ protected
63
+ def get_twitter_client(options = {})
64
+ Twitter::Client.new(:consumer_key => options[:consumer_key],
65
+ :consumer_secret => options[:consumer_secret],
66
+ :oauth_token => options[:token],
67
+ :oauth_token_secret => options[:secret]
68
+ )
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module Socialshare
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'socialshare/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "socialshare"
8
+ gem.version = Socialshare::VERSION
9
+ gem.authors = ["pandurang"]
10
+ gem.email = ["pandurang.plw@gmail.com"]
11
+ gem.description = %q{This gem allows text/messages to be shared on social networking sites (twitter,facebook,linkedin)}
12
+ gem.summary = %q{This gem allows text/messages to be shared on social networking sites (twitter,facebook,linkedin)}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: socialshare
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - pandurang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem allows text/messages to be shared on social networking sites
14
+ (twitter,facebook,linkedin)
15
+ email:
16
+ - pandurang.plw@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/socialshare.rb
27
+ - lib/socialshare/facebook.rb
28
+ - lib/socialshare/linkdin.rb
29
+ - lib/socialshare/tweeter.rb
30
+ - lib/socialshare/version.rb
31
+ - socialshare.gemspec
32
+ homepage: ''
33
+ licenses: []
34
+ metadata: {}
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 2.0.3
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: This gem allows text/messages to be shared on social networking sites (twitter,facebook,linkedin)
55
+ test_files: []