order_already 0.3.0 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06d0792edcb48d855dd6d7fe7f7e7bd28ee198f6144a816e4b7594f49ea7fe32
4
- data.tar.gz: bc0bb4eafc7c7f01bdbb90e3a5ab20b59abc74f797509f0da4f592ba946ca628
3
+ metadata.gz: e9133e5102bbf4b0b4f6ef2207ee536e63dc6ac7d44181aedae6f1e179ebd22c
4
+ data.tar.gz: 69ce14225f00f535e165be4c951692bdb5d7c372595e59c9bd2ba9c51496d009
5
5
  SHA512:
6
- metadata.gz: 57752a7bf98a638194b27db452a8028e30cfe94e2490972ee3b9164e72c3e20e6fbb3db4db9c1b6e3a1987259daf29e69b78657578a42342d68377d11e127a50
7
- data.tar.gz: 16d4471e24105b2641ff0640963e3de6a2eff56dc84e0ea104415b1b4cbbe77ab146fcb71df6938f60f4bf1158b5fcf0bdee2d7e2c22939a8209669c83455d29
6
+ metadata.gz: 76eca41dc67a98dd12273bbd49eb4a4f21db9d2540ed976939adb4c66099a1d9216c2d178667536ff4e79f4a41b85c71f8dfa5fab9dbfdf9886130b98ab2041e
7
+ data.tar.gz: '04979a7b87e416ac7d81df70a3f4f8c2e12f7b1b04211c879dc86cdb13124c8ebdbea5010fb76e52c5b87edc10030497444248c269c05db4f776038097626921'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OrderAlready
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2"
5
5
  end
data/lib/order_already.rb CHANGED
@@ -62,6 +62,10 @@ module OrderAlready
62
62
  define_method(:attribute_is_ordered_already?) do |attribute|
63
63
  ordered_attributes.include?(attribute.to_sym)
64
64
  end
65
+
66
+ define_method(:already_ordered_attributes) do
67
+ ordered_attributes
68
+ end
65
69
  end
66
70
  end
67
71
 
@@ -77,7 +81,9 @@ module OrderAlready
77
81
  # @param arr [Array]
78
82
  # @return [Array]
79
83
  def self.deserialize(arr)
80
- return [] if arr&.empty?
84
+ arr = arr&.compact || []
85
+ arr = arr.reject(&:empty?)
86
+ return [] if arr.empty?
81
87
 
82
88
  sort(arr).map do |val|
83
89
  get_value(val)
@@ -91,7 +97,9 @@ module OrderAlready
91
97
  # @param arr [Array]
92
98
  # @return [Array]
93
99
  def self.serialize(arr)
94
- return [] if arr&.empty?
100
+ arr = arr&.compact || []
101
+ arr = arr.reject(&:empty?)
102
+ return [] if arr.empty?
95
103
 
96
104
  arr = sanitize(arr)
97
105
 
@@ -104,6 +112,8 @@ module OrderAlready
104
112
  end
105
113
 
106
114
  def self.sanitize(values)
115
+ return if values.nil?
116
+
107
117
  full_sanitizer = Rails::Html::FullSanitizer.new
108
118
  sanitized_values = Array.new(values.size, '')
109
119
  empty = TOKEN_DELIMITER * 3
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.3.0
4
+ version: 0.3.2
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: 2023-03-01 00:00:00.000000000 Z
12
+ date: 2024-09-19 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
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.3.7
103
+ rubygems_version: 3.5.3
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: A tiny gem to provide naive sorting for Fedora Commons properties.
data/Gemfile.lock DELETED
@@ -1,92 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- order_already (0.2.1)
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