rlab-assert 0.1.0 → 0.1.1
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/.gitignore +1 -0
- data/bin/rake +16 -0
- data/lib/rlab/assert/version.rb +1 -1
- data/lib/rlab/assert.rb +2 -0
- data/lib/rlab/util.rb +66 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ee1e83c66567717b164c2e89a34aa7cfff9f59
|
4
|
+
data.tar.gz: 1a4bd0774d5d08c1ee407bfdb95b08be1657d262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ef84bcc7c631de9d3fc293491217e2d6b8c06f10ed2776534c8106804445e47e8bf669b093e8d9fa51f16de7e8c48c3fc2091f1aca9ca76625c9be943df3a2
|
7
|
+
data.tar.gz: 807e20fa8a4bbfd95013ce652975dc7147bd2395275cc56da2df21663861f1e248c83c9aa65a6570264f7c8fe4d0be114cb866aa3a5f57b52abefec3dc1488d6
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/lib/rlab/assert/version.rb
CHANGED
data/lib/rlab/assert.rb
CHANGED
data/lib/rlab/util.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module RLab
|
2
|
+
module Util
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def extract_key_args hsh, *args
|
6
|
+
defaults, args = extract_hash args
|
7
|
+
unknown_args = hsh.keys - (args + defaults.keys)
|
8
|
+
missing_args = args - hsh.keys
|
9
|
+
unless unknown_args.empty? and missing_args.empty?
|
10
|
+
raise ArgumentError, key_arg_error(unknown_args, missing_args)
|
11
|
+
end
|
12
|
+
(args + defaults.keys).map do |arg|
|
13
|
+
hsh.fetch arg do defaults.fetch arg end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def extract_hash ary
|
18
|
+
if ary.last.is_a? Hash
|
19
|
+
hsh = ary.pop
|
20
|
+
else
|
21
|
+
hsh = {}
|
22
|
+
end
|
23
|
+
[hsh, ary]
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_camel_case str
|
27
|
+
str = "_#{str}"
|
28
|
+
str.gsub!(%r{_[a-z]}) { |snake| snake.slice(1).upcase }
|
29
|
+
str.gsub!('/', '::')
|
30
|
+
str
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_snake_case str
|
34
|
+
str = str.gsub '::', '/'
|
35
|
+
# Convert FOOBar => FooBar
|
36
|
+
str.gsub! %r{[[:upper:]]{2,}} do |uppercase|
|
37
|
+
bit = uppercase[0]
|
38
|
+
bit << uppercase[1...-1].downcase
|
39
|
+
bit << uppercase[-1]
|
40
|
+
bit
|
41
|
+
end
|
42
|
+
# Convert FooBar => foo_bar
|
43
|
+
str.gsub! %r{[[:lower:]][[:upper:]]+[[:lower:]]} do |camel|
|
44
|
+
bit = camel[0]
|
45
|
+
bit << '_'
|
46
|
+
bit << camel[1..-1].downcase
|
47
|
+
end
|
48
|
+
str.downcase!
|
49
|
+
str
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def key_arg_error unknown, missing
|
55
|
+
str = "bad arguments. "
|
56
|
+
if unknown.any?
|
57
|
+
str.concat " unknown: #{unknown.join ', '}"
|
58
|
+
str.concat "; " if missing.any?
|
59
|
+
end
|
60
|
+
if missing.any?
|
61
|
+
str.concat " missing: #{missing.join ', '}"
|
62
|
+
end
|
63
|
+
str
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlab-assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ntl
|
@@ -61,10 +61,12 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- ".bundle/config"
|
64
|
+
- ".gitignore"
|
64
65
|
- ".travis.yml"
|
65
66
|
- Gemfile
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
69
|
+
- bin/rake
|
68
70
|
- bin/tests
|
69
71
|
- lib/rlab/assert.rb
|
70
72
|
- lib/rlab/assert/assertion.rb
|
@@ -76,6 +78,7 @@ files:
|
|
76
78
|
- lib/rlab/assert/refutation.rb
|
77
79
|
- lib/rlab/assert/syntax.rb
|
78
80
|
- lib/rlab/assert/version.rb
|
81
|
+
- lib/rlab/util.rb
|
79
82
|
- rlab-assert.gemspec
|
80
83
|
homepage: https://github.com/ntl/rlab-assert
|
81
84
|
licenses: []
|