pinned 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.
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/README.markdown +20 -0
- data/Rakefile +17 -0
- data/TODO.md +4 -0
- data/example/get_by_tag.rb +6 -0
- data/lib/pinned/base.rb +75 -0
- data/lib/pinned/version.rb +3 -0
- data/lib/pinned.rb +4 -0
- data/pinned.gemspec +13 -0
- data/test/base_test.rb +20 -0
- data/test/helper.rb +3 -0
- metadata +56 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Pinned is a [Pinboard API (v1.0)](http://pinboard.in/api/) wrapper.
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
gem install pinned
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Get all posts
|
10
|
+
|
11
|
+
require 'pinned'
|
12
|
+
|
13
|
+
pinned = Pinned.create(username, password)
|
14
|
+
pinned.all
|
15
|
+
|
16
|
+
## Thanks
|
17
|
+
A big thanks to the originators of the script:
|
18
|
+
|
19
|
+
- SingAlong
|
20
|
+
- [adr-enal](https://github.com/adr-enal-in/pinboard-ruby)
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
task :default => :test
|
4
|
+
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.test_files = FileList['test/*_test.rb']
|
7
|
+
t.ruby_opts = ['-rubygems'] if defined? Gem
|
8
|
+
t.ruby_opts << '-I.'
|
9
|
+
end
|
10
|
+
|
11
|
+
task :build do
|
12
|
+
sh 'gem build pinned.gemspec'
|
13
|
+
end
|
14
|
+
|
15
|
+
task :install do
|
16
|
+
sh 'gem install pinned --local'
|
17
|
+
end
|
data/TODO.md
ADDED
data/lib/pinned/base.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
class Pinned
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
base_uri 'https://api.pinboard.in/v1'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def create(u, p)
|
11
|
+
Pinned.new(:username => u, :password => p)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(auth)
|
16
|
+
@auth = auth
|
17
|
+
end
|
18
|
+
|
19
|
+
def all(options={})
|
20
|
+
options.merge!({ :basic_auth => @auth })
|
21
|
+
self.class.get('/posts/all', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def posts(options={})
|
25
|
+
options.merge!({ :basic_auth => @auth })
|
26
|
+
self.class.get('/posts/get', options)
|
27
|
+
end
|
28
|
+
|
29
|
+
#####
|
30
|
+
# To look at
|
31
|
+
#####
|
32
|
+
|
33
|
+
def recentPosts(options={})
|
34
|
+
apiData = { :basic_auth=>@auth }
|
35
|
+
apiData.merge!(options)
|
36
|
+
self.class.get('/posts/recent', apiData)
|
37
|
+
end
|
38
|
+
|
39
|
+
def addPost(u, d, options={})
|
40
|
+
apiQuery = {:url=>u, :description=>d}.merge(options)
|
41
|
+
apiData = { :basic_auth=>@auth, :query=>apiQuery }
|
42
|
+
self.class.get('/posts/add', apiData)
|
43
|
+
end
|
44
|
+
|
45
|
+
def deletePost(url)
|
46
|
+
apiQuery = { :url=>url }
|
47
|
+
apiData = { :basic_auth=>@auth, :query=>apiQuery }
|
48
|
+
self.class.get('/posts/delete', apiData)
|
49
|
+
end
|
50
|
+
|
51
|
+
def getDates(tag='')
|
52
|
+
if(tag.strip.empty?)
|
53
|
+
apiData = { :basic_auth=>@auth, :query=>{:tag=>tag} }
|
54
|
+
else
|
55
|
+
apiData = { :basic_auth=>@auth }
|
56
|
+
end
|
57
|
+
|
58
|
+
self.class.get('/posts/delete', apiData)
|
59
|
+
end
|
60
|
+
|
61
|
+
def getHashes(options={})
|
62
|
+
apiData = { :basic_auth=>@auth, :query=>options }
|
63
|
+
self.class.get("/posts/all", apiData)
|
64
|
+
end
|
65
|
+
|
66
|
+
def suggestPosts(url='')
|
67
|
+
if(url.strip.empty?)
|
68
|
+
apiData = { :basic_auth=>@auth, :query=>{:url=>url} }
|
69
|
+
else
|
70
|
+
apiData = { :basic_auth=>@auth }
|
71
|
+
end
|
72
|
+
|
73
|
+
self.class.get('/posts/suggest', apiData)
|
74
|
+
end
|
75
|
+
end
|
data/lib/pinned.rb
ADDED
data/pinned.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
require 'pinned/version'
|
3
|
+
|
4
|
+
Gem::Specification.new 'pinned', Pinned::VERSION do |n|
|
5
|
+
n.description = "Pinned is an API wrapper for the Pinboard.in service by Maciej Ceglowski"
|
6
|
+
n.summary = "Easy access to the pinboard api."
|
7
|
+
n.date = "2011-10-01"
|
8
|
+
n.authors = ["Gavin Miller"]
|
9
|
+
n.email = "gavin@randomtype.ca"
|
10
|
+
n.files = `git ls-files`.split("\n")
|
11
|
+
n.homepage = "http://randomtype.ca/projects/pinned/"
|
12
|
+
end
|
13
|
+
|
data/test/base_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class BaseTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
config = YAML::load(File.read(File.join(ENV['HOME'], '.pinboard')))
|
6
|
+
@pinned = Pinned.create(config['username'], config['password'])
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_default
|
10
|
+
assert true
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_posts
|
14
|
+
# p @pinned.posts
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_all
|
18
|
+
p @pinned.all
|
19
|
+
end
|
20
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pinned
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gavin Miller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-01 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Pinned is an API wrapper for the Pinboard.in service by Maciej Ceglowski
|
15
|
+
email: gavin@randomtype.ca
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- Gemfile
|
22
|
+
- README.markdown
|
23
|
+
- Rakefile
|
24
|
+
- TODO.md
|
25
|
+
- example/get_by_tag.rb
|
26
|
+
- lib/pinned.rb
|
27
|
+
- lib/pinned/base.rb
|
28
|
+
- lib/pinned/version.rb
|
29
|
+
- pinned.gemspec
|
30
|
+
- test/base_test.rb
|
31
|
+
- test/helper.rb
|
32
|
+
homepage: http://randomtype.ca/projects/pinned/
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.10
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Easy access to the pinboard api.
|
56
|
+
test_files: []
|