quandora 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +59 -0
- data/LICENSE +373 -0
- data/LICENSE.txt +21 -0
- data/README.md +178 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/quandora.rb +52 -0
- data/lib/quandora/activity.rb +8 -0
- data/lib/quandora/answer.rb +29 -0
- data/lib/quandora/badges.rb +2 -0
- data/lib/quandora/bases.rb +51 -0
- data/lib/quandora/comment.rb +40 -0
- data/lib/quandora/configuration.rb +11 -0
- data/lib/quandora/end_points.rb +6 -0
- data/lib/quandora/question.rb +52 -0
- data/lib/quandora/report.rb +19 -0
- data/lib/quandora/request.rb +26 -0
- data/lib/quandora/tag.rb +75 -0
- data/lib/quandora/users.rb +27 -0
- data/lib/quandora/version.rb +3 -0
- data/quandora.gemspec +35 -0
- metadata +158 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
# show
|
2
|
+
|
3
|
+
class Quandora::Question < Quandora::Request
|
4
|
+
def detail(question_id)
|
5
|
+
@api = "q/"
|
6
|
+
show("#{question_id}")
|
7
|
+
end
|
8
|
+
|
9
|
+
def view(question_id, args = {})
|
10
|
+
@api = "q/"
|
11
|
+
show("#{question_id}/view")
|
12
|
+
end
|
13
|
+
|
14
|
+
def mlt(question_id, args = {})
|
15
|
+
@api = "q/"
|
16
|
+
show("#{question_id}/mlt")
|
17
|
+
end
|
18
|
+
|
19
|
+
def answer(question_id, args)
|
20
|
+
body = {
|
21
|
+
"type": "post-answer",
|
22
|
+
"data": {
|
23
|
+
"content": args["content"],
|
24
|
+
"contentType": args["content_type"] || "markdown"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
resp = @conn.post("q/#{question_id}/answer") do |req|
|
28
|
+
req.body = body.to_json
|
29
|
+
req.headers['Content-Type'] = 'application/json'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def vote(question_id, args)
|
34
|
+
body = {
|
35
|
+
"type": "boolean",
|
36
|
+
"data": args["vote"]
|
37
|
+
}
|
38
|
+
|
39
|
+
resp = @conn.post("q/#{question_id}/vote") do |req|
|
40
|
+
req.body = body.to_json
|
41
|
+
req.headers['Content-Type'] = 'application/json'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def comment(question_id)
|
46
|
+
Quandora::Comment.new(@conn, "q", question_id)
|
47
|
+
end
|
48
|
+
|
49
|
+
def tag(answer_id)
|
50
|
+
Quandora::Tag.new(@conn, "q", answer_id)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Quandora::Report
|
2
|
+
def initialize(conn, api, id)
|
3
|
+
@conn = conn
|
4
|
+
@api = api
|
5
|
+
@id = id
|
6
|
+
end
|
7
|
+
|
8
|
+
def asked
|
9
|
+
resp = @conn.get("#{@api}/#{@id}/report/asked")
|
10
|
+
end
|
11
|
+
|
12
|
+
def users_reputation_change
|
13
|
+
resp = @conn.get("#{@api}/#{@id}/report/usersByReputationChange")
|
14
|
+
end
|
15
|
+
|
16
|
+
def most_voted_question
|
17
|
+
resp = @conn.get("#{@api}/#{@id}/report/mostVotedQuestion")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Quandora::Request
|
2
|
+
attr_accessor :api, :params
|
3
|
+
|
4
|
+
def initialize(conn, api, params)
|
5
|
+
@conn = conn
|
6
|
+
@api = api
|
7
|
+
@params = params
|
8
|
+
end
|
9
|
+
|
10
|
+
def index(args = {})
|
11
|
+
@params.merge!("o": args["o"]) unless args.fetch('o', nil).nil?
|
12
|
+
@params.merge!("l": args["l"]) unless args.fetch('l', nil).nil?
|
13
|
+
|
14
|
+
resp = @conn.get(@api.to_s) do |req|
|
15
|
+
req.params = @params
|
16
|
+
req.headers['Content-Type'] = 'application/json'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def show(id, args = {})
|
21
|
+
resp = @conn.get("#{@api}/#{id}") do |req|
|
22
|
+
req.params = @params
|
23
|
+
req.headers['Content-Type'] = 'application/json'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/quandora/tag.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
class Quandora::Tag
|
2
|
+
def initialize(conn, api, id)
|
3
|
+
@conn = conn
|
4
|
+
@api = api
|
5
|
+
@id = id
|
6
|
+
end
|
7
|
+
|
8
|
+
def index(args={})
|
9
|
+
query = {}
|
10
|
+
query.merge!("q": args["q"]) unless args.fetch('q', nil).nil?
|
11
|
+
query.merge!("s": args["s"]) unless args.fetch('s', nil).nil?
|
12
|
+
query.merge!("o": args["o"]) unless args.fetch('o', nil).nil?
|
13
|
+
query.merge!("l": args["l"]) unless args.fetch('l', nil).nil?
|
14
|
+
|
15
|
+
resp = @conn.get("#{@api}/#{@id}/tags") do |req|
|
16
|
+
req.params = query
|
17
|
+
req.headers['Content-Type'] = 'application/json'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def show(tag_name, query = nil)
|
22
|
+
resp = @conn.get("#{@api}/#{@id}/tags/#{tag_name}/#{query}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(args)
|
26
|
+
body = {
|
27
|
+
"type": "tag-content",
|
28
|
+
"data": {
|
29
|
+
"name": args[:name],
|
30
|
+
"category": nil,
|
31
|
+
"location": nil,
|
32
|
+
"url": args[:url],
|
33
|
+
"content": args[:content]
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
resp = @conn.post("#{@api}/#{@id}/tags") do |req|
|
38
|
+
req.body = body.to_s
|
39
|
+
req.headers['Content-Type'] = 'application/json'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def update(args)
|
44
|
+
body = {
|
45
|
+
"type": "tag-content",
|
46
|
+
"data": {
|
47
|
+
"content": args["content"],
|
48
|
+
"uid": args["uid"]
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
resp = @conn.put("#{@api}/#{@id}/tags") do |req|
|
53
|
+
req.body = body.to_s
|
54
|
+
req.headers['Content-Type'] = 'application/json'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def delete(tag_name)
|
59
|
+
resp = @conn.delete("#{@api}/#{@id}/tags/#{tag_name}")
|
60
|
+
end
|
61
|
+
|
62
|
+
def set(tags)
|
63
|
+
tags = tags.join(',') if tags.is_a? Array
|
64
|
+
resp = @conn.post("/#{@api}/#{@id}/tags/#{tags}") do |req|
|
65
|
+
req.headers['Content-Type'] = 'application/json'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def add(tags)
|
70
|
+
tags = tags.join(',') if tags.is_a? Array
|
71
|
+
resp = @conn.put("/#{@api}/#{@id}/tags/#{tags}") do |req|
|
72
|
+
req.headers['Content-Type'] = 'application/json'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Quandora::Users < Quandora::Request
|
2
|
+
# API LIST: Me, Index, Show
|
3
|
+
def me
|
4
|
+
resp = @conn.get("#{@api}/me")
|
5
|
+
end
|
6
|
+
|
7
|
+
def create(args)
|
8
|
+
body = {
|
9
|
+
"type": "post-user",
|
10
|
+
"data": {
|
11
|
+
"email": args["email"],
|
12
|
+
"password": args["password"],
|
13
|
+
"firstName": args["first_name"],
|
14
|
+
"lastName": args["last_name"],
|
15
|
+
"title": args["title"],
|
16
|
+
"isManager": args["is_manager"],
|
17
|
+
"aliases": args["aliases"],
|
18
|
+
"groups": args["groups"]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
resp = @conn.post(@api) do |req|
|
23
|
+
req.body = body.to_s
|
24
|
+
req.headers['Content-Type'] = 'application/json'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/quandora.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "quandora/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "quandora"
|
7
|
+
spec.version = Quandora::VERSION
|
8
|
+
spec.authors = ["buzzjective"]
|
9
|
+
spec.email = ["hamid@buzzjective.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{A simple gem to connect to the quandora}
|
12
|
+
spec.description = %q{A simple gem to connect to the quandora}
|
13
|
+
spec.homepage = "https://buzzjective.com/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = "https://buzzjective.com/"
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/buzzjective/quandora/"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/buzzjective/quandora/"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
33
|
+
spec.add_development_dependency "byebug", "~> 3.0"
|
34
|
+
spec.add_dependency "faraday"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quandora
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- buzzjective
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A simple gem to connect to the quandora
|
98
|
+
email:
|
99
|
+
- hamid@buzzjective.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- lib/quandora.rb
|
117
|
+
- lib/quandora/activity.rb
|
118
|
+
- lib/quandora/answer.rb
|
119
|
+
- lib/quandora/badges.rb
|
120
|
+
- lib/quandora/bases.rb
|
121
|
+
- lib/quandora/comment.rb
|
122
|
+
- lib/quandora/configuration.rb
|
123
|
+
- lib/quandora/end_points.rb
|
124
|
+
- lib/quandora/question.rb
|
125
|
+
- lib/quandora/report.rb
|
126
|
+
- lib/quandora/request.rb
|
127
|
+
- lib/quandora/tag.rb
|
128
|
+
- lib/quandora/users.rb
|
129
|
+
- lib/quandora/version.rb
|
130
|
+
- quandora.gemspec
|
131
|
+
homepage: https://buzzjective.com/
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata:
|
135
|
+
homepage_uri: https://buzzjective.com/
|
136
|
+
source_code_uri: https://github.com/buzzjective/quandora/
|
137
|
+
changelog_uri: https://github.com/buzzjective/quandora/
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.7.6
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: A simple gem to connect to the quandora
|
158
|
+
test_files: []
|