ruby-rails-extensions 2.1.2 → 2.3.0.rc.pre.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 541166471417caf89e3f04bb8a03136c2b6e9702ec76507e565eb79a736dd824
|
|
4
|
+
data.tar.gz: dcbbed73afa3c5f4d67d99646c3d637a6ffe5aa14da4ff1e65ad662a13756962
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1d7fc97453a87800cd51e455e0e3f2079f7ee71c740351f28d32cf1d96e02542d370e3bd50f2b0222e80b4eb43ee1c155261aae35b35fd71c2807c78b24a54d
|
|
7
|
+
data.tar.gz: 26c09e794f57530e4dd6daed4067e57bb6ab53b03ad235ec1291924c837651fa416d7411f94e4fc571bc91c4fb84a694fa5de48b501fc88986cf4d8507331972
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
Unreleased Changes
|
|
2
2
|
------------------
|
|
3
3
|
|
|
4
|
+
2.3.0 (2025-12-23)
|
|
5
|
+
------------------
|
|
6
|
+
* Modules added:
|
|
7
|
+
* `String#word_wrap`
|
|
8
|
+
* Other changes:
|
|
9
|
+
* Updated rake task for new gem creation to use `class` instead of `class_eval`
|
|
10
|
+
* Added devcontainer support
|
|
11
|
+
* Changed the `VERSION` module structure
|
|
12
|
+
* Corrected RSpecs to standard
|
|
13
|
+
|
|
14
|
+
2.2.0 (2025-07-29)
|
|
15
|
+
------------------
|
|
16
|
+
|
|
17
|
+
* Modules added:
|
|
18
|
+
* `Range#-`
|
|
19
|
+
|
|
4
20
|
2.1.2 (2025-01-13)
|
|
5
21
|
------------------
|
|
6
22
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Range
|
|
4
|
+
# Allows subtracting of a range.
|
|
5
|
+
#
|
|
6
|
+
# @raise [RubyRailsExtensions::Errors::NonNumericError] When trying to subtract from
|
|
7
|
+
# a range that isn't numeric, or the object isn't a numeric range, or the object
|
|
8
|
+
# isn't of numeric class.
|
|
9
|
+
#
|
|
10
|
+
# @note A new range will be created since ranges are immutable.
|
|
11
|
+
# This means you need to use `new_range = old_range - range/number`
|
|
12
|
+
# or `current_range -= range/number`.
|
|
13
|
+
#
|
|
14
|
+
# @param other [Range<Numeric>, Numeric]
|
|
15
|
+
#
|
|
16
|
+
# @return [Range]
|
|
17
|
+
#
|
|
18
|
+
def -(other)
|
|
19
|
+
unless self.begin.is_a?(Numeric)
|
|
20
|
+
raise(
|
|
21
|
+
RubyRailsExtensions::Errors::NonNumericError,
|
|
22
|
+
"Wrong range type (given #{self.begin.class}, expected Numeric)"
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
new_begin, new_end =
|
|
27
|
+
if other.is_a?(Range)
|
|
28
|
+
unless other.begin.is_a?(Numeric)
|
|
29
|
+
raise(
|
|
30
|
+
RubyRailsExtensions::Errors::NonNumericError,
|
|
31
|
+
"Wrong range type (given #{other.begin.class}, expected Numeric)"
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
[self.begin - other.begin, self.end - other.end]
|
|
36
|
+
else
|
|
37
|
+
unless other.is_a?(Numeric)
|
|
38
|
+
raise(
|
|
39
|
+
RubyRailsExtensions::Errors::NonNumericError,
|
|
40
|
+
"Wrong type (given #{other.class}, expected Numeric)"
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
[self.begin - other, self.end - other]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Range.new(new_begin, new_end, exclude_end?)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class String
|
|
4
|
+
# Wraps a string by inserting line breaks at a specified line width.
|
|
5
|
+
#
|
|
6
|
+
# @param line_width [Numeric]
|
|
7
|
+
# @param break_sequence [String]
|
|
8
|
+
# @param return_type [String] 'string' or 'array'
|
|
9
|
+
#
|
|
10
|
+
# @return [String, Array<String>]
|
|
11
|
+
#
|
|
12
|
+
def word_wrap(line_width: 80, break_sequence: "\n", return_type: 'string')
|
|
13
|
+
results =
|
|
14
|
+
split("\n").map! do |line|
|
|
15
|
+
(line.length > line_width) ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
results *= break_sequence
|
|
19
|
+
|
|
20
|
+
# Special case for returning an array of the results
|
|
21
|
+
if return_type.to_s == 'array'
|
|
22
|
+
return results.split(break_sequence)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
results
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module RubyRailsExtensions
|
|
4
|
-
VERSION
|
|
4
|
+
module VERSION
|
|
5
|
+
MAJOR = 2
|
|
6
|
+
MINOR = 3
|
|
7
|
+
TINY = 0
|
|
8
|
+
|
|
9
|
+
# Set PRE to nil unless it's a pre-release (beta, rc, etc.)
|
|
10
|
+
PRE = 'rc.pre.1'
|
|
11
|
+
|
|
12
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.').freeze
|
|
13
|
+
|
|
14
|
+
# @return [String]
|
|
15
|
+
def self.to_s
|
|
16
|
+
STRING
|
|
17
|
+
end
|
|
18
|
+
end
|
|
5
19
|
end
|
|
@@ -49,6 +49,7 @@ module RubyRailsExtensions
|
|
|
49
49
|
range_comparisons
|
|
50
50
|
range_multiply
|
|
51
51
|
range_round
|
|
52
|
+
range_subtract
|
|
52
53
|
remove_reserved_keywords
|
|
53
54
|
safe_parse
|
|
54
55
|
select_present
|
|
@@ -76,6 +77,7 @@ module RubyRailsExtensions
|
|
|
76
77
|
usd_to_i
|
|
77
78
|
utf8_encode
|
|
78
79
|
weighted_sum
|
|
80
|
+
word_wrap
|
|
79
81
|
yesno
|
|
80
82
|
zero_range
|
|
81
83
|
].freeze
|
|
@@ -123,6 +125,15 @@ module RubyRailsExtensions
|
|
|
123
125
|
|
|
124
126
|
module_function
|
|
125
127
|
|
|
128
|
+
# Returns RubyRailsExtensions' `::Gem::Version`, convenient for comparisons. This is
|
|
129
|
+
# recommended over `::RubyRailsExtensions::VERSION::STRING`.
|
|
130
|
+
#
|
|
131
|
+
# @api public
|
|
132
|
+
#
|
|
133
|
+
def gem_version
|
|
134
|
+
::Gem::Version.new(VERSION::STRING)
|
|
135
|
+
end
|
|
136
|
+
|
|
126
137
|
# @return [Configuration]
|
|
127
138
|
def configuration
|
|
128
139
|
@configuration ||= Configuration.new
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-rails-extensions
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1
|
|
4
|
+
version: 2.3.0.rc.pre.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brands Insurance
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -63,6 +63,7 @@ files:
|
|
|
63
63
|
- lib/ruby-rails-extensions/extensions/range_comparisons.rb
|
|
64
64
|
- lib/ruby-rails-extensions/extensions/range_multiply.rb
|
|
65
65
|
- lib/ruby-rails-extensions/extensions/range_round.rb
|
|
66
|
+
- lib/ruby-rails-extensions/extensions/range_subtract.rb
|
|
66
67
|
- lib/ruby-rails-extensions/extensions/remove_reserved_keywords.rb
|
|
67
68
|
- lib/ruby-rails-extensions/extensions/safe_parse.rb
|
|
68
69
|
- lib/ruby-rails-extensions/extensions/select_present.rb
|
|
@@ -90,6 +91,7 @@ files:
|
|
|
90
91
|
- lib/ruby-rails-extensions/extensions/usd_to_i.rb
|
|
91
92
|
- lib/ruby-rails-extensions/extensions/utf8_encode.rb
|
|
92
93
|
- lib/ruby-rails-extensions/extensions/weighted_sum.rb
|
|
94
|
+
- lib/ruby-rails-extensions/extensions/word_wrap.rb
|
|
93
95
|
- lib/ruby-rails-extensions/extensions/yesno.rb
|
|
94
96
|
- lib/ruby-rails-extensions/extensions/zero_range.rb
|
|
95
97
|
- lib/ruby-rails-extensions/version.rb
|
|
@@ -110,9 +112,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
110
112
|
version: 3.0.1
|
|
111
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
114
|
requirements:
|
|
113
|
-
- - "
|
|
115
|
+
- - ">"
|
|
114
116
|
- !ruby/object:Gem::Version
|
|
115
|
-
version:
|
|
117
|
+
version: 1.3.1
|
|
116
118
|
requirements: []
|
|
117
119
|
rubygems_version: 3.2.15
|
|
118
120
|
signing_key:
|