ramda-ruby 0.1.1 → 0.1.4
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/ROADMAP.md +0 -16
- data/docs/FUNCTIONS.md +12 -0
- data/lib/ramda.rb +4 -0
- data/lib/ramda/function.rb +8 -0
- data/lib/ramda/list.rb +33 -4
- data/lib/ramda/version.rb +1 -1
- data/spec/ramda/function_spec.rb +7 -0
- data/spec/ramda/list_spec.rb +29 -0
- data/spec/ramda_spec.rb +4 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e9fde33339db665f8cc1bd20ba439d490de4ced5
         | 
| 4 | 
            +
              data.tar.gz: 89a420e74940dd7bf124ba9a1da690eefa7de2ea
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4cd815afc079d285f8485f3e4c62ec436a49b40f1c489bce0fc80b11fc0b8771ea23090c100431f2a4ba8f6da6c92be9e2a3f52aee74768e99031db58830854c
         | 
| 7 | 
            +
              data.tar.gz: e71938b6211936c3880d60bc3119e84e11d1bbe3f16579b79c87cec63fe8f661a0682af9d3746dccf9056ae17c1ddca0bd22ea66138da08203f8dc42c772039c
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/ROADMAP.md
    CHANGED
    
    | @@ -2,22 +2,6 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            * Find out suitable documentation format
         | 
| 4 4 |  | 
| 5 | 
            -
            #### release 0.1.1
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            * find_index
         | 
| 8 | 
            -
            * find_last
         | 
| 9 | 
            -
            * find_last_index
         | 
| 10 | 
            -
            * for_each
         | 
| 11 | 
            -
            * modulo
         | 
| 12 | 
            -
            * repeat
         | 
| 13 | 
            -
            * where
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            #### release 0.1.4
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            last
         | 
| 18 | 
            -
            partition
         | 
| 19 | 
            -
            slice
         | 
| 20 | 
            -
             | 
| 21 5 | 
             
            ### release 0.2.0
         | 
| 22 6 |  | 
| 23 7 | 
             
            binary
         | 
    
        data/docs/FUNCTIONS.md
    CHANGED
    
    | @@ -28,10 +28,14 @@ | |
| 28 28 | 
             
            * filter
         | 
| 29 29 | 
             
            * find
         | 
| 30 30 | 
             
            * find_index
         | 
| 31 | 
            +
            * find_index
         | 
| 32 | 
            +
            * find_last
         | 
| 31 33 | 
             
            * find_last
         | 
| 32 34 | 
             
            * find_last_index
         | 
| 35 | 
            +
            * find_last_index
         | 
| 33 36 | 
             
            * flatten
         | 
| 34 37 | 
             
            * flip
         | 
| 38 | 
            +
            * for_each
         | 
| 35 39 | 
             
            * group_by
         | 
| 36 40 | 
             
            * gt
         | 
| 37 41 | 
             
            * gte
         | 
| @@ -43,8 +47,11 @@ | |
| 43 47 | 
             
            * intersection
         | 
| 44 48 | 
             
            * invoker
         | 
| 45 49 | 
             
            * is_empty
         | 
| 50 | 
            +
            * is_nil
         | 
| 46 51 | 
             
            * join
         | 
| 52 | 
            +
            * juxt
         | 
| 47 53 | 
             
            * keys
         | 
| 54 | 
            +
            * last
         | 
| 48 55 | 
             
            * last_index_of
         | 
| 49 56 | 
             
            * length
         | 
| 50 57 | 
             
            * lt
         | 
| @@ -55,6 +62,7 @@ | |
| 55 62 | 
             
            * memoize
         | 
| 56 63 | 
             
            * merge
         | 
| 57 64 | 
             
            * min
         | 
| 65 | 
            +
            * modulo
         | 
| 58 66 | 
             
            * multiply
         | 
| 59 67 | 
             
            * n_ary
         | 
| 60 68 | 
             
            * not
         | 
| @@ -62,6 +70,7 @@ | |
| 62 70 | 
             
            * omit
         | 
| 63 71 | 
             
            * once
         | 
| 64 72 | 
             
            * or
         | 
| 73 | 
            +
            * partition
         | 
| 65 74 | 
             
            * pick
         | 
| 66 75 | 
             
            * pick_all
         | 
| 67 76 | 
             
            * pipe
         | 
| @@ -76,7 +85,9 @@ | |
| 76 85 | 
             
            * reduce
         | 
| 77 86 | 
             
            * reduce_right
         | 
| 78 87 | 
             
            * reject
         | 
| 88 | 
            +
            * repeat
         | 
| 79 89 | 
             
            * reverse
         | 
| 90 | 
            +
            * slice
         | 
| 80 91 | 
             
            * sort
         | 
| 81 92 | 
             
            * sort_by
         | 
| 82 93 | 
             
            * split
         | 
| @@ -93,6 +104,7 @@ | |
| 93 104 | 
             
            * uniq
         | 
| 94 105 | 
             
            * use_with
         | 
| 95 106 | 
             
            * values
         | 
| 107 | 
            +
            * where
         | 
| 96 108 | 
             
            * xprod
         | 
| 97 109 | 
             
            * zip
         | 
| 98 110 | 
             
            * zip_with
         | 
    
        data/lib/ramda.rb
    CHANGED
    
    | @@ -25,6 +25,7 @@ module Ramda | |
| 25 25 | 
             
                             :flip,
         | 
| 26 26 | 
             
                             :identity,
         | 
| 27 27 | 
             
                             :invoker,
         | 
| 28 | 
            +
                             :juxt,
         | 
| 28 29 | 
             
                             :memoize,
         | 
| 29 30 | 
             
                             :n_ary,
         | 
| 30 31 | 
             
                             :once,
         | 
| @@ -50,11 +51,14 @@ module Ramda | |
| 50 51 | 
             
                             :head,
         | 
| 51 52 | 
             
                             :index_of,
         | 
| 52 53 | 
             
                             :join,
         | 
| 54 | 
            +
                             :last,
         | 
| 53 55 | 
             
                             :last_index_of,
         | 
| 54 56 | 
             
                             :length,
         | 
| 57 | 
            +
                             :slice,
         | 
| 55 58 | 
             
                             :sort,
         | 
| 56 59 | 
             
                             :map,
         | 
| 57 60 | 
             
                             :nth,
         | 
| 61 | 
            +
                             :partition,
         | 
| 58 62 | 
             
                             :pluck,
         | 
| 59 63 | 
             
                             :prepend,
         | 
| 60 64 | 
             
                             :range,
         | 
    
        data/lib/ramda/function.rb
    CHANGED
    
    | @@ -103,6 +103,14 @@ module Ramda | |
| 103 103 | 
             
                  end.curry
         | 
| 104 104 | 
             
                end
         | 
| 105 105 |  | 
| 106 | 
            +
                # juxt applies a list of functions to a list of values.
         | 
| 107 | 
            +
                #
         | 
| 108 | 
            +
                # [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n])
         | 
| 109 | 
            +
                #
         | 
| 110 | 
            +
                curried_method(:juxt) do |fns, a, *bs|
         | 
| 111 | 
            +
                  fns.map { |fn| fn.call(a, *bs) }
         | 
| 112 | 
            +
                end
         | 
| 113 | 
            +
             | 
| 106 114 | 
             
                # Creates a new function that, when invoked, caches the result of calling
         | 
| 107 115 | 
             
                # fn for a given argument set and returns the result. Subsequent calls to
         | 
| 108 116 | 
             
                # the memoized fn with the same argument set will not result in an
         | 
    
        data/lib/ramda/list.rb
    CHANGED
    
    | @@ -165,12 +165,12 @@ module Ramda | |
| 165 165 | 
             
                # [a] -> a | NilClass
         | 
| 166 166 | 
             
                # String -> String
         | 
| 167 167 | 
             
                #
         | 
| 168 | 
            -
                curried_method(:head) do | | 
| 169 | 
            -
                  case  | 
| 168 | 
            +
                curried_method(:head) do |xs|
         | 
| 169 | 
            +
                  case xs
         | 
| 170 170 | 
             
                  when ::String
         | 
| 171 | 
            -
                     | 
| 171 | 
            +
                    xs[0] || ''
         | 
| 172 172 | 
             
                  else
         | 
| 173 | 
            -
                     | 
| 173 | 
            +
                    xs[0]
         | 
| 174 174 | 
             
                  end
         | 
| 175 175 | 
             
                end
         | 
| 176 176 |  | 
| @@ -201,6 +201,15 @@ module Ramda | |
| 201 201 | 
             
                  xs.rindex(x)
         | 
| 202 202 | 
             
                end
         | 
| 203 203 |  | 
| 204 | 
            +
                curried_method(:last) do |xs|
         | 
| 205 | 
            +
                  case xs
         | 
| 206 | 
            +
                  when ::String
         | 
| 207 | 
            +
                    xs[-1] || ''
         | 
| 208 | 
            +
                  else
         | 
| 209 | 
            +
                    xs[-1]
         | 
| 210 | 
            +
                  end
         | 
| 211 | 
            +
                end
         | 
| 212 | 
            +
             | 
| 204 213 | 
             
                # Returns the number of elements in the array by returning list.length
         | 
| 205 214 | 
             
                #
         | 
| 206 215 | 
             
                # [a] -> Number
         | 
| @@ -242,6 +251,16 @@ module Ramda | |
| 242 251 | 
             
                  end
         | 
| 243 252 | 
             
                end
         | 
| 244 253 |  | 
| 254 | 
            +
                # Takes a predicate and a list or other Filterable object and returns
         | 
| 255 | 
            +
                # the pair of filterable objects of the same type of elements which do
         | 
| 256 | 
            +
                # and do not satisfy, the predicate, respectively.
         | 
| 257 | 
            +
                #
         | 
| 258 | 
            +
                # Filterable f => (a -> Boolean) -> f a -> [f a, f a]
         | 
| 259 | 
            +
                #
         | 
| 260 | 
            +
                curried_method(:partition) do |fn, xs|
         | 
| 261 | 
            +
                  R.juxt([filter, reject]).call(fn, xs)
         | 
| 262 | 
            +
                end
         | 
| 263 | 
            +
             | 
| 245 264 | 
             
                # Returns a new list by plucking the same named property off all objects
         | 
| 246 265 | 
             
                # in the list supplied.
         | 
| 247 266 | 
             
                #
         | 
| @@ -332,6 +351,16 @@ module Ramda | |
| 332 351 | 
             
                  Array.new(n, a)
         | 
| 333 352 | 
             
                end
         | 
| 334 353 |  | 
| 354 | 
            +
                # Returns the elements of the given list or string
         | 
| 355 | 
            +
                # from fromIndex (inclusive) to toIndex (exclusive).
         | 
| 356 | 
            +
                #
         | 
| 357 | 
            +
                # Number -> Number -> [a] -> [a]
         | 
| 358 | 
            +
                # Number -> Number -> String -> String
         | 
| 359 | 
            +
                #
         | 
| 360 | 
            +
                curried_method(:slice) do |from, to, xs|
         | 
| 361 | 
            +
                  xs[from...to]
         | 
| 362 | 
            +
                end
         | 
| 363 | 
            +
             | 
| 335 364 | 
             
                # Returns a copy of the list, sorted according to the comparator function,
         | 
| 336 365 | 
             
                # which should accept two values at a time and return a negative number
         | 
| 337 366 | 
             
                # if the first value is smaller, a positive number if it's larger, and
         | 
    
        data/lib/ramda/version.rb
    CHANGED
    
    
    
        data/spec/ramda/function_spec.rb
    CHANGED
    
    | @@ -112,6 +112,13 @@ describe Ramda::Function do | |
| 112 112 | 
             
                end
         | 
| 113 113 | 
             
              end
         | 
| 114 114 |  | 
| 115 | 
            +
              context '#juxt' do
         | 
| 116 | 
            +
                it 'from docs' do
         | 
| 117 | 
            +
                  get_range = r.juxt([->(*xs) { xs.min }, ->(*xs) { xs.max }])
         | 
| 118 | 
            +
                  expect(get_range.call(3, 4, 9, -3)).to eq([-3, 9])
         | 
| 119 | 
            +
                end
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
             | 
| 115 122 | 
             
              context '#memoize' do
         | 
| 116 123 | 
             
                it 'from docs' do
         | 
| 117 124 | 
             
                  count = 0
         | 
    
        data/spec/ramda/list_spec.rb
    CHANGED
    
    | @@ -221,6 +221,16 @@ describe Ramda::List do | |
| 221 221 | 
             
                end
         | 
| 222 222 | 
             
              end
         | 
| 223 223 |  | 
| 224 | 
            +
              context '#last' do
         | 
| 225 | 
            +
                it 'from docs' do
         | 
| 226 | 
            +
                  expect(r.last(['fi', 'fo', 'fum'])).to eq('fum')
         | 
| 227 | 
            +
                  expect(r.last([])).to eq(nil)
         | 
| 228 | 
            +
             | 
| 229 | 
            +
                  expect(r.last('abc')).to eq('c')
         | 
| 230 | 
            +
                  expect(r.last('')).to eq('')
         | 
| 231 | 
            +
                end
         | 
| 232 | 
            +
              end
         | 
| 233 | 
            +
             | 
| 224 234 | 
             
              context '#last_index_of' do
         | 
| 225 235 | 
             
                it 'from docs' do
         | 
| 226 236 | 
             
                  expect(r.last_index_of(3, [-1, 3, 3, 0, 1, 2, 3, 4])).to be(6)
         | 
| @@ -262,6 +272,16 @@ describe Ramda::List do | |
| 262 272 | 
             
                end
         | 
| 263 273 | 
             
              end
         | 
| 264 274 |  | 
| 275 | 
            +
              context '#partition' do
         | 
| 276 | 
            +
                it 'from docs' do
         | 
| 277 | 
            +
                  expect(r.partition(R.contains('s'), ['sss', 'ttt', 'foo', 'bars']))
         | 
| 278 | 
            +
                    .to eq([['sss', 'bars'], ['ttt', 'foo']])
         | 
| 279 | 
            +
             | 
| 280 | 
            +
                  expect(r.partition(R.contains('s'), a: 'sss', b: 'ttt', foo: 'bars'))
         | 
| 281 | 
            +
                    .to eq([{ a: 'sss', foo: 'bars' }, { b: 'ttt' }])
         | 
| 282 | 
            +
                end
         | 
| 283 | 
            +
              end
         | 
| 284 | 
            +
             | 
| 265 285 | 
             
              context '#pluck' do
         | 
| 266 286 | 
             
                it 'from docs' do
         | 
| 267 287 | 
             
                  expect(r.pluck(:a).call([{ a: 1 }, { a: 2 }])).to eq([1, 2])
         | 
| @@ -345,6 +365,15 @@ describe Ramda::List do | |
| 345 365 | 
             
                end
         | 
| 346 366 | 
             
              end
         | 
| 347 367 |  | 
| 368 | 
            +
              context '#slice' do
         | 
| 369 | 
            +
                it 'from docs' do
         | 
| 370 | 
            +
                  expect(r.slice(1, 3, ['a', 'b', 'c', 'd'])).to eq(['b', 'c'])
         | 
| 371 | 
            +
                  expect(r.slice(0, -1, ['a', 'b', 'c', 'd'])).to eq(['a', 'b', 'c'])
         | 
| 372 | 
            +
                  expect(r.slice(-3, -1, ['a', 'b', 'c', 'd'])).to eq(['b', 'c'])
         | 
| 373 | 
            +
                  expect(r.slice(0, 3, 'ramda')).to eq('ram')
         | 
| 374 | 
            +
                end
         | 
| 375 | 
            +
              end
         | 
| 376 | 
            +
             | 
| 348 377 | 
             
              context '#sort' do
         | 
| 349 378 | 
             
                it 'from docs' do
         | 
| 350 379 | 
             
                  diff = ->(a, b) { a - b }
         | 
    
        data/spec/ramda_spec.rb
    CHANGED
    
    | @@ -56,7 +56,9 @@ describe Ramda do | |
| 56 56 | 
             
              r(:is_empty)
         | 
| 57 57 | 
             
              r(:is_nil)
         | 
| 58 58 | 
             
              r(:join)
         | 
| 59 | 
            +
              r(:juxt)
         | 
| 59 60 | 
             
              r(:keys)
         | 
| 61 | 
            +
              r(:last)
         | 
| 60 62 | 
             
              r(:last_index_of)
         | 
| 61 63 | 
             
              r(:length)
         | 
| 62 64 | 
             
              r(:lt)
         | 
| @@ -75,6 +77,7 @@ describe Ramda do | |
| 75 77 | 
             
              r(:omit)
         | 
| 76 78 | 
             
              r(:once)
         | 
| 77 79 | 
             
              r(:or)
         | 
| 80 | 
            +
              r(:partition)
         | 
| 78 81 | 
             
              r(:pick)
         | 
| 79 82 | 
             
              r(:pick_all)
         | 
| 80 83 | 
             
              r(:pipe)
         | 
| @@ -91,6 +94,7 @@ describe Ramda do | |
| 91 94 | 
             
              r(:reject)
         | 
| 92 95 | 
             
              r(:repeat)
         | 
| 93 96 | 
             
              r(:reverse)
         | 
| 97 | 
            +
              r(:slice)
         | 
| 94 98 | 
             
              r(:sort)
         | 
| 95 99 | 
             
              r(:sort_by)
         | 
| 96 100 | 
             
              r(:split)
         |