fmrest 0.2.5 → 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 +8 -0
- data/README.md +39 -1
- data/fmrest.gemspec +1 -0
- data/lib/fmrest/token_store/moneta.rb +41 -0
- data/lib/fmrest/version.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8222e5d83f79a3d60a6aa6fa0a3513cc00a46a0bb2e1dfd8d49b4651d89b0f
|
4
|
+
data.tar.gz: 451b7e41eaacbc7e5b0da15746fd9d53e4639a862ea07c7d3cca30b8ee095ec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02dec88a0482d6f26e5a899f4f5bc2451a54461bc02c3ded6ce86348a62e8753d75d7285adf8fda2759e660b59f2da765f993c13a448d4aefc0f869efb848708
|
7
|
+
data.tar.gz: 3035f10f9a9a91242f4cad5d479725ed490ea5ec801c5798e64b88ede8035746d417513a9f74f3e56308b34f798353b4808e76371534cc2992038ffd32aed528
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -140,7 +140,8 @@ FmRest.token_store = FmRest::TokenStore::Redis
|
|
140
140
|
|
141
141
|
You can also initialize it with the following options:
|
142
142
|
|
143
|
-
* `:redis` - A `Redis` object to use as connection, if ommited a new `Redis`
|
143
|
+
* `:redis` - A `Redis` object to use as connection, if ommited a new `Redis`
|
144
|
+
object will be created with remaining options
|
144
145
|
* `:prefix` - The prefix to use for token keys, by default `"fmrest-token:"`
|
145
146
|
* Any other options will be passed to `Redis.new` if `:redis` isn't provided
|
146
147
|
|
@@ -157,6 +158,43 @@ FmRest.token_store = FmRest::TokenStore::Redis.new(prefix: "my-fancy-prefix:", h
|
|
157
158
|
**NOTE:** redis-rb is not included as a gem dependency of fmrest-ruby, so you'll
|
158
159
|
have to add it to your Gemfile.
|
159
160
|
|
161
|
+
### Moneta
|
162
|
+
|
163
|
+
[Moneta](https://github.com/moneta-rb/moneta) is a key/value store wrapper
|
164
|
+
around many different storage backends. If ActiveRecord or Redis don't suit
|
165
|
+
your needs, chances are Moneta will.
|
166
|
+
|
167
|
+
To use it:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
# config/initializers/fmrest.rb
|
171
|
+
require "fmrest/token_store/moneta"
|
172
|
+
|
173
|
+
FmRest.token_store = FmRest::TokenStore::Moneta
|
174
|
+
```
|
175
|
+
|
176
|
+
By default the `:Memory` moneta backend will be used.
|
177
|
+
|
178
|
+
You can also initialize it with the following options:
|
179
|
+
|
180
|
+
* `:backend` - The moneta backend to initialize the store with
|
181
|
+
* `:prefix` - The prefix to use for token keys, by default `"fmrest-token:"`
|
182
|
+
* Any other options will be passed to `Moneta.new`
|
183
|
+
|
184
|
+
Examples:
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
# Using YAML as a backend with a custom prefix
|
188
|
+
FmRest.token_store = FmRest::TokenStore::Moneta.new(
|
189
|
+
backend: :YAML,
|
190
|
+
file: "tmp/tokens.yml",
|
191
|
+
prefix: "my-tokens"
|
192
|
+
)
|
193
|
+
```
|
194
|
+
|
195
|
+
**NOTE:** the moneta gem is not included as a dependency of fmrest-ruby, so
|
196
|
+
you'll have to add it to your Gemfile.
|
197
|
+
|
160
198
|
## Spyke support (ActiveRecord-like ORM)
|
161
199
|
|
162
200
|
[Spyke](https://github.com/balvig/spyke) is an ActiveRecord-like gem for
|
data/fmrest.gemspec
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fmrest/token_store/base"
|
4
|
+
require "moneta"
|
5
|
+
|
6
|
+
module FmRest
|
7
|
+
module TokenStore
|
8
|
+
class Moneta < Base
|
9
|
+
DEFAULT_BACKEND = :Memory
|
10
|
+
DEFAULT_PREFIX = "fmrest-token:".freeze
|
11
|
+
|
12
|
+
attr_reader :moneta
|
13
|
+
|
14
|
+
# @param options [Hash]
|
15
|
+
# Options to pass to `Moneta.new`
|
16
|
+
# @option options [Symbol] :backend (:Memory)
|
17
|
+
# The Moneta backend to use
|
18
|
+
# @option options [String] :prefix (DEFAULT_PREFIX)
|
19
|
+
# The prefix to use for keys
|
20
|
+
def initialize(options = {})
|
21
|
+
options = options.dup
|
22
|
+
super(options)
|
23
|
+
backend = options.delete(:backend) || DEFAULT_BACKEND
|
24
|
+
options[:prefix] ||= DEFAULT_PREFIX
|
25
|
+
@moneta = ::Moneta.new(backend, options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def load(key)
|
29
|
+
moneta[key]
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete(key)
|
33
|
+
moneta.delete(key)
|
34
|
+
end
|
35
|
+
|
36
|
+
def store(key, value)
|
37
|
+
moneta[key] = value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/fmrest/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fmrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Carbajal
|
@@ -176,6 +176,20 @@ dependencies:
|
|
176
176
|
- - ">="
|
177
177
|
- !ruby/object:Gem::Version
|
178
178
|
version: '0'
|
179
|
+
- !ruby/object:Gem::Dependency
|
180
|
+
name: moneta
|
181
|
+
requirement: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
type: :development
|
187
|
+
prerelease: false
|
188
|
+
version_requirements: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
179
193
|
description: FileMaker Data API client using Faraday, with optional ActiveRecord-like
|
180
194
|
ORM based on Spyke
|
181
195
|
email:
|
@@ -215,6 +229,7 @@ files:
|
|
215
229
|
- lib/fmrest/token_store/active_record.rb
|
216
230
|
- lib/fmrest/token_store/base.rb
|
217
231
|
- lib/fmrest/token_store/memory.rb
|
232
|
+
- lib/fmrest/token_store/moneta.rb
|
218
233
|
- lib/fmrest/token_store/redis.rb
|
219
234
|
- lib/fmrest/v1.rb
|
220
235
|
- lib/fmrest/v1/connection.rb
|