more_core_extensions 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.rubocop.yml +4 -0
- data/.rubocop_local.yml +0 -0
- data/.travis.yml +18 -0
- data/CHANGELOG.md +54 -0
- data/Gemfile +8 -0
- data/README.md +21 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/more_core_extensions/all.rb +2 -0
- data/lib/more_core_extensions/core_ext/hash/sorting.rb +20 -0
- data/lib/more_core_extensions/core_ext/hash.rb +2 -1
- data/lib/more_core_extensions/core_ext/object/descendants.rb +17 -0
- data/lib/more_core_extensions/core_ext/object.rb +1 -0
- data/lib/more_core_extensions/core_ext/range/step_value.rb +45 -0
- data/lib/more_core_extensions/core_ext/range.rb +1 -0
- data/lib/more_core_extensions/core_ext/string/decimal_suffix.rb +17 -0
- data/lib/more_core_extensions/core_ext/string.rb +1 -0
- data/lib/more_core_extensions/core_ext/symbol/to_i.rb +9 -0
- data/lib/more_core_extensions/core_ext/symbol.rb +1 -0
- data/lib/more_core_extensions/version.rb +1 -1
- data/more_core_extensions.gemspec +32 -0
- metadata +36 -44
- data/spec/core_ext/array/deletes_spec.rb +0 -15
- data/spec/core_ext/array/duplicates_spec.rb +0 -9
- data/spec/core_ext/array/element_counts_spec.rb +0 -16
- data/spec/core_ext/array/inclusions_spec.rb +0 -51
- data/spec/core_ext/array/math_spec.rb +0 -16
- data/spec/core_ext/array/nested_spec.rb +0 -183
- data/spec/core_ext/array/random_spec.rb +0 -21
- data/spec/core_ext/array/stretch_spec.rb +0 -94
- data/spec/core_ext/array/tableize_spec.rb +0 -156
- data/spec/core_ext/hash/deletes_spec.rb +0 -15
- data/spec/core_ext/hash/nested_spec.rb +0 -232
- data/spec/core_ext/numeric/clamp_spec.rb +0 -17
- data/spec/core_ext/numeric/math_spec.rb +0 -6
- data/spec/core_ext/numeric/rounding_spec.rb +0 -19
- data/spec/core_ext/object/namespace_spec.rb +0 -30
- data/spec/core_ext/string/formats_spec.rb +0 -77
- data/spec/core_ext/string/hex_dump_spec.rb +0 -84
- data/spec/core_ext/string/iec60027_2_spec.rb +0 -13
- data/spec/spec_helper.rb +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8445d02cce0bc6bc1cfc1554bd6db773e335c2f8
|
4
|
+
data.tar.gz: 010cb3f4eb19a5d6c36a7593e77d65012b48e8c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4731d3a3029b3aa664031f4c794ce22f57da5c4718dd6c6bd4810b0a98a112d19028c3d7ca1400c64568f3505d6e6798dd76b4eec59e106bbedba7637b894a84
|
7
|
+
data.tar.gz: f0660e800d33a9d89c02a84e21825b7ed0ff7712594844dc3b5159dc1d0dbf960023a15005221501aabe5aa0255d9986c2e9f8e64497e1ecd673c25841b63489
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_local.yml
ADDED
File without changes
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- "2.0"
|
4
|
+
- "2.1"
|
5
|
+
- "2.2"
|
6
|
+
- "2.3.3"
|
7
|
+
- "2.4.0"
|
8
|
+
- ruby-head
|
9
|
+
- jruby-head
|
10
|
+
sudo: false
|
11
|
+
cache: bundler
|
12
|
+
before_install: gem install bundler -v ">= 1.13.6"
|
13
|
+
after_script: bundle exec codeclimate-test-reporter
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: ruby-head
|
17
|
+
- rvm: jruby-head
|
18
|
+
fast_finish: true
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
|
5
|
+
## [Unreleased]
|
6
|
+
|
7
|
+
## [3.3.0] - 2017-07-21
|
8
|
+
### Added
|
9
|
+
- Added Symbol#to_i [[#49](https://github.com/ManageIQ/more_core_extensions/pull/49)]
|
10
|
+
- Added Range#step_value [[#47](https://github.com/ManageIQ/more_core_extensions/pull/47)]
|
11
|
+
- Added Hash#sort! & #sort_by! [[#46](https://github.com/ManageIQ/more_core_extensions/pull/46)]
|
12
|
+
- Added Object.descendant_get [[#45](https://github.com/ManageIQ/more_core_extensions/pull/45)]
|
13
|
+
- Added String#decimal_si_to_f [[#43](https://github.com/ManageIQ/more_core_extensions/pull/43)]
|
14
|
+
|
15
|
+
## [3.2.0] - 2017-03-03
|
16
|
+
### Added
|
17
|
+
- Added Numeric#clamp [[#30](https://github.com/ManageIQ/more_core_extensions/pull/30)]
|
18
|
+
- Added String#to_iec_integer [[#24](https://github.com/ManageIQ/more_core_extensions/pull/24)]
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
- Updated email Regex to allow mixed case [[#39](https://github.com/ManageIQ/more_core_extensions/pull/39)]
|
22
|
+
|
23
|
+
## [3.1.1] - 2016-12-16
|
24
|
+
### Changed
|
25
|
+
- Updated email Regex to be more accurate and slightly less restrictive
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
- Fixed issue where email Regex did not support more than 3 char TLDs
|
29
|
+
|
30
|
+
## [3.1.0] - 2016-08-11
|
31
|
+
### Added
|
32
|
+
- Add Array #deviation, #mean, #squares, #variance
|
33
|
+
- Add Numeric #square, #round_up, #round_down
|
34
|
+
|
35
|
+
## [3.0.0] - 2016-07-07
|
36
|
+
### Changed
|
37
|
+
- **BREAKING**: Drop support for Ruby 1.9.3 [[#22](https://github.com/ManageIQ/more_core_extensions/pull/22)]
|
38
|
+
- Drop dependency on ActiveSupport due to Rails 5 minimum Ruby version [[#22](https://github.com/ManageIQ/more_core_extensions/pull/22)]
|
39
|
+
|
40
|
+
## [2.0.0] - 2015-12-02
|
41
|
+
### Changed
|
42
|
+
- **BREAKING**: Remove Object#namespace [[#20](https://github.com/ManageIQ/more_core_extensions/pull/20)]
|
43
|
+
- Add ability to pass a transformation block to element_counts [[#21](https://github.com/ManageIQ/more_core_extensions/pull/21)]
|
44
|
+
- Array#include_any? and friends now accept a single argument Array. [[#18](https://github.com/ManageIQ/more_core_extensions/pull/18)]
|
45
|
+
- Upgraded to RSpec 3 [[#16](https://github.com/ManageIQ/more_core_extensions/pull/16)]
|
46
|
+
- Added the Change Log!
|
47
|
+
|
48
|
+
[Unreleased]: https://github.com/ManageIQ/more_core_extensions/compare/v3.3.0...HEAD
|
49
|
+
[3.3.0]: https://github.com/ManageIQ/more_core_extensions/compare/v3.2.0...v3.3.0
|
50
|
+
[3.2.0]: https://github.com/ManageIQ/more_core_extensions/compare/v3.1.1...v3.2.0
|
51
|
+
[3.1.1]: https://github.com/ManageIQ/more_core_extensions/compare/v3.1.0...v3.1.1
|
52
|
+
[3.1.0]: https://github.com/ManageIQ/more_core_extensions/compare/v3.0.0...v3.1.0
|
53
|
+
[3.0.0]: https://github.com/ManageIQ/more_core_extensions/compare/v2.0.0...v3.0.0
|
54
|
+
[2.0.0]: https://github.com/ManageIQ/more_core_extensions/compare/v1.2.0...v2.0.0
|
data/Gemfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in more_core_extensions.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# HACK: Rails 5 dropped support for Ruby < 2.2.2
|
7
|
+
active_support_version = "< 5" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2.2")
|
8
|
+
gem 'activesupport', active_support_version
|
data/README.md
CHANGED
@@ -51,6 +51,9 @@ MoreCoreExtensions are a set of core extensions beyond those provided by ActiveS
|
|
51
51
|
* `#delete_nils` - Deletes all keys where the value is nil
|
52
52
|
* core_ext/hash/nested.rb (see [Shared](#shared))
|
53
53
|
* `#delete_blank_paths` - Deletes all paths where the value is blank
|
54
|
+
* core_ext/hash/sorting.rb (see [Shared](#shared))
|
55
|
+
* `#sort!` - Replace the original with the sorted hash
|
56
|
+
* `#sort_by!` - Replace the original with the sorted_by hash
|
54
57
|
|
55
58
|
#### Module
|
56
59
|
|
@@ -69,11 +72,20 @@ MoreCoreExtensions are a set of core extensions beyond those provided by ActiveS
|
|
69
72
|
|
70
73
|
#### Object
|
71
74
|
|
75
|
+
* core_ext/module/descendants.rb
|
76
|
+
* `#descendant_get` - Returns the descendant with a given name
|
72
77
|
* core_ext/module/namespace.rb
|
73
78
|
* `#in_namespace?` - Returns whether or not the object is in the given namespace
|
74
79
|
|
80
|
+
#### Range
|
81
|
+
|
82
|
+
* core_ext/range/step_value.rb
|
83
|
+
* `#step_value` - Step through a range at a given increment
|
84
|
+
|
75
85
|
#### String
|
76
86
|
|
87
|
+
* core_ext/string/decimal_suffix.rb
|
88
|
+
* `#decimal_si_to_f` - Returns a Float based on the number and suffix given
|
77
89
|
* core_ext/string/formats.rb
|
78
90
|
* `#email?` - Returns whether or not the String is an= valid email
|
79
91
|
* `#domain_name?` - Returns whether or not the String is a valid domain name
|
@@ -87,6 +99,11 @@ MoreCoreExtensions are a set of core extensions beyond those provided by ActiveS
|
|
87
99
|
* core_ext/string/iec60027_2.rb
|
88
100
|
* `#iec_60027_2_to_i` - Convert strings with an IEC60027-2 suffix to an integer
|
89
101
|
|
102
|
+
#### Symbol
|
103
|
+
|
104
|
+
* core_ext/symbol/to_i.rb
|
105
|
+
* `#to_i` - Returns the integer value of a symbol
|
106
|
+
|
90
107
|
#### Shared
|
91
108
|
|
92
109
|
* core_ext/shared/nested.rb
|
@@ -120,3 +137,7 @@ Or install it yourself as:
|
|
120
137
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
121
138
|
4. Push to the branch (`git push origin my-new-feature`)
|
122
139
|
5. Create new Pull Request
|
140
|
+
|
141
|
+
## License
|
142
|
+
|
143
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "more_core_extensions"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -5,4 +5,6 @@ require 'more_core_extensions/core_ext/hash'
|
|
5
5
|
require 'more_core_extensions/core_ext/module'
|
6
6
|
require 'more_core_extensions/core_ext/numeric'
|
7
7
|
require 'more_core_extensions/core_ext/object'
|
8
|
+
require 'more_core_extensions/core_ext/range'
|
8
9
|
require 'more_core_extensions/core_ext/string'
|
10
|
+
require 'more_core_extensions/core_ext/symbol'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MoreCoreExtensions
|
2
|
+
module HashSortBang
|
3
|
+
def sort!(*args, &block)
|
4
|
+
sorted = sort(*args, &block)
|
5
|
+
sorted = self.class[sorted.to_a] unless sorted.instance_of?(self.class)
|
6
|
+
replace(sorted)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module HashSortByBang
|
11
|
+
def sort_by!(*args, &block)
|
12
|
+
sorted = sort_by(*args, &block)
|
13
|
+
sorted = self.class[sorted.to_a] unless sorted.instance_of?(self.class)
|
14
|
+
replace(sorted)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Hash.send(:include, MoreCoreExtensions::HashSortBang) unless Hash.method_defined?(:sort!)
|
20
|
+
Hash.send(:include, MoreCoreExtensions::HashSortByBang) unless Hash.method_defined?(:sort_by!)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'active_support/core_ext/class/subclasses'
|
2
|
+
|
3
|
+
module MoreCoreExtensions
|
4
|
+
module Descendants
|
5
|
+
#
|
6
|
+
# Retrieve a descendant by its name
|
7
|
+
#
|
8
|
+
def descendant_get(desc_name)
|
9
|
+
return self if desc_name == name || desc_name.nil?
|
10
|
+
klass = descendants.find { |desc| desc.name == desc_name }
|
11
|
+
raise ArgumentError, "#{desc_name} is not a descendant of #{name}" unless klass
|
12
|
+
klass
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Object.send(:include, MoreCoreExtensions::Descendants)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module MoreCoreExtensions
|
2
|
+
module RangeStepValue
|
3
|
+
# Iterates over rng, starting with the beginning of rng, incrementing by the
|
4
|
+
# value, and passing that element to the block. Unlike +step+, +step_value+
|
5
|
+
# invokes the + operator to iterate over the range elements. Unless the end is
|
6
|
+
# excluded from the range, the final value of the iteration will always be the
|
7
|
+
# end value, even if the increment value goes past the end of the range.
|
8
|
+
#
|
9
|
+
# This method has performance benefits over +step+ when working with ranges of
|
10
|
+
# Time objects, for example, where step calling succ may be called an
|
11
|
+
# inordinate number of times.
|
12
|
+
#
|
13
|
+
# t = Time.now.midnight
|
14
|
+
# range = (t - 3.days)..t
|
15
|
+
# range.step_value(1.day) {|x| puts x}
|
16
|
+
#
|
17
|
+
# produces:
|
18
|
+
# Tue Dec 14 00:00:00 -0500 2010
|
19
|
+
# Wed Dec 15 00:00:00 -0500 2010
|
20
|
+
# Thu Dec 16 00:00:00 -0500 2010
|
21
|
+
# Fri Dec 17 00:00:00 -0500 2010
|
22
|
+
#
|
23
|
+
def step_value(value)
|
24
|
+
if block_given?
|
25
|
+
return if self.begin > self.end
|
26
|
+
|
27
|
+
iter = self.begin
|
28
|
+
loop do
|
29
|
+
yield iter unless iter == self.end && exclude_end?
|
30
|
+
break if iter == self.end
|
31
|
+
iter += value
|
32
|
+
iter = self.end if iter > self.end
|
33
|
+
end
|
34
|
+
|
35
|
+
self
|
36
|
+
else
|
37
|
+
ret = []
|
38
|
+
step_value(value) { |v| ret << v }
|
39
|
+
ret
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Range.send(:include, MoreCoreExtensions::RangeStepValue)
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'more_core_extensions/core_ext/range/step_value'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MoreCoreExtensions
|
2
|
+
module DecimalSI
|
3
|
+
DECIMAL_SUFFIXES = {"d" => 1e-1, "c" => 1e-2, "m" => 1e-3, "μ" => 1e-6, "n" => 1e-9, "p" => 1e-12, "f" => 1e-15,
|
4
|
+
"a" => 1e-18, "h" => 1e2, "k" => 1e3, "M" => 1e6, "G" => 1e9, "T" => 1e12, "P" => 1e15,
|
5
|
+
"E" => 1e18}.freeze
|
6
|
+
def decimal_si_to_f
|
7
|
+
multiplier = DECIMAL_SUFFIXES[self[-1]]
|
8
|
+
if multiplier
|
9
|
+
Float(self[0..-2]) * multiplier
|
10
|
+
else
|
11
|
+
Float(self)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
String.send(:prepend, MoreCoreExtensions::DecimalSI)
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'more_core_extensions/core_ext/symbol/to_i'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'more_core_extensions/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "more_core_extensions"
|
8
|
+
spec.version = MoreCoreExtensions::VERSION
|
9
|
+
spec.authors = ["Jason Frey", "Brandon Dunne"]
|
10
|
+
spec.email = ["fryguy9@gmail.com", "bdunne@redhat.com"]
|
11
|
+
spec.description = %q{MoreCoreExtensions are a set of core extensions beyond those provided by ActiveSupport.}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "http://github.com/ManageIQ/more_core_extensions"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.required_ruby_version = ">= 2.0.0"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "rspec", ">= 3.0"
|
29
|
+
spec.add_development_dependency "simplecov"
|
30
|
+
|
31
|
+
spec.add_runtime_dependency "activesupport"
|
32
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: more_core_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Frey
|
8
8
|
- Brandon Dunne
|
9
9
|
autorequire:
|
10
|
-
bindir:
|
10
|
+
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: codeclimate-test-reporter
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: simplecov
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: activesupport
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,9 +104,18 @@ executables: []
|
|
90
104
|
extensions: []
|
91
105
|
extra_rdoc_files: []
|
92
106
|
files:
|
107
|
+
- ".gitignore"
|
93
108
|
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
110
|
+
- ".rubocop_local.yml"
|
111
|
+
- ".travis.yml"
|
112
|
+
- CHANGELOG.md
|
113
|
+
- Gemfile
|
94
114
|
- LICENSE.txt
|
95
115
|
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
96
119
|
- lib/more_core_extensions.rb
|
97
120
|
- lib/more_core_extensions/all.rb
|
98
121
|
- lib/more_core_extensions/core_ext/array.rb
|
@@ -108,6 +131,7 @@ files:
|
|
108
131
|
- lib/more_core_extensions/core_ext/hash.rb
|
109
132
|
- lib/more_core_extensions/core_ext/hash/deletes.rb
|
110
133
|
- lib/more_core_extensions/core_ext/hash/nested.rb
|
134
|
+
- lib/more_core_extensions/core_ext/hash/sorting.rb
|
111
135
|
- lib/more_core_extensions/core_ext/module.rb
|
112
136
|
- lib/more_core_extensions/core_ext/module/namespace.rb
|
113
137
|
- lib/more_core_extensions/core_ext/numeric.rb
|
@@ -115,32 +139,20 @@ files:
|
|
115
139
|
- lib/more_core_extensions/core_ext/numeric/math.rb
|
116
140
|
- lib/more_core_extensions/core_ext/numeric/rounding.rb
|
117
141
|
- lib/more_core_extensions/core_ext/object.rb
|
142
|
+
- lib/more_core_extensions/core_ext/object/descendants.rb
|
118
143
|
- lib/more_core_extensions/core_ext/object/namespace.rb
|
144
|
+
- lib/more_core_extensions/core_ext/range.rb
|
145
|
+
- lib/more_core_extensions/core_ext/range/step_value.rb
|
119
146
|
- lib/more_core_extensions/core_ext/shared/nested.rb
|
120
147
|
- lib/more_core_extensions/core_ext/string.rb
|
148
|
+
- lib/more_core_extensions/core_ext/string/decimal_suffix.rb
|
121
149
|
- lib/more_core_extensions/core_ext/string/formats.rb
|
122
150
|
- lib/more_core_extensions/core_ext/string/hex_dump.rb
|
123
151
|
- lib/more_core_extensions/core_ext/string/iec60027_2.rb
|
152
|
+
- lib/more_core_extensions/core_ext/symbol.rb
|
153
|
+
- lib/more_core_extensions/core_ext/symbol/to_i.rb
|
124
154
|
- lib/more_core_extensions/version.rb
|
125
|
-
-
|
126
|
-
- spec/core_ext/array/duplicates_spec.rb
|
127
|
-
- spec/core_ext/array/element_counts_spec.rb
|
128
|
-
- spec/core_ext/array/inclusions_spec.rb
|
129
|
-
- spec/core_ext/array/math_spec.rb
|
130
|
-
- spec/core_ext/array/nested_spec.rb
|
131
|
-
- spec/core_ext/array/random_spec.rb
|
132
|
-
- spec/core_ext/array/stretch_spec.rb
|
133
|
-
- spec/core_ext/array/tableize_spec.rb
|
134
|
-
- spec/core_ext/hash/deletes_spec.rb
|
135
|
-
- spec/core_ext/hash/nested_spec.rb
|
136
|
-
- spec/core_ext/numeric/clamp_spec.rb
|
137
|
-
- spec/core_ext/numeric/math_spec.rb
|
138
|
-
- spec/core_ext/numeric/rounding_spec.rb
|
139
|
-
- spec/core_ext/object/namespace_spec.rb
|
140
|
-
- spec/core_ext/string/formats_spec.rb
|
141
|
-
- spec/core_ext/string/hex_dump_spec.rb
|
142
|
-
- spec/core_ext/string/iec60027_2_spec.rb
|
143
|
-
- spec/spec_helper.rb
|
155
|
+
- more_core_extensions.gemspec
|
144
156
|
homepage: http://github.com/ManageIQ/more_core_extensions
|
145
157
|
licenses:
|
146
158
|
- MIT
|
@@ -166,24 +178,4 @@ signing_key:
|
|
166
178
|
specification_version: 4
|
167
179
|
summary: MoreCoreExtensions are a set of core extensions beyond those provided by
|
168
180
|
ActiveSupport.
|
169
|
-
test_files:
|
170
|
-
- spec/core_ext/array/deletes_spec.rb
|
171
|
-
- spec/core_ext/array/duplicates_spec.rb
|
172
|
-
- spec/core_ext/array/element_counts_spec.rb
|
173
|
-
- spec/core_ext/array/inclusions_spec.rb
|
174
|
-
- spec/core_ext/array/math_spec.rb
|
175
|
-
- spec/core_ext/array/nested_spec.rb
|
176
|
-
- spec/core_ext/array/random_spec.rb
|
177
|
-
- spec/core_ext/array/stretch_spec.rb
|
178
|
-
- spec/core_ext/array/tableize_spec.rb
|
179
|
-
- spec/core_ext/hash/deletes_spec.rb
|
180
|
-
- spec/core_ext/hash/nested_spec.rb
|
181
|
-
- spec/core_ext/numeric/clamp_spec.rb
|
182
|
-
- spec/core_ext/numeric/math_spec.rb
|
183
|
-
- spec/core_ext/numeric/rounding_spec.rb
|
184
|
-
- spec/core_ext/object/namespace_spec.rb
|
185
|
-
- spec/core_ext/string/formats_spec.rb
|
186
|
-
- spec/core_ext/string/hex_dump_spec.rb
|
187
|
-
- spec/core_ext/string/iec60027_2_spec.rb
|
188
|
-
- spec/spec_helper.rb
|
189
|
-
- ".rspec"
|
181
|
+
test_files: []
|
@@ -1,15 +0,0 @@
|
|
1
|
-
describe Array do
|
2
|
-
it "#delete_nils" do
|
3
|
-
expect([].delete_nils).to eq([])
|
4
|
-
expect([1].delete_nils).to eq([1])
|
5
|
-
expect([nil].delete_nils).to eq([])
|
6
|
-
expect([1, [], nil].delete_nils).to eq([1, []])
|
7
|
-
end
|
8
|
-
|
9
|
-
it "#delete_blanks" do
|
10
|
-
expect([].delete_blanks).to eq([])
|
11
|
-
expect([1].delete_blanks).to eq([1])
|
12
|
-
expect([nil].delete_blanks).to eq([])
|
13
|
-
expect([1, [], nil].delete_blanks).to eq([1])
|
14
|
-
end
|
15
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
describe Array do
|
2
|
-
it '#duplicates' do
|
3
|
-
expect([1, 2, 3, 4].duplicates).to be_empty
|
4
|
-
expect([1, 2, 3, 4, 2, 4].duplicates).to match_array [2, 4]
|
5
|
-
|
6
|
-
expect(['1', '2', '3', '4'].duplicates).to be_empty
|
7
|
-
expect(['1', '2', '3', '4', '2', '4'].duplicates).to match_array ['2', '4']
|
8
|
-
end
|
9
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
describe Array do
|
2
|
-
describe "#element_counts" do
|
3
|
-
it "without a block" do
|
4
|
-
expect([].element_counts).to eq({})
|
5
|
-
expect([1].element_counts).to eq({1 => 1})
|
6
|
-
expect([nil].element_counts).to eq({nil => 1})
|
7
|
-
expect([1, 2, 3, 1, 3, 1].element_counts).to eq({1 => 3, 2 => 1, 3 => 2})
|
8
|
-
end
|
9
|
-
|
10
|
-
it "with a block" do
|
11
|
-
expect([].element_counts(&:size)).to eq({})
|
12
|
-
expect(%w(a).element_counts(&:size)).to eq({1 => 1})
|
13
|
-
expect(%w(a aa aaa a aaa a).element_counts(&:size)).to eq({1 => 3, 2 => 1, 3 => 2})
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
describe Array do
|
2
|
-
it '#include_any?' do
|
3
|
-
expect([1, 2, 3].include_any?(1, 2)).to be_truthy
|
4
|
-
expect([1, 2, 3].include_any?(1, 4)).to be_truthy
|
5
|
-
expect([1, 2, 3].include_any?(4, 5)).to be_falsey
|
6
|
-
expect([1, 2, 3].include_any?([1, 4])).to be_truthy
|
7
|
-
expect([1, 2, 3].include_any?([4, 5])).to be_falsey
|
8
|
-
|
9
|
-
expect(['1', '2', '3'].include_any?('1', '2')).to be_truthy
|
10
|
-
expect(['1', '2', '3'].include_any?('1', '4')).to be_truthy
|
11
|
-
expect(['1', '2', '3'].include_any?('4', '5')).to be_falsey
|
12
|
-
expect(['1', '2', '3'].include_any?(['1', '4'])).to be_truthy
|
13
|
-
expect(['1', '2', '3'].include_any?(['4', '5'])).to be_falsey
|
14
|
-
end
|
15
|
-
|
16
|
-
it '#include_none?' do
|
17
|
-
expect([1, 2, 3].include_none?(1, 2)).to be_falsey
|
18
|
-
expect([1, 2, 3].include_none?(1, 4)).to be_falsey
|
19
|
-
expect([1, 2, 3].include_none?(4, 5)).to be_truthy
|
20
|
-
expect([1, 2, 3].include_none?([1, 4])).to be_falsey
|
21
|
-
expect([1, 2, 3].include_none?([4, 5])).to be_truthy
|
22
|
-
|
23
|
-
expect(['1', '2', '3'].include_none?('1', '2')).to be_falsey
|
24
|
-
expect(['1', '2', '3'].include_none?('1', '4')).to be_falsey
|
25
|
-
expect(['1', '2', '3'].include_none?('4', '5')).to be_truthy
|
26
|
-
expect(['1', '2', '3'].include_none?(['1', '4'])).to be_falsey
|
27
|
-
expect(['1', '2', '3'].include_none?(['4', '5'])).to be_truthy
|
28
|
-
end
|
29
|
-
|
30
|
-
it '#include_all?' do
|
31
|
-
expect([1, 2, 3].include_all?(1, 2)).to be_truthy
|
32
|
-
expect([1, 2, 3].include_all?(1, 4)).to be_falsey
|
33
|
-
expect([1, 2, 3].include_all?(4, 5)).to be_falsey
|
34
|
-
expect([1, 2, 3].include_all?([1, 2])).to be_truthy
|
35
|
-
expect([1, 2, 3].include_all?([1, 4])).to be_falsey
|
36
|
-
|
37
|
-
expect(['1', '2', '3'].include_all?('1', '2')).to be_truthy
|
38
|
-
expect(['1', '2', '3'].include_all?('1', '4')).to be_falsey
|
39
|
-
expect(['1', '2', '3'].include_all?('4', '5')).to be_falsey
|
40
|
-
expect(['1', '2', '3'].include_all?(['1', '2'])).to be_truthy
|
41
|
-
expect(['1', '2', '3'].include_all?(['1', '4'])).to be_falsey
|
42
|
-
end
|
43
|
-
|
44
|
-
it "#includes_index?" do
|
45
|
-
expect([1, 2, 3].includes_index?(-4)).to be_falsey
|
46
|
-
expect([1, 2, 3].includes_index?(-3)).to be_truthy
|
47
|
-
expect([1, 2, 3].includes_index?(1)).to be_truthy
|
48
|
-
expect([1, 2, 3].includes_index?(2)).to be_truthy
|
49
|
-
expect([1, 2, 3].includes_index?(3)).to be_falsey
|
50
|
-
end
|
51
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
describe Array do
|
2
|
-
let(:floats) { [1.1, 2.2, 3.3, 4.4, 5.5] }
|
3
|
-
let(:integers) { [1, 2, 3, 4, 5] }
|
4
|
-
|
5
|
-
context "with floats" do
|
6
|
-
it("#stddev") { expect(floats.stddev).to be_within(0.00001).of(1.73925) }
|
7
|
-
it("#mean") { expect(floats.mean).to be_within(0.00001).of(3.30000) }
|
8
|
-
it("#variance") { expect(floats.variance).to be_within(0.00001).of(3.02500) }
|
9
|
-
end
|
10
|
-
|
11
|
-
context "with integers" do
|
12
|
-
it("#stddev") { expect(integers.stddev).to be_within(0.00001).of(1.58113) }
|
13
|
-
it("#mean") { expect(integers.mean).to be_within(0.00001).of(3.00000) }
|
14
|
-
it("#variance") { expect(integers.variance).to be_within(0.00001).of(2.50000) }
|
15
|
-
end
|
16
|
-
end
|