order_already 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/lib/order_already/version.rb +1 -1
- data/lib/order_already.rb +6 -6
- data/order_already.gemspec +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c26d17f72e31fe01a89459e031b394237dfe163d8c5548307cc7b00308115175
|
4
|
+
data.tar.gz: 0c1b6a4e25e973ff90a2dcd05cc21b9b3267a9110f762c15707cee9d4b7e10a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 640aae2c6f8f6c678afe164aa37044afad6192f88ea042e7aa50b431e62258cd267a95368ab82bbcb2a28845e57be939d7a663f8e8995bb532dc038d5d8c0c54
|
7
|
+
data.tar.gz: 6400c35df376c1767b59d7a8bbab52a8554917c51c84fdd4592a09b6bdf703d344e2765824d6a7f1ab24d1d96b37a62045a74bd03906ab981ae302c9a2e53719
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ With a plain old Ruby object (PORO):
|
|
24
24
|
class MyModel
|
25
25
|
attr_accessor :author, :subject
|
26
26
|
|
27
|
-
|
27
|
+
prepend OrderAlready.for(:author, :subject)
|
28
28
|
end
|
29
29
|
```
|
30
30
|
|
@@ -43,7 +43,7 @@ class GenericWork < ActiveFedora::Base
|
|
43
43
|
# schema (by adding accepts_nested_attributes)
|
44
44
|
include ::Hyrax::BasicMetadata
|
45
45
|
|
46
|
-
|
46
|
+
prepend OrderAlready.for(:creator, :contributor)
|
47
47
|
end
|
48
48
|
```
|
49
49
|
|
data/lib/order_already.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "order_already/version"
|
4
|
-
# require "set"
|
5
|
-
# require "loofah"
|
6
4
|
require "rails-html-sanitizer"
|
7
|
-
# require "rails/html/scrubbers"
|
8
5
|
|
9
6
|
# In the spirit of Browse Everything and Questioning Authority, the Order Already module provides a
|
10
7
|
# simple interface for ordering properties that have an indeterminate persistence order (looking at
|
@@ -19,6 +16,9 @@ module OrderAlready
|
|
19
16
|
# @api public
|
20
17
|
#
|
21
18
|
# @param attributes [Array<Symbol>] the name of the attributes/properties you want to order.
|
19
|
+
# @param serializer [#serialize, #deserialize] the service class responsible for serializing the
|
20
|
+
# data. Want to auto-alphabetize? Inject a new serializer.
|
21
|
+
#
|
22
22
|
# @return [Module] a module that wraps the attr_accessor methods for the given :attributes.
|
23
23
|
#
|
24
24
|
# @note In testing, you need to use `prepend` instead of `include`; but that may be a function of
|
@@ -34,16 +34,16 @@ module OrderAlready
|
|
34
34
|
# end
|
35
35
|
# prepend OrderAlready.for(:creators)
|
36
36
|
# end
|
37
|
-
def self.for(*attributes)
|
37
|
+
def self.for(*attributes, serializer: StringSerializer)
|
38
38
|
# By creating a module, we have access to `super`.
|
39
39
|
Module.new do
|
40
40
|
attributes.each do |attribute|
|
41
41
|
define_method(attribute) do
|
42
|
-
|
42
|
+
serializer.deserialize(super())
|
43
43
|
end
|
44
44
|
|
45
45
|
define_method("#{attribute}=") do |values|
|
46
|
-
super(
|
46
|
+
super(serializer.serialize(values))
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/order_already.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Jeremy Friesen", "Rob Kaufman"]
|
9
9
|
spec.email = ["jeremy.n.friesen@gmail.com", "rob@notch8.com"]
|
10
10
|
|
11
|
-
spec.summary = "A tiny gem to provide naive sorting for Fedora Commons
|
12
|
-
spec.description = "A tiny gem to provide naive sorting for Fedora Commons
|
11
|
+
spec.summary = "A tiny gem to provide naive sorting for Fedora Commons properties."
|
12
|
+
spec.description = "A tiny gem to provide naive sorting for Fedora Commons properties."
|
13
13
|
spec.homepage = "https://github.com/scientist-softserv/order_already"
|
14
14
|
spec.required_ruby_version = ">= 2.6.0"
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: order_already
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails-html-sanitizer
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 5.0.2
|
62
|
-
description: A tiny gem to provide naive sorting for Fedora Commons
|
62
|
+
description: A tiny gem to provide naive sorting for Fedora Commons properties.
|
63
63
|
email:
|
64
64
|
- jeremy.n.friesen@gmail.com
|
65
65
|
- rob@notch8.com
|
@@ -69,6 +69,7 @@ extra_rdoc_files: []
|
|
69
69
|
files:
|
70
70
|
- ".rspec"
|
71
71
|
- ".rubocop.yml"
|
72
|
+
- CHANGELOG.md
|
72
73
|
- Gemfile
|
73
74
|
- Gemfile.lock
|
74
75
|
- LICENSE
|
@@ -102,5 +103,5 @@ requirements: []
|
|
102
103
|
rubygems_version: 3.3.7
|
103
104
|
signing_key:
|
104
105
|
specification_version: 4
|
105
|
-
summary: A tiny gem to provide naive sorting for Fedora Commons
|
106
|
+
summary: A tiny gem to provide naive sorting for Fedora Commons properties.
|
106
107
|
test_files: []
|