xify 0.0.1 → 0.0.2
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 +4 -4
- data/lib/xify/event.rb +8 -0
- data/lib/xify/input/stdin.rb +3 -2
- data/lib/xify/output/rocket_chat.rb +6 -9
- data/lib/xify/output/stdout.rb +2 -2
- data/lib/xify.rb +1 -1
- metadata +3 -3
- data/lib/xify/item.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7887a75fe26b23e8914d2c644ab854b43f10962cba6098f6cef821cf1e331e4b
|
4
|
+
data.tar.gz: 8e5d734727dbfb96767d1a96376f851c83095c2d6ebcfc0dbb3d932fcf100dbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51b09d9c1f0aaa42a03347ff6a1d6c7f462d305295719a965ee70f8068cc096ffc7e325dfb84cd1974c0fbc32695ebfcde9533bff0cbf8587d0bfc2bb3802db2
|
7
|
+
data.tar.gz: eafcba6853de81298f3ea6d7c1966a79530684efefc4e78474b1c908e50898446feacb007793d3fd4284bd99229ba43829e0e5c805ed75361e864be56997de5a
|
data/lib/xify/event.rb
ADDED
data/lib/xify/input/stdin.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require 'xify/
|
1
|
+
require 'xify/event'
|
2
2
|
|
3
3
|
class Stdin
|
4
4
|
def initialize(config)
|
5
|
+
@author = config['author']
|
5
6
|
end
|
6
7
|
|
7
8
|
def updates
|
@@ -16,7 +17,7 @@ class Stdin
|
|
16
17
|
end
|
17
18
|
|
18
19
|
if input.length != 1
|
19
|
-
yield
|
20
|
+
yield Event.new @author, input
|
20
21
|
end
|
21
22
|
rescue Interrupt
|
22
23
|
# Stop on CTRL+C
|
@@ -56,19 +56,16 @@ class RocketChat
|
|
56
56
|
req
|
57
57
|
end
|
58
58
|
|
59
|
-
def process(
|
59
|
+
def process(event)
|
60
60
|
res = @http.request(authenticated_request do |req|
|
61
61
|
req.body = {
|
62
62
|
channel: @channel,
|
63
|
-
alias:
|
63
|
+
alias: event.author,
|
64
64
|
attachments: [
|
65
65
|
{
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
title: item.parent,
|
70
|
-
title_link: item.parent_link,
|
71
|
-
text: item.message
|
66
|
+
title: event.args[:parent],
|
67
|
+
title_link: event.args[:parent_link],
|
68
|
+
text: event.args[:link] ? "#{event.message.chomp} ([more](#{event.args[:link]}))" : event.message.chomp
|
72
69
|
}
|
73
70
|
]
|
74
71
|
}.to_json
|
@@ -77,7 +74,7 @@ class RocketChat
|
|
77
74
|
case res
|
78
75
|
when Net::HTTPUnauthorized
|
79
76
|
reset_auth
|
80
|
-
process
|
77
|
+
process event
|
81
78
|
when Net::HTTPSuccess
|
82
79
|
# nothing
|
83
80
|
else
|
data/lib/xify/output/stdout.rb
CHANGED
data/lib/xify.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xify
|
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
|
- Finn Glöe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Cross-post content from one service to another.
|
14
14
|
email: fgloee@united-internet.de
|
@@ -19,8 +19,8 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- bin/xify
|
21
21
|
- lib/xify.rb
|
22
|
+
- lib/xify/event.rb
|
22
23
|
- lib/xify/input/stdin.rb
|
23
|
-
- lib/xify/item.rb
|
24
24
|
- lib/xify/output/rocket_chat.rb
|
25
25
|
- lib/xify/output/stdout.rb
|
26
26
|
homepage:
|
data/lib/xify/item.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Item
|
2
|
-
attr_accessor :link, :message, :source, :author, :parent, :parent_link, :time
|
3
|
-
def initialize(link:, message:, source:, author: 'Anonymous', parent: nil, parent_link: nil, time: Time.now.iso8601)
|
4
|
-
self.author = author
|
5
|
-
self.link = link
|
6
|
-
self.message = message
|
7
|
-
self.parent = parent
|
8
|
-
self.parent_link = parent_link
|
9
|
-
self.source = source
|
10
|
-
self.time = time
|
11
|
-
end
|
12
|
-
end
|