lnkdtogo 3.2.0
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/lib/lnkdtogo.rb +67 -0
- metadata +62 -0
data/lib/lnkdtogo.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'rest-client'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
module Lnkdtogo
|
|
5
|
+
# => Auth Configuration from config block
|
|
6
|
+
class Configuration
|
|
7
|
+
attr_accessor :key, :secret
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
self.key = nil
|
|
11
|
+
self.secret = nil
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.configuration
|
|
16
|
+
@configuration ||= Configuration.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.configure
|
|
20
|
+
yield(configuration) if block_given?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
attr_accessor :key, :secret, :api_path
|
|
25
|
+
def key
|
|
26
|
+
raise "The API key is needed" unless @key
|
|
27
|
+
@key
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def secret
|
|
31
|
+
raise "The API secret is needed" unless @secret
|
|
32
|
+
@secret
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def api_path
|
|
36
|
+
@api_path = "http://lnkdto.com"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.shares(urls)
|
|
41
|
+
if urls.is_a? Array
|
|
42
|
+
# => many_urls
|
|
43
|
+
many_urls(urls)
|
|
44
|
+
else
|
|
45
|
+
# => single_url
|
|
46
|
+
single_url(urls)
|
|
47
|
+
end
|
|
48
|
+
# Lnkdtogo.configuration.key
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# => Private methods used for the public method [shares].
|
|
52
|
+
private
|
|
53
|
+
def self.many_urls(urls)
|
|
54
|
+
clean_array = Array.new
|
|
55
|
+
urls.each{|url| clean_array << {"url" => url}}
|
|
56
|
+
RestClient.post Lnkdtogo.api_path + '/api', [{"urls" => clean_array,
|
|
57
|
+
"key" => Lnkdtogo.configuration.key,
|
|
58
|
+
"secret" => Lnkdtogo.configuration.secret}].to_json,
|
|
59
|
+
:content_type => :json, :accept => :json
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.single_url(url)
|
|
63
|
+
RestClient.get Lnkdtogo.api_path + '/api', {:url => url,
|
|
64
|
+
"key" => Lnkdtogo.configuration.key,
|
|
65
|
+
"secret" => Lnkdtogo.configuration.secret}
|
|
66
|
+
end
|
|
67
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lnkdtogo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 3.2.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Greg Winn
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rest-client
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 1.6.7
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 1.6.7
|
|
30
|
+
description: This is an unoffical gem for the service Lnkdto.com
|
|
31
|
+
email: greg@winn.ws
|
|
32
|
+
executables: []
|
|
33
|
+
extensions: []
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- lib/lnkdtogo.rb
|
|
37
|
+
homepage: http://rubygems.org/gems/lnkdto_gregwinn
|
|
38
|
+
licenses:
|
|
39
|
+
- MIT
|
|
40
|
+
post_install_message:
|
|
41
|
+
rdoc_options: []
|
|
42
|
+
require_paths:
|
|
43
|
+
- lib
|
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
|
+
none: false
|
|
46
|
+
requirements:
|
|
47
|
+
- - ! '>='
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
none: false
|
|
52
|
+
requirements:
|
|
53
|
+
- - ! '>='
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubyforge_project:
|
|
58
|
+
rubygems_version: 1.8.25
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 3
|
|
61
|
+
summary: This is an unoffical gem for the service Lnkdto.com
|
|
62
|
+
test_files: []
|