blue_factory 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10e968b7723f9f1244cc006195c899ef5152d8aca0393787fbf0ac39901c7a2a
4
- data.tar.gz: 0d020d91890d1afdac88a993cc6f659a29b6790b6dc031c7464f93ca347c263a
3
+ metadata.gz: 41390cf32bc0c614a9cec3414ce6b5f4c2b325d81c59655089efe4e732356bd0
4
+ data.tar.gz: 24f49ed933396117be07381b43ae1878022a687b5a88d3b1e0dd1feb0582b972
5
5
  SHA512:
6
- metadata.gz: 90304d80cc54255f1550bdf42403e699334f92a1a1bf6d0b0ecea43a66e109f1f1fbcee9600f6ff38198093a7bbf9d189c3e31d226d0db7f8ae956521a051967
7
- data.tar.gz: 70180d3c1fde075b0e088882b47a18716dc7488cdb669bf28808d2b7a9b55917053ce7adf4418a1e2ce00eade2eabef49dda211a93cbf6c6dc92918351587d7a
6
+ metadata.gz: 94accb55c086ea2302e479f6f7e5f5cf83631c47a165d429349207dbeb654c48970a78b095fe6b2f9a3686674869f7fbfe382841d49bad84dd67b391585d05f5
7
+ data.tar.gz: c2b1d4590f546ee2c1c8d98b4c7a776974ca2c9dd1a94cce517a7021cb9e9f295d39b4f986fc41dd058bee00af1942113ab770d91cadbc135bc7ca4c9e27cfcb
data/CHANGELOG.md CHANGED
@@ -1 +1,12 @@
1
- ## [Unreleased]
1
+ ## [0.1.2] - 2023-06-15
2
+
3
+ - added validation for feed rkey
4
+ - renamed `all_feeds` to `feed_keys`, `all_feeds` now returns an array of feeds
5
+
6
+ ## [0.1.1] - 2023-06-13
7
+
8
+ - added a rake task for publishing the feed to Bluesky
9
+
10
+ ## [0.1.0] - 2023-06-12
11
+
12
+ 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
@@ -83,7 +83,7 @@ module BlueFactory
83
83
  get '/xrpc/app.bsky.feed.describeFeedGenerator' do
84
84
  return json({
85
85
  did: config.service_did,
86
- feeds: config.all_feeds.map { |f| { uri: feed_uri(f) }}
86
+ feeds: config.feed_keys.map { |f| { uri: feed_uri(f) }}
87
87
  })
88
88
  end
89
89
 
@@ -1,3 +1,3 @@
1
1
  module BlueFactory
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
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.2
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-06-15 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: []