circle_orbit 0.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.
- checksums.yaml +7 -0
- data/.env.sample +4 -0
- data/.github/CODE_OF_CONDUCT.md +134 -0
- data/.github/CONTRIBUTING.md +69 -0
- data/.github/workflows/CI.yml +25 -0
- data/.gitignore +34 -0
- data/.rubocop.yml +31 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +137 -0
- data/LICENSE +21 -0
- data/README.md +105 -0
- data/bin/circle_orbit +38 -0
- data/circle_orbit.gemspec +39 -0
- data/docs/setup.md +11 -0
- data/docs/ways-to-use.png +0 -0
- data/lib/circle_orbit.rb +12 -0
- data/lib/circle_orbit/circle.rb +89 -0
- data/lib/circle_orbit/client.rb +90 -0
- data/lib/circle_orbit/interactions/comment.rb +75 -0
- data/lib/circle_orbit/interactions/post.rb +75 -0
- data/lib/circle_orbit/orbit.rb +40 -0
- data/lib/circle_orbit/version.rb +7 -0
- data/readme-images/screenshot_of_activity.png +0 -0
- data/readme-images/ways-to-use.png +0 -0
- data/scripts/check_comments.rb +17 -0
- data/scripts/check_posts.rb +17 -0
- metadata +213 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "action_view"
|
|
5
|
+
|
|
6
|
+
module CircleOrbit
|
|
7
|
+
module Interactions
|
|
8
|
+
class Post
|
|
9
|
+
def initialize(post_title:, body:, created_at:, id:, space:, url:, author:, email:, workspace_id:, api_key:)
|
|
10
|
+
@post_title = post_title
|
|
11
|
+
@body = sanitize_body(body)
|
|
12
|
+
@created_at = created_at
|
|
13
|
+
@id = id
|
|
14
|
+
@space = space
|
|
15
|
+
@url = url
|
|
16
|
+
@author = author
|
|
17
|
+
@email = email
|
|
18
|
+
@workspace_id = workspace_id
|
|
19
|
+
@api_key = api_key
|
|
20
|
+
|
|
21
|
+
after_initialize!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def after_initialize!
|
|
25
|
+
OrbitActivities::Request.new(
|
|
26
|
+
api_key: @api_key,
|
|
27
|
+
workspace_id: @workspace_id,
|
|
28
|
+
user_agent: "community-ruby-circle-orbit/#{CircleOrbit::VERSION}",
|
|
29
|
+
action: "new_activity",
|
|
30
|
+
body: construct_body.to_json
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def construct_body
|
|
35
|
+
{
|
|
36
|
+
activity: {
|
|
37
|
+
activity_type: "circle:post",
|
|
38
|
+
tags: ["channel:circle"],
|
|
39
|
+
key: "circle-post-#{@id}",
|
|
40
|
+
title: "New post in the #{@space} Space in Circle",
|
|
41
|
+
description: construct_description(@post_title, @body),
|
|
42
|
+
occurred_at: @created_at,
|
|
43
|
+
link: @url,
|
|
44
|
+
member: {
|
|
45
|
+
name: @author,
|
|
46
|
+
email: @email
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
identity: {
|
|
50
|
+
source: "circle",
|
|
51
|
+
email: @email
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def construct_description(title, body)
|
|
57
|
+
return body if title == "" || title.nil?
|
|
58
|
+
|
|
59
|
+
<<~HEREDOC
|
|
60
|
+
## #{title}
|
|
61
|
+
|
|
62
|
+
#{body}
|
|
63
|
+
HEREDOC
|
|
64
|
+
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
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module CircleOrbit
|
|
7
|
+
class Orbit
|
|
8
|
+
def self.call(type:, data:, orbit_workspace:, orbit_api_key:)
|
|
9
|
+
if type == "post"
|
|
10
|
+
CircleOrbit::Interactions::Post.new(
|
|
11
|
+
post_title: data["name"],
|
|
12
|
+
body: data["body"]["body"],
|
|
13
|
+
created_at: data["body"]["created_at"],
|
|
14
|
+
id: data["body"]["record_id"],
|
|
15
|
+
space: data["space_name"],
|
|
16
|
+
url: data["url"],
|
|
17
|
+
author: data["user_name"],
|
|
18
|
+
email: data["user_email"],
|
|
19
|
+
workspace_id: orbit_workspace,
|
|
20
|
+
api_key: orbit_api_key
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
if type == "comment"
|
|
25
|
+
CircleOrbit::Interactions::Comment.new(
|
|
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
|
+
)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "circle_orbit"
|
|
5
|
+
require "thor"
|
|
6
|
+
|
|
7
|
+
module CircleOrbit
|
|
8
|
+
module Scripts
|
|
9
|
+
class CheckComments < Thor
|
|
10
|
+
desc "render", "check for new comments in Spaces posts and push them to Orbit"
|
|
11
|
+
def render
|
|
12
|
+
client = CircleOrbit::Client.new
|
|
13
|
+
client.comments
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "circle_orbit"
|
|
5
|
+
require "thor"
|
|
6
|
+
|
|
7
|
+
module CircleOrbit
|
|
8
|
+
module Scripts
|
|
9
|
+
class CheckPosts < Thor
|
|
10
|
+
desc "render", "check for new posts in Circle Spaces and push them to Orbit"
|
|
11
|
+
def render
|
|
12
|
+
client = CircleOrbit::Client.new
|
|
13
|
+
client.posts
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: circle_orbit
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Orbit DevRel
|
|
8
|
+
- Ben Greenberg
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: actionview
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '6.1'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '6.1'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: activesupport
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '6.1'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '6.1'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: dotenv
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - "~>"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '2.7'
|
|
49
|
+
type: :runtime
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - "~>"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '2.7'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: http
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - "~>"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '4.4'
|
|
63
|
+
type: :runtime
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '4.4'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: json
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - "~>"
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '2.5'
|
|
77
|
+
type: :runtime
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - "~>"
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '2.5'
|
|
84
|
+
- !ruby/object:Gem::Dependency
|
|
85
|
+
name: orbit_activities
|
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - "~>"
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0.1'
|
|
91
|
+
type: :runtime
|
|
92
|
+
prerelease: false
|
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - "~>"
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0.1'
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: thor
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - "~>"
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '1.1'
|
|
105
|
+
type: :runtime
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - "~>"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '1.1'
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: zeitwerk
|
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - "~>"
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '2.4'
|
|
119
|
+
type: :runtime
|
|
120
|
+
prerelease: false
|
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - "~>"
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '2.4'
|
|
126
|
+
- !ruby/object:Gem::Dependency
|
|
127
|
+
name: rspec
|
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
|
129
|
+
requirements:
|
|
130
|
+
- - "~>"
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: '3.4'
|
|
133
|
+
type: :development
|
|
134
|
+
prerelease: false
|
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - "~>"
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '3.4'
|
|
140
|
+
- !ruby/object:Gem::Dependency
|
|
141
|
+
name: webmock
|
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
|
143
|
+
requirements:
|
|
144
|
+
- - "~>"
|
|
145
|
+
- !ruby/object:Gem::Version
|
|
146
|
+
version: '3.12'
|
|
147
|
+
type: :development
|
|
148
|
+
prerelease: false
|
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
150
|
+
requirements:
|
|
151
|
+
- - "~>"
|
|
152
|
+
- !ruby/object:Gem::Version
|
|
153
|
+
version: '3.12'
|
|
154
|
+
description: This gem brings in Circle activities to your Orbit workspace
|
|
155
|
+
email:
|
|
156
|
+
- devrel@orbit.love
|
|
157
|
+
executables:
|
|
158
|
+
- circle_orbit
|
|
159
|
+
extensions: []
|
|
160
|
+
extra_rdoc_files: []
|
|
161
|
+
files:
|
|
162
|
+
- ".env.sample"
|
|
163
|
+
- ".github/CODE_OF_CONDUCT.md"
|
|
164
|
+
- ".github/CONTRIBUTING.md"
|
|
165
|
+
- ".github/workflows/CI.yml"
|
|
166
|
+
- ".gitignore"
|
|
167
|
+
- ".rubocop.yml"
|
|
168
|
+
- Gemfile
|
|
169
|
+
- Gemfile.lock
|
|
170
|
+
- LICENSE
|
|
171
|
+
- README.md
|
|
172
|
+
- bin/circle_orbit
|
|
173
|
+
- circle_orbit.gemspec
|
|
174
|
+
- docs/setup.md
|
|
175
|
+
- docs/ways-to-use.png
|
|
176
|
+
- lib/circle_orbit.rb
|
|
177
|
+
- lib/circle_orbit/circle.rb
|
|
178
|
+
- lib/circle_orbit/client.rb
|
|
179
|
+
- lib/circle_orbit/interactions/comment.rb
|
|
180
|
+
- lib/circle_orbit/interactions/post.rb
|
|
181
|
+
- lib/circle_orbit/orbit.rb
|
|
182
|
+
- lib/circle_orbit/version.rb
|
|
183
|
+
- readme-images/screenshot_of_activity.png
|
|
184
|
+
- readme-images/ways-to-use.png
|
|
185
|
+
- scripts/check_comments.rb
|
|
186
|
+
- scripts/check_posts.rb
|
|
187
|
+
homepage: https://github.com/orbit-love/community-ruby-circle-orbit
|
|
188
|
+
licenses:
|
|
189
|
+
- MIT
|
|
190
|
+
metadata:
|
|
191
|
+
homepage_uri: https://github.com/orbit-love/community-ruby-circle-orbit
|
|
192
|
+
source_code_uri: https://github.com/orbit-love/community-ruby-circle-orbit
|
|
193
|
+
changelog_uri: https://github.com/orbit-love/community-ruby-circle-orbit/blob/main/CHANGELOG.md
|
|
194
|
+
post_install_message:
|
|
195
|
+
rdoc_options: []
|
|
196
|
+
require_paths:
|
|
197
|
+
- lib
|
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
|
+
requirements:
|
|
200
|
+
- - ">="
|
|
201
|
+
- !ruby/object:Gem::Version
|
|
202
|
+
version: 2.7.2
|
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
|
+
requirements:
|
|
205
|
+
- - ">="
|
|
206
|
+
- !ruby/object:Gem::Version
|
|
207
|
+
version: '0'
|
|
208
|
+
requirements: []
|
|
209
|
+
rubygems_version: 3.2.15
|
|
210
|
+
signing_key:
|
|
211
|
+
specification_version: 4
|
|
212
|
+
summary: Integrate Circle interactions into Orbit
|
|
213
|
+
test_files: []
|