blue_factory 0.1.1 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10e968b7723f9f1244cc006195c899ef5152d8aca0393787fbf0ac39901c7a2a
4
- data.tar.gz: 0d020d91890d1afdac88a993cc6f659a29b6790b6dc031c7464f93ca347c263a
3
+ metadata.gz: c1a078159ccaad626c030e20a9ad18e1a408cc8897c27cddb9773c1bd1a6295c
4
+ data.tar.gz: b7c45df10d3419f21745b760b586fe21e1eb262e9a12c72a5282e3ca0616eace
5
5
  SHA512:
6
- metadata.gz: 90304d80cc54255f1550bdf42403e699334f92a1a1bf6d0b0ecea43a66e109f1f1fbcee9600f6ff38198093a7bbf9d189c3e31d226d0db7f8ae956521a051967
7
- data.tar.gz: 70180d3c1fde075b0e088882b47a18716dc7488cdb669bf28808d2b7a9b55917053ce7adf4418a1e2ce00eade2eabef49dda211a93cbf6c6dc92918351587d7a
6
+ metadata.gz: 3347004aff37324480e13d2c1a21b85f737a9ab8898d874ecf26dad6f1b8f74ffa621ca24d4d76098be1479e145c08745d8c86a5cfcab68e66c8148bd6f76a8c
7
+ data.tar.gz: 15fd3de8b85ecb2175c3d3ede61b73257bac08e849935ad42aad6b428d70c1fbe1fbec970887db354a6fea8f36fa93851f2909452497cc33f50419bff4cd1bea
data/CHANGELOG.md CHANGED
@@ -1 +1,16 @@
1
- ## [Unreleased]
1
+ ## [0.1.3] - 2023-07-27
2
+
3
+ - fixed incorrect response when reaching the end of the feed
4
+
5
+ ## [0.1.2] - 2023-06-15
6
+
7
+ - added validation for feed rkey
8
+ - renamed `all_feeds` to `feed_keys`, `all_feeds` now returns an array of feeds
9
+
10
+ ## [0.1.1] - 2023-06-13
11
+
12
+ - added a rake task for publishing the feed to Bluesky
13
+
14
+ ## [0.1.0] - 2023-06-12
15
+
16
+ Initial release: working version that serves all required endpoints for the feed.
data/README.md CHANGED
@@ -22,7 +22,7 @@ The server is configured through the `BlueFactory` module. The two required sett
22
22
  - `publisher_did` - DID identifier of the account that you will publish the feed on (the string that starts with `did:plc:...`)
23
23
  - `hostname` - the hostname on which the feed service will be run
24
24
 
25
- You also need to configure at least one feed by passing a feed key and a feed object. The key is the identifier that will appear at the end of the feed URI - ideally something short and lowercase. The object is anything that implements the single required method `get_posts` (could be a class, a module or an instance).
25
+ You also need to configure at least one feed by passing a feed key and a feed object. The key is the identifier that will appear at the end of the feed URI - it must only contain characters that are valid in URLs (preferably all lowercase) and it can't be longer than 15 characters. The object is anything that implements the single required method `get_posts` (could be a class, a module or an instance).
26
26
 
27
27
  So a simple setup could look like this:
28
28
 
@@ -1,4 +1,7 @@
1
1
  module BlueFactory
2
+ class InvalidKeyError < StandardError
3
+ end
4
+
2
5
  class InvalidRequestError < StandardError
3
6
  attr_reader :error_type
4
7
 
@@ -5,15 +5,29 @@ module BlueFactory
5
5
  end
6
6
 
7
7
  def add_feed(key, feed_class)
8
+ validate_key(key)
8
9
  @feeds[key.to_s] = feed_class
9
10
  end
10
11
 
11
- def all_feeds
12
+ def feed_keys
12
13
  @feeds.keys
13
14
  end
14
15
 
15
16
  def get_feed(key)
16
17
  @feeds[key.to_s]
17
18
  end
19
+
20
+ def all_feeds
21
+ @feeds.values
22
+ end
23
+
24
+ private
25
+
26
+ def validate_key(key)
27
+ raise InvalidKeyError, "Key must be a string" unless key.is_a?(String)
28
+ raise InvalidKeyError, "Key must not be empty" if key == ''
29
+ raise InvalidKeyError, "Key must not contain a slash" if key.include?('/')
30
+ raise InvalidKeyError, "Key must not be longer than 15 characters" if key.length > 15
31
+ end
18
32
  end
19
33
  end
@@ -69,10 +69,11 @@ module BlueFactory
69
69
  response = feed.get_posts(params.slice(:feed, :cursor, :limit))
70
70
  validate_response(response) if config.validate_responses
71
71
 
72
- return json({
73
- cursor: response[:cursor],
74
- feed: response[:posts].map { |s| { post: s }}
75
- })
72
+ output = {}
73
+ output[:feed] = response[:posts].map { |s| { post: s }}
74
+ output[:cursor] = response[:cursor] if response[:cursor]
75
+
76
+ return json(output)
76
77
  rescue InvalidRequestError => e
77
78
  return json_error(e.error_type || "InvalidRequest", e.message)
78
79
  rescue InvalidResponseError => e
@@ -83,7 +84,7 @@ module BlueFactory
83
84
  get '/xrpc/app.bsky.feed.describeFeedGenerator' do
84
85
  return json({
85
86
  did: config.service_did,
86
- feeds: config.all_feeds.map { |f| { uri: feed_uri(f) }}
87
+ feeds: config.feed_keys.map { |f| { uri: feed_uri(f) }}
87
88
  })
88
89
  end
89
90
 
@@ -1,3 +1,3 @@
1
1
  module BlueFactory
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blue_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Suder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-13 00:00:00.000000000 Z
11
+ date: 2023-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -24,7 +24,11 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
- description: Write a longer description or delete this line.
27
+ description: "\n BlueFactory is a Ruby library which helps you build a web service
28
+ that hosts custom feeds a.k.a. feed generators\n for the Bluesky social network.
29
+ It implements a simple HTTP server based on Sinatra which provides the required\n
30
+ \ endpoints for the feed generator interface. You need to provide the content
31
+ for the feed by making a query to your\n preferred local database.\n "
28
32
  email:
29
33
  - jakub.suder@gmail.com
30
34
  executables: []
@@ -70,5 +74,5 @@ requirements: []
70
74
  rubygems_version: 3.4.10
71
75
  signing_key:
72
76
  specification_version: 4
73
- summary: Write a short summary, because RubyGems requires one.
77
+ summary: A Ruby gem for hosting custom feeds for Bluesky
74
78
  test_files: []