degenerate 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +10 -0
- data/degenerate.gemspec +26 -0
- data/lib/degenerate/generators.rb +28 -0
- data/lib/degenerate/version.rb +3 -0
- data/lib/degenerate.rb +9 -0
- data/spec/lib/degenerate_spec.rb +33 -0
- data/spec/lib/generators_spec.rb +61 -0
- data/spec/spec_helper.rb +6 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac65b80667efb1b4e4a370b86545decd3e5d58b7
|
4
|
+
data.tar.gz: 5ce63cb196ee90a20c6ab33b5fca9364efdd82e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be0c4a49c1fe48cf8dd728b10c6088abb52005928f2ab67ca5603727c337b9f9a1c6efc52ced2d73684d51f88b615ada2656732a7c3ef93d82d1ed48b48ac22b
|
7
|
+
data.tar.gz: 2c392b8c239924c171dd59907104f29b4e1605293bc36dd354e1cb71be76d2496eee49717df0221335979f152dc2afd21fe51df7d6de64f3026ccb6587f74375
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Nate West
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Degenerate
|
2
|
+
|
3
|
+
[![Codeship Status for niftyn8/degenerate](https://codeship.com/projects/b2753af0-4a18-0132-8cc7-7ac1f13cf35d/status)](https://codeship.com/projects/46223)
|
4
|
+
|
5
|
+
Degenerate is a random data generator for use with [Generative](https://github.com/justincampbell/generative).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'degenerate'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Next require it in your `spec/spec_helper.rb` file:
|
18
|
+
|
19
|
+
require 'degenerate'
|
20
|
+
|
21
|
+
Degenerate automatically registers several primative generators with generative.
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
In your spec:
|
26
|
+
|
27
|
+
```rb
|
28
|
+
describe "#reverse" do
|
29
|
+
generative do
|
30
|
+
data(:string) { generate(:string) }
|
31
|
+
|
32
|
+
it "should preserve length" do
|
33
|
+
expect(string.reverse.length).to eq(string.length)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it ( https://github.com/[my-github-username]/degenerate/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/degenerate.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'degenerate/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "degenerate"
|
8
|
+
spec.version = Degenerate::VERSION
|
9
|
+
spec.authors = ["Nate West", "Eric West", "Jack Newton"]
|
10
|
+
spec.email = ["natescott.west@gmail.com", "esw9999@gmail.com", "eternal.turtles@gmail.com"]
|
11
|
+
spec.summary = %q{Random data generator for use with Generative.}
|
12
|
+
spec.description = %q{Random data generator for use with Generative.}
|
13
|
+
spec.homepage = "http://github.com/niftyn8/degenerate"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec-core', '~> 3.1.3'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
25
|
+
spec.add_development_dependency 'pry'
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Degenerate
|
2
|
+
module Generators
|
3
|
+
INTEGER_MAX = (2**(0.size * 8 -2) -1) / 2
|
4
|
+
INTEGER_MIN = -(INTEGER_MAX)
|
5
|
+
|
6
|
+
def self.integer
|
7
|
+
->(opts={}) { rand((opts[:min] || INTEGER_MIN)..(opts[:max] || INTEGER_MAX)) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.string
|
11
|
+
->(opts={}) { random_string(opts[:length] || random_int) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.array
|
15
|
+
->(opts={}) { [].class.new(opts[:size] || random_int) }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self.random_string(length)
|
21
|
+
[].class.new(length) { "" << rand(0..3000) }.join
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.random_int
|
25
|
+
Degenerate::Generators.integer.call(min: 0, max: 9999)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/degenerate.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'degenerate/version'
|
2
|
+
require 'degenerate/generators'
|
3
|
+
require 'generative'
|
4
|
+
|
5
|
+
module Degenerate
|
6
|
+
Generative.register_generator(:string, Generators.string)
|
7
|
+
Generative.register_generator(:integer, Generators.integer)
|
8
|
+
Generative.register_generator(:array, Generators.array)
|
9
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Degenerate do
|
4
|
+
describe "string generator" do
|
5
|
+
generative do
|
6
|
+
data(:string) { generate(:string) }
|
7
|
+
|
8
|
+
it "registers a string generator" do
|
9
|
+
expect(string).to be_a(String)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "integer generator" do
|
15
|
+
generative do
|
16
|
+
data(:integer) { generate(:integer) }
|
17
|
+
|
18
|
+
it "registers a integer generator" do
|
19
|
+
expect(integer).to be_a(Integer)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "array generator" do
|
25
|
+
generative do
|
26
|
+
data(:array) { generate(:array) }
|
27
|
+
|
28
|
+
it "registers a array generator" do
|
29
|
+
expect(array).to be_a(Array)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative '../spec_helper.rb'
|
2
|
+
|
3
|
+
RSpec.describe Degenerate::Generators do
|
4
|
+
describe ".integer" do
|
5
|
+
generative do
|
6
|
+
data(:integer) { Degenerate::Generators.integer }
|
7
|
+
|
8
|
+
it "returns a proc" do
|
9
|
+
expect(integer).to be_a(Proc)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "'s generator returns a integer" do
|
13
|
+
expect(integer.call).to be_a(Integer)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "will never be greater than an imposed limit" do
|
17
|
+
expect(integer.call).to be < described_class::INTEGER_MAX
|
18
|
+
end
|
19
|
+
|
20
|
+
it "will never be less than an imposed minimum" do
|
21
|
+
expect(integer.call).to be > described_class::INTEGER_MIN
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".string" do
|
27
|
+
generative do
|
28
|
+
it "returns a proc" do
|
29
|
+
expect(Degenerate::Generators.string).to be_a(Proc)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "'s generator returns a string" do
|
33
|
+
expect(Degenerate::Generators.string.call).to be_a(String)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".array" do
|
39
|
+
generative do
|
40
|
+
it "returns a proc" do
|
41
|
+
expect(Degenerate::Generators.array).to be_a(Proc)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "'s generator returns a array" do
|
45
|
+
expect(Degenerate::Generators.array.call).to be_a(Array)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".random_int" do
|
51
|
+
generative do
|
52
|
+
it "is never greater than 9999" do
|
53
|
+
expect(Degenerate::Generators.random_int).to be <= 9999
|
54
|
+
end
|
55
|
+
|
56
|
+
it "will never be negative" do
|
57
|
+
expect(Degenerate::Generators.random_int).to be >= 0
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: degenerate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nate West
|
8
|
+
- Eric West
|
9
|
+
- Jack Newton
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-11-12 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.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.6'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rspec-core
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 3.1.3
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.1.3
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 3.1.0
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 3.1.0
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: pry
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
description: Random data generator for use with Generative.
|
86
|
+
email:
|
87
|
+
- natescott.west@gmail.com
|
88
|
+
- esw9999@gmail.com
|
89
|
+
- eternal.turtles@gmail.com
|
90
|
+
executables: []
|
91
|
+
extensions: []
|
92
|
+
extra_rdoc_files: []
|
93
|
+
files:
|
94
|
+
- ".gitignore"
|
95
|
+
- ".rspec"
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- degenerate.gemspec
|
101
|
+
- lib/degenerate.rb
|
102
|
+
- lib/degenerate/generators.rb
|
103
|
+
- lib/degenerate/version.rb
|
104
|
+
- spec/lib/degenerate_spec.rb
|
105
|
+
- spec/lib/generators_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
homepage: http://github.com/niftyn8/degenerate
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.2.2
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: Random data generator for use with Generative.
|
131
|
+
test_files:
|
132
|
+
- spec/lib/degenerate_spec.rb
|
133
|
+
- spec/lib/generators_spec.rb
|
134
|
+
- spec/spec_helper.rb
|