rudash 2.13.0 → 2.14.0

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: b56da576534a47e10249114fcf614309b555b953cf4429356aa78f0f56e87c54
4
- data.tar.gz: 3c1f5b409f01e1e882409c764c705846c15e31ab6a5837d2f491df551174c8ed
3
+ metadata.gz: a0efde163ec32f1ae10522e24a34dc1d316a6b106db818e18760c86a4b95b53f
4
+ data.tar.gz: ff3255666168a904db28841d7f82ccc319dadc0c65054009e6b056c13b9a3927
5
5
  SHA512:
6
- metadata.gz: d34d9153330154ee1cd08c0190acfbd6fe701e486539c20386d31b3c0697ea494b721fe35e61b6093a82af7efa8706434892953e74532e39c96722a49786f7a0
7
- data.tar.gz: a16f4f2749ab707a75aa2c3dac1634e0dca67afa6d6f9b35722a8e0b604773a5c4b578f6287530aa589efaebee0ca341aa9e3e123de83789210122952bbb422c
6
+ metadata.gz: 99de8b06532e11d4f96c5a9ce64b96a9cd4a7dff105d8e61fed16472e8e49980cd7c59eef8b18d90522f2d8ef2a073752c069bdb2b2ce357d1f5fe989ae435f1
7
+ data.tar.gz: 6b9bbd93a29b3e4af5d423ec5a06b6d1052e52dd169b2ad65ab8d99a748ad2d357f295a60cb8fdaabc79e3273c8efc507441fbb72ee4ad7494335a1b0363503c
@@ -0,0 +1,7 @@
1
+ module Rudash
2
+ module Chain
3
+ def chain(value)
4
+ Rudash::ChainUtils::ChainWrapper.new(value, self)
5
+ end
6
+ end
7
+ end
data/lib/rudash.rb CHANGED
@@ -48,6 +48,9 @@ require_relative './rudash/range.rb'
48
48
  require_relative './rudash/group_by.rb'
49
49
  require_relative './rudash/take.rb'
50
50
  require_relative './rudash/drop_right.rb'
51
+ require_relative './rudash/chain.rb'
52
+
53
+ require_relative './utils/chain_wrapper.rb'
51
54
 
52
55
  # This is the exposed Gem class that contains all Rudash methods.
53
56
  # New methods can use already implemented methods in the library by refering to "self"
@@ -103,4 +106,5 @@ class R_
103
106
  extend Rudash::GroupBy
104
107
  extend Rudash::Take
105
108
  extend Rudash::DropRight
109
+ extend Rudash::Chain
106
110
  end
@@ -0,0 +1,21 @@
1
+ module Rudash
2
+ module ChainUtils
3
+ class ChainWrapper
4
+ def initialize(value, r_)
5
+ @value = value
6
+ @r_ = r_
7
+ end
8
+
9
+ def value
10
+ @value
11
+ end
12
+
13
+ def method_missing(method_name, *args, &block)
14
+ result = @r_.public_send(method_name, @value, *args)
15
+ self.class.new(result, @r_)
16
+ rescue NameError
17
+ raise NameError.new("\"#{method_name}\" doesn't exist in Rudash")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -10,7 +10,7 @@ module Rudash
10
10
  begin
11
11
  return func.(*args)
12
12
  rescue ArgumentError => e
13
- raise 'Argument Error' if args.size == 0
13
+ raise ArgumentError.new('Argument Error') if args.size == 0
14
14
  *initial, last = args
15
15
  return self.call(func, *initial)
16
16
  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.13.0
4
+ version: 2.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Islam Attrash
@@ -19,6 +19,7 @@ files:
19
19
  - lib/rudash.rb
20
20
  - lib/rudash/at.rb
21
21
  - lib/rudash/capitalize.rb
22
+ - lib/rudash/chain.rb
22
23
  - lib/rudash/compact.rb
23
24
  - lib/rudash/concat.rb
24
25
  - lib/rudash/curry.rb
@@ -67,6 +68,7 @@ files:
67
68
  - lib/rudash/uniq.rb
68
69
  - lib/rudash/update.rb
69
70
  - lib/rudash/without.rb
71
+ - lib/utils/chain_wrapper.rb
70
72
  - lib/utils/dynamic_args_count.rb
71
73
  - lib/utils/index.rb
72
74
  - lib/utils/nested_path_creator.rb