manana 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +12 -17
- data/.travis.yml +5 -3
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +35 -23
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +17 -18
- data/README.md +12 -6
- data/Rakefile +22 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/manana.rb +23 -31
- data/lib/manana/version.rb +1 -1
- data/manana.gemspec +22 -11
- data/samples/exponential_backoff.rb +0 -1
- data/samples/fast_startup.rb +1 -1
- metadata +35 -29
- data/samples/common/samples.gemfile.lock +0 -42
- data/test/base_klass.rb +0 -17
- data/test/klass.rb +0 -32
- data/test/minitest_helper.rb +0 -15
- data/test/test_manana.rb +0 -90
- data/test/test_with_subclass.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3007d43eab8321a4310df44bcd1663d88295fd4
|
4
|
+
data.tar.gz: 869f7b7dd49e4f35c5ae17f7abfedc3508e40788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65c4e7340c3710eb97b92fd1fbab52d73dc6042db81a6096f85d72c25ab53142be4cd78de75ddd102085675fa6ea5eaadc6159fb8b4c73d43df7287ef33d4344
|
7
|
+
data.tar.gz: 5b8e334a96377e78d0aef566f99a55a3996a272c2b6b41da3291d48fccbacf961860518eccb8ec217dfacd01d69cf1cf0e94bcb760d999fd30e899511738a1b9
|
data/.gitignore
CHANGED
@@ -1,17 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
samples/common/samples.gemfile.lock
|
10
|
+
|
11
|
+
# ignore rvm
|
12
|
+
.ruby-*
|
data/.travis.yml
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at larry.kyrala@mathworks.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -1,35 +1,47 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in manana.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
|
-
# these aren't strictly needed for development but are nice to have
|
7
8
|
unless ENV["TRAVIS"] == "1"
|
9
|
+
group :development, :test do
|
10
|
+
gem 'pry'
|
11
|
+
end
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem 'simplecov', "~> 0.16.1"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# these aren't strictly needed for development but are nice to have
|
19
|
+
# unless ENV["TRAVIS"] == "1"
|
8
20
|
|
9
|
-
|
10
|
-
|
11
|
-
|
21
|
+
# group :development do
|
22
|
+
# gem 'yard'
|
23
|
+
# gem 'redcarpet'
|
12
24
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
25
|
+
# if RUBY_VERSION =~ /^2\./
|
26
|
+
# gem 'pry-byebug'
|
27
|
+
# else
|
28
|
+
# gem 'pry'
|
29
|
+
# end
|
18
30
|
|
19
|
-
|
31
|
+
# end
|
20
32
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
33
|
+
# group :samples do
|
34
|
+
# gem 'savon', '~> 2.3'
|
35
|
+
# gem 'webmock'
|
36
|
+
# end
|
25
37
|
|
26
|
-
|
27
|
-
|
28
|
-
|
38
|
+
# group :test do
|
39
|
+
# gem 'simplecov'
|
40
|
+
# end
|
29
41
|
|
30
|
-
end
|
42
|
+
# end
|
31
43
|
|
32
|
-
# for travis.cl
|
33
|
-
group :test do
|
34
|
-
|
35
|
-
end
|
44
|
+
# # for travis.cl
|
45
|
+
# group :test do
|
46
|
+
# gem 'mocha'
|
47
|
+
# end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
manana (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.2)
|
10
|
+
docile (1.3.0)
|
11
|
+
json (2.1.0)
|
12
|
+
method_source (0.9.0)
|
13
|
+
minitest (5.11.3)
|
14
|
+
pry (0.11.3)
|
15
|
+
coderay (~> 1.1.0)
|
16
|
+
method_source (~> 0.9.0)
|
17
|
+
rake (10.5.0)
|
18
|
+
simplecov (0.16.1)
|
19
|
+
docile (~> 1.1)
|
20
|
+
json (>= 1.8, < 3)
|
21
|
+
simplecov-html (~> 0.10.0)
|
22
|
+
simplecov-html (0.10.2)
|
23
|
+
yard (0.9.12)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.16)
|
30
|
+
manana!
|
31
|
+
minitest (~> 5.0)
|
32
|
+
pry
|
33
|
+
rake (~> 10.0)
|
34
|
+
simplecov (~> 0.16.1)
|
35
|
+
yard
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
1.16.1
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2018 Larry Kyrala
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
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:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
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
CHANGED
@@ -42,7 +42,9 @@ i.e. your app starts fast and initializes other dependencies afterwards, providi
|
|
42
42
|
|
43
43
|
Add this line to your application's Gemfile:
|
44
44
|
|
45
|
-
|
45
|
+
```ruby
|
46
|
+
gem 'manana'
|
47
|
+
```
|
46
48
|
|
47
49
|
And then execute:
|
48
50
|
|
@@ -75,8 +77,12 @@ See the [samples](https://github.com/coldnebo/manana/blob/master/samples) for mo
|
|
75
77
|
|
76
78
|
## Contributing
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/manana. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
85
|
+
|
86
|
+
## Code of Conduct
|
87
|
+
|
88
|
+
Everyone interacting in the Manana project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/coldnebo/manana/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -3,6 +3,8 @@ require "rake/testtask"
|
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
5
|
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
6
8
|
end
|
7
9
|
|
8
10
|
task :default => :test
|
@@ -13,3 +15,23 @@ task :samples do
|
|
13
15
|
sh "bundle install --gemfile=samples/common/samples.gemfile"
|
14
16
|
end
|
15
17
|
end
|
18
|
+
|
19
|
+
|
20
|
+
# require 'pry'
|
21
|
+
# binding.pry
|
22
|
+
|
23
|
+
CLOBBER << "coverage"
|
24
|
+
CLOBBER << "samples/common/samples.gemfile.lock"
|
25
|
+
CLOBBER << ".yardoc"
|
26
|
+
|
27
|
+
#CLOBBER << Rake::FileList.new("coverage/**/*", "coverage")
|
28
|
+
|
29
|
+
|
30
|
+
desc "clean the intermediate yardoc and start a yard server - just for local development"
|
31
|
+
task :yardserver do
|
32
|
+
exec "yard server --reload -b 0.0.0.0"
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
require 'yard'
|
37
|
+
YARD::Rake::YardocTask.new :doc
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "manana"
|
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/manana.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "manana/version"
|
2
2
|
|
3
|
-
|
4
3
|
# *Manana* lets you defer the initialization of an object until its methods are called.
|
5
4
|
# @example basic usage - see {https://github.com/coldnebo/manana/blob/master/samples/self_healing.rb samples/self_healing.rb}
|
6
5
|
# # initialization...
|
@@ -28,40 +27,33 @@ class Manana
|
|
28
27
|
# @param initialization_block [Proc] object initialization. the block must return the object to be wrapped.
|
29
28
|
# @return [Deferrable] a wrapped version of the object.
|
30
29
|
def self.wrap(&initialization_block)
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
|
30
|
+
new(&initialization_block)
|
31
|
+
end
|
32
|
+
|
33
|
+
# passes any method call through to the wrapped object after ensuring that the initialization block has
|
34
|
+
# successfully completed once (thereby initializing the wrapped object).
|
35
|
+
# @note Once the initialization block succeeds, it keeps the resulting object for subsequent method calls.
|
36
|
+
#
|
37
|
+
# @example calling a wrapped object - see {https://github.com/coldnebo/manana/blob/master/samples/self_healing.rb samples/self_healing.rb}
|
38
|
+
# weather = client.city_weather("02201")
|
39
|
+
#
|
40
|
+
def method_missing(method, *args, &block)
|
41
|
+
_object.send(method, *args, &block);
|
42
|
+
end
|
37
43
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# weather = client.city_weather("02201")
|
44
|
-
#
|
45
|
-
def method_missing(method, *args, &block)
|
46
|
-
_object.send(method, *args, &block);
|
44
|
+
# allows direct access to the wrapped object -- useful for debugging
|
45
|
+
# @return [Object] the object being wrapped
|
46
|
+
def _object
|
47
|
+
@mutex.synchronize do
|
48
|
+
@object ||= @deferred_initialization.call
|
47
49
|
end
|
50
|
+
end
|
48
51
|
|
49
|
-
|
50
|
-
# @return [Object] the object being wrapped
|
51
|
-
def _object
|
52
|
-
@mutex.synchronize do
|
53
|
-
if @object.nil?
|
54
|
-
@object = @deferred_initialization.call
|
55
|
-
end
|
56
|
-
@object
|
57
|
-
end
|
58
|
-
end
|
52
|
+
private
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@deferred_initialization = initialization_block
|
64
|
-
end
|
54
|
+
def initialize(&initialization_block)
|
55
|
+
@mutex = ::Mutex.new
|
56
|
+
@deferred_initialization = initialization_block
|
65
57
|
end
|
66
58
|
|
67
59
|
end
|
data/lib/manana/version.rb
CHANGED
data/manana.gemspec
CHANGED
@@ -1,24 +1,35 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path(
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "manana/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "manana"
|
8
8
|
spec.version = Manana::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["Larry Kyrala"]
|
10
10
|
spec.email = ["larry.kyrala@gmail.com"]
|
11
|
-
spec.description = %q{provides a simple way to defer initialization of an object until its methods are called}
|
12
11
|
spec.summary = %q{provides a simple way to defer initialization of an object until its methods are called}
|
13
12
|
spec.homepage = "https://github.com/coldnebo/manana"
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
21
|
+
"public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
29
|
spec.require_paths = ["lib"]
|
20
30
|
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "minitest"
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
34
|
+
spec.add_development_dependency "yard"
|
24
35
|
end
|
data/samples/fast_startup.rb
CHANGED
@@ -41,7 +41,7 @@ end
|
|
41
41
|
|
42
42
|
mini_death_star = nil
|
43
43
|
|
44
|
-
puts "[Vader]:
|
44
|
+
puts "[Vader]: requisition a new DeathStar and make it snappy!"
|
45
45
|
# boss said requisitions have to be faster*! Manana to the rescue!
|
46
46
|
puts Benchmark.measure {
|
47
47
|
mini_death_star = Manana.wrap {
|
metadata
CHANGED
@@ -1,45 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Larry Kyrala
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -52,8 +66,7 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
|
-
description:
|
56
|
-
methods are called
|
69
|
+
description:
|
57
70
|
email:
|
58
71
|
- larry.kyrala@gmail.com
|
59
72
|
executables: []
|
@@ -63,28 +76,27 @@ files:
|
|
63
76
|
- ".gitignore"
|
64
77
|
- ".travis.yml"
|
65
78
|
- ".yardopts"
|
79
|
+
- CODE_OF_CONDUCT.md
|
66
80
|
- Gemfile
|
81
|
+
- Gemfile.lock
|
67
82
|
- LICENSE.txt
|
68
83
|
- README.md
|
69
84
|
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
70
87
|
- lib/manana.rb
|
71
88
|
- lib/manana/version.rb
|
72
89
|
- manana.gemspec
|
73
90
|
- samples/common/samples.gemfile
|
74
|
-
- samples/common/samples.gemfile.lock
|
75
91
|
- samples/common/samples_helper.rb
|
76
92
|
- samples/exponential_backoff.rb
|
77
93
|
- samples/fast_startup.rb
|
78
94
|
- samples/self_healing.rb
|
79
|
-
- test/base_klass.rb
|
80
|
-
- test/klass.rb
|
81
|
-
- test/minitest_helper.rb
|
82
|
-
- test/test_manana.rb
|
83
|
-
- test/test_with_subclass.rb
|
84
95
|
homepage: https://github.com/coldnebo/manana
|
85
96
|
licenses:
|
86
97
|
- MIT
|
87
|
-
metadata:
|
98
|
+
metadata:
|
99
|
+
allowed_push_host: https://rubygems.org
|
88
100
|
post_install_message:
|
89
101
|
rdoc_options: []
|
90
102
|
require_paths:
|
@@ -101,15 +113,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
113
|
version: '0'
|
102
114
|
requirements: []
|
103
115
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.6.14
|
105
117
|
signing_key:
|
106
118
|
specification_version: 4
|
107
119
|
summary: provides a simple way to defer initialization of an object until its methods
|
108
120
|
are called
|
109
|
-
test_files:
|
110
|
-
- test/base_klass.rb
|
111
|
-
- test/klass.rb
|
112
|
-
- test/minitest_helper.rb
|
113
|
-
- test/test_manana.rb
|
114
|
-
- test/test_with_subclass.rb
|
115
|
-
has_rdoc:
|
121
|
+
test_files: []
|
@@ -1,42 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
addressable (2.3.5)
|
5
|
-
akami (1.2.0)
|
6
|
-
gyoku (>= 0.4.0)
|
7
|
-
nokogiri (>= 1.4.0)
|
8
|
-
builder (3.2.2)
|
9
|
-
crack (0.4.1)
|
10
|
-
safe_yaml (~> 0.9.0)
|
11
|
-
gyoku (1.1.0)
|
12
|
-
builder (>= 2.1.2)
|
13
|
-
httpi (2.1.0)
|
14
|
-
rack
|
15
|
-
rubyntlm (~> 0.3.2)
|
16
|
-
nokogiri (1.5.10)
|
17
|
-
nori (2.3.0)
|
18
|
-
rack (1.5.2)
|
19
|
-
rubyntlm (0.3.4)
|
20
|
-
safe_yaml (0.9.7)
|
21
|
-
savon (2.3.0)
|
22
|
-
akami (~> 1.2.0)
|
23
|
-
builder (>= 2.1.2)
|
24
|
-
gyoku (~> 1.1.0)
|
25
|
-
httpi (~> 2.1.0)
|
26
|
-
nokogiri (>= 1.4.0, < 1.6)
|
27
|
-
nori (~> 2.3.0)
|
28
|
-
wasabi (~> 3.2.0)
|
29
|
-
wasabi (3.2.0)
|
30
|
-
httpi (~> 2.0)
|
31
|
-
nokogiri (>= 1.4.0, < 1.6)
|
32
|
-
webmock (1.15.2)
|
33
|
-
addressable (>= 2.2.7)
|
34
|
-
crack (>= 0.3.2)
|
35
|
-
|
36
|
-
PLATFORMS
|
37
|
-
ruby
|
38
|
-
|
39
|
-
DEPENDENCIES
|
40
|
-
rack
|
41
|
-
savon (~> 2.3)
|
42
|
-
webmock
|
data/test/base_klass.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# something like ActiveRecord::Base
|
2
|
-
class BaseKlass
|
3
|
-
|
4
|
-
def self.connected?
|
5
|
-
@@connected ||= false
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.establish_connection
|
9
|
-
@@connected = true
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.find
|
13
|
-
raise "not connected!" unless self.connected?
|
14
|
-
[1,2,3]
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
data/test/klass.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
class Klass
|
2
|
-
INITIALIZE_MESSAGE = "initialized!"
|
3
|
-
DO_SOMETHING_MESSAGE = "I did something!"
|
4
|
-
RAISE_MESSAGE = "kablooey!"
|
5
|
-
|
6
|
-
def self.incr
|
7
|
-
@count ||= 0
|
8
|
-
@count += 1
|
9
|
-
@count
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.count
|
13
|
-
@count ||= 0
|
14
|
-
@count
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.reset
|
18
|
-
@count = 0
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
puts INITIALIZE_MESSAGE
|
23
|
-
end
|
24
|
-
|
25
|
-
def do_something
|
26
|
-
DO_SOMETHING_MESSAGE
|
27
|
-
end
|
28
|
-
|
29
|
-
def raise_something
|
30
|
-
raise RAISE_MESSAGE
|
31
|
-
end
|
32
|
-
end
|
data/test/minitest_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
unless ENV["TRAVIS"] == "1"
|
2
|
-
require 'simplecov'
|
3
|
-
require 'pry'
|
4
|
-
SimpleCov.start do
|
5
|
-
add_filter "/test/"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
10
|
-
require 'manana'
|
11
|
-
|
12
|
-
|
13
|
-
require 'minitest/autorun'
|
14
|
-
require 'mocha/setup'
|
15
|
-
|
data/test/test_manana.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'minitest_helper'
|
2
|
-
require 'klass'
|
3
|
-
|
4
|
-
class TestManana < Minitest::Test
|
5
|
-
def test_that_it_has_a_version_number
|
6
|
-
refute_nil ::Manana::VERSION
|
7
|
-
end
|
8
|
-
|
9
|
-
# initialize a very generic example object that does some stuff in initialization
|
10
|
-
# and has some instance methods you can call.
|
11
|
-
def setup
|
12
|
-
end
|
13
|
-
|
14
|
-
# sanity check
|
15
|
-
def test_that_things_work_without_manana
|
16
|
-
obj = nil
|
17
|
-
|
18
|
-
out, err = capture_io do
|
19
|
-
obj = Klass.new
|
20
|
-
end
|
21
|
-
assert_match(/#{Klass::INITIALIZE_MESSAGE}/, out)
|
22
|
-
assert_instance_of(String, obj.do_something)
|
23
|
-
assert_match(/#{Klass::DO_SOMETHING_MESSAGE}/, obj.do_something)
|
24
|
-
assert_raises RuntimeError do
|
25
|
-
obj.raise_something
|
26
|
-
end
|
27
|
-
|
28
|
-
begin
|
29
|
-
obj.raise_something
|
30
|
-
rescue Exception => e
|
31
|
-
# make sure we get an appropriate stack trace at the point of raise.
|
32
|
-
assert_match(/.*klass.rb:\d+:in .raise_something./, e.backtrace.first)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_wrap
|
37
|
-
obj = nil
|
38
|
-
out, err = capture_io do
|
39
|
-
obj = Manana.wrap {
|
40
|
-
Klass.new
|
41
|
-
}
|
42
|
-
end
|
43
|
-
# make sure the init isn't executed until we call...
|
44
|
-
refute_match(/#{Klass::INITIALIZE_MESSAGE}/, out)
|
45
|
-
|
46
|
-
# now call a method on the object...
|
47
|
-
result = nil
|
48
|
-
out, err = capture_io do
|
49
|
-
result = obj.do_something
|
50
|
-
end
|
51
|
-
# and make sure the init was called
|
52
|
-
assert_match(/#{Klass::INITIALIZE_MESSAGE}/, out)
|
53
|
-
# and that we got the desired result
|
54
|
-
assert_instance_of(String, result)
|
55
|
-
assert_match(/#{Klass::DO_SOMETHING_MESSAGE}/, result)
|
56
|
-
assert_raises RuntimeError do
|
57
|
-
obj.raise_something
|
58
|
-
end
|
59
|
-
|
60
|
-
begin
|
61
|
-
obj.raise_something
|
62
|
-
rescue Exception => e
|
63
|
-
# make sure we get an appropriate stack trace at the point of raise.
|
64
|
-
assert_match(/.*klass.rb:\d+:in .raise_something./, e.backtrace.first)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
# https://github.com/coldnebo/manana/issues/1
|
70
|
-
def test_that_init_is_threadsafe
|
71
|
-
Klass.reset
|
72
|
-
|
73
|
-
klass = Manana.wrap {
|
74
|
-
sleep(1)
|
75
|
-
Klass.incr
|
76
|
-
Klass
|
77
|
-
}
|
78
|
-
|
79
|
-
t1 = Thread.new{klass.count}
|
80
|
-
t2 = Thread.new{klass.count}
|
81
|
-
t3 = Thread.new{klass.count}
|
82
|
-
t1.join
|
83
|
-
t2.join
|
84
|
-
t3.join
|
85
|
-
|
86
|
-
assert_equal(1,klass.count)
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
end
|
data/test/test_with_subclass.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'minitest_helper'
|
2
|
-
require 'base_klass'
|
3
|
-
|
4
|
-
class TestWithSubclass < Minitest::Test
|
5
|
-
|
6
|
-
# initialize a very generic example object that does some stuff in initialization and has some instance methods you can call.
|
7
|
-
def setup
|
8
|
-
BaseKlass.class_variable_set(:@@connected, false)
|
9
|
-
end
|
10
|
-
|
11
|
-
# sanity check
|
12
|
-
def test_that_things_work_without_manana
|
13
|
-
@subklass = Class.new(BaseKlass)
|
14
|
-
|
15
|
-
assert_raises RuntimeError do
|
16
|
-
res = @subklass.find
|
17
|
-
end
|
18
|
-
|
19
|
-
BaseKlass.establish_connection
|
20
|
-
|
21
|
-
res = @subklass.find
|
22
|
-
refute_empty(res)
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_wrap
|
27
|
-
|
28
|
-
@subklass = Manana.wrap {
|
29
|
-
unless BaseKlass.connected?
|
30
|
-
BaseKlass.establish_connection
|
31
|
-
end
|
32
|
-
subklass = Class.new(BaseKlass)
|
33
|
-
}
|
34
|
-
|
35
|
-
res = @subklass.find
|
36
|
-
refute_empty(res)
|
37
|
-
assert(BaseKlass.connected?)
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
end
|