niceties 0.1.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 +7 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +8 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +12 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/niceties/object.rb +25 -0
- data/lib/niceties/version.rb +5 -0
- data/lib/niceties.rb +9 -0
- data/sig/niceties.rbs +4 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a344de89699dbdc123ebe5cd16c0457e0b35b7ef3717db07348415b752b6b75
|
4
|
+
data.tar.gz: 3a4f87520eb6808cc9998720aa283f84a6841f9f5505f1d4d6faf02773314441
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d05d3be08f1576176537516acedead938c049985e81a5e6ac143d90b3b1af477e2a95110da8209355630ecef5a9dd360f2c34e4bd12c0d2de5c3a28b7a4e53dd
|
7
|
+
data.tar.gz: e21eb52f1c78b876fb340f3b276eb210c1c96dacea0491f23d700e13e20e777e0fd98f4a5652c5f84f9433c5cf2711533283f6588a5b4ac44ca89b53e4ca0272
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Carl Dawson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Niceties
|
2
|
+
|
3
|
+
Niceties is a curated collection of small, thoughtful additions to Rails.
|
4
|
+
Nothing fancy, nothing heavy — just expressive, elegant helpers that make
|
5
|
+
everyday code smoother and more joyful.
|
6
|
+
|
7
|
+
It’s the kind of thing you might monkey-patch in your own app and forget about. Niceties gives those private little helpers a permanent, public home.
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
## ✨ Philosophy
|
12
|
+
|
13
|
+
Niceties is built on a few quiet principles:
|
14
|
+
|
15
|
+
- **Ergonomics matter.** Tiny syntax improvements compound across projects and years.
|
16
|
+
- **Less is more.** This isn’t a kitchen sink. Every addition is judged by feel.
|
17
|
+
- **No surprises.** If you have to explain what it’s doing, it probably doesn’t belong here.
|
18
|
+
- **Ruby’s voice, not ours.** Every method should *read* like Ruby. Nothing flashy, nothing clever for its own sake.
|
19
|
+
|
20
|
+
You should be able to drop Niceties into your app and feel like it’s always been there.
|
21
|
+
|
22
|
+
---
|
23
|
+
|
24
|
+
## 🫂 Contributing
|
25
|
+
|
26
|
+
Niceties is open to anyone with an idea that makes Ruby or Rails feel better to use.
|
27
|
+
|
28
|
+
If you’ve ever written a helper method and thought:
|
29
|
+
|
30
|
+
> _"This is too small for a gem, but I wish it lived somewhere..."_
|
31
|
+
|
32
|
+
That’s exactly what Niceties is for.
|
33
|
+
|
34
|
+
**Guiding questions for contributors:**
|
35
|
+
|
36
|
+
- Does this make everyday code more readable or expressive?
|
37
|
+
- Does it align with Ruby’s style and philosophy?
|
38
|
+
- Would I be delighted if this existed in the language?
|
39
|
+
|
40
|
+
If yes — open a PR or start a discussion.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "niceties"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "irb"
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class Object
|
2
|
+
def not_a?(klass)
|
3
|
+
!is_a?(klass)
|
4
|
+
end
|
5
|
+
|
6
|
+
def try_all(*methods)
|
7
|
+
methods.each do |method|
|
8
|
+
result = try(method)
|
9
|
+
return result unless result.nil?
|
10
|
+
end
|
11
|
+
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def coalesce(*messages)
|
16
|
+
*methods, fallback = messages
|
17
|
+
|
18
|
+
methods.each do |method|
|
19
|
+
result = try(method)
|
20
|
+
return result if result.present?
|
21
|
+
end
|
22
|
+
|
23
|
+
fallback.is_a?(Symbol) ? try(fallback) : fallback
|
24
|
+
end
|
25
|
+
end
|
data/lib/niceties.rb
ADDED
data/sig/niceties.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: niceties
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carl Dawson
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: activesupport
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '6.0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '6.0'
|
26
|
+
description: Niceties is a carefully curated set of ergonomic Ruby and Rails extensions—small,
|
27
|
+
expressive methods that make code feel more natural and joyful to write.
|
28
|
+
email:
|
29
|
+
- email@carldaws.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- bin/console
|
41
|
+
- bin/setup
|
42
|
+
- lib/niceties.rb
|
43
|
+
- lib/niceties/object.rb
|
44
|
+
- lib/niceties/version.rb
|
45
|
+
- sig/niceties.rbs
|
46
|
+
homepage: https://github.com/carldaws/niceties
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata:
|
50
|
+
allowed_push_host: https://rubygems.org
|
51
|
+
homepage_uri: https://github.com/carldaws/niceties
|
52
|
+
source_code_uri: https://github.com/carldaws/niceties
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.1.0
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubygems_version: 3.6.7
|
68
|
+
specification_version: 4
|
69
|
+
summary: A collection of thoughtful Ruby and Rails helpers.
|
70
|
+
test_files: []
|