ruby-rails-extensions 2.1.0.pre.rc.8 → 2.1.0.pre.rc.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b3a4f70a6e3a5dee5a465b1d7e53dc163118c71f8da1b67ef3a9086f7b1ec55
|
4
|
+
data.tar.gz: 39feabe026daa75b4e8fd5a3197eae29c18b8c28deacafc845b9f2b26bf8adb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c295fea115ef77cebfbd42b3fb1f36631ee040ca9a697630be671e17737dc31b4d4335186ba66defbdca3d795b27f59429cd58c18dea462be1a32600b1ea4bb7
|
7
|
+
data.tar.gz: 721b32f34431371b2cad8dd3264b73808262a3447f74d8542bb22c261d638da3ea50f75380bf20a997e0573726227774ef8aa6f213d9c09c7650009dfa8c09d6
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Range.class_eval do
|
4
|
+
# Rounds a range. Rounds the beginning and ending values only
|
5
|
+
# and creates a new range with the rounded values.
|
6
|
+
#
|
7
|
+
# @param precision [Integer]
|
8
|
+
#
|
9
|
+
# @return [Range]
|
10
|
+
#
|
11
|
+
def round(precision = 0)
|
12
|
+
Range.new(self.begin.round(precision), self.end.round(precision), exclude_end?)
|
13
|
+
end
|
14
|
+
end
|
@@ -45,6 +45,7 @@ module RubyRailsExtensions
|
|
45
45
|
range_add
|
46
46
|
range_comparisons
|
47
47
|
range_multiply
|
48
|
+
range_round
|
48
49
|
remove_reserved_keywords
|
49
50
|
safe_parse
|
50
51
|
select_present
|
@@ -111,13 +112,15 @@ module RubyRailsExtensions
|
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
115
|
+
module_function
|
116
|
+
|
114
117
|
# @return [Configuration]
|
115
|
-
def
|
118
|
+
def configuration
|
116
119
|
@configuration ||= Configuration.new
|
117
120
|
end
|
118
121
|
|
119
122
|
# @yield [Configuration]
|
120
|
-
def
|
123
|
+
def configure
|
121
124
|
yield(configuration)
|
122
125
|
|
123
126
|
Configuration::BOOLEAN_GEMS.each do |extension|
|
@@ -132,5 +135,28 @@ module RubyRailsExtensions
|
|
132
135
|
configuration.flags
|
133
136
|
end
|
134
137
|
|
135
|
-
|
138
|
+
# @see Object#presence from active_support/core_ext/object/blank.rb
|
139
|
+
def presence(item)
|
140
|
+
return item if present?(item)
|
141
|
+
|
142
|
+
nil
|
143
|
+
end
|
144
|
+
|
145
|
+
# @see Object#blank? from active_support/core_ext/object/blank.rb
|
146
|
+
def blank?(item)
|
147
|
+
if item.respond_to?(:blank?)
|
148
|
+
return item.blank?
|
149
|
+
end
|
150
|
+
|
151
|
+
item.respond_to?(:empty?) ? !!item.empty? : !item
|
152
|
+
end
|
153
|
+
|
154
|
+
# @see Object#present? from active_support/core_ext/object/blank.rb
|
155
|
+
def present?(item)
|
156
|
+
if item.respond_to?(:present?)
|
157
|
+
return item.present?
|
158
|
+
end
|
159
|
+
|
160
|
+
!blank?(item)
|
161
|
+
end
|
136
162
|
end
|
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.0.pre.rc.
|
4
|
+
version: 2.1.0.pre.rc.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brands Insurance
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/ruby-rails-extensions/extensions/range_add.rb
|
94
94
|
- lib/ruby-rails-extensions/extensions/range_comparisons.rb
|
95
95
|
- lib/ruby-rails-extensions/extensions/range_multiply.rb
|
96
|
+
- lib/ruby-rails-extensions/extensions/range_round.rb
|
96
97
|
- lib/ruby-rails-extensions/extensions/remove_reserved_keywords.rb
|
97
98
|
- lib/ruby-rails-extensions/extensions/safe_parse.rb
|
98
99
|
- lib/ruby-rails-extensions/extensions/select_present.rb
|