randeaux 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 +7 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/randeaux +3 -0
- data/bin/setup +8 -0
- data/lib/randeaux.rb +33 -0
- data/lib/randeaux/version.rb +3 -0
- data/randeaux.gemspec +24 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 896baacda3e2ce0f1919f8fcf05f2d7b606c28dd
|
4
|
+
data.tar.gz: 15a4e76d92a35d6cbc3264c6ece68c54c525b69d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3494a950994eaa04e61784f51c16dedf5d15406158a923484b52ae3747f7553f803f381192a8dae3e28747aa964937481c56959ec576ac0e1a328bb31c3d6e58
|
7
|
+
data.tar.gz: e26af639ffe7d7e7180194dfd588deba2e2ff204850e6460791bcfd5a3a6ee73c0abeee3741d62994764080fcf652157748abeac8d69f5c221a3d516bf192b3e
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jeff Schneider
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 jjschnei
|
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,25 @@
|
|
1
|
+
## Usage
|
2
|
+
|
3
|
+
Make sure to include the randeaux gem.
|
4
|
+
|
5
|
+
Randeaux returns an array of random elements, indexes, keys and values selected at random from an array or hash.
|
6
|
+
|
7
|
+
The randeaux methods takes two arguments: the data structure you wish to sample (hash or array) and an optional argument for the number of elements you wish to be returned. By default, randeaux will return one random element from the data structure.
|
8
|
+
|
9
|
+
The randeaux_index method takes the same arguments, except it returns random indexes instead of random values.
|
10
|
+
|
11
|
+
## Development
|
12
|
+
|
13
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
14
|
+
|
15
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
16
|
+
|
17
|
+
## Contributing
|
18
|
+
|
19
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jjschnei/randeaux.
|
20
|
+
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
25
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "randeaux"
|
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/randeaux
ADDED
data/bin/setup
ADDED
data/lib/randeaux.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "randeaux/version"
|
2
|
+
|
3
|
+
module Randeaux
|
4
|
+
|
5
|
+
def randeaux(data_structure, n=1)
|
6
|
+
output_arry = []
|
7
|
+
if data_structure.class.to_s == 'Hash'
|
8
|
+
n.times do
|
9
|
+
output_arry << data_structure.values.sample
|
10
|
+
end
|
11
|
+
elsif data_structure.class.to_s == 'Array'
|
12
|
+
n.times do
|
13
|
+
output_arry << data_structure.sample
|
14
|
+
end
|
15
|
+
end
|
16
|
+
output_arry
|
17
|
+
end
|
18
|
+
|
19
|
+
def randeaux_index(data_structure, n=1)
|
20
|
+
output_arry = []
|
21
|
+
if data_structure.class.to_s == 'Hash'
|
22
|
+
n.times do
|
23
|
+
output_arry << data_structure.keys.sample
|
24
|
+
end
|
25
|
+
elsif data_structure.class.to_s == 'Array'
|
26
|
+
n.times do
|
27
|
+
output_arry << data_structure.index(data_structure.sample)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
output_arry
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/randeaux.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 'randeaux/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "randeaux"
|
8
|
+
spec.version = Randeaux::VERSION
|
9
|
+
spec.authors = ["Jeff Schneider", "David Valencia", "Kyle Cierzan"]
|
10
|
+
spec.email = ["davencia1@gmail.com","jeffjschneider@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Return random elements, indexes, keys and values from arrays and hashes}
|
13
|
+
spec.description = %q{Return randomized data from arrays and hashes. The randeaux methods takes two arguments: the data structure you wish to sample and an optional argument for the number of elements you wish to be returned. By default, randeaux will return one random element.}
|
14
|
+
spec.homepage = "https://github.com/jjschnei/randeaux"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: randeaux
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Schneider
|
8
|
+
- David Valencia
|
9
|
+
- Kyle Cierzan
|
10
|
+
autorequire:
|
11
|
+
bindir: exe
|
12
|
+
cert_chain: []
|
13
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.11'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.11'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '10.0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '10.0'
|
43
|
+
description: 'Return randomized data from arrays and hashes. The randeaux methods
|
44
|
+
takes two arguments: the data structure you wish to sample and an optional argument
|
45
|
+
for the number of elements you wish to be returned. By default, randeaux will return
|
46
|
+
one random element.'
|
47
|
+
email:
|
48
|
+
- davencia1@gmail.com
|
49
|
+
- jeffjschneider@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/console
|
60
|
+
- bin/randeaux
|
61
|
+
- bin/setup
|
62
|
+
- lib/randeaux.rb
|
63
|
+
- lib/randeaux/version.rb
|
64
|
+
- randeaux.gemspec
|
65
|
+
homepage: https://github.com/jjschnei/randeaux
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.4.5
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Return random elements, indexes, keys and values from arrays and hashes
|
89
|
+
test_files: []
|