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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58bbcf6f098dfc3b905837315feb9634415f5ffd97402acb4ff0aaf783d3fb94
4
- data.tar.gz: 97c0f11482e7c1170b737a9fcb556c7f2a6825b61f562f9bd655c72be39fa3d6
3
+ metadata.gz: c26d17f72e31fe01a89459e031b394237dfe163d8c5548307cc7b00308115175
4
+ data.tar.gz: 0c1b6a4e25e973ff90a2dcd05cc21b9b3267a9110f762c15707cee9d4b7e10a8
5
5
  SHA512:
6
- metadata.gz: 83034c9a260068af690abff7de0d4a92cd0fae477e10b9428f6a71a296fd2af9b8246c43c85549e9994800e609f23c2d393c6890f4579b561477e30f300d0c5c
7
- data.tar.gz: b008abc0792f025b468a875d41021797cfa708bd3d28782aa27487e1225736a52fc7e93cbeca85db54b0481c4cb0793d5161509983ea0687013532b6c815f01b
6
+ metadata.gz: 640aae2c6f8f6c678afe164aa37044afad6192f88ea042e7aa50b431e62258cd267a95368ab82bbcb2a28845e57be939d7a663f8e8995bb532dc038d5d8c0c54
7
+ data.tar.gz: 6400c35df376c1767b59d7a8bbab52a8554917c51c84fdd4592a09b6bdf703d344e2765824d6a7f1ab24d1d96b37a62045a74bd03906ab981ae302c9a2e53719
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # v0.2.0
2
+
3
+ - Adding `:serializer` keyword to `OrderAlready.for`. This allows for you to specify a custom serializer (e.g. did someone say alphabetizer?)
4
+
5
+ # v0.1.0
6
+
7
+ - Initial release.
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
- include OrderAlready.for(:author, :subject)
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
- include OrderAlready.for(:creator, :contributor)
46
+ prepend OrderAlready.for(:creator, :contributor)
47
47
  end
48
48
  ```
49
49
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OrderAlready
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
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
- StringSerializer.deserialize(super())
42
+ serializer.deserialize(super())
43
43
  end
44
44
 
45
45
  define_method("#{attribute}=") do |values|
46
- super(StringSerializer.serialize(values))
46
+ super(serializer.serialize(values))
47
47
  end
48
48
  end
49
49
  end
@@ -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 objects."
12
- spec.description = "A tiny gem to provide naive sorting for Fedora Commons objects."
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.1.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-17 00:00:00.000000000 Z
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 objects.
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 objects.
106
+ summary: A tiny gem to provide naive sorting for Fedora Commons properties.
106
107
  test_files: []