rudash 2.16.0 → 2.17.0

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: e652511c0d1f058e6008b955f3d601c8e8d17f34097662f3a3f06c4aaa109161
4
- data.tar.gz: 5f6fac4442c45d311e51f327047ae40edeac1e7db49844c255e2c489128738fe
3
+ metadata.gz: 87006924b8306d1dcb903192cc048f98eaab46d221a8d3a4ec562983a2022dbc
4
+ data.tar.gz: 5c14cb17c6670b9341c79a07f1d81cc4624cc0a604de4bdde2d25e10050186e6
5
5
  SHA512:
6
- metadata.gz: 89ec61e8ca7cb52adfc95dd3355a8ff3de03dad29117d9dda4457ab9ca6bd632ace7b6da46605363016427cbc7fa3a57a10233ceccd7fbac5155b2396ffca4f1
7
- data.tar.gz: aa092bfe4f6c50686ebc49ce62cdd52fed28810f16738cc61d489fe0aa4ec620d9a95c64294c58429431dac9e74eaf2b4f70c63f19f1f2f7d7e4fa152852dac1
6
+ metadata.gz: 7691a9391fd6763b9b64498776d7143fecc151f53b557b1cf8843814e4e867706d86e765d25c095b5d5252d5af51716eeeebb83cebc37d0aef37f1f0303910c9
7
+ data.tar.gz: 0cb3cd38629c407d63c312fb418e801d21512dd6ff32322828d2dff4ea09ad19b92a2f5607005c9768e9afe1e21fd196eb1bd0cff29a91bcf31513ec53e88167
@@ -1,5 +1,3 @@
1
- require_relative '../utils/index.rb'
2
-
3
1
  module Rudash
4
2
  module EachRight
5
3
  def each_right(collection, *rest_args)
data/lib/rudash/filter.rb CHANGED
@@ -1,7 +1,3 @@
1
- require_relative '../utils/index.rb'
2
- require_relative '../utils/subset_deep_match.rb'
3
- require_relative '../utils/dynamic_args_count.rb'
4
-
5
1
  module Rudash
6
2
  module Filter
7
3
  def filter(collection, *rest_args)
data/lib/rudash/flip.rb CHANGED
@@ -1,5 +1,3 @@
1
- require_relative '../utils/index.rb'
2
-
3
1
  module Rudash
4
2
  module Flip
5
3
  def flip(a_proc)
data/lib/rudash/flow.rb CHANGED
@@ -1,5 +1,3 @@
1
- require_relative '../utils/index.rb'
2
-
3
1
  module Rudash
4
2
  module Flow
5
3
  def flow(*funs)
@@ -1,5 +1,3 @@
1
- require_relative '../utils/index.rb'
2
-
3
1
  module Rudash
4
2
  module FlowRight
5
3
  def flow_right(*funs)
data/lib/rudash/get.rb CHANGED
@@ -1,6 +1,3 @@
1
- require_relative '../utils/path_resolver.rb'
2
- require_relative '../utils/index.rb'
3
-
4
1
  module Rudash
5
2
  module Get
6
3
  def get(hash, path, *rest_args)
data/lib/rudash/map.rb CHANGED
@@ -1,6 +1,3 @@
1
- require_relative '../utils/index.rb'
2
- require_relative '../utils/dynamic_args_count.rb'
3
-
4
1
  module Rudash
5
2
  module Map
6
3
  def map(collection, *rest_args)
data/lib/rudash/negate.rb CHANGED
@@ -1,5 +1,3 @@
1
- require_relative '../utils/index.rb'
2
-
3
1
  module Rudash
4
2
  module Negate
5
3
  def negate(a_proc)
data/lib/rudash/reduce.rb CHANGED
@@ -1,6 +1,3 @@
1
- require_relative '../utils/index.rb'
2
- require_relative '../utils/dynamic_args_count.rb'
3
-
4
1
  module Rudash
5
2
  module Reduce
6
3
  def reduce(collection, *rest_args)
@@ -1,5 +1,3 @@
1
- require_relative '../utils/index.rb'
2
-
3
1
  module Rudash
4
2
  module ReduceRight
5
3
  def reduce_right(collection, *rest_args)
data/lib/rudash/reject.rb CHANGED
@@ -1,6 +1,3 @@
1
- require_relative '../utils/index.rb'
2
- require_relative '../utils/subset_deep_match.rb'
3
-
4
1
  module Rudash
5
2
  module Reject
6
3
  def reject(collection, *rest_args)
data/lib/rudash/set.rb CHANGED
@@ -1,7 +1,3 @@
1
- require_relative '../utils/path_resolver.rb'
2
- require_relative '../utils/nested_path_creator.rb'
3
- require_relative '../utils/index.rb'
4
-
5
1
  module Rudash
6
2
  module Set
7
3
  def set(object, path, value)
@@ -0,0 +1,34 @@
1
+ module Rudash
2
+ module Unset
3
+ def unset(object, path)
4
+ return object if !object.is_a?(Hash) && !object.is_a?(Array)
5
+
6
+ *initial_path, last = Rudash::PathResolver.resolve(path)
7
+
8
+ last_parent = self.get(object, initial_path)
9
+
10
+ case last_parent
11
+ when Array
12
+ return false if !Rudash::Utils.match_number?(last)
13
+
14
+ last_key = last.to_i
15
+ if last_key > 0 && last_key < last_parent.length
16
+ last_parent.delete_at(last_key)
17
+ true
18
+ else
19
+ false
20
+ end
21
+ when Hash
22
+ last_key = Rudash::Utils.match_number?(last) ? last.to_i : last.to_sym
23
+ if last_parent.key?(last_key)
24
+ last_parent.delete(last_key)
25
+ true
26
+ else
27
+ false
28
+ end
29
+ else
30
+ false
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/rudash/update.rb CHANGED
@@ -1,6 +1,3 @@
1
- require_relative '../utils/index.rb'
2
- require_relative '../utils/dynamic_args_count.rb'
3
-
4
1
  module Rudash
5
2
  module Update
6
3
  def update(object, path, *rest_args)
data/lib/rudash.rb CHANGED
@@ -51,7 +51,14 @@ require_relative './rudash/drop_right.rb'
51
51
  require_relative './rudash/chain.rb'
52
52
  require_relative './rudash/flow.rb'
53
53
  require_relative './rudash/flow_right.rb'
54
+ require_relative './rudash/unset.rb'
54
55
 
56
+ ### Utils Requires
57
+ require_relative './utils/index.rb'
58
+ require_relative './utils/dynamic_args_count.rb'
59
+ require_relative './utils/path_resolver.rb'
60
+ require_relative './utils/subset_deep_match.rb'
61
+ require_relative './utils/nested_path_creator.rb'
55
62
  require_relative './utils/chain_wrapper.rb'
56
63
 
57
64
  # This is the exposed Gem class that contains all Rudash methods.
@@ -111,4 +118,5 @@ class R_
111
118
  extend Rudash::Chain
112
119
  extend Rudash::Flow
113
120
  extend Rudash::FlowRight
121
+ extend Rudash::Unset
114
122
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rudash
2
- VERSION = '2.16.0'
2
+ VERSION = '2.17.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Islam Attrash
@@ -68,6 +68,7 @@ files:
68
68
  - lib/rudash/take.rb
69
69
  - lib/rudash/union.rb
70
70
  - lib/rudash/uniq.rb
71
+ - lib/rudash/unset.rb
71
72
  - lib/rudash/update.rb
72
73
  - lib/rudash/without.rb
73
74
  - lib/utils/chain_wrapper.rb
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  version: '0'
99
100
  requirements: []
100
101
  rubyforge_project:
101
- rubygems_version: 2.7.8
102
+ rubygems_version: 2.7.7
102
103
  signing_key:
103
104
  specification_version: 4
104
105
  summary: Rudash - Lodash for Ruby Apps