put 0.1.0 → 0.2.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 +4 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +52 -26
- data/README.md +14 -12
- data/lib/put/version.rb +1 -1
- metadata +4 -9
- data/put.gemspec +0 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 535145ee17f2f25a68d80ed7afa1e58cb2edd1d261c2b0f976cd9706c4304049
|
|
4
|
+
data.tar.gz: 4551a7ac241dc9d0b6fc7b975ae0a7d10c87b1dadf35c3832128ecaf563b1b2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cd640fd7da59ca4ad28472284addf6df5db063dba76a1e98f9de4c44e6a243818f8366f1b79ebc345010e0cfc454c5a03c7030449710967f945f9504419937c
|
|
7
|
+
data.tar.gz: e8217fdfbe3fb805bd31bc5632c227c2b9265fc176004a94b41943c33a8b24b06399868026fdb8e8098e4c32162db4a4ff03006a9db7668675af8ac04615bde5
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,49 +1,70 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
put (0.
|
|
4
|
+
put (0.2.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
ast (2.4.
|
|
9
|
+
ast (2.4.3)
|
|
10
|
+
base64 (0.3.0)
|
|
10
11
|
debug (1.6.2)
|
|
11
12
|
irb (>= 1.3.6)
|
|
12
13
|
reline (>= 0.3.1)
|
|
14
|
+
fiddle (1.1.8)
|
|
13
15
|
io-console (0.5.11)
|
|
14
16
|
irb (1.4.1)
|
|
15
17
|
reline (>= 0.3.0)
|
|
16
|
-
json (2.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
json (2.21.2)
|
|
19
|
+
language_server-protocol (3.17.0.6)
|
|
20
|
+
lint_roller (1.1.0)
|
|
21
|
+
minitest (5.27.0)
|
|
22
|
+
ostruct (0.6.3)
|
|
23
|
+
parallel (1.28.0)
|
|
24
|
+
parser (3.3.12.0)
|
|
20
25
|
ast (~> 2.4.1)
|
|
26
|
+
racc
|
|
27
|
+
prism (1.9.0)
|
|
28
|
+
racc (1.8.1)
|
|
21
29
|
rainbow (3.1.1)
|
|
22
30
|
rake (13.0.6)
|
|
23
|
-
regexp_parser (2.
|
|
31
|
+
regexp_parser (2.13.0)
|
|
24
32
|
reline (0.3.1)
|
|
25
33
|
io-console (~> 0.5)
|
|
26
|
-
|
|
27
|
-
rubocop (1.35.1)
|
|
34
|
+
rubocop (1.88.2)
|
|
28
35
|
json (~> 2.3)
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
language_server-protocol (~> 3.17.0.2)
|
|
37
|
+
lint_roller (~> 1.1.0)
|
|
38
|
+
parallel (>= 1.10)
|
|
39
|
+
parser (>= 3.3.0.2)
|
|
31
40
|
rainbow (>= 2.2.2, < 4.0)
|
|
32
|
-
regexp_parser (>=
|
|
33
|
-
|
|
34
|
-
rubocop-ast (>= 1.20.1, < 2.0)
|
|
41
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
42
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
35
43
|
ruby-progressbar (~> 1.7)
|
|
36
|
-
unicode-display_width (>=
|
|
37
|
-
rubocop-ast (1.
|
|
38
|
-
parser (>= 3.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
45
|
+
rubocop-ast (1.50.0)
|
|
46
|
+
parser (>= 3.3.7.2)
|
|
47
|
+
prism (~> 1.7)
|
|
48
|
+
rubocop-performance (1.26.1)
|
|
49
|
+
lint_roller (~> 1.1)
|
|
50
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
51
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
52
|
+
ruby-progressbar (1.13.0)
|
|
53
|
+
standard (1.56.0)
|
|
54
|
+
language_server-protocol (~> 3.17.0.2)
|
|
55
|
+
lint_roller (~> 1.0)
|
|
56
|
+
rubocop (~> 1.88.0)
|
|
57
|
+
standard-custom (~> 1.0.0)
|
|
58
|
+
standard-performance (~> 1.8)
|
|
59
|
+
standard-custom (1.0.2)
|
|
60
|
+
lint_roller (~> 1.0)
|
|
61
|
+
rubocop (~> 1.50)
|
|
62
|
+
standard-performance (1.9.0)
|
|
63
|
+
lint_roller (~> 1.1)
|
|
64
|
+
rubocop-performance (~> 1.26.0)
|
|
65
|
+
unicode-display_width (3.3.0)
|
|
66
|
+
unicode-emoji (~> 4.3)
|
|
67
|
+
unicode-emoji (4.3.0)
|
|
47
68
|
|
|
48
69
|
PLATFORMS
|
|
49
70
|
arm64-darwin-21
|
|
@@ -51,9 +72,14 @@ PLATFORMS
|
|
|
51
72
|
x86_64-linux
|
|
52
73
|
|
|
53
74
|
DEPENDENCIES
|
|
75
|
+
base64
|
|
54
76
|
debug
|
|
55
|
-
|
|
77
|
+
fiddle
|
|
78
|
+
minitest (< 6)
|
|
79
|
+
ostruct
|
|
80
|
+
parallel (< 2)
|
|
56
81
|
put!
|
|
82
|
+
racc
|
|
57
83
|
rake
|
|
58
84
|
standard
|
|
59
85
|
|
data/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
# Put
|
|
1
|
+
# Put puts your objects in order 💎
|
|
2
2
|
|
|
3
3
|
Put pairs with
|
|
4
4
|
[Enumerable#sort_by](https://ruby-doc.org/core-3.1.2/Enumerable.html#method-i-sort_by)
|
|
5
5
|
to provide a more expressive, fault-tolerant, and configurable approach to
|
|
6
|
-
sorting Ruby objects with multiple criteria.
|
|
6
|
+
sorting Ruby objects with multiple criteria. [Here's a screencast & short blog
|
|
7
|
+
post](https://blog.testdouble.com/talks/2022-09-28-a-better-way-to-sort-ruby-objects/)
|
|
8
|
+
that we put out, in case you're interested.
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
## Put "put" in your Gemfile
|
|
9
11
|
|
|
10
12
|
You've probably already put a few gems in there, so why not put Put, too:
|
|
11
13
|
|
|
@@ -20,8 +22,8 @@ Of course after you push Put, your colleagues will wonder why you put Put there.
|
|
|
20
22
|
A neat trick when applying complex sorting rules to a collection is to map them
|
|
21
23
|
to an array of arrays of comparable values in priority order. It's a common
|
|
22
24
|
approach (and a special subtype of what's called a [Schwartzian
|
|
23
|
-
transform](https://en.wikipedia.org/wiki/Schwartzian_transform)), but
|
|
24
|
-
pattern doesn't have
|
|
25
|
+
transform](https://en.wikipedia.org/wiki/Schwartzian_transform)), but the
|
|
26
|
+
pattern doesn't have a widely-accepted name yet, so let's use code to explain.
|
|
25
27
|
|
|
26
28
|
Suppose you have some people:
|
|
27
29
|
|
|
@@ -68,8 +70,8 @@ is almost begging for a code comment above it to explain its intent
|
|
|
68
70
|
number](https://en.wikipedia.org/wiki/Magic_number_(programming))'s like `1` and
|
|
69
71
|
`0`.
|
|
70
72
|
* Any `nil` values will result in a bad time. If a person's `age` is nil, you'll
|
|
71
|
-
get "_undefined method
|
|
72
|
-
* Relatedly, if any two items aren't comparable (e.
|
|
73
|
+
get "_undefined method '*' for nil:NilClass_" `NoMethodError`
|
|
74
|
+
* Relatedly, if any two items aren't comparable (i.e. `<=>` returns nil), you'll
|
|
73
75
|
be greeted with an inscrutable `ArgumentError` that just says "_comparison of
|
|
74
76
|
Array with Array failed_"
|
|
75
77
|
|
|
@@ -95,8 +97,8 @@ The Put gem solves every one of the above issues:
|
|
|
95
97
|
impenetrable `ArgumentError` messages whenever any two values turn out not to
|
|
96
98
|
be comparable
|
|
97
99
|
|
|
98
|
-
After reading this, your teammates
|
|
99
|
-
putting
|
|
100
|
+
After reading this, your teammates will be glad they put you in charge of
|
|
101
|
+
putting gems like Put in the Gemfile.
|
|
100
102
|
|
|
101
103
|
## When you Put it that way
|
|
102
104
|
|
|
@@ -116,8 +118,8 @@ either `Put.first` or `nil`, like this:
|
|
|
116
118
|
|
|
117
119
|
### Put.last
|
|
118
120
|
|
|
119
|
-
When
|
|
120
|
-
|
|
121
|
+
When a sort criteria should go to the bottom of the list, you can do the same
|
|
122
|
+
sort of conditional expression with `Put.last`:
|
|
121
123
|
|
|
122
124
|
```ruby
|
|
123
125
|
%w[Jin drinks Gin on Gym day].sort_by { |s|
|
|
@@ -226,4 +228,4 @@ conduct](https://testdouble.com/code-of-conduct) for all community interactions,
|
|
|
226
228
|
including (but not limited to) one-on-one communications, public posts/comments,
|
|
227
229
|
code reviews, pull requests, and GitHub issues. If violations occur, Test Double
|
|
228
230
|
will take any action they deem appropriate for the infraction, up to and
|
|
229
|
-
including blocking a user from the organization's repositories.
|
|
231
|
+
including blocking a user from the organization's repositories.
|
data/lib/put/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: put
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Searls
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
|
-
description:
|
|
14
12
|
email:
|
|
15
13
|
- searls@gmail.com
|
|
16
14
|
executables: []
|
|
@@ -38,7 +36,6 @@ files:
|
|
|
38
36
|
- lib/put/puts_thing/nils_first.rb
|
|
39
37
|
- lib/put/puts_thing/nils_last.rb
|
|
40
38
|
- lib/put/version.rb
|
|
41
|
-
- put.gemspec
|
|
42
39
|
- sig/put.rbs
|
|
43
40
|
homepage: https://github.com/testdouble/put
|
|
44
41
|
licenses:
|
|
@@ -47,7 +44,6 @@ metadata:
|
|
|
47
44
|
homepage_uri: https://github.com/testdouble/put
|
|
48
45
|
source_code_uri: https://github.com/testdouble/put
|
|
49
46
|
changelog_uri: https://github.com/testdouble/put/blob/main/CHANGELOG.md
|
|
50
|
-
post_install_message:
|
|
51
47
|
rdoc_options: []
|
|
52
48
|
require_paths:
|
|
53
49
|
- lib
|
|
@@ -55,15 +51,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
55
51
|
requirements:
|
|
56
52
|
- - ">="
|
|
57
53
|
- !ruby/object:Gem::Version
|
|
58
|
-
version:
|
|
54
|
+
version: 3.1.0
|
|
59
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
56
|
requirements:
|
|
61
57
|
- - ">="
|
|
62
58
|
- !ruby/object:Gem::Version
|
|
63
59
|
version: '0'
|
|
64
60
|
requirements: []
|
|
65
|
-
rubygems_version:
|
|
66
|
-
signing_key:
|
|
61
|
+
rubygems_version: 4.0.21
|
|
67
62
|
specification_version: 4
|
|
68
63
|
summary: Put helps you write prioritized, multi-variate sort_by blocks
|
|
69
64
|
test_files: []
|
data/put.gemspec
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require_relative "lib/put/version"
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |spec|
|
|
4
|
-
spec.name = "put"
|
|
5
|
-
spec.version = Put::VERSION
|
|
6
|
-
spec.authors = ["Justin Searls"]
|
|
7
|
-
spec.email = ["searls@gmail.com"]
|
|
8
|
-
|
|
9
|
-
spec.summary = "Put helps you write prioritized, multi-variate sort_by blocks"
|
|
10
|
-
spec.homepage = "https://github.com/testdouble/put"
|
|
11
|
-
spec.license = "MIT"
|
|
12
|
-
spec.required_ruby_version = ">= 2.6.0"
|
|
13
|
-
|
|
14
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
15
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
|
16
|
-
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
17
|
-
|
|
18
|
-
# Specify which files should be added to the gem when it is released.
|
|
19
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
20
|
-
spec.files = Dir.chdir(__dir__) do
|
|
21
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
|
22
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
spec.bindir = "exe"
|
|
26
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
27
|
-
spec.require_paths = ["lib"]
|
|
28
|
-
end
|