-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben Slaughter
committed
Aug 14, 2015
1 parent
8b0e958
commit 57ef221
Showing
24 changed files
with
273 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Metrics/LineLength: | ||
Exclude: | ||
- '*.gemspec' | ||
- 'spec/**/*_spec.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require 'utilise/augment/bool.rb' | ||
require 'utilise/augment/bool' | ||
|
||
# Extend existing ruby class Array | ||
class Array | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'utilise/string' | ||
|
||
module Utilise | ||
module Augment | ||
# Extends a hash to modify keys | ||
module Hash | ||
# Transforms all keys to snake case | ||
def snake_keys | ||
transform_keys(self) { |key| key.snake } | ||
end | ||
|
||
# Transforms all keys to camel case | ||
def camel_keys | ||
transform_keys(self) { |key| key.camel } | ||
end | ||
|
||
# Transforms all keys to space case | ||
def space_keys | ||
transform_keys(self) { |key| key.space } | ||
end | ||
|
||
private | ||
|
||
# Deep transform keys | ||
# An awesome piece of code from rails | ||
# apidock.com/rails/v4.2.1/Hash/_deep_transform_keys_in_object%21 | ||
def transform_keys(object, &block) | ||
case object | ||
when Hash | ||
object.each_with_object({}) do |(key, value), result| | ||
result[yield(key)] = transform_keys(value, &block) | ||
end | ||
when Array | ||
object.map { |e| transform_keys(e, &block) } | ||
else | ||
object | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
require 'utilise/augment/bool.rb' | ||
require 'utilise/augment/bool' | ||
require 'utilise/augment/hash' | ||
|
||
# Extend existing ruby class Hash | ||
class Hash | ||
include Utilise::Augment::Bool | ||
include Utilise::Augment::Hash | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
require 'utilise/augment/bool.rb' | ||
require 'utilise/augment/bool' | ||
require 'utilise/augment/modify' | ||
|
||
# Extend existing ruby class Symbol | ||
class Symbol | ||
include Utilise::Augment::Bool | ||
include Utilise::Augment::Modify | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require 'utilise/augment/time.rb' | ||
require 'utilise/augment/time' | ||
|
||
# Extend existing ruby class Time | ||
class Time | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,3 @@ | |
Coveralls.wear! | ||
SimpleCov.start | ||
require 'utilise' | ||
|
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.