finishing_moves 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 70d5165e29dbddcb1383c9216698d22a734e8394
4
- data.tar.gz: 0a7bea820fa4b2a2423f20f43ab2ca9243393dd8
3
+ metadata.gz: 7edf17bb22f39f2a5ef98ff9a636605c0dfc0772
4
+ data.tar.gz: 9f60832e76dfa4d8738844398bfef705dc76a059
5
5
  SHA512:
6
- metadata.gz: 823eb4ebc4605b5cad2e3dcfb1ed2609ffb789bd5169c8c9d59bce26733924f125844148a7478a555e8afe5da9556c106e8aa50c867c0e44862f720747a75f20
7
- data.tar.gz: 308f6cc084cb11a58e110021e2dc73967cd4db7e51eeb3bb57ff41f7b95d8e0f86819a544f1e1fc94b6a7e7caff600aa65177bfe0344c49d0aa70f0ebf30c922
6
+ metadata.gz: 89e13ebcf8b735570055a2d1a3270989b9424f2c47947c1f1c59af6451c1c2fa6ebc6b2ac92d93160bc1154738db2891110e269143deaae90173eee0498a1cdb
7
+ data.tar.gz: 16e94f9abb4f914aaff7b37cacc9734ae07269a52d2eae05848648ab9e67e4833cc97a662cb24c629f541fcfd6b783db40f5eddb906f77772d05e53481ce442a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- finishing_moves (0.1.0)
4
+ finishing_moves (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -8,17 +8,25 @@ In gamer terms, if standard Ruby methods are your default moves, `finishing_move
8
8
 
9
9
  ## Development approach
10
10
 
11
- - **Never** override default Ruby behavior, only add functionality. No hacks.
11
+ - **Never** override default Ruby behavior, only add functionality.
12
12
  - Follow the Unix philosophy of *"Do one job really well."*
13
13
  - Minimize assumptions within the method, e.g. avoid formatting output, mutating values, and long conditional logic flows.
14
14
  - Test all the things.
15
15
 
16
16
  ## Installation
17
17
 
18
+ Gemfile
18
19
  ```
19
- (Gemification coming soon!)
20
+ gem 'finishing_moves'
20
21
  ```
21
22
 
23
+ Command line
24
+ ```
25
+ gem install 'finishing_moves'
26
+ ```
27
+
28
+ [Here's the gem link](https://rubygems.org/gems/finishing_moves), if you like looking at that stuff.
29
+
22
30
  ## Current Finishers
23
31
 
24
32
  ### Extensions to `Object`
@@ -204,9 +212,6 @@ var = nil_chain(Geomancer.reset_ley_lines) { summon_fel_beast[:step_3].scry }
204
212
 
205
213
  `nil_chain` is aliased to `chain` for more brevity, and `method_chain` for alternative clarity.
206
214
 
207
-
208
- ---
209
-
210
215
  #### `Object#bool_chain`
211
216
 
212
217
  This is the same logic under the hood as `nil_chain`, however we forcibly return a boolean `false` instead of `nil` if the chain breaks.
@@ -225,8 +230,6 @@ nil_chain(false) { a.b.c.hello }
225
230
  # => false
226
231
  ```
227
232
 
228
- ---
229
-
230
233
  #### `Object#same_as`
231
234
 
232
235
  Comparison operator that normalizes both sides into strings, then runs them over `==`.
@@ -283,8 +286,6 @@ user.same_as 'FACELESS_ONE'
283
286
  # => false
284
287
  ```
285
288
 
286
- ---
287
-
288
289
  #### `Object#class_exists?`
289
290
 
290
291
  > *I just want to know if [insert class name] has been defined!*
@@ -329,8 +330,6 @@ class_exists? :DefinitelyFakeClass
329
330
  # => false (at least it better be; if you actually use this name, I will find you...)
330
331
  ```
331
332
 
332
- ---
333
-
334
333
  #### `Object#not_nil?`
335
334
 
336
335
  Because that dangling `!` on the front of a call to `nil?` is just oh so not-ruby-chic.
@@ -342,9 +341,7 @@ nil.not_nil?
342
341
  # => true
343
342
  ```
344
343
 
345
- There, much more legible. Now pass me my fedora and another PBR.
346
-
347
- ---
344
+ Much better. Now pass me another PBR and my fedora.
348
345
 
349
346
  ### Extensions to `Hash`
350
347
 
@@ -373,8 +370,6 @@ power_rangers.delete! :radiant_orchid
373
370
  # It probably would've triggered if I included Kimberly
374
371
  ```
375
372
 
376
- ---
377
-
378
373
  #### `Hash#delete_each`
379
374
  Deletes all records in a hash matching the keys passed in as an array. Returns a hash of deleted entries. Silently ignores any keys which are not found.
380
375
 
@@ -397,8 +392,6 @@ mega_man_bosses
397
392
  # => { :wood_man => 4 }
398
393
  ```
399
394
 
400
- ---
401
-
402
395
  #### `Hash#delete_each!`
403
396
 
404
397
  Same logic as `delete_each`, but return the modified hash, and discard the deleted values.
@@ -419,11 +412,9 @@ mega_man_bosses.delete_each! :crash_man, :quick_man
419
412
  # => { }
420
413
  ```
421
414
 
422
- ---
423
-
424
415
  ### `Fixnum#length` and `Bignum#length`
425
416
 
426
- Ruby doesn't provide a native way to see how many digits are in an integer, but that's exactly what we worry about anytime out database `INT` lengths collide with Ruby `Fixnum` or `Bignum` values.
417
+ Ruby doesn't provide a native way to see how many digits are in an integer, but that's exactly what we worry about anytime database `INT` lengths collide with Ruby `Fixnum` or `Bignum` values.
427
418
 
428
419
  ```ruby
429
420
  1.length
@@ -459,17 +450,17 @@ For consistency, we added matching methods to `Float` and `BigDecimal` that simp
459
450
  # => ArgumentError: Cannot get length: "1.2654377184388666e+21" is not an integer
460
451
  ```
461
452
 
462
- ---
463
-
464
453
  ### Typecasting *to* `Boolean`
465
454
 
466
455
  Boolean values are frequently represented as strings and integers in databases and file storage. So we always thought it was a little odd that Ruby lacked a boolean typecasting method, given the proliferation of `to_*` methods for `String`, `Symbol`, `Integer`, `Float`, `Hash`, etc.
467
456
 
468
- So we made one for strings and integers.
457
+ So we made one for strings, integers, and nil.
469
458
 
470
459
  #### `String#to_bool`
471
460
 
472
- Strings get analyzed and return true/false for a small set of potential values. These comparisons are case-insensitive.
461
+ Strings get analyzed and return `true` or `false` for a small set of potential values.
462
+
463
+ These comparisons are not case-sensitive.
473
464
 
474
465
  ```ruby
475
466
  ['1', 't', 'true', 'on', 'y', 'yes'].each do |true_string|
@@ -498,7 +489,7 @@ end
498
489
  A string with anything other than these matching values will throw an error.
499
490
 
500
491
  ```ruby
501
- ["foo", "tru", "trueish", "druish", "000"].each do |bad_string|
492
+ ["foo", "tru", "trueish", "druish", "00", "000"].each do |bad_string|
502
493
  bad_string.to_bool
503
494
  # => ArgumentError: invalid value for Boolean
504
495
  end
@@ -506,7 +497,7 @@ end
506
497
 
507
498
  #### `Fixnum#to_bool`
508
499
 
509
- A zero is false, a one is true. That's it. Everything else throws `ArgumentError`
500
+ A zero is false, a one is true. That's it. Everything else throws `ArgumentError`.
510
501
 
511
502
  ```ruby
512
503
  0.to_bool
@@ -542,7 +533,7 @@ nil.to_bool == false
542
533
 
543
534
  #### `TrueClass#to_bool` and `FalseClass#to_bool`
544
535
 
545
- They return what you expect, we added them simply for sake of consistency, in case your code calls `to_bool` on a variable of indeterminate type.
536
+ In case your code calls `to_bool` on a variable of indeterminate type, they return what you expect.
546
537
 
547
538
  ```ruby
548
539
  true.to_bool
@@ -552,11 +543,9 @@ false.to_bool
552
543
  # => false
553
544
  ```
554
545
 
555
- ---
556
-
557
546
  ### Typecasting *from* `Boolean` and `Nil`
558
547
 
559
- Complementing the methods to typecast boolean values coming out of data storage, we have methods to convert booleans and `nil` into string and symbol representations.
548
+ Complementing the methods to typecast boolean values coming out of data storage, we have methods to convert booleans and `nil` into integer and symbol representations.
560
549
 
561
550
  ```ruby
562
551
  true.to_i
@@ -570,33 +559,31 @@ false.to_sym
570
559
  # => :false
571
560
 
572
561
  nil.to_i
573
- # => 0 (follows same logic as `NilClass#to_bool`)
562
+ # => 0 (following same logic as `NilClass#to_bool`)
574
563
  nil.to_sym
575
564
  # => :nil
576
565
  ```
577
566
 
578
- ## Share your finishing moves!
579
-
580
- ### Got an idea for another finisher?
567
+ ## Add your own finisher!
581
568
 
582
569
  1. Fork this repo
583
570
  2. Write your tests
584
571
  3. Add your finisher
585
- 4. Repeat steps 2 and 3 until badass
572
+ 4. Repeat steps 2 and 3 until you see a brilliant luster
586
573
  5. Submit a pull request
587
- 6. Everyone kicks even more ass!
588
574
 
589
575
  ###### Got a good nerdy reference for our code samples?
590
576
  We'll take pull requests on those too. Bonus karma points if you apply the reference to the specs too.
591
577
 
592
- ## License
578
+ ## Credits
593
579
 
594
- Finishing Moves is distributed under MIT license.
580
+ ![forge software](http://www.forgecrafted.com/logo.png)
595
581
 
596
- Copyright (c) 2015 Forge Software, LLC
582
+ Finishing Moves is maintained and funded by [Forge Software (forgecrafted.com)](http://www.forgecrafted.com)
597
583
 
598
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
584
+ If you like our code, please give us a hollar if your company needs outside pro's who write damn-good code AND run servers at the same time!
599
585
 
600
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
586
+ ## License
601
587
 
602
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
588
+ Finishing Moves is Copyright 20XX (that means "forever") Forge Software, LLC. It is free software, and may be
589
+ redistributed under the terms specified in the LICENSE file.
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Small, focused, incredibly useful methods added to core Ruby classes.}
13
13
  s.description = <<-EOF
14
14
  Ruby includes a huge amount of default awesomeness that tackles most common development challenges. But every now and then, you find yourself in a situation where an elaborate-yet-precise coding maneuver wins the day. Finishing Moves is a collection of methods designed to assist in those just-typical-enough-to-be-annoying scenarios.
15
-
16
- In gamer terms, if standard Ruby methods are your default actions, finishing_moves would be mana-consuming techniques. Your cooldown spells. Your grenades (there's never enough grenades). In the right situation, they kick serious cyclomatic butt.
17
15
  EOF
18
16
  s.homepage = "https://github.com/forgecrafted/finishing_moves"
19
17
  s.license = "MIT"
@@ -10,7 +10,6 @@ class Object
10
10
  return ret_val
11
11
  end
12
12
  end
13
- alias_method :chain, :nil_chain
14
13
  alias_method :method_chain, :nil_chain
15
14
 
16
15
  def bool_chain(&block)
@@ -38,5 +37,11 @@ class Object
38
37
  end
39
38
  end
40
39
 
40
+ def cascade(&block)
41
+ loop do
42
+ yield
43
+ break
44
+ end
45
+ end
41
46
 
42
47
  end
@@ -1,3 +1,3 @@
1
1
  module FinishingMoves
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finishing_moves
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Koehl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-17 00:00:00.000000000 Z
12
+ date: 2014-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rb-readline
@@ -83,8 +83,6 @@ dependencies:
83
83
  version: '0'
84
84
  description: |2
85
85
  Ruby includes a huge amount of default awesomeness that tackles most common development challenges. But every now and then, you find yourself in a situation where an elaborate-yet-precise coding maneuver wins the day. Finishing Moves is a collection of methods designed to assist in those just-typical-enough-to-be-annoying scenarios.
86
-
87
- In gamer terms, if standard Ruby methods are your default actions, finishing_moves would be mana-consuming techniques. Your cooldown spells. Your grenades (there's never enough grenades). In the right situation, they kick serious cyclomatic butt.
88
86
  email:
89
87
  - frank@forgecrafted.com
90
88
  - chris@forgecrafted.com