sakaki 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/sakaki.rb +58 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1ae2655d0e941c99f99c740079ac034180d8093e
|
4
|
+
data.tar.gz: 88d39b6d5830b752f5f6de3c33c1f089ca0592bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7334fbcd7b8d1743ad4783110f0d6a0e44e9ad78bcfdda431ba117a0b694c7f43d0e43cc378ef7ad2b7754dcb4a7316693d00e28464ec49cf88a523097e21c9f
|
7
|
+
data.tar.gz: 3275bd9d89cc9229bd20b1aace7abb22c3bbbb1a3ed5c5a06e99e94f2da9977232d248e9b0ad7a7bfa064be7d3027b0253020c9d286dae4d134f248482534c80
|
data/lib/sakaki.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# sakaki.rb - Ruby API wrapper for Sakaki
|
2
|
+
# (c) 2017 prefetcher
|
3
|
+
|
4
|
+
require 'socket'
|
5
|
+
require 'json'
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
API = "/api/v1/"
|
9
|
+
|
10
|
+
class Sakaki
|
11
|
+
###############
|
12
|
+
# Indexes a board
|
13
|
+
# Returns a hash of arrays
|
14
|
+
def index_board(board)
|
15
|
+
return JSON.parse(get(API + "board/" + board))
|
16
|
+
end
|
17
|
+
|
18
|
+
###############
|
19
|
+
# Gets replies from thread
|
20
|
+
# Returns a hash of arrays
|
21
|
+
def get_thread_replies(id)
|
22
|
+
return JSON.parse(get(API + "thread/" + id.to_s))
|
23
|
+
end
|
24
|
+
|
25
|
+
###############
|
26
|
+
# Gets all boards with their descriptions
|
27
|
+
# Returns a hash of arrays
|
28
|
+
def get_boards
|
29
|
+
return JSON.parse(get(API + "boards"))
|
30
|
+
end
|
31
|
+
|
32
|
+
###############
|
33
|
+
# Replies to a thread
|
34
|
+
# Returns nothing
|
35
|
+
def reply(id, board, comment)
|
36
|
+
get("/" + board + "/reply/" + id.to_s, comment)
|
37
|
+
end
|
38
|
+
|
39
|
+
###############
|
40
|
+
# Creates a new thread
|
41
|
+
# Returns nothing
|
42
|
+
def new_thread(board, title, comment)
|
43
|
+
get("/" + board + "/post/" + Base64.urlsafe_encode64(title), comment)
|
44
|
+
end
|
45
|
+
|
46
|
+
def get(location, query="")
|
47
|
+
socket = TCPSocket.new("gopher.dangeru.us", 70)
|
48
|
+
|
49
|
+
if query.empty? then
|
50
|
+
socket.print location + "\n"
|
51
|
+
else
|
52
|
+
socket.print location + "\t" + query + "\n"
|
53
|
+
end
|
54
|
+
response = socket.read
|
55
|
+
|
56
|
+
return response[0..-5]
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sakaki
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- prefetcher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Gopher/u/ / Sakaki wrapper for Ruby
|
28
|
+
email: 0xlunaric@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/sakaki.rb
|
34
|
+
homepage: http://rubygems.org/gems/sakaki
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.6.11
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: sakaki.rb
|
58
|
+
test_files: []
|