rlab-assert 0.1.0 → 0.1.1

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: e6938e62081cbd09fc601ff5d7c00f66e68b1b61
4
- data.tar.gz: 56a1a0c69cdd1de23185353b272159ea0b493d97
3
+ metadata.gz: 26ee1e83c66567717b164c2e89a34aa7cfff9f59
4
+ data.tar.gz: 1a4bd0774d5d08c1ee407bfdb95b08be1657d262
5
5
  SHA512:
6
- metadata.gz: 3ed5a18f1393c4ed0610e37e13acf0e492f3357ac618f0ed66638a15e1afe0fbc490f9a90e868b9a72e487a1a23d91ca89365a52599b8c3ae69c194377876288
7
- data.tar.gz: e3493df70e1ec449ffa61e2c2e9e7b84ed3fafd017c826748481351c33b701603451647e68310373d33976f6422cce110a09c41ceb735969994ec255b5541ec7
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')
@@ -1,5 +1,5 @@
1
1
  module RLab
2
2
  module Assert
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data/lib/rlab/assert.rb CHANGED
@@ -7,6 +7,8 @@ require_relative "assert/refutation"
7
7
  require_relative "assert/syntax"
8
8
  require_relative "assert/version"
9
9
 
10
+ require "rlab/util"
11
+
10
12
  module RLab
11
13
  module Assert
12
14
  def self.filter_trace trace
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.0
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: []