seda 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c939ffe800985113244ed7a54f0915edf258fe74
4
+ data.tar.gz: 02bd3d3e68d6b38eff5c38ab27e839198149c390
5
+ SHA512:
6
+ metadata.gz: 953feb41bc4fde4d53f82830cc6b4265874a300c69d7a643406ebfdc0a66cc37aba93fc9d46783f7eebb17149c75ec2d8e5c85f8b93f3ddb9bd6930d6606a738
7
+ data.tar.gz: 33a08827f5007e6d0f42f2c40f0e62731e7453bb2fb146adb2e3730e391f5389f47755f1b1a79af0aaff90c5d5908003c62e73e845c77335d99b3ebb952631f3
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in seda.gemspec
4
+ gemspec
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Alexander Aleksanyan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # Seda: An underbar/lodash like gem for Ruby
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'seda'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install seda
18
+
19
+ ## Usage
20
+
21
+
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/seda.
32
+
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
37
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "seda"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,542 @@
1
+ require "seda/version"
2
+
3
+ module Seda
4
+
5
+ def self.identity(value)
6
+ value
7
+ end
8
+
9
+ def self.first(arr, n_first_elements)
10
+ n_first_elements == nil ? arr[0] : arr.slice(0, n_first_elements)
11
+ end
12
+
13
+ def self.index_of(arr, target)
14
+ if(arr == nil)
15
+ return arr
16
+ end
17
+
18
+ result = -1
19
+
20
+ arr.each_with_index do |element, i|
21
+ if(element == target && result == -1)
22
+ result = i
23
+ end
24
+ end
25
+
26
+ result
27
+ end
28
+
29
+ def self.contains(collection, target)
30
+ collection.each do |element|
31
+ if element == target
32
+ return true
33
+ end
34
+ end
35
+ false
36
+ end
37
+
38
+
39
+ def self.defaults(*obj)
40
+ final_object = (eval(local_variables[0].to_s))[0]
41
+ iterables = (eval(local_variables[0].to_s))[1..-1]
42
+
43
+ if final_object.class == Hash && iterables.class == Array
44
+ iterables.each do |element|
45
+ if element.class == Hash
46
+ for k in element
47
+ if final_object[k[0].to_sym] == nil
48
+ final_object[k[0].to_sym] = k[1]
49
+ end
50
+ end
51
+ elsif element.class == Array
52
+ element.each do |item|
53
+ if final_object[item.to_sym] == nil
54
+ final_object[item.to_sym] = item
55
+ end
56
+ end
57
+ else
58
+ if final_object[element.to_sym] == nil
59
+ final_object[element.to_sym] = element
60
+ end
61
+ end
62
+ end
63
+ else
64
+ raise ArgumentError.new('Must pass in the destination Hash as first argument, and additional argument objects to extend values from')
65
+ end
66
+
67
+ return final_object
68
+ end
69
+
70
+
71
+ def self.extend(*obj)
72
+ initial_obj = (eval(local_variables[0].to_s))[0]
73
+ iterables = (eval(local_variables[0].to_s))[1..-1]
74
+ final_object = {}
75
+
76
+ if initial_obj.class == Hash
77
+ initial_obj.each do |k, v|
78
+ final_object[k.to_s] = v
79
+ end
80
+
81
+ if iterables.class == Array
82
+ iterables.each do |element|
83
+ if element.class == Hash
84
+ for k in element
85
+ final_object[k[0].to_s] = k[1]
86
+ end
87
+ elsif element.class == Array
88
+ element.each do |item|
89
+ final_object[item.to_s] = item
90
+ end
91
+ else
92
+ final_object[element.to_s] = element
93
+ end
94
+ end
95
+ end
96
+ else
97
+ raise ArgumentError.new('Must pass in the destination Hash as first argument, and additional argument objects to extend values from')
98
+ end
99
+
100
+ return final_object
101
+ end
102
+
103
+ def self.intersection(*arrays)
104
+ result = []
105
+ seen = {}
106
+
107
+ iterables = (eval(local_variables[0].to_s))[0..-1]
108
+
109
+ iterables.flatten.each do |element|
110
+ seen[element] == nil ? seen[element] = 1 : seen[element] += 1
111
+ end
112
+
113
+ for k in seen
114
+ if k[1] == iterables.length
115
+ result << k[0]
116
+ end
117
+ end
118
+
119
+ result
120
+ end
121
+
122
+
123
+ def self.last(arr, n)
124
+ if(n > arr.length)
125
+ arr
126
+ else
127
+ n == nil ? arr[arr.length - 1] : arr.slice(arr.length - n, arr.length)
128
+ end
129
+ end
130
+
131
+
132
+ def self.pluck(collection, key)
133
+ collection.map{|item| item[key]}
134
+ end
135
+
136
+ def self.shuffle(arr)
137
+ counter = arr.length - 1
138
+
139
+ while counter > 0
140
+ random_index = rand(counter)
141
+ arr[counter], arr[random_index] = arr[random_index], arr[counter]
142
+ counter -= 1
143
+ end
144
+
145
+ arr
146
+ end
147
+
148
+ def self.filter(collection, some_method)
149
+ arr = []
150
+ result_obj = {}
151
+
152
+ if collection.class == Array
153
+ collection.each_with_index do |element, idx|
154
+ if some_method.class == String
155
+ if method(some_method.to_sym).call(collection, idx)
156
+ arr << element
157
+ end
158
+ elsif some_method.class == Symbol
159
+ if method(some_method).call(collection, idx)
160
+ arr << element
161
+ end
162
+ elsif some_method.class == Method
163
+ if some_method.call(collection, idx)
164
+ arr << element
165
+ end
166
+ else
167
+ raise ArgumentError.new('The second argument must be a method. You could pass in the actual method, a string of the method name, or a symbol of the method name. Both arguments are needed.')
168
+ end
169
+ end
170
+ return arr
171
+ elsif collection.class == Hash
172
+ for k in collection
173
+ if some_method.class == String
174
+ if method(some_method.to_sym).call(k[1])
175
+ result_obj[k[0]] = k[1]
176
+ end
177
+ elsif some_method.class == Symbol
178
+ if method(some_method).call(k[1])
179
+ result_obj[k[0]] = k[1]
180
+ end
181
+ elsif some_method.class == Method
182
+ if some_method.call(k[1])
183
+ result_obj[k[0]] = k[1]
184
+ end
185
+ else
186
+ raise ArgumentError.new('The second argument must be a method. You could pass in the actual method, a string of the method name, or a symbol of the method name. Both arguments are needed.')
187
+ end
188
+ end
189
+ return result_obj
190
+ else
191
+ raise ArgumentError.new('Must provide an Array, or a Hash as the first Argument.')
192
+ end
193
+ end
194
+
195
+
196
+ def self.reject(collection, some_method)
197
+ arr = []
198
+ result_obj = {}
199
+
200
+ if collection.class == Array
201
+ collection.each_with_index do |element, idx|
202
+ if some_method.class == String
203
+ if !method(some_method.to_sym).call(collection, idx)
204
+ arr << element
205
+ end
206
+ elsif some_method.class == Symbol
207
+ if !method(some_method).call(collection, idx)
208
+ arr << element
209
+ end
210
+ elsif some_method.class == Method
211
+ if !some_method.call(collection, idx)
212
+ arr << element
213
+ end
214
+ else
215
+ raise ArgumentError.new('The second argument must be a method. You could pass in the actual method, a string of the method name, or a symbol of the method name. Both arguments are needed.')
216
+ end
217
+ end
218
+
219
+ return arr
220
+ elsif collection.class == Hash
221
+ for k in collection
222
+ if some_method.class == String
223
+ if !method(some_method.to_sym).call(k[1])
224
+ result_obj[k[0]] = k[1]
225
+ end
226
+ elsif some_method.class == Symbol
227
+ if !method(some_method).call(k[1])
228
+ result_obj[k[0]] = k[1]
229
+ end
230
+ elsif some_method.class == Method
231
+ if !some_method.call(k[1])
232
+ result_obj[k[0]] = k[1]
233
+ end
234
+ else
235
+ raise ArgumentError.new('The second argument must be a method. You could pass in the actual method, a string of the method name, or a symbol of the method name. Both arguments are needed.')
236
+ end
237
+ end
238
+ return result_obj
239
+ else
240
+ raise ArgumentError.new('Must provide an Array, or a Hash as the first Argument.')
241
+ end
242
+ end
243
+
244
+
245
+ def self.reduce(collection, some_method)
246
+ accumulator = ''
247
+ cloned_collection = Marshal.load(Marshal.dump(collection))
248
+ counter = 0
249
+ optional_result_object = cloned_collection.class.new()
250
+
251
+ if cloned_collection.class == Array
252
+ accumulator = cloned_collection[0]
253
+ optional_result_object << accumulator
254
+
255
+ cloned_collection.each_with_index do |element, idx|
256
+
257
+ if counter == 0
258
+ counter = 1
259
+ next
260
+ end
261
+
262
+ if some_method.class == String
263
+ args = method(some_method).parameters.map { |arg| arg[1].to_s }
264
+
265
+ if args.length < 3
266
+ accumulator = method(some_method.to_sym).call(accumulator, element)
267
+ optional_result_object << accumulator
268
+ else
269
+ accumulator = method(some_method.to_sym).call(accumulator, element, idx)
270
+ optional_result_object << accumulator
271
+ end
272
+
273
+ elsif some_method.class == Symbol
274
+ args = method(some_method).parameters.map { |arg| arg[1].to_s }
275
+
276
+ if args.length < 3
277
+ accumulator = method(some_method).call(accumulator, element)
278
+ optional_result_object << accumulator
279
+ else
280
+ accumulator = method(some_method).call(accumulator, element, idx)
281
+ optional_result_object << accumulator
282
+ end
283
+
284
+ elsif some_method.class == Method
285
+ args = some_method.parameters.map { |arg| arg[1].to_s }
286
+
287
+ if args.length < 3
288
+ accumulator = some_method.call(accumulator, element)
289
+ optional_result_object << accumulator
290
+ else
291
+ accumulator = some_method.call(accumulator, element, idx)
292
+ optional_result_object << accumulator
293
+ end
294
+
295
+ end
296
+
297
+ end
298
+
299
+ elsif cloned_collection.class == Hash
300
+ accumulator = cloned_collection.values[0]
301
+
302
+ for k in cloned_collection
303
+
304
+ if counter == 0
305
+ optional_result_object[k[0]] = accumulator
306
+ counter = 1
307
+ next
308
+ else
309
+
310
+ if some_method.class == String
311
+ args = some_method.parameters.map { |arg| arg[1].to_s }
312
+
313
+ if args.length < 3
314
+ accumulator = method(some_method.to_sym).call(accumulator, k[1])
315
+ optional_result_object[k[0]] = accumulator
316
+ else
317
+ accumulator = method(some_method.to_sym).call(accumulator, k[1], counter)
318
+ optional_result_object[k[0]] = accumulator
319
+ end
320
+ elsif some_method.class == Symbol
321
+ args = some_method.parameters.map { |arg| arg[1].to_s }
322
+
323
+ if args.length < 3
324
+ accumulator = method(some_method).call(accumulator, k[1])
325
+ optional_result_object[k[0]] = accumulator
326
+ else
327
+ accumulator = method(some_method).call(accumulator, k[1], counter)
328
+ optional_result_object[k[0]] = accumulator
329
+ end
330
+ elsif some_method.class == Method
331
+ args = some_method.parameters.map { |arg| arg[1].to_s }
332
+
333
+ if args.length < 3
334
+ accumulator = some_method.call(accumulator, k[1])
335
+ optional_result_object[k[0]] = accumulator
336
+ else
337
+ accumulator = some_method.call(accumulator, k[1], counter)
338
+ optional_result_object[k[0]] = accumulator
339
+ end
340
+ end
341
+
342
+ end
343
+ counter = counter + 1
344
+
345
+ end
346
+
347
+ else
348
+ return cloned_collection
349
+ end
350
+
351
+ if accumulator.class == Float || accumulator.class == Integer
352
+ accumulator
353
+ else
354
+ cloned_collection
355
+ end
356
+ end
357
+
358
+
359
+ def self.difference(*arrays)
360
+ checker = (eval(local_variables[0].to_s))[0]
361
+ iterables = (eval(local_variables[0].to_s))[1..-1]
362
+
363
+ arr = []
364
+ seen = {}
365
+
366
+ checker.each do |element|
367
+ seen[element] = element
368
+ arr << element
369
+ end
370
+
371
+ iterables.each do |inner_arr|
372
+ inner_arr.each do |element|
373
+ if seen[element]
374
+ arr = arr.reject{|el| el == element}
375
+ end
376
+ end
377
+ end
378
+
379
+ arr
380
+ end
381
+
382
+
383
+ def self.delay(some_method, wait, *some_method_args)
384
+ args = eval(local_variables[2].to_s)
385
+
386
+ if some_method.class == String
387
+ some_method = some_method.to_sym
388
+ some_method = method(some_method)
389
+ elsif some_method.class == Symbol
390
+ some_method = method(some_method)
391
+ end
392
+
393
+ if some_method.class == Method
394
+ sleep (wait.to_f/1000)
395
+ some_method.call(*args)
396
+ else
397
+ raise ArgumentError.new('First argument must reference a method')
398
+ end
399
+ end
400
+
401
+
402
+ def self.every(collection, some_method)
403
+ collection.each do |item|
404
+ if some_method.class == Method
405
+ if !some_method.call(item)
406
+ return false
407
+ end
408
+ elsif some_method.class == Symbol
409
+ if !method(some_method).call(item)
410
+ return false
411
+ end
412
+ elsif some_method.class == String
413
+ if !method(some_method.to_sym).call(item)
414
+ return false
415
+ end
416
+ else
417
+ raise ArgumentError.new('First argument must reference a method')
418
+ end
419
+ end
420
+ return true
421
+ end
422
+
423
+
424
+ def self.flatten(nested_array, result = [])
425
+ nested_array.each do |element|
426
+ if element.class == Array
427
+ self.flatten(element, result)
428
+ else
429
+ result << element
430
+ end
431
+ end
432
+
433
+ result
434
+ end
435
+
436
+
437
+ def self.map(collection, some_method)
438
+ arr = []
439
+
440
+ if collection.class == Array
441
+ collection.each_with_index do |element, idx|
442
+ if some_method.class == String
443
+ arr << method(some_method.to_sym).call(element, idx, collection)
444
+ elsif some_method.class == Symbol
445
+ arr << method(some_method).call(element, idx, collection)
446
+ elsif some_method.class == Method
447
+ arr << some_method.call(element, idx, collection)
448
+ else
449
+ raise ArgumentError.new('The second argument must be a method. You could pass in the actual method, a string of the method name, or a symbol of the method name. Both arguments are needed.')
450
+ end
451
+ end
452
+ elsif collection.class == Hash
453
+ for k in collection
454
+ if some_method.class == String
455
+ arr << method(some_method.to_sym).call(k[1], k[0], collection)
456
+ elsif some_method.class == Symbol
457
+ arr << method(some_method).call(k[1], k[0], collection)
458
+ elsif some_method.class == Method
459
+ arr << some_method.call(k[1], k[0], collection)
460
+ else
461
+ raise ArgumentError.new('The second argument must be a method. You could pass in the actual method, a string of the method name, or a symbol of the method name. Both arguments are needed.')
462
+ end
463
+ end
464
+ else
465
+ raise ArgumentError.new('Must provide an Array, or a Hash as the first Argument.')
466
+ end
467
+
468
+ arr
469
+ end
470
+
471
+
472
+ def self.memoize(some_method, *some_method_args)
473
+ storage = {}
474
+ result = ''
475
+ b = eval(local_variables[1].to_s)
476
+
477
+ if some_method.class == String
478
+ some_method = method(some_method.to_sym)
479
+ elsif some_method.class == Symbol
480
+ some_method = method(some_method)
481
+ end
482
+
483
+ result = lambda{|a = b, arg = b.to_s|
484
+ if !storage[arg]
485
+ storage[arg] = some_method.call(*a)
486
+ end
487
+
488
+ return storage[arg]
489
+ }
490
+
491
+ return result.call(b)
492
+ end
493
+
494
+
495
+ def self.some(collection, some_method)
496
+ result = true
497
+ collection.each do |item|
498
+ if some_method.class == Method
499
+ result = some_method.call(item)
500
+ elsif some_method.class == Symbol
501
+ result = method(some_method).call(item)
502
+ elsif some_method.class == String
503
+ result = method(some_method.to_sym).call(item)
504
+ else
505
+ raise ArgumentError.new('First argument must reference a method')
506
+ end
507
+ end
508
+
509
+ return result
510
+ end
511
+
512
+
513
+ def self.sort_by_max(collection)
514
+ if collection.class == Hash
515
+ result = {}
516
+ arr = collection.sort{|a, b| b <=> a }
517
+ arr.flatten.uniq.inject({}) do |memo, item|
518
+ result[item] = item
519
+ end
520
+
521
+ return result
522
+ elsif collection.class == Array
523
+ collection.sort!{|a, b| b <=> a }
524
+ end
525
+ end
526
+
527
+ def self.sort_by_min(collection)
528
+ if collection.class == Hash
529
+ result = {}
530
+ arr = collection.sort{|a, b| a <=> b }
531
+ arr.flatten.uniq.inject({}) do |memo, item|
532
+ result[item] = item
533
+ end
534
+
535
+ return result
536
+ elsif collection.class == Array
537
+ collection.sort!{|a, b| a <=> b }
538
+ end
539
+ end
540
+
541
+
542
+ end
@@ -0,0 +1,3 @@
1
+ module Seda
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'seda/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "seda"
8
+ spec.version = Seda::VERSION
9
+ spec.authors = ["Alexander Aleksanyan"]
10
+ spec.email = ["alex1100.software@gmail.com"]
11
+
12
+ spec.summary = %q{Familiar Methods From Underbar/Lodash}
13
+ spec.description = %q{Familiar Methods From Underbar and Lodash Ported Over To Ruby}
14
+ spec.homepage = "https://github.com/Alex1100/seda"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "guard-rspec"
37
+ spec.add_development_dependency "guard"
38
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seda
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Aleksanyan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Familiar Methods From Underbar and Lodash Ported Over To Ruby
84
+ email:
85
+ - alex1100.software@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - Guardfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/seda.rb
100
+ - lib/seda/version.rb
101
+ - seda.gemspec
102
+ homepage: https://github.com/Alex1100/seda
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.6.12
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Familiar Methods From Underbar/Lodash
126
+ test_files: []