multiio 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/multiio.rb +20 -0
- data/lib/multiio/version.rb +3 -0
- data/multiio.gemspec +27 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2650c926d3c1135cc755a6d3d74d9554b5d2bed7cc01be3797e409f7da43eefb
|
4
|
+
data.tar.gz: 5c19d96e52fca8dbf314d909493ba9955a5c5bb016433d46ba25383340b7ddad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a439f57dd00a38acee65e4d8bf465a30e3b7e13388931eac8a7bd2389928f84594aebf612d0f099023fc60f9659043b53ea79b79f6404ef8d0330e497fc9ad8d
|
7
|
+
data.tar.gz: 33aabd37b0c5518f58a4014c5416fb72a1e648cc647e635dca01e05b2a074c76af2eee8ddbf0e29ddf535962abc3e097ef1f31d65a547d3d594db993a674f5d9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Multiio
|
2
|
+
|
3
|
+
Delegates to Multiple IO sources (e.g. STDOUT, File)
|
4
|
+
|
5
|
+
Inspired by this answer on stackoverflow:
|
6
|
+
https://stackoverflow.com/a/20422708/3384609
|
7
|
+
|
8
|
+
>Also, if you want colors, STDOUT or STDERR must be put last, since it's the only two where colors are supposed to be output. But then, it will also output colors to your file.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'multiio'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install multiio
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
|
30
|
+
default_log_location = File.absolute_path(File.join(
|
31
|
+
File.dirname(__FILE__), "..", "log", "vr2-worker-driver.log")
|
32
|
+
)
|
33
|
+
log_file_location = ENV['LOG_FILE_LOCATION']
|
34
|
+
if log_file_location == nil
|
35
|
+
FileUtils.mkdir_p File.dirname(default_log_location)
|
36
|
+
log_file_location = default_log_location
|
37
|
+
end
|
38
|
+
file = File.open(log_file_location, 'w')
|
39
|
+
@logger = Logger.new(MultiIO.new(file, STDOUT), 'daily')
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
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.
|
46
|
+
|
47
|
+
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).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/multiio.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "multiio"
|
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/multiio.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "multiio/version"
|
2
|
+
|
3
|
+
class MultiIO
|
4
|
+
|
5
|
+
def self.delegate_all
|
6
|
+
IO.methods.each do |m|
|
7
|
+
define_method(m) do |*args|
|
8
|
+
ret = nil
|
9
|
+
@targets.each { |t| ret = t.send(m, *args) }
|
10
|
+
ret
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(*targets)
|
16
|
+
@targets = targets
|
17
|
+
MultiIO.delegate_all
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/multiio.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "multiio/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "multiio"
|
8
|
+
spec.version = Multiio::VERSION
|
9
|
+
spec.authors = ["Clint M"]
|
10
|
+
spec.email = ["cmodien@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Delegates to Multiple IO sources (e.g. STDOUT, File)"
|
13
|
+
spec.description = "Delegates to Multiple IO sources (e.g. STDOUT, File)"
|
14
|
+
spec.homepage = "https://github.com/clintmod/multiio"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: multiio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Clint M
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-26 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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
|
+
description: Delegates to Multiple IO sources (e.g. STDOUT, File)
|
42
|
+
email:
|
43
|
+
- cmodien@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- bin/console
|
53
|
+
- bin/setup
|
54
|
+
- lib/multiio.rb
|
55
|
+
- lib/multiio/version.rb
|
56
|
+
- multiio.gemspec
|
57
|
+
homepage: https://github.com/clintmod/multiio
|
58
|
+
licenses: []
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.7.7
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Delegates to Multiple IO sources (e.g. STDOUT, File)
|
80
|
+
test_files: []
|