discourse_cli 0.2.0 → 0.3.0
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/CHANGELOG.md +4 -0
- data/lib/discourse_cli/cli.rb +32 -0
- data/lib/discourse_cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58ce26ab3f14e909ebcbac7b6d79722fccaa1307
|
|
4
|
+
data.tar.gz: b0d2373806b546d06e420a9901e07611d86c14de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ce9b0d845620d9a57c0a9a59c3081c140f8d1c5f5d2c1dfa35f2286d5ea40a76227ae626aede13c4b5f4c65dfa6198d7f21b2c97710f71624dd21c709046049
|
|
7
|
+
data.tar.gz: fe5b562a3c2a4c465b4a451499b2f9c57b95372d817ea623eec8de76118c3969ff82def4716df935ab6b749fe32f25333bdb1713aee2af3abd4c215e11ebcc23
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [0.3.0] - 2015-11-28
|
|
6
|
+
### Added
|
|
7
|
+
- added `posts` command
|
|
8
|
+
|
|
5
9
|
## [0.2.0] - 2015-11-21
|
|
6
10
|
### Added
|
|
7
11
|
- added `topics` command.
|
data/lib/discourse_cli/cli.rb
CHANGED
|
@@ -40,5 +40,37 @@ module DiscourseCli
|
|
|
40
40
|
puts "#{v['id']} #{v['title']}"
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
desc "posts TOPIC_ID", "returns a list of posts in the specified topic"
|
|
45
|
+
def posts(topic_id)
|
|
46
|
+
client = DiscourseCli::Client.client
|
|
47
|
+
post_ids = []
|
|
48
|
+
|
|
49
|
+
# fetch topic
|
|
50
|
+
topic = client.topic(topic_id)
|
|
51
|
+
|
|
52
|
+
# array of all post id's in topic
|
|
53
|
+
stream = topic['post_stream']['stream']
|
|
54
|
+
|
|
55
|
+
# get the first ~20 posts in the topic
|
|
56
|
+
posts = topic['post_stream']['posts']
|
|
57
|
+
posts.each do |p|
|
|
58
|
+
post_ids.push(p['id'])
|
|
59
|
+
puts "#{p['id']} #{p['cooked'][3..13]}..."
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# get the rest of the posts in chunks of 20
|
|
63
|
+
diff = stream - post_ids
|
|
64
|
+
while diff.count > 0 do
|
|
65
|
+
response = client.topic_posts(topic_id, diff.slice(0, 19))
|
|
66
|
+
response_posts = response['post_stream']['posts']
|
|
67
|
+
response_posts.each do |p|
|
|
68
|
+
post_ids.push(p['id'])
|
|
69
|
+
puts "#{p['id']} #{p['cooked'][3..13]}..."
|
|
70
|
+
end
|
|
71
|
+
diff = stream - post_ids
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
43
75
|
end
|
|
44
76
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: discourse_cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Blake Erickson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-11-
|
|
11
|
+
date: 2015-11-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|