I hereby claim:
- I am apeiros on github.
- I am apeiros (https://keybase.io/apeiros) on keybase.
- I have a public key whose fingerprint is 8069 6F42 1FD4 35A8 F0FD 23B6 97C0 D061 072D 0718
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| class Hash | |
| def map_keys | |
| map_pairs { |key, value| [yield(key), value] } | |
| end | |
| def map_keys! | |
| map_pairs! { |key, value| [yield(key), value] } | |
| end | |
| def map_values |
| class String | |
| def match_all(regex) | |
| if block_given? | |
| scan(regex) { yield $~ } | |
| else | |
| enum_for(:scan, regex).map { $~ } | |
| end | |
| end | |
| end |
| def ==(other) | |
| other.data == @data | |
| rescue NoMethodError | |
| false | |
| end |
| def invoke(verb, path, expected_code, additional_params=nil) | |
| if additional_params | |
| response = RestClient.public_send(verb, restclient_uri(path), additional_params.to_json, core_params(verb)) | |
| else | |
| response = RestClient.public_send(verb, restclient_uri(path), core_params(verb)) | |
| end | |
| rescue RestClient::Exception => e | |
| e | |
| rescue | |
| response |
| module MyApp | |
| class Link | |
| def self.json(json_string) | |
| new(JSON.parse(json_string)) # could add a json-schema validation here, fitting Link | |
| end | |
| attr_accessor :rel, :href | |
| def initialize(rel: nil, href: nil) | |
| @rel = rel |
| class Namespace | |
| def initialize(current=[], &block) | |
| @current = current | |
| instance_eval(&block) | |
| end | |
| def namespace(name, &block) | |
| Namespace.new(@current+[name], &block) | |
| end |
| # encoding: utf-8 | |
| require 'spreadsheet' | |
| require 'stringio' | |
| class Spreadsheet::Workbook |
| module Test::Unit::Assertions | |
| def assert_unordered_equal(expected, actual, message=nil) | |
| full_message = build_message(message, "<?> expected but was\n<?>.\n", expected, actual) | |
| assert_block(full_message) { | |
| seen = Hash.new(0) | |
| expected.each { |e| seen[e] += 1 } | |
| actual.each { |e| seen[e] -= 1 } | |
| seen.invert.keys == [0] | |
| } | |
| end |
| class Array | |
| def split(*separator, include_separator: false) | |
| if separator.empty? | |
| if !block_given? | |
| return enum_for(__method__) if separator.empty? && !block_given? | |
| end | |
| elsif block_given? | |
| raise ArgumentError, "Must either pass a block or a separator, not both" | |
| else | |
| separator = separator.first |