sticks-pipe 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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/sticks/pipe.rb +73 -0
- data/lib/sticks/pipe/version.rb +5 -0
- data/sticks-pipe.gemspec +23 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d1e3ceb3866a9a7db751258b7abe860672c6f8f7
|
4
|
+
data.tar.gz: 8b43302634c3a3b59d71adf2bc2a67e467d7f296
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b538f8b7b7f95c3c73de10158e422c1057463bce1baa0c5d99e0af860eb22eb07ae439192dc3a4e072387f3c62ee2ee637a267dc20815fa5672daf07abc82a15
|
7
|
+
data.tar.gz: bf58eac7be58fba61956ca5eadba466f63c555141643235ba71f72114430a6aedc63efa08b8ecd9c6221c747b7dcef6024626047259b0fd22a24c22b56df6cd4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
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 NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <http://unlicense.org>
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Sticks::Pipe
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sticks-pipe'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sticks-pipe
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/sticks-pipe/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/sticks/pipe.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "sticks/pipe/version"
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
require 'readline'
|
5
|
+
|
6
|
+
module Sticks
|
7
|
+
|
8
|
+
module Pipe
|
9
|
+
|
10
|
+
module Blocks
|
11
|
+
|
12
|
+
module_function
|
13
|
+
|
14
|
+
def capture
|
15
|
+
Proc.new { |i,o,t|
|
16
|
+
i.close
|
17
|
+
result = o.readlines.join("")
|
18
|
+
Process.waitpid(t.pid) rescue nil
|
19
|
+
result.chomp
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def stream name = nil
|
25
|
+
Proc.new { |i,o,t|
|
26
|
+
i.close
|
27
|
+
ot = Thread.new{
|
28
|
+
while !o.eof? do
|
29
|
+
$stdout.puts(name ? "[#{name}] #{o.gets}" : o.gets)
|
30
|
+
end
|
31
|
+
}
|
32
|
+
ot.abort_on_exception = true
|
33
|
+
Process.waitpid(t.pid) rescue nil
|
34
|
+
ot.join
|
35
|
+
Process.waitpid(t.pid) rescue nil
|
36
|
+
t.value #Process::status
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def interactive
|
42
|
+
Proc.new { |i,o,t|
|
43
|
+
pid = t.pid
|
44
|
+
ot = Thread.new {
|
45
|
+
while !o.eof? do
|
46
|
+
$stdout.puts PROMPT + o.gets
|
47
|
+
end
|
48
|
+
}
|
49
|
+
catch :exit do
|
50
|
+
while !i.closed?
|
51
|
+
input = Readline.readline(PROMPT, true)
|
52
|
+
i.puts input
|
53
|
+
throw :exit if input == "exit"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
i.close
|
57
|
+
ot.join
|
58
|
+
t.value #Process::status
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
INTERACTIVE_COMMANDS = /bash|sh|irb|console/
|
65
|
+
PROMPT = "> "
|
66
|
+
|
67
|
+
def pipe *args, &block
|
68
|
+
block = Blocks.capture unless block_given?
|
69
|
+
Open3.popen2e(*args,&block)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
data/sticks-pipe.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sticks/pipe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sticks-pipe"
|
8
|
+
spec.version = Sticks::Pipe::VERSION
|
9
|
+
spec.authors = ["Onur Uyar"]
|
10
|
+
spec.email = ["me@onuruyar.com"]
|
11
|
+
spec.summary = %q{Smokey Proc blocks for redirecting streams to everywhere}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "Unlicence"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_dependency "rb-readline"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sticks-pipe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Onur Uyar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-16 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rb-readline
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- me@onuruyar.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/sticks/pipe.rb
|
68
|
+
- lib/sticks/pipe/version.rb
|
69
|
+
- sticks-pipe.gemspec
|
70
|
+
homepage: ''
|
71
|
+
licenses:
|
72
|
+
- Unlicence
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.2.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Smokey Proc blocks for redirecting streams to everywhere
|
94
|
+
test_files: []
|