circle_orbit 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/circle_orbit +10 -8
- data/lib/circle_orbit/circle.rb +27 -23
- data/lib/circle_orbit/interactions/comment.rb +2 -9
- data/lib/circle_orbit/interactions/post.rb +2 -9
- data/lib/circle_orbit/orbit.rb +10 -10
- data/lib/circle_orbit/utils.rb +13 -0
- data/lib/circle_orbit/version.rb +1 -1
- data/scripts/check_comments.rb +1 -1
- data/scripts/check_posts.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05150b8b72010db06ed8915304757ae06a885e62130c9911b3de0e770177024d
|
4
|
+
data.tar.gz: f89c0f9b61f0aa4719a95e1e10a34e4c4d62519908a6a99aad38804acb9617ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bba116eab82c62e33bdae6abd7b03bf63934b07b892f2eb1bfc8424efb0f1863c9dc5e75df722bf7fbcb0117cd348f966c5858dcb6fa955ef59ad72cfbca5a2
|
7
|
+
data.tar.gz: 67d5bdf2f0a18ffdcaae2e29108c40794d01b30dd56268268ffe401809ae363831dfc3b4356c3222855ae86778401783869c842c986c46b8267fe2b09d90062b
|
data/bin/circle_orbit
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "optparse"
|
3
5
|
|
4
6
|
check_comments = false
|
5
7
|
check_posts = false
|
@@ -19,20 +21,20 @@ choices = OptionParser.new do |opts|
|
|
19
21
|
end
|
20
22
|
end.parse!
|
21
23
|
|
22
|
-
$LOAD_PATH.unshift(File.expand_path(
|
24
|
+
$LOAD_PATH.unshift(File.expand_path("../lib/circle_orbit", __dir__))
|
23
25
|
|
24
|
-
require_relative
|
25
|
-
require_relative
|
26
|
-
require_relative
|
26
|
+
require_relative "../lib/circle_orbit"
|
27
|
+
require_relative "../scripts/check_comments"
|
28
|
+
require_relative "../scripts/check_posts"
|
27
29
|
|
28
30
|
if check_comments
|
29
31
|
puts "Checking for new Circle Spaces post comments within the past day and sending them to your Orbit workspace..."
|
30
|
-
ARGV[0] =
|
32
|
+
ARGV[0] = "render"
|
31
33
|
CircleOrbit::Scripts::CheckComments.start(ARGV)
|
32
34
|
end
|
33
35
|
|
34
36
|
if check_posts
|
35
37
|
puts "Checking for new Circle Spaces posts and sending them to your Orbit workspace..."
|
36
|
-
ARGV[0] =
|
38
|
+
ARGV[0] = "render"
|
37
39
|
CircleOrbit::Scripts::CheckPosts.start(ARGV)
|
38
|
-
end
|
40
|
+
end
|
data/lib/circle_orbit/circle.rb
CHANGED
@@ -17,6 +17,8 @@ module CircleOrbit
|
|
17
17
|
posts = get_posts(space["id"])
|
18
18
|
|
19
19
|
posts.each do |post|
|
20
|
+
next if post.nil? || post.empty?
|
21
|
+
|
20
22
|
CircleOrbit::Orbit.call(
|
21
23
|
type: "post",
|
22
24
|
data: post,
|
@@ -28,18 +30,20 @@ module CircleOrbit
|
|
28
30
|
end
|
29
31
|
|
30
32
|
def process_comments
|
31
|
-
|
33
|
+
comments = get_comments
|
32
34
|
|
33
|
-
|
35
|
+
return if comments.nil? || comments.empty?
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
comments.each do |comment|
|
38
|
+
next if comment.nil? || comment.empty?
|
39
|
+
|
40
|
+
CircleOrbit::Orbit.call(
|
41
|
+
type: "comment",
|
42
|
+
data: comment,
|
43
|
+
orbit_api_key: @orbit_api_key,
|
44
|
+
orbit_workspace: @orbit_workspace
|
45
|
+
)
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
private
|
@@ -55,7 +59,7 @@ module CircleOrbit
|
|
55
59
|
|
56
60
|
response = https.request(request)
|
57
61
|
|
58
|
-
|
62
|
+
JSON.parse(response.body)
|
59
63
|
end
|
60
64
|
|
61
65
|
def get_posts(id)
|
@@ -69,21 +73,21 @@ module CircleOrbit
|
|
69
73
|
|
70
74
|
response = https.request(request)
|
71
75
|
|
72
|
-
|
76
|
+
JSON.parse(response.body)
|
73
77
|
end
|
74
78
|
|
75
79
|
def get_comments
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
url = URI("#{@circle_url}/api/v1/comments?community_id=#{@circle_community_id}")
|
81
|
+
|
82
|
+
https = Net::HTTP.new(url.host, url.port)
|
83
|
+
https.use_ssl = true
|
84
|
+
|
85
|
+
request = Net::HTTP::Get.new(url)
|
86
|
+
request["Authorization"] = "Token #{@circle_api_key}"
|
87
|
+
|
88
|
+
response = https.request(request)
|
89
|
+
|
90
|
+
JSON.parse(response.body)
|
87
91
|
end
|
88
92
|
end
|
89
93
|
end
|
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
require "json"
|
4
4
|
require "action_view"
|
5
|
+
require_relative "../utils"
|
5
6
|
|
6
7
|
module CircleOrbit
|
7
8
|
module Interactions
|
8
9
|
class Comment
|
9
10
|
def initialize(post_title:, body:, created_at:, id:, space:, url:, author:, email:, workspace_id:, api_key:)
|
10
11
|
@post_title = post_title
|
11
|
-
@body = sanitize_body(body)
|
12
|
+
@body = CircleOrbit::Utils.sanitize_body(body)
|
12
13
|
@created_at = created_at
|
13
14
|
@id = id
|
14
15
|
@space = space
|
@@ -62,14 +63,6 @@ module CircleOrbit
|
|
62
63
|
#{body}
|
63
64
|
HEREDOC
|
64
65
|
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def sanitize_body(body)
|
69
|
-
body = ActionView::Base.full_sanitizer.sanitize(body)
|
70
|
-
|
71
|
-
body.gsub("\n", " ")
|
72
|
-
end
|
73
66
|
end
|
74
67
|
end
|
75
68
|
end
|
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
require "json"
|
4
4
|
require "action_view"
|
5
|
+
require_relative "../utils"
|
5
6
|
|
6
7
|
module CircleOrbit
|
7
8
|
module Interactions
|
8
9
|
class Post
|
9
10
|
def initialize(post_title:, body:, created_at:, id:, space:, url:, author:, email:, workspace_id:, api_key:)
|
10
11
|
@post_title = post_title
|
11
|
-
@body = sanitize_body(body)
|
12
|
+
@body = CircleOrbit::Utils.sanitize_body(body)
|
12
13
|
@created_at = created_at
|
13
14
|
@id = id
|
14
15
|
@space = space
|
@@ -62,14 +63,6 @@ module CircleOrbit
|
|
62
63
|
#{body}
|
63
64
|
HEREDOC
|
64
65
|
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def sanitize_body(body)
|
69
|
-
body = ActionView::Base.full_sanitizer.sanitize(body)
|
70
|
-
|
71
|
-
body.gsub("\n", " ")
|
72
|
-
end
|
73
66
|
end
|
74
67
|
end
|
75
68
|
end
|
data/lib/circle_orbit/orbit.rb
CHANGED
@@ -23,16 +23,16 @@ module CircleOrbit
|
|
23
23
|
|
24
24
|
if type == "comment"
|
25
25
|
CircleOrbit::Interactions::Comment.new(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
post_title: data["post_name"],
|
27
|
+
body: data["body"]["body"],
|
28
|
+
created_at: data["body"]["created_at"],
|
29
|
+
id: data["body"]["record_id"],
|
30
|
+
space: data["space_slug"].gsub(/-/, " ").capitalize,
|
31
|
+
url: data["url"],
|
32
|
+
author: data["user_name"],
|
33
|
+
email: data["user_email"],
|
34
|
+
workspace_id: orbit_workspace,
|
35
|
+
api_key: orbit_api_key
|
36
36
|
)
|
37
37
|
end
|
38
38
|
end
|
data/lib/circle_orbit/version.rb
CHANGED
data/scripts/check_comments.rb
CHANGED
data/scripts/check_posts.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circle_orbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orbit DevRel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-06-
|
12
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionview
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- lib/circle_orbit/interactions/comment.rb
|
180
180
|
- lib/circle_orbit/interactions/post.rb
|
181
181
|
- lib/circle_orbit/orbit.rb
|
182
|
+
- lib/circle_orbit/utils.rb
|
182
183
|
- lib/circle_orbit/version.rb
|
183
184
|
- readme-images/screenshot_of_activity.png
|
184
185
|
- readme-images/ways-to-use.png
|