plurb 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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d214efaf0b142ff1df7f4639421151a20361733
4
+ data.tar.gz: f04dc0a6bcb755bd623e6a596102640b7dae0aaf
5
+ SHA512:
6
+ metadata.gz: 7986c8b144b77e67aa0df0dce1ea8270d2f85de63fd7aed822f29fab1c22b37171c5e299223dba810e1688ef5b25a0c949ba43a82d3441e425cd07647b3e2724
7
+ data.tar.gz: 20ae4934dcc30be17c7be22b67d8ade1a4feffcbb83eb52c31e9b678a4cf67b9df77e8cb76f0793855a198bcce4ea7fbffb088c7cfcf721ac590ccfc3bc3e860
@@ -0,0 +1,2 @@
1
+ *.swp
2
+ *.gem
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Edwin Tunggawan
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,44 @@
1
+ # Plurb
2
+
3
+ Another [Plurk](http://www.plurk.com) API wrapper for Ruby.
4
+
5
+ ## Features
6
+
7
+ Plurb allows us to use the following Plurk API endpoints:
8
+
9
+ - Get Plurks
10
+ - Add Plurk
11
+ - Edit Plurk
12
+ - Delete Plurk
13
+
14
+ There are still [a lot of other features of Plurk accessible through their endpoints](http://www.plurk.com/API). Will add more of them to Plurb.
15
+
16
+ ## Installation
17
+
18
+ ```
19
+ gem install plurb
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```rb
25
+ require 'plurb'
26
+
27
+ client = Plurb::Client.new('your_app_key', 'your_app_secret')
28
+ client.authorize('your_user_token', 'your_user_token_secret')
29
+
30
+ client.get_plurks # retrieving plurks from your timeline
31
+ client.plurk('you a Merry Christmas', 'wishes') # plurks: `wishes` you a Merry Christmas
32
+ client.edit_plurk(543623, 'you a happy new year') # edits previous plurk to: `wishes` you a happy new year
33
+ client.delete_plurk(543623)
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ - Fork this repository
39
+ - Create a new branch, implement your awesome feature
40
+ - Create a pull request
41
+
42
+ ## License
43
+
44
+ MIT License
@@ -0,0 +1,5 @@
1
+ require 'oauth'
2
+ require 'json'
3
+ require 'plurb/version'
4
+ require 'plurb/url'
5
+ require 'plurb/client'
@@ -0,0 +1,75 @@
1
+ module Plurb
2
+ class Client
3
+
4
+ QUALIFIERS = [
5
+ 'says', 'was', 'is', 'thinks', 'feels', 'wonders', 'has', 'asks',
6
+ 'hopes', 'will', 'needs', 'wishes', 'wants', 'hates', 'gives', 'shares',
7
+ 'likes', 'loves', ''
8
+ ]
9
+
10
+ def initialize(app_key, app_secret)
11
+ @oauth_consumer = OAuth::Consumer.new(
12
+ app_key,
13
+ app_secret,
14
+ {
15
+ scheme: :header,
16
+ http_method: :post,
17
+ site: ::Plurb::URL::SITE,
18
+ request_token_path: ::Plurb::URL::REQUEST_TOKEN,
19
+ access_token_path: ::Plurb::URL::ACCESS_TOKEN,
20
+ authorize_path: ::Plurb::URL::AUTHORIZE
21
+ }
22
+ )
23
+ end
24
+
25
+ def authorize(token, token_secret)
26
+ @client = OAuth::AccessToken.new(@oauth_consumer, token, token_secret)
27
+ end
28
+
29
+ def get_plurks(options={})
30
+ get_response(
31
+ ::Plurb::URL::GET_PLURKS,
32
+ options
33
+ )
34
+ end
35
+
36
+ def plurk(content, qualifier='', options={})
37
+ q = qualifier.downcase
38
+ q = QUALIFIERS.include?(q) ? q : ''
39
+
40
+ get_response(
41
+ ::Plurb::URL::PLURK_ADD,
42
+ {
43
+ content: content,
44
+ qualifier: q
45
+ }.merge(options)
46
+ )
47
+ end
48
+
49
+ def delete_plurk(plurk_id)
50
+ get_response(
51
+ ::Plurb::URL::PLURK_DELETE,
52
+ plurk_id: plurk_id
53
+ )
54
+ end
55
+
56
+ def edit_plurk(plurk_id, content)
57
+ get_response(
58
+ ::Plurb::URL::PLURK_EDIT,
59
+ {
60
+ plurk_id: plurk_id,
61
+ content: content
62
+ }
63
+ )
64
+ end
65
+
66
+ private
67
+ def get_response(target_path, request_data)
68
+ response = @client.post(
69
+ target_path,
70
+ request_data
71
+ )
72
+ JSON.parse(response.body)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,38 @@
1
+ module Plurb
2
+ module URL
3
+ SITE = 'http://www.plurk.com'
4
+
5
+ # OAuth Paths
6
+ REQUEST_TOKEN = '/OAuth/request_token'
7
+ ACCESS_TOKEN = '/OAuth/access_token'
8
+ AUTHORIZE = '/OAuth/authorize'
9
+
10
+ # Profile Paths
11
+ GET_OWN_PROFILE = '/APP/Profile/getOwnProfile'
12
+ GET_PUBLIC_PROFILE = '/APP/Profile/getPublicProfile'
13
+
14
+ # Timeline Paths
15
+ GET_PLURK = '/APP/Timeline/getPlurk'
16
+ GET_PLURKS = '/APP/Timeline/getPlurks'
17
+ GET_UNREAD_PLURKS = '/APP/Timeline/getUnreadPlurks'
18
+ GET_PUBLIC_PLURKS = '/APP/Timeline/getPublicPlurks'
19
+ PLURK_ADD = '/APP/Timeline/plurkAdd'
20
+ PLURK_DELETE = '/APP/Timeline/plurkDelete'
21
+ PLURK_EDIT = '/APP/Timeline/plurkEdit'
22
+ TOGGLE_COMMENTS = '/APP/Timeline/toggleComments'
23
+ MUTE_PLURKS = '/APP/Timeline/mutePlurks'
24
+ UNMUTE_PLURKS = '/APP/Timeline/unmutePlurks'
25
+ FAVORITE_PLURKS = '/APP/Timeline/favoritePlurks'
26
+ UNFAVORITE_PLURKS = '/APP/Timeline/unfavoritePlurks'
27
+ REPLURK = '/APP/Timeline/replurk'
28
+ UNREPLURK = '/APP/Timeline/unreplurk'
29
+ MARK_AS_READ = '/APP/Timeline/markAsRead'
30
+ UPLOAD_PICTURE = '/APP/Timeline/uploadPicture'
31
+ REPORT_ABUSE = '/APP/Timeline/reportAbuse'
32
+
33
+ # Responses Paths
34
+ GET_RESPONSES = '/APP/Responses/get'
35
+ RESPONSE_ADD = '/APP/Responses/responseAdd'
36
+ RESPONSE_DELETE = '/APP/Responses/responseDelete'
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Plurb
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 'plurb/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'plurb'
8
+ gem.version = Plurb::VERSION
9
+ gem.authors = ['Edwin Tunggawan']
10
+ gem.email = ['vcc.edwint@gmail.com']
11
+ gem.description = 'Plurk API wrapper for Ruby'
12
+ gem.summary = 'Another Plurk API wrapper for Ruby'
13
+ gem.homepage = 'https://github.com/sdsdkkk/plurb'
14
+ gem.licenses = ['MIT']
15
+
16
+ gem.add_runtime_dependency 'oauth', '~> 0.5.1'
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.require_paths = ['lib', 'lib/plurb']
20
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: plurb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Edwin Tunggawan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.5.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.1
27
+ description: Plurk API wrapper for Ruby
28
+ email:
29
+ - vcc.edwint@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - LICENSE
36
+ - README.md
37
+ - lib/plurb.rb
38
+ - lib/plurb/client.rb
39
+ - lib/plurb/url.rb
40
+ - lib/plurb/version.rb
41
+ - plurb.gemspec
42
+ homepage: https://github.com/sdsdkkk/plurb
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ - lib/plurb
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.4.8
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Another Plurk API wrapper for Ruby
67
+ test_files: []