time_turner 0.1.0
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/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +68 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +6 -0
- data/lib/time_turner.rb +32 -0
- data/lib/version.rb +3 -0
- data/time_turner.gemspec +42 -0
- metadata +117 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 58422f5306dedcda95a04da03aecd75dc2564867
|
|
4
|
+
data.tar.gz: 1e53fecce97f5c0c364be0dc38e193607a6d893d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 572330487d2fe19e2acb94cc6e157b3c2ad238e75492bab842d1c9e268aa5334ef3e7a2b96433f0ac5370ff1cb63a3c8745c755a86eef16f1948130b6a58db3b
|
|
7
|
+
data.tar.gz: b715598c66b9cccdbe91e451f50826ab70a8b2ab0f346a6a16488eb828430eac6075fca6631d11cda09951febc6b21909859237db1d7a69609587030324c8287
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
require:
|
|
3
|
+
- rubocop-rspec
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 2.3
|
|
6
|
+
Exclude:
|
|
7
|
+
- 'vendor/**/*'
|
|
8
|
+
- 'spec/fixtures/**/*'
|
|
9
|
+
- 'tmp/**/*'
|
|
10
|
+
Layout/AlignParameters:
|
|
11
|
+
# Customize to allow first parameter on same line
|
|
12
|
+
EnforcedStyle: with_fixed_indentation
|
|
13
|
+
Layout/MultilineMethodCallBraceLayout:
|
|
14
|
+
EnforcedStyle: new_line
|
|
15
|
+
Metrics/BlockLength:
|
|
16
|
+
Exclude:
|
|
17
|
+
- 'Rakefile'
|
|
18
|
+
- '**/*.rake'
|
|
19
|
+
- 'spec/**/*.rb'
|
|
20
|
+
Metrics/LineLength:
|
|
21
|
+
Max: 100
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Exclude:
|
|
24
|
+
- 'spec/**/*.rb'
|
|
25
|
+
Metrics/LineLength:
|
|
26
|
+
Max: 100
|
|
27
|
+
Naming/MemoizedInstanceVariableName:
|
|
28
|
+
Severity: error
|
|
29
|
+
Naming/PredicateName:
|
|
30
|
+
# Method define macros for dynamically generated method.
|
|
31
|
+
MethodDefinitionMacros:
|
|
32
|
+
- define_method
|
|
33
|
+
- define_singleton_method
|
|
34
|
+
- field
|
|
35
|
+
RSpec/NestedGroups:
|
|
36
|
+
# Default of 3 is too hardcore, since there is user login, etc.)
|
|
37
|
+
Max: 5
|
|
38
|
+
RSpec/ExampleLength:
|
|
39
|
+
# Default of 5 is too hardcore)
|
|
40
|
+
Max: 20
|
|
41
|
+
RSpec/MultipleExpectations:
|
|
42
|
+
# We can use several expect not inside an aggregate failures to be used like rescue clause
|
|
43
|
+
# (eg intercept there is an included resource before mathcing the resource to a payload)
|
|
44
|
+
Max: 2
|
|
45
|
+
|
|
46
|
+
Style/AndOr:
|
|
47
|
+
# Whether `and` and `or` are banned only in conditionals (conditionals)
|
|
48
|
+
# or completely (always).
|
|
49
|
+
EnforcedStyle: conditionals
|
|
50
|
+
Style/CommentAnnotation:
|
|
51
|
+
Keywords:
|
|
52
|
+
- TODO
|
|
53
|
+
- TOTHINKABOUT
|
|
54
|
+
- TODO
|
|
55
|
+
- SECURITY
|
|
56
|
+
- FIXME
|
|
57
|
+
- OPTIMIZE
|
|
58
|
+
- HACK
|
|
59
|
+
- REVIEW
|
|
60
|
+
Style/Copyright:
|
|
61
|
+
Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
|
|
62
|
+
AutocorrectNotice: 'Copyright (c) 2017-2018 My Job Glasses'
|
|
63
|
+
Style/TrailingCommaInArguments:
|
|
64
|
+
EnforcedStyleForMultiline: comma
|
|
65
|
+
Style/TrailingCommaInArrayLiteral:
|
|
66
|
+
EnforcedStyleForMultiline: comma
|
|
67
|
+
Style/TrailingCommaInHashLiteral:
|
|
68
|
+
EnforcedStyleForMultiline: comma
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2019-04-09
|
|
10
|
+
### Added
|
|
11
|
+
- Added pseudo-random number generator with seed
|
|
12
|
+
- Initial gem creation
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 My Job Glasses
|
|
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/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# TimeTurner
|
|
2
|
+
|
|
3
|
+
TimeTurner is a gem that generates random dates based on relative constraints.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'time_turner'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install time_turner
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
TODO: Write usage instructions here
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
28
|
+
|
|
29
|
+
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).
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/MyJobGlasses/time_turner.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "time_turner"
|
|
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(__FILE__)
|
data/bin/setup
ADDED
data/lib/time_turner.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'version'
|
|
2
|
+
require 'active_support/core_ext/integer'
|
|
3
|
+
|
|
4
|
+
class TimeTurner
|
|
5
|
+
# Returns random time that will act as the epoch for the class instance
|
|
6
|
+
#
|
|
7
|
+
# @return [Time]
|
|
8
|
+
attr_reader :big_bang
|
|
9
|
+
attr_reader :log
|
|
10
|
+
|
|
11
|
+
# Initialize TimeTurner pseudo-random generator with a seed value
|
|
12
|
+
#
|
|
13
|
+
# @param [Integer] seed
|
|
14
|
+
def initialize(seed)
|
|
15
|
+
@seed = seed
|
|
16
|
+
@generator = Random.new(seed)
|
|
17
|
+
@big_bang = Time.at(@generator.rand(0..Time.utc(2420).to_i))
|
|
18
|
+
@log = []
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Generates random value within the range provided
|
|
22
|
+
# By default, returns a floating point number between 0 and 1
|
|
23
|
+
#
|
|
24
|
+
# @param [Range] range
|
|
25
|
+
#
|
|
26
|
+
# @return [Time]
|
|
27
|
+
def rand(range = 0.0..1)
|
|
28
|
+
time = @generator.rand(range)
|
|
29
|
+
@log << { constraint: range, val: time }
|
|
30
|
+
time
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/version.rb
ADDED
data/time_turner.gemspec
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "time_turner"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "time_turner"
|
|
8
|
+
spec.version = TimeTurner::VERSION
|
|
9
|
+
spec.authors = ["Gleb Billig"]
|
|
10
|
+
spec.email = ["gleb.billig@myjobglasses.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Generate random dates based on relative constraints"
|
|
13
|
+
spec.homepage = "https://github.com/MyJobGlasses/time_turner"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/MyJobGlasses/time_turner"
|
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/MyJobGlasses/time_turner/blob/master/CHANGELOG.md"
|
|
23
|
+
else
|
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
25
|
+
"public gem pushes."
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
32
|
+
end
|
|
33
|
+
spec.bindir = "exe"
|
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
35
|
+
spec.require_paths = ["lib"]
|
|
36
|
+
|
|
37
|
+
spec.add_dependency "activesupport", "~> 5"
|
|
38
|
+
|
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
42
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: time_turner
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Gleb Billig
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-04-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: activesupport
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '5'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '5'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- gleb.billig@myjobglasses.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- ".rubocop.yml"
|
|
79
|
+
- ".travis.yml"
|
|
80
|
+
- CHANGELOG.md
|
|
81
|
+
- Gemfile
|
|
82
|
+
- LICENSE
|
|
83
|
+
- README.md
|
|
84
|
+
- Rakefile
|
|
85
|
+
- bin/console
|
|
86
|
+
- bin/setup
|
|
87
|
+
- lib/time_turner.rb
|
|
88
|
+
- lib/version.rb
|
|
89
|
+
- time_turner.gemspec
|
|
90
|
+
homepage: https://github.com/MyJobGlasses/time_turner
|
|
91
|
+
licenses:
|
|
92
|
+
- MIT
|
|
93
|
+
metadata:
|
|
94
|
+
homepage_uri: https://github.com/MyJobGlasses/time_turner
|
|
95
|
+
source_code_uri: https://github.com/MyJobGlasses/time_turner
|
|
96
|
+
changelog_uri: https://github.com/MyJobGlasses/time_turner/blob/master/CHANGELOG.md
|
|
97
|
+
post_install_message:
|
|
98
|
+
rdoc_options: []
|
|
99
|
+
require_paths:
|
|
100
|
+
- lib
|
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - ">="
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '0'
|
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
requirements: []
|
|
112
|
+
rubyforge_project:
|
|
113
|
+
rubygems_version: 2.5.2
|
|
114
|
+
signing_key:
|
|
115
|
+
specification_version: 4
|
|
116
|
+
summary: Generate random dates based on relative constraints
|
|
117
|
+
test_files: []
|