more_core_extensions 3.1.0 → 3.1.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
  SHA1:
3
- metadata.gz: de0bf2437f3829de0a5f82ebd288a6cac59f0a71
4
- data.tar.gz: 386ac9e9871d381269e507143b72df08619bfd75
3
+ metadata.gz: 813c1118ca8bd1502d467502dbc10c1965cfccb8
4
+ data.tar.gz: 44f901136763832691e94be69e73cc90e82d3a16
5
5
  SHA512:
6
- metadata.gz: a132740693a2bd42601ef83c2cedb3680a742e7ad87a44c0643953d1f0f10a77c51118609532c184e21e5766404acdc90fcb0222e7b2a123d846c5d69dbec777
7
- data.tar.gz: e7c599a6db36661dc88a85666aaac6ac6355441c059e9a54e04b6834f68359a4a970a104e9ba7321b037084527c49fa440db207096caccd303199aecdcd49c1f
6
+ metadata.gz: 82cbb225f4ba697fc29cc1b6b6ef0d1e00561de1fb6071d8078cae1981aa0209f983b843e787841706b4f584121b1a0c9d29078942ea1f606b682c58f79a4e65
7
+ data.tar.gz: 94645bbb55387932f89711371041e09bc4c00a7d7c43fe6224d52acf2d9ce00bb7f416ff2eb308ef3a3a8d8f26789657c178e8e095fa58e4d4294769708347e9
data/README.md CHANGED
@@ -12,57 +12,88 @@ MoreCoreExtensions are a set of core extensions beyond those provided by ActiveS
12
12
 
13
13
  ## Extensions Provided
14
14
 
15
- * Array
16
- * delete_nils
17
- * delete_blanks
18
- * delete_blank_paths
19
- * delete_path
20
- * deviation
21
- * duplicates
22
- * include_any?
23
- * include_none?
24
- * include_all?
25
- * fetch_path
26
- * find_path
27
- * has_key_path?
28
- * include_path?
29
- * key_path?
30
- * member_path?
31
- * mean
32
- * random_index
33
- * random_element
34
- * squares
35
- * store_path
36
- * stretch
37
- * stretch!
38
- * zip_stretched
39
- * tableize
40
- * variance
41
- * Hash
42
- * delete_nils
43
- * delete_blanks
44
- * delete_blank_paths
45
- * delete_path
46
- * fetch_path
47
- * find_path
48
- * has_key_path?
49
- * include_path?
50
- * key_path?
51
- * member_path?
52
- * store_path
53
- * Numeric
54
- * square
55
- * round_down
56
- * round_up
57
- * String
58
- * email?
59
- * domain_name?
60
- * ipv4?
61
- * ipv6?
62
- * ipaddress?
63
- * integer?
64
- * guid?
65
- * hex_dump
15
+ #### Array
16
+
17
+ * core_ext/array/deletes.rb
18
+ * `#delete_blanks` - Deletes all items where the value is blank
19
+ * `#delete_nils` - Deletes all items where the value is nil
20
+ * core_ext/array/duplicates.rb
21
+ * `#duplicates` - Returns an Array of the duplicates found
22
+ * core_ext/array/element_counts.rb
23
+ * `#element_counts` - Returns a Hash of each element to the count of those elements
24
+ * core_ext/array/inclusions.rb
25
+ * `#include_all?` - Returns whether the Array contains all of the items
26
+ * `#include_any?` - Returns whether the Array contains any of the items
27
+ * `#include_none?` - Returns whether the Array contains none of the items
28
+ * `#includes_index?` - Returns whether the Array has a value at the index
29
+ * core_ext/array/math.rb
30
+ * `#mean` - Returns the mean of an Array of Numerics
31
+ * `#stddev` - Returns the standard deviation of an Array of Numerics
32
+ * `#variance` - Returns the variance of an Array of Numerics
33
+ * core_ext/array/nested.rb (see [Shared](#shared))
34
+ * `#delete_blank_paths` - Deletes all paths where the value is blank
35
+ * core_ext/array/random.rb
36
+ * `#random_index` - Picks a valid index randomly
37
+ * `#random_element` - Picks an element randomly
38
+ * core_ext/array/stretch.rb
39
+ * `.stretch` - Stretch all argument Arrays to make them the same size
40
+ * `.stretch!` - Stretch all argument Arrays to make them the same size. Modifies the arguments in place.
41
+ * `#stretch` - Stretch receiver to be the same size as the longest argument Array.
42
+ * `#stretch`! - Stretch receiver to be the same size as the longest argument Array. Modifies the receiver in place.
43
+ * `#zip_stretched` - Zip arguments stretching the receiver if necessary
44
+ * core_ext/array/tableize.rb
45
+ * `#tableize` - Create a string representation of receiver in a tabular format if receiver is an Array of Arrays or an Array of Hashes
46
+
47
+ #### Hash
48
+
49
+ * core_ext/hash/deletes.rb
50
+ * `#delete_blanks` - Deletes all keys where the value is blank
51
+ * `#delete_nils` - Deletes all keys where the value is nil
52
+ * core_ext/hash/nested.rb (see [Shared](#shared))
53
+ * `#delete_blank_paths` - Deletes all paths where the value is blank
54
+
55
+ #### Module
56
+
57
+ * core_ext/module/namespace.rb
58
+ * `#namespace` - Returns an Array with the namespace to the current Module
59
+
60
+ #### Numeric
61
+
62
+ * core_ext/numeric/math.rb
63
+ * `#square` - Returns the square of a Numeric
64
+ * core_ext/numeric/rounding.rb
65
+ * `#round_down` - Round down to the specified precision
66
+ * `#round_up` - Round up to the specified precision
67
+
68
+ #### Object
69
+
70
+ * core_ext/module/namespace.rb
71
+ * `#in_namespace?` - Returns whether or not the object is in the given namespace
72
+
73
+ #### String
74
+
75
+ * core_ext/string/formats.rb
76
+ * `#email?` - Returns whether or not the String is an= valid email
77
+ * `#domain_name?` - Returns whether or not the String is a valid domain name
78
+ * `#ipv4?` - Returns whether or not the String is an IPv4 address
79
+ * `#ipv6?` - Returns whether or not the String is an IPv6 address
80
+ * `#ipaddress?` - Returns whether or not the String is an IPv4 or IPv6 address
81
+ * `#integer?` - Returns whether or not the String is an integer
82
+ * `#guid?` - Returns whether or not the String is a valid GUID
83
+ * core_ext/string/hex_dump.rb
84
+ * `#hex_dump` - Dumps the string in a hex editor style format
85
+
86
+ #### Shared
87
+
88
+ * core_ext/shared/nested.rb
89
+ * `#delete_path` - Delete the value at the specified nesting
90
+ * `#fetch_path` - Fetch the value at the specified nesting
91
+ * `#find_path` - Detect which nesting holds the specified value
92
+ * `#has_key_path?` - Check if a key exists at the specified nesting
93
+ * `#include_path?` - alias of `#has_key_path?`
94
+ * `#key_path?` - alias of `#has_key_path?`
95
+ * `#member_path?` - alias of `#has_key_path?`
96
+ * `#store_path` - Store a value at the specified nesting
66
97
 
67
98
  ## Installation
68
99
 
@@ -5,6 +5,9 @@ module MoreCoreExtensions
5
5
  include MoreCoreExtensions::Shared::Nested
6
6
  extend MoreCoreExtensions::Shared::Nested
7
7
 
8
+ #
9
+ # Deletes all paths where the value is blank
10
+ #
8
11
  def delete_blank_paths
9
12
  self.each { |v| v.delete_blank_paths if v.respond_to?(:delete_blank_paths) }
10
13
  self.delete_blanks
@@ -12,4 +15,4 @@ module MoreCoreExtensions
12
15
  end
13
16
  end
14
17
 
15
- Array.send(:include, MoreCoreExtensions::ArrayNested)
18
+ Array.send(:include, MoreCoreExtensions::ArrayNested)
@@ -5,6 +5,9 @@ module MoreCoreExtensions
5
5
  include MoreCoreExtensions::Shared::Nested
6
6
  extend MoreCoreExtensions::Shared::Nested
7
7
 
8
+ #
9
+ # Deletes all paths where the value is blank
10
+ #
8
11
  def delete_blank_paths
9
12
  self.each_value { |v| v.delete_blank_paths if v.respond_to?(:delete_blank_paths) }
10
13
  self.delete_blanks
@@ -1,7 +1,9 @@
1
1
  module MoreCoreExtensions
2
2
  module Shared
3
3
  module Nested
4
-
4
+ #
5
+ # Delete the value at the specified nesting
6
+ #
5
7
  def delete_path(*args)
6
8
  args = args.first if args.length == 1 && args.first.kind_of?(Array)
7
9
  raise ArgumentError, "must pass at least one key" if args.empty?
@@ -17,6 +19,9 @@ module MoreCoreExtensions
17
19
  end
18
20
  end
19
21
 
22
+ #
23
+ # Fetch the value at the specific nesting
24
+ #
20
25
  def fetch_path(*args)
21
26
  args = args.first if args.length == 1 && args.first.kind_of?(Array)
22
27
  raise ArgumentError, "must pass at least one key" if args.empty?
@@ -30,6 +35,9 @@ module MoreCoreExtensions
30
35
  return child.fetch_path(args[1..-1])
31
36
  end
32
37
 
38
+ #
39
+ # Check if a key exists at the specified nesting
40
+ #
33
41
  def has_key_path?(*args)
34
42
  args = args.first if args.length == 1 && args.first.kind_of?(Array)
35
43
  raise ArgumentError, "must pass at least one key" if args.empty?
@@ -48,6 +56,9 @@ module MoreCoreExtensions
48
56
  alias key_path? has_key_path?
49
57
  alias member_path? has_key_path?
50
58
 
59
+ #
60
+ # Store a value at the specified nesting
61
+ #
51
62
  def store_path(*args)
52
63
  raise ArgumentError, "must pass at least one key, and a value" if args.length < 2
53
64
  value = args.pop
@@ -68,6 +79,9 @@ module MoreCoreExtensions
68
79
  end
69
80
  end
70
81
 
82
+ #
83
+ # Detect which nesting holds the specified value
84
+ #
71
85
  def find_path(val)
72
86
  self.each_with_index do |v, k|
73
87
  k, v = v if self.kind_of?(Hash)
@@ -1,7 +1,8 @@
1
1
  module MoreCoreExtensions
2
2
  module StringFormats
3
- # From: Regular Expression Cookbook: 4.1 Validate Email Addresses
4
- RE_EMAIL = %r{\A[\w!#$\%&'*+/=?`\{|\}~^-]+(?:\.[\w!#$\%&'*+/=?`\{|\}~^-]+)*@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\Z}i
3
+ # From: http://www.regular-expressions.info/email.html
4
+ RE_EMAIL = %r{\A[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z}
5
+
5
6
  def email?
6
7
  !!(self =~ RE_EMAIL)
7
8
  end
@@ -1,3 +1,3 @@
1
1
  module MoreCoreExtensions
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1".freeze
3
3
  end
@@ -2,9 +2,10 @@ describe String do
2
2
  it '#email?' do
3
3
  expect("john@example.com").to be_email
4
4
  expect("john.doe@example.com").to be_email
5
+ expect("john.doe@my-company.prestidigitation").to be_email
6
+ expect("john.o'doe@example.com").to be_email
5
7
 
6
- expect("john.doe@examplecom").not_to be_email
7
- expect("john.doe@example-com").not_to be_email
8
+ expect("john\ndoe@example.com").not_to be_email
8
9
  expect("").not_to be_email
9
10
  expect("foo").not_to be_email
10
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: more_core_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Frey
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-11 00:00:00.000000000 Z
12
+ date: 2016-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.5.1
160
+ rubygems_version: 2.5.2
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: MoreCoreExtensions are a set of core extensions beyond those provided by