order_already 0.2.1 → 0.3.1
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/README.md +13 -0
- data/lib/order_already/spec_helper.rb +14 -0
- data/lib/order_already/version.rb +1 -1
- data/lib/order_already.rb +15 -2
- metadata +3 -3
- data/Gemfile.lock +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d7a220ae782eabbe029a0e45f909d1b605b07b881e612b09150819b5cafdc6
|
4
|
+
data.tar.gz: 364e044bd3e6b73201f87987cec8f98f09e49d9ef14152bbbdad7c9623bca900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb6868e1c646a11440e211b90afb49d4662a5312fdd49f75fec4f3cadef7508a72c6af8a99b9f8db46148de56b5be6741a37eddc52af5f39e7dbec8e51571cd7
|
7
|
+
data.tar.gz: 441506b2660ff35e8555e451401ed9ae73db8008a233755f77d6e7d4ec61b903d8244bf54f85e052b99571671c1408316a34c35d89ae2d74f396b787bedb2052
|
data/README.md
CHANGED
@@ -47,6 +47,19 @@ class GenericWork < ActiveFedora::Base
|
|
47
47
|
end
|
48
48
|
```
|
49
49
|
|
50
|
+
Included, as of v0.3.1, is the `order_already/spec_helper`. This provides the custom matcher: `have_already_ordered_attributes`.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
require 'spec_helper'
|
54
|
+
require 'order_already/spec_helper'
|
55
|
+
|
56
|
+
RSpec.describe GenericWork do
|
57
|
+
subject { described_class.new }
|
58
|
+
|
59
|
+
it { is_expected.to have_already_ordered_attributes(:creator, :contributor) }
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
50
63
|
As of v0.2.0, the `OrderAlready.for` method takes a `:serializer` keyword. By default this is the preserve the order of the input serializers.
|
51
64
|
|
52
65
|
## Development
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec::Matchers.define :have_already_ordered_attributes do |*expected_attributes|
|
2
|
+
match do |actual|
|
3
|
+
actual.already_ordered_attributes.map(&:to_sym).sort == expected_attributes.map(&:to_sym).sort
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message do |actual|
|
7
|
+
actual_attrs = actual.already_ordered_attributes.map(&:to_sym).sort
|
8
|
+
expected_attrs = expected_attributes.map(&:to_sym).sort
|
9
|
+
|
10
|
+
"Expected that #{actual} would have the following ordered attributes:\n" \
|
11
|
+
"#{expected_attrs.inspect}.\n"
|
12
|
+
"Actual: #{actual_attrs.inspect}\n"
|
13
|
+
end
|
14
|
+
end
|
data/lib/order_already.rb
CHANGED
@@ -20,7 +20,8 @@ module OrderAlready
|
|
20
20
|
# data. Want to auto-alphabetize? Use a different serializer than the default.
|
21
21
|
#
|
22
22
|
# @return [Module] a module that wraps the attr_accessor methods for the given :attributes. In
|
23
|
-
# using a module, we have access to `super`; which is super convenient!
|
23
|
+
# using a module, we have access to `super`; which is super convenient! The module will
|
24
|
+
# also add a `#attribute_is_ordered_already?` method.
|
24
25
|
#
|
25
26
|
# @note In testing, you need to use `prepend` instead of `include`; but that may be a function of
|
26
27
|
# my specs.
|
@@ -42,9 +43,13 @@ module OrderAlready
|
|
42
43
|
# prepend OrderAlready.for(:subjects, serializer: Alphabetizer)
|
43
44
|
# end
|
44
45
|
def self.for(*attributes, serializer: InputOrderSerializer)
|
46
|
+
# Capturing the named attributes to create a local binding; this helps ensure we have that
|
47
|
+
# available in the later :attribute_is_ordered_already? method definition.
|
48
|
+
ordered_attributes = attributes.map(&:to_sym)
|
49
|
+
|
45
50
|
# By creating a module, we have access to `super`.
|
46
51
|
Module.new do
|
47
|
-
|
52
|
+
ordered_attributes.each do |attribute|
|
48
53
|
define_method(attribute) do
|
49
54
|
serializer.deserialize(super())
|
50
55
|
end
|
@@ -53,6 +58,14 @@ module OrderAlready
|
|
53
58
|
super(serializer.serialize(values))
|
54
59
|
end
|
55
60
|
end
|
61
|
+
|
62
|
+
define_method(:attribute_is_ordered_already?) do |attribute|
|
63
|
+
ordered_attributes.include?(attribute.to_sym)
|
64
|
+
end
|
65
|
+
|
66
|
+
define_method(:already_ordered_attributes) do
|
67
|
+
ordered_attributes
|
68
|
+
end
|
56
69
|
end
|
57
70
|
end
|
58
71
|
|
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.3.1
|
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:
|
12
|
+
date: 2023-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails-html-sanitizer
|
@@ -71,11 +71,11 @@ files:
|
|
71
71
|
- ".rubocop.yml"
|
72
72
|
- CHANGELOG.md
|
73
73
|
- Gemfile
|
74
|
-
- Gemfile.lock
|
75
74
|
- LICENSE
|
76
75
|
- README.md
|
77
76
|
- Rakefile
|
78
77
|
- lib/order_already.rb
|
78
|
+
- lib/order_already/spec_helper.rb
|
79
79
|
- lib/order_already/version.rb
|
80
80
|
- order_already.gemspec
|
81
81
|
homepage: https://github.com/scientist-softserv/order_already
|
data/Gemfile.lock
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
order_already (0.2.0)
|
5
|
-
rails-html-sanitizer (~> 1.4)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activesupport (7.0.4)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>= 1.6, < 2)
|
13
|
-
minitest (>= 5.1)
|
14
|
-
tzinfo (~> 2.0)
|
15
|
-
ast (2.4.2)
|
16
|
-
bixby (5.0.2)
|
17
|
-
rubocop (= 1.28.2)
|
18
|
-
rubocop-ast
|
19
|
-
rubocop-performance
|
20
|
-
rubocop-rails
|
21
|
-
rubocop-rspec
|
22
|
-
concurrent-ruby (1.1.10)
|
23
|
-
crass (1.0.6)
|
24
|
-
diff-lcs (1.5.0)
|
25
|
-
i18n (1.12.0)
|
26
|
-
concurrent-ruby (~> 1.0)
|
27
|
-
loofah (2.19.0)
|
28
|
-
crass (~> 1.0.2)
|
29
|
-
nokogiri (>= 1.5.9)
|
30
|
-
minitest (5.16.3)
|
31
|
-
nokogiri (1.13.9-arm64-darwin)
|
32
|
-
racc (~> 1.4)
|
33
|
-
parallel (1.22.1)
|
34
|
-
parser (3.1.2.1)
|
35
|
-
ast (~> 2.4.1)
|
36
|
-
racc (1.6.0)
|
37
|
-
rack (3.0.0)
|
38
|
-
rails-html-sanitizer (1.4.3)
|
39
|
-
loofah (~> 2.3)
|
40
|
-
rainbow (3.1.1)
|
41
|
-
rake (13.0.6)
|
42
|
-
regexp_parser (2.6.1)
|
43
|
-
rexml (3.2.5)
|
44
|
-
rspec (3.12.0)
|
45
|
-
rspec-core (~> 3.12.0)
|
46
|
-
rspec-expectations (~> 3.12.0)
|
47
|
-
rspec-mocks (~> 3.12.0)
|
48
|
-
rspec-core (3.12.0)
|
49
|
-
rspec-support (~> 3.12.0)
|
50
|
-
rspec-expectations (3.12.0)
|
51
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.12.0)
|
53
|
-
rspec-mocks (3.12.0)
|
54
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
-
rspec-support (~> 3.12.0)
|
56
|
-
rspec-support (3.12.0)
|
57
|
-
rubocop (1.28.2)
|
58
|
-
parallel (~> 1.10)
|
59
|
-
parser (>= 3.1.0.0)
|
60
|
-
rainbow (>= 2.2.2, < 4.0)
|
61
|
-
regexp_parser (>= 1.8, < 3.0)
|
62
|
-
rexml
|
63
|
-
rubocop-ast (>= 1.17.0, < 2.0)
|
64
|
-
ruby-progressbar (~> 1.7)
|
65
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
66
|
-
rubocop-ast (1.23.0)
|
67
|
-
parser (>= 3.1.1.0)
|
68
|
-
rubocop-performance (1.15.1)
|
69
|
-
rubocop (>= 1.7.0, < 2.0)
|
70
|
-
rubocop-ast (>= 0.4.0)
|
71
|
-
rubocop-rails (2.15.2)
|
72
|
-
activesupport (>= 4.2.0)
|
73
|
-
rack (>= 1.1)
|
74
|
-
rubocop (>= 1.7.0, < 2.0)
|
75
|
-
rubocop-rspec (2.11.1)
|
76
|
-
rubocop (~> 1.19)
|
77
|
-
ruby-progressbar (1.11.0)
|
78
|
-
tzinfo (2.0.5)
|
79
|
-
concurrent-ruby (~> 1.0)
|
80
|
-
unicode-display_width (2.3.0)
|
81
|
-
|
82
|
-
PLATFORMS
|
83
|
-
arm64-darwin-21
|
84
|
-
|
85
|
-
DEPENDENCIES
|
86
|
-
bixby (~> 5.0, >= 5.0.2)
|
87
|
-
order_already!
|
88
|
-
rake (~> 13.0)
|
89
|
-
rspec (~> 3.0)
|
90
|
-
|
91
|
-
BUNDLED WITH
|
92
|
-
2.3.9
|