optionally 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/optionally.rb +5 -0
- data/lib/optionally/required.rb +16 -0
- data/lib/optionally/version.rb +3 -0
- data/optionally.gemspec +24 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODliNDViMjMyMzQ2NjM3YTI4NjE0OWQ1NzI2NWE5YjBmMzQ0MmM2Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MzNmMmU1MTE4MmY4NjUzMzRiMzcwODg5Mzc2ZDNiMTMzOWU2ZDY0Mw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OTM2Y2JmZGE0M2EzYmQ1ODBlNWI5MDRiNjNkN2FiODhkNjlhNjBkMGQ2MmI1
|
10
|
+
NWU4YTYwOTMyYTUzYzJlZGVlMmE4MjBmMmE1ZTU5ZjFiOGZhYzkzZDEyNWRk
|
11
|
+
M2UxMmFjOTE2YWNhNzExMmY4NDczZWNlOTQzNjY5ZjBmZTdjNjk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDA5NDFmMTAwNzI3MGQwYjgyMTMwZDljYjk5MDgwYjcwYmQyMmE3NDY1YTQ4
|
14
|
+
NWVmODMyZDU5MDE5OThmNmMwMTI5ZTllOTEzMWIxZTdkMDM5YWViMzRhZDE2
|
15
|
+
NzA2MjlkZGRlMzE3YjkzNjgzNTA0YTQyMDllZGNiYzFkMmE4NWY=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Dennis Walters
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Optionally
|
2
|
+
|
3
|
+
This is, like, so totally just a tiny little mix-in that lets your classes
|
4
|
+
be super cereals about the stuff their methods get in options hashes, fersure.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'optionally'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install optionally
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'optionally'
|
26
|
+
|
27
|
+
class Something
|
28
|
+
include Optionally::Required
|
29
|
+
|
30
|
+
def fersure(options = {})
|
31
|
+
check_required_options(options, :totally)
|
32
|
+
|
33
|
+
puts "totally #{options[:totally]}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
s = Something.new
|
38
|
+
s.fersure(totally: 'like, freal')
|
39
|
+
# "totally like, freal"
|
40
|
+
# => nil
|
41
|
+
|
42
|
+
s.fersure(bummer: "gag me with a spoon")
|
43
|
+
# ArgumentError: totally is required
|
44
|
+
# Big Ugly Stacktrace (TM)
|
45
|
+
```
|
46
|
+
|
47
|
+
## Contributing ##
|
48
|
+
|
49
|
+
Do you use git-flow? I sure do. Please base anything you do off of
|
50
|
+
[the develop branch](https://github.com/ess/optionally/tree/develop).
|
51
|
+
|
52
|
+
1. Fork it.
|
53
|
+
2. Perform some BDD magic. Seriously. Be testing.
|
54
|
+
3. Submit a pull request.
|
55
|
+
|
56
|
+
## License ##
|
57
|
+
|
58
|
+
MIT License. Copyright 2015 Dennis Walters
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "optionally"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/optionally.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Optionally
|
2
|
+
module Required
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(self)
|
5
|
+
end
|
6
|
+
|
7
|
+
def check_required_options(candidate, *required_keys)
|
8
|
+
required_keys.each do |key|
|
9
|
+
unless candidate.keys.include?(key)
|
10
|
+
raise ArgumentError.new("#{key} is required")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/optionally.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'optionally/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "optionally"
|
8
|
+
spec.version = Optionally::VERSION
|
9
|
+
spec.authors = ["Dennis Walters"]
|
10
|
+
spec.email = ["pooster@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Quick and dirty required fields for options hashes}
|
13
|
+
spec.homepage = "https://github.com/ess/optionally"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: optionally
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dennis Walters
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- pooster@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- .travis.yml
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/optionally.rb
|
72
|
+
- lib/optionally/required.rb
|
73
|
+
- lib/optionally/version.rb
|
74
|
+
- optionally.gemspec
|
75
|
+
homepage: https://github.com/ess/optionally
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.5
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Quick and dirty required fields for options hashes
|
99
|
+
test_files: []
|